documentation.d.ts 3.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333
  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. _getVertexShaderCode(): string | null;
  1082. /** @hidden */
  1083. _getFragmentShaderCode(): string | null;
  1084. /** @hidden */
  1085. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1086. }
  1087. }
  1088. declare module BABYLON {
  1089. /**
  1090. * Class used to store gfx data (like WebGLBuffer)
  1091. */
  1092. export class DataBuffer {
  1093. /**
  1094. * Gets or sets the number of objects referencing this buffer
  1095. */
  1096. references: number;
  1097. /** Gets or sets the size of the underlying buffer */
  1098. capacity: number;
  1099. /**
  1100. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1101. */
  1102. is32Bits: boolean;
  1103. /**
  1104. * Gets the underlying buffer
  1105. */
  1106. get underlyingResource(): any;
  1107. }
  1108. }
  1109. declare module BABYLON {
  1110. /** @hidden */
  1111. export interface IShaderProcessor {
  1112. attributeProcessor?: (attribute: string) => string;
  1113. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1114. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1115. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1116. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1117. lineProcessor?: (line: string, isFragment: boolean) => string;
  1118. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1119. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1120. }
  1121. }
  1122. declare module BABYLON {
  1123. /** @hidden */
  1124. export interface ProcessingOptions {
  1125. defines: string[];
  1126. indexParameters: any;
  1127. isFragment: boolean;
  1128. shouldUseHighPrecisionShader: boolean;
  1129. supportsUniformBuffers: boolean;
  1130. shadersRepository: string;
  1131. includesShadersStore: {
  1132. [key: string]: string;
  1133. };
  1134. processor?: IShaderProcessor;
  1135. version: string;
  1136. platformName: string;
  1137. lookForClosingBracketForUniformBuffer?: boolean;
  1138. }
  1139. }
  1140. declare module BABYLON {
  1141. /** @hidden */
  1142. export class ShaderCodeNode {
  1143. line: string;
  1144. children: ShaderCodeNode[];
  1145. additionalDefineKey?: string;
  1146. additionalDefineValue?: string;
  1147. isValid(preprocessors: {
  1148. [key: string]: string;
  1149. }): boolean;
  1150. process(preprocessors: {
  1151. [key: string]: string;
  1152. }, options: ProcessingOptions): string;
  1153. }
  1154. }
  1155. declare module BABYLON {
  1156. /** @hidden */
  1157. export class ShaderCodeCursor {
  1158. private _lines;
  1159. lineIndex: number;
  1160. get currentLine(): string;
  1161. get canRead(): boolean;
  1162. set lines(value: string[]);
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1168. process(preprocessors: {
  1169. [key: string]: string;
  1170. }, options: ProcessingOptions): string;
  1171. }
  1172. }
  1173. declare module BABYLON {
  1174. /** @hidden */
  1175. export class ShaderDefineExpression {
  1176. isTrue(preprocessors: {
  1177. [key: string]: string;
  1178. }): boolean;
  1179. }
  1180. }
  1181. declare module BABYLON {
  1182. /** @hidden */
  1183. export class ShaderCodeTestNode extends ShaderCodeNode {
  1184. testExpression: ShaderDefineExpression;
  1185. isValid(preprocessors: {
  1186. [key: string]: string;
  1187. }): boolean;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1193. define: string;
  1194. not: boolean;
  1195. constructor(define: string, not?: boolean);
  1196. isTrue(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. }
  1200. }
  1201. declare module BABYLON {
  1202. /** @hidden */
  1203. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1204. leftOperand: ShaderDefineExpression;
  1205. rightOperand: ShaderDefineExpression;
  1206. isTrue(preprocessors: {
  1207. [key: string]: string;
  1208. }): boolean;
  1209. }
  1210. }
  1211. declare module BABYLON {
  1212. /** @hidden */
  1213. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1214. leftOperand: ShaderDefineExpression;
  1215. rightOperand: ShaderDefineExpression;
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module BABYLON {
  1222. /** @hidden */
  1223. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1224. define: string;
  1225. operand: string;
  1226. testValue: string;
  1227. constructor(define: string, operand: string, testValue: string);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /**
  1235. * Class used to enable access to offline support
  1236. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1237. */
  1238. export interface IOfflineProvider {
  1239. /**
  1240. * Gets a boolean indicating if scene must be saved in the database
  1241. */
  1242. enableSceneOffline: boolean;
  1243. /**
  1244. * Gets a boolean indicating if textures must be saved in the database
  1245. */
  1246. enableTexturesOffline: boolean;
  1247. /**
  1248. * Open the offline support and make it available
  1249. * @param successCallback defines the callback to call on success
  1250. * @param errorCallback defines the callback to call on error
  1251. */
  1252. open(successCallback: () => void, errorCallback: () => void): void;
  1253. /**
  1254. * Loads an image from the offline support
  1255. * @param url defines the url to load from
  1256. * @param image defines the target DOM image
  1257. */
  1258. loadImage(url: string, image: HTMLImageElement): void;
  1259. /**
  1260. * Loads a file from offline support
  1261. * @param url defines the URL to load from
  1262. * @param sceneLoaded defines a callback to call on success
  1263. * @param progressCallBack defines a callback to call when progress changed
  1264. * @param errorCallback defines a callback to call on error
  1265. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1266. */
  1267. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1268. }
  1269. }
  1270. declare module BABYLON {
  1271. /**
  1272. * Class used to help managing file picking and drag'n'drop
  1273. * File Storage
  1274. */
  1275. export class FilesInputStore {
  1276. /**
  1277. * List of files ready to be loaded
  1278. */
  1279. static FilesToLoad: {
  1280. [key: string]: File;
  1281. };
  1282. }
  1283. }
  1284. declare module BABYLON {
  1285. /**
  1286. * Class used to define a retry strategy when error happens while loading assets
  1287. */
  1288. export class RetryStrategy {
  1289. /**
  1290. * Function used to defines an exponential back off strategy
  1291. * @param maxRetries defines the maximum number of retries (3 by default)
  1292. * @param baseInterval defines the interval between retries
  1293. * @returns the strategy function to use
  1294. */
  1295. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1296. }
  1297. }
  1298. declare module BABYLON {
  1299. /**
  1300. * @ignore
  1301. * Application error to support additional information when loading a file
  1302. */
  1303. export abstract class BaseError extends Error {
  1304. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1305. }
  1306. }
  1307. declare module BABYLON {
  1308. /** @ignore */
  1309. export class LoadFileError extends BaseError {
  1310. request?: WebRequest;
  1311. file?: File;
  1312. /**
  1313. * Creates a new LoadFileError
  1314. * @param message defines the message of the error
  1315. * @param request defines the optional web request
  1316. * @param file defines the optional file
  1317. */
  1318. constructor(message: string, object?: WebRequest | File);
  1319. }
  1320. /** @ignore */
  1321. export class RequestFileError extends BaseError {
  1322. request: WebRequest;
  1323. /**
  1324. * Creates a new LoadFileError
  1325. * @param message defines the message of the error
  1326. * @param request defines the optional web request
  1327. */
  1328. constructor(message: string, request: WebRequest);
  1329. }
  1330. /** @ignore */
  1331. export class ReadFileError extends BaseError {
  1332. file: File;
  1333. /**
  1334. * Creates a new ReadFileError
  1335. * @param message defines the message of the error
  1336. * @param file defines the optional file
  1337. */
  1338. constructor(message: string, file: File);
  1339. }
  1340. /**
  1341. * @hidden
  1342. */
  1343. export class FileTools {
  1344. /**
  1345. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1346. */
  1347. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1348. /**
  1349. * Gets or sets the base URL to use to load assets
  1350. */
  1351. static BaseUrl: string;
  1352. /**
  1353. * Default behaviour for cors in the application.
  1354. * It can be a string if the expected behavior is identical in the entire app.
  1355. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1356. */
  1357. static CorsBehavior: string | ((url: string | string[]) => string);
  1358. /**
  1359. * Gets or sets a function used to pre-process url before using them to load assets
  1360. */
  1361. static PreprocessUrl: (url: string) => string;
  1362. /**
  1363. * Removes unwanted characters from an url
  1364. * @param url defines the url to clean
  1365. * @returns the cleaned url
  1366. */
  1367. private static _CleanUrl;
  1368. /**
  1369. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1370. * @param url define the url we are trying
  1371. * @param element define the dom element where to configure the cors policy
  1372. */
  1373. static SetCorsBehavior(url: string | string[], element: {
  1374. crossOrigin: string | null;
  1375. }): void;
  1376. /**
  1377. * Loads an image as an HTMLImageElement.
  1378. * @param input url string, ArrayBuffer, or Blob to load
  1379. * @param onLoad callback called when the image successfully loads
  1380. * @param onError callback called when the image fails to load
  1381. * @param offlineProvider offline provider for caching
  1382. * @param mimeType optional mime type
  1383. * @returns the HTMLImageElement of the loaded image
  1384. */
  1385. 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>;
  1386. /**
  1387. * Reads a file from a File object
  1388. * @param file defines the file to load
  1389. * @param onSuccess defines the callback to call when data is loaded
  1390. * @param onProgress defines the callback to call during loading process
  1391. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1392. * @param onError defines the callback to call when an error occurs
  1393. * @returns a file request object
  1394. */
  1395. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1396. /**
  1397. * Loads a file from a url
  1398. * @param url url to load
  1399. * @param onSuccess callback called when the file successfully loads
  1400. * @param onProgress callback called while file is loading (if the server supports this mode)
  1401. * @param offlineProvider defines the offline provider for caching
  1402. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1403. * @param onError callback called when the file fails to load
  1404. * @returns a file request object
  1405. */
  1406. 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;
  1407. /**
  1408. * Loads a file
  1409. * @param url url to load
  1410. * @param onSuccess callback called when the file successfully loads
  1411. * @param onProgress callback called while file is loading (if the server supports this mode)
  1412. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1413. * @param onError callback called when the file fails to load
  1414. * @param onOpened callback called when the web request is opened
  1415. * @returns a file request object
  1416. */
  1417. 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;
  1418. /**
  1419. * Checks if the loaded document was accessed via `file:`-Protocol.
  1420. * @returns boolean
  1421. */
  1422. static IsFileURL(): boolean;
  1423. }
  1424. }
  1425. declare module BABYLON {
  1426. /** @hidden */
  1427. export class ShaderProcessor {
  1428. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1429. private static _ProcessPrecision;
  1430. private static _ExtractOperation;
  1431. private static _BuildSubExpression;
  1432. private static _BuildExpression;
  1433. private static _MoveCursorWithinIf;
  1434. private static _MoveCursor;
  1435. private static _EvaluatePreProcessors;
  1436. private static _PreparePreProcessors;
  1437. private static _ProcessShaderConversion;
  1438. private static _ProcessIncludes;
  1439. /**
  1440. * Loads a file from a url
  1441. * @param url url to load
  1442. * @param onSuccess callback called when the file successfully loads
  1443. * @param onProgress callback called while file is loading (if the server supports this mode)
  1444. * @param offlineProvider defines the offline provider for caching
  1445. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1446. * @param onError callback called when the file fails to load
  1447. * @returns a file request object
  1448. * @hidden
  1449. */
  1450. 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;
  1451. }
  1452. }
  1453. declare module BABYLON {
  1454. /**
  1455. * @hidden
  1456. */
  1457. export interface IColor4Like {
  1458. r: float;
  1459. g: float;
  1460. b: float;
  1461. a: float;
  1462. }
  1463. /**
  1464. * @hidden
  1465. */
  1466. export interface IColor3Like {
  1467. r: float;
  1468. g: float;
  1469. b: float;
  1470. }
  1471. /**
  1472. * @hidden
  1473. */
  1474. export interface IVector4Like {
  1475. x: float;
  1476. y: float;
  1477. z: float;
  1478. w: float;
  1479. }
  1480. /**
  1481. * @hidden
  1482. */
  1483. export interface IVector3Like {
  1484. x: float;
  1485. y: float;
  1486. z: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IVector2Like {
  1492. x: float;
  1493. y: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IMatrixLike {
  1499. toArray(): DeepImmutable<Float32Array>;
  1500. updateFlag: int;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IViewportLike {
  1506. x: float;
  1507. y: float;
  1508. width: float;
  1509. height: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IPlaneLike {
  1515. normal: IVector3Like;
  1516. d: float;
  1517. normalize(): void;
  1518. }
  1519. }
  1520. declare module BABYLON {
  1521. /**
  1522. * Interface used to define common properties for effect fallbacks
  1523. */
  1524. export interface IEffectFallbacks {
  1525. /**
  1526. * Removes the defines that should be removed when falling back.
  1527. * @param currentDefines defines the current define statements for the shader.
  1528. * @param effect defines the current effect we try to compile
  1529. * @returns The resulting defines with defines of the current rank removed.
  1530. */
  1531. reduce(currentDefines: string, effect: Effect): string;
  1532. /**
  1533. * Removes the fallback from the bound mesh.
  1534. */
  1535. unBindMesh(): void;
  1536. /**
  1537. * Checks to see if more fallbacks are still availible.
  1538. */
  1539. hasMoreFallbacks: boolean;
  1540. }
  1541. }
  1542. declare module BABYLON {
  1543. /**
  1544. * Class used to evalaute queries containing `and` and `or` operators
  1545. */
  1546. export class AndOrNotEvaluator {
  1547. /**
  1548. * Evaluate a query
  1549. * @param query defines the query to evaluate
  1550. * @param evaluateCallback defines the callback used to filter result
  1551. * @returns true if the query matches
  1552. */
  1553. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1554. private static _HandleParenthesisContent;
  1555. private static _SimplifyNegation;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to store custom tags
  1561. */
  1562. export class Tags {
  1563. /**
  1564. * Adds support for tags on the given object
  1565. * @param obj defines the object to use
  1566. */
  1567. static EnableFor(obj: any): void;
  1568. /**
  1569. * Removes tags support
  1570. * @param obj defines the object to use
  1571. */
  1572. static DisableFor(obj: any): void;
  1573. /**
  1574. * Gets a boolean indicating if the given object has tags
  1575. * @param obj defines the object to use
  1576. * @returns a boolean
  1577. */
  1578. static HasTags(obj: any): boolean;
  1579. /**
  1580. * Gets the tags available on a given object
  1581. * @param obj defines the object to use
  1582. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1583. * @returns the tags
  1584. */
  1585. static GetTags(obj: any, asString?: boolean): any;
  1586. /**
  1587. * Adds tags to an object
  1588. * @param obj defines the object to use
  1589. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1590. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1591. */
  1592. static AddTagsTo(obj: any, tagsString: string): void;
  1593. /**
  1594. * @hidden
  1595. */
  1596. static _AddTagTo(obj: any, tag: string): void;
  1597. /**
  1598. * Removes specific tags from a specific object
  1599. * @param obj defines the object to use
  1600. * @param tagsString defines the tags to remove
  1601. */
  1602. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1603. /**
  1604. * @hidden
  1605. */
  1606. static _RemoveTagFrom(obj: any, tag: string): void;
  1607. /**
  1608. * Defines if tags hosted on an object match a given query
  1609. * @param obj defines the object to use
  1610. * @param tagsQuery defines the tag query
  1611. * @returns a boolean
  1612. */
  1613. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1614. }
  1615. }
  1616. declare module BABYLON {
  1617. /**
  1618. * Scalar computation library
  1619. */
  1620. export class Scalar {
  1621. /**
  1622. * Two pi constants convenient for computation.
  1623. */
  1624. static TwoPi: number;
  1625. /**
  1626. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1627. * @param a number
  1628. * @param b number
  1629. * @param epsilon (default = 1.401298E-45)
  1630. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1631. */
  1632. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1633. /**
  1634. * Returns a string : the upper case translation of the number i to hexadecimal.
  1635. * @param i number
  1636. * @returns the upper case translation of the number i to hexadecimal.
  1637. */
  1638. static ToHex(i: number): string;
  1639. /**
  1640. * Returns -1 if value is negative and +1 is value is positive.
  1641. * @param value the value
  1642. * @returns the value itself if it's equal to zero.
  1643. */
  1644. static Sign(value: number): number;
  1645. /**
  1646. * Returns the value itself if it's between min and max.
  1647. * Returns min if the value is lower than min.
  1648. * Returns max if the value is greater than max.
  1649. * @param value the value to clmap
  1650. * @param min the min value to clamp to (default: 0)
  1651. * @param max the max value to clamp to (default: 1)
  1652. * @returns the clamped value
  1653. */
  1654. static Clamp(value: number, min?: number, max?: number): number;
  1655. /**
  1656. * the log2 of value.
  1657. * @param value the value to compute log2 of
  1658. * @returns the log2 of value.
  1659. */
  1660. static Log2(value: number): number;
  1661. /**
  1662. * Loops the value, so that it is never larger than length and never smaller than 0.
  1663. *
  1664. * This is similar to the modulo operator but it works with floating point numbers.
  1665. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1666. * With t = 5 and length = 2.5, the result would be 0.0.
  1667. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1668. * @param value the value
  1669. * @param length the length
  1670. * @returns the looped value
  1671. */
  1672. static Repeat(value: number, length: number): number;
  1673. /**
  1674. * Normalize the value between 0.0 and 1.0 using min and max values
  1675. * @param value value to normalize
  1676. * @param min max to normalize between
  1677. * @param max min to normalize between
  1678. * @returns the normalized value
  1679. */
  1680. static Normalize(value: number, min: number, max: number): number;
  1681. /**
  1682. * Denormalize the value from 0.0 and 1.0 using min and max values
  1683. * @param normalized value to denormalize
  1684. * @param min max to denormalize between
  1685. * @param max min to denormalize between
  1686. * @returns the denormalized value
  1687. */
  1688. static Denormalize(normalized: number, min: number, max: number): number;
  1689. /**
  1690. * Calculates the shortest difference between two given angles given in degrees.
  1691. * @param current current angle in degrees
  1692. * @param target target angle in degrees
  1693. * @returns the delta
  1694. */
  1695. static DeltaAngle(current: number, target: number): number;
  1696. /**
  1697. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1698. * @param tx value
  1699. * @param length length
  1700. * @returns The returned value will move back and forth between 0 and length
  1701. */
  1702. static PingPong(tx: number, length: number): number;
  1703. /**
  1704. * Interpolates between min and max with smoothing at the limits.
  1705. *
  1706. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1707. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1708. * @param from from
  1709. * @param to to
  1710. * @param tx value
  1711. * @returns the smooth stepped value
  1712. */
  1713. static SmoothStep(from: number, to: number, tx: number): number;
  1714. /**
  1715. * Moves a value current towards target.
  1716. *
  1717. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1718. * Negative values of maxDelta pushes the value away from target.
  1719. * @param current current value
  1720. * @param target target value
  1721. * @param maxDelta max distance to move
  1722. * @returns resulting value
  1723. */
  1724. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1725. /**
  1726. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1727. *
  1728. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1729. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1730. * @param current current value
  1731. * @param target target value
  1732. * @param maxDelta max distance to move
  1733. * @returns resulting angle
  1734. */
  1735. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1736. /**
  1737. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1738. * @param start start value
  1739. * @param end target value
  1740. * @param amount amount to lerp between
  1741. * @returns the lerped value
  1742. */
  1743. static Lerp(start: number, end: number, amount: number): number;
  1744. /**
  1745. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1746. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1747. * @param start start value
  1748. * @param end target value
  1749. * @param amount amount to lerp between
  1750. * @returns the lerped value
  1751. */
  1752. static LerpAngle(start: number, end: number, amount: number): number;
  1753. /**
  1754. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1755. * @param a start value
  1756. * @param b target value
  1757. * @param value value between a and b
  1758. * @returns the inverseLerp value
  1759. */
  1760. static InverseLerp(a: number, b: number, value: number): number;
  1761. /**
  1762. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1763. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1764. * @param value1 spline value
  1765. * @param tangent1 spline value
  1766. * @param value2 spline value
  1767. * @param tangent2 spline value
  1768. * @param amount input value
  1769. * @returns hermite result
  1770. */
  1771. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1772. /**
  1773. * Returns a random float number between and min and max values
  1774. * @param min min value of random
  1775. * @param max max value of random
  1776. * @returns random value
  1777. */
  1778. static RandomRange(min: number, max: number): number;
  1779. /**
  1780. * This function returns percentage of a number in a given range.
  1781. *
  1782. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1783. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1784. * @param number to convert to percentage
  1785. * @param min min range
  1786. * @param max max range
  1787. * @returns the percentage
  1788. */
  1789. static RangeToPercent(number: number, min: number, max: number): number;
  1790. /**
  1791. * This function returns number that corresponds to the percentage in a given range.
  1792. *
  1793. * PercentToRange(0.34,0,100) will return 34.
  1794. * @param percent to convert to number
  1795. * @param min min range
  1796. * @param max max range
  1797. * @returns the number
  1798. */
  1799. static PercentToRange(percent: number, min: number, max: number): number;
  1800. /**
  1801. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1802. * @param angle The angle to normalize in radian.
  1803. * @return The converted angle.
  1804. */
  1805. static NormalizeRadians(angle: number): number;
  1806. }
  1807. }
  1808. declare module BABYLON {
  1809. /**
  1810. * Constant used to convert a value to gamma space
  1811. * @ignorenaming
  1812. */
  1813. export const ToGammaSpace: number;
  1814. /**
  1815. * Constant used to convert a value to linear space
  1816. * @ignorenaming
  1817. */
  1818. export const ToLinearSpace = 2.2;
  1819. /**
  1820. * Constant used to define the minimal number value in Babylon.js
  1821. * @ignorenaming
  1822. */
  1823. let Epsilon: number;
  1824. }
  1825. declare module BABYLON {
  1826. /**
  1827. * Class used to represent a viewport on screen
  1828. */
  1829. export class Viewport {
  1830. /** viewport left coordinate */
  1831. x: number;
  1832. /** viewport top coordinate */
  1833. y: number;
  1834. /**viewport width */
  1835. width: number;
  1836. /** viewport height */
  1837. height: number;
  1838. /**
  1839. * Creates a Viewport object located at (x, y) and sized (width, height)
  1840. * @param x defines viewport left coordinate
  1841. * @param y defines viewport top coordinate
  1842. * @param width defines the viewport width
  1843. * @param height defines the viewport height
  1844. */
  1845. constructor(
  1846. /** viewport left coordinate */
  1847. x: number,
  1848. /** viewport top coordinate */
  1849. y: number,
  1850. /**viewport width */
  1851. width: number,
  1852. /** viewport height */
  1853. height: number);
  1854. /**
  1855. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1856. * @param renderWidth defines the rendering width
  1857. * @param renderHeight defines the rendering height
  1858. * @returns a new Viewport
  1859. */
  1860. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1861. /**
  1862. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1863. * @param renderWidth defines the rendering width
  1864. * @param renderHeight defines the rendering height
  1865. * @param ref defines the target viewport
  1866. * @returns the current viewport
  1867. */
  1868. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1869. /**
  1870. * Returns a new Viewport copied from the current one
  1871. * @returns a new Viewport
  1872. */
  1873. clone(): Viewport;
  1874. }
  1875. }
  1876. declare module BABYLON {
  1877. /**
  1878. * Class containing a set of static utilities functions for arrays.
  1879. */
  1880. export class ArrayTools {
  1881. /**
  1882. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1883. * @param size the number of element to construct and put in the array
  1884. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1885. * @returns a new array filled with new objects
  1886. */
  1887. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1888. }
  1889. }
  1890. declare module BABYLON {
  1891. /**
  1892. * Class representing a vector containing 2 coordinates
  1893. */
  1894. export class Vector2 {
  1895. /** defines the first coordinate */
  1896. x: number;
  1897. /** defines the second coordinate */
  1898. y: number;
  1899. /**
  1900. * Creates a new Vector2 from the given x and y coordinates
  1901. * @param x defines the first coordinate
  1902. * @param y defines the second coordinate
  1903. */
  1904. constructor(
  1905. /** defines the first coordinate */
  1906. x?: number,
  1907. /** defines the second coordinate */
  1908. y?: number);
  1909. /**
  1910. * Gets a string with the Vector2 coordinates
  1911. * @returns a string with the Vector2 coordinates
  1912. */
  1913. toString(): string;
  1914. /**
  1915. * Gets class name
  1916. * @returns the string "Vector2"
  1917. */
  1918. getClassName(): string;
  1919. /**
  1920. * Gets current vector hash code
  1921. * @returns the Vector2 hash code as a number
  1922. */
  1923. getHashCode(): number;
  1924. /**
  1925. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1926. * @param array defines the source array
  1927. * @param index defines the offset in source array
  1928. * @returns the current Vector2
  1929. */
  1930. toArray(array: FloatArray, index?: number): Vector2;
  1931. /**
  1932. * Copy the current vector to an array
  1933. * @returns a new array with 2 elements: the Vector2 coordinates.
  1934. */
  1935. asArray(): number[];
  1936. /**
  1937. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1938. * @param source defines the source Vector2
  1939. * @returns the current updated Vector2
  1940. */
  1941. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1942. /**
  1943. * Sets the Vector2 coordinates with the given floats
  1944. * @param x defines the first coordinate
  1945. * @param y defines the second coordinate
  1946. * @returns the current updated Vector2
  1947. */
  1948. copyFromFloats(x: number, y: number): Vector2;
  1949. /**
  1950. * Sets the Vector2 coordinates with the given floats
  1951. * @param x defines the first coordinate
  1952. * @param y defines the second coordinate
  1953. * @returns the current updated Vector2
  1954. */
  1955. set(x: number, y: number): Vector2;
  1956. /**
  1957. * Add another vector with the current one
  1958. * @param otherVector defines the other vector
  1959. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1960. */
  1961. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1962. /**
  1963. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1964. * @param otherVector defines the other vector
  1965. * @param result defines the target vector
  1966. * @returns the unmodified current Vector2
  1967. */
  1968. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1969. /**
  1970. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1971. * @param otherVector defines the other vector
  1972. * @returns the current updated Vector2
  1973. */
  1974. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1975. /**
  1976. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1977. * @param otherVector defines the other vector
  1978. * @returns a new Vector2
  1979. */
  1980. addVector3(otherVector: Vector3): Vector2;
  1981. /**
  1982. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2
  1985. */
  1986. subtract(otherVector: Vector2): Vector2;
  1987. /**
  1988. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1989. * @param otherVector defines the other vector
  1990. * @param result defines the target vector
  1991. * @returns the unmodified current Vector2
  1992. */
  1993. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1994. /**
  1995. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1996. * @param otherVector defines the other vector
  1997. * @returns the current updated Vector2
  1998. */
  1999. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2000. /**
  2001. * Multiplies in place the current Vector2 coordinates by the given ones
  2002. * @param otherVector defines the other vector
  2003. * @returns the current updated Vector2
  2004. */
  2005. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2006. /**
  2007. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2012. /**
  2013. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2014. * @param otherVector defines the other vector
  2015. * @param result defines the target vector
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2019. /**
  2020. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2021. * @param x defines the first coordinate
  2022. * @param y defines the second coordinate
  2023. * @returns a new Vector2
  2024. */
  2025. multiplyByFloats(x: number, y: number): Vector2;
  2026. /**
  2027. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2028. * @param otherVector defines the other vector
  2029. * @returns a new Vector2
  2030. */
  2031. divide(otherVector: Vector2): Vector2;
  2032. /**
  2033. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2034. * @param otherVector defines the other vector
  2035. * @param result defines the target vector
  2036. * @returns the unmodified current Vector2
  2037. */
  2038. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2039. /**
  2040. * Divides the current Vector2 coordinates by the given ones
  2041. * @param otherVector defines the other vector
  2042. * @returns the current updated Vector2
  2043. */
  2044. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2045. /**
  2046. * Gets a new Vector2 with current Vector2 negated coordinates
  2047. * @returns a new Vector2
  2048. */
  2049. negate(): Vector2;
  2050. /**
  2051. * Negate this vector in place
  2052. * @returns this
  2053. */
  2054. negateInPlace(): Vector2;
  2055. /**
  2056. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2057. * @param result defines the Vector3 object where to store the result
  2058. * @returns the current Vector2
  2059. */
  2060. negateToRef(result: Vector2): Vector2;
  2061. /**
  2062. * Multiply the Vector2 coordinates by scale
  2063. * @param scale defines the scaling factor
  2064. * @returns the current updated Vector2
  2065. */
  2066. scaleInPlace(scale: number): Vector2;
  2067. /**
  2068. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2069. * @param scale defines the scaling factor
  2070. * @returns a new Vector2
  2071. */
  2072. scale(scale: number): Vector2;
  2073. /**
  2074. * Scale the current Vector2 values by a factor to a given Vector2
  2075. * @param scale defines the scale factor
  2076. * @param result defines the Vector2 object where to store the result
  2077. * @returns the unmodified current Vector2
  2078. */
  2079. scaleToRef(scale: number, result: Vector2): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Gets a boolean if two vectors are equals
  2089. * @param otherVector defines the other vector
  2090. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2091. */
  2092. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2093. /**
  2094. * Gets a boolean if two vectors are equals (using an epsilon value)
  2095. * @param otherVector defines the other vector
  2096. * @param epsilon defines the minimal distance to consider equality
  2097. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2098. */
  2099. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2100. /**
  2101. * Gets a new Vector2 from current Vector2 floored values
  2102. * @returns a new Vector2
  2103. */
  2104. floor(): Vector2;
  2105. /**
  2106. * Gets a new Vector2 from current Vector2 floored values
  2107. * @returns a new Vector2
  2108. */
  2109. fract(): Vector2;
  2110. /**
  2111. * Gets the length of the vector
  2112. * @returns the vector length (float)
  2113. */
  2114. length(): number;
  2115. /**
  2116. * Gets the vector squared length
  2117. * @returns the vector squared length (float)
  2118. */
  2119. lengthSquared(): number;
  2120. /**
  2121. * Normalize the vector
  2122. * @returns the current updated Vector2
  2123. */
  2124. normalize(): Vector2;
  2125. /**
  2126. * Gets a new Vector2 copied from the Vector2
  2127. * @returns a new Vector2
  2128. */
  2129. clone(): Vector2;
  2130. /**
  2131. * Gets a new Vector2(0, 0)
  2132. * @returns a new Vector2
  2133. */
  2134. static Zero(): Vector2;
  2135. /**
  2136. * Gets a new Vector2(1, 1)
  2137. * @returns a new Vector2
  2138. */
  2139. static One(): Vector2;
  2140. /**
  2141. * Gets a new Vector2 set from the given index element of the given array
  2142. * @param array defines the data source
  2143. * @param offset defines the offset in the data source
  2144. * @returns a new Vector2
  2145. */
  2146. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2147. /**
  2148. * Sets "result" from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @param result defines the target vector
  2152. */
  2153. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2154. /**
  2155. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2156. * @param value1 defines 1st point of control
  2157. * @param value2 defines 2nd point of control
  2158. * @param value3 defines 3rd point of control
  2159. * @param value4 defines 4th point of control
  2160. * @param amount defines the interpolation factor
  2161. * @returns a new Vector2
  2162. */
  2163. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2164. /**
  2165. * 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".
  2166. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2167. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2168. * @param value defines the value to clamp
  2169. * @param min defines the lower limit
  2170. * @param max defines the upper limit
  2171. * @returns a new Vector2
  2172. */
  2173. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2176. * @param value1 defines the 1st control point
  2177. * @param tangent1 defines the outgoing tangent
  2178. * @param value2 defines the 2nd control point
  2179. * @param tangent2 defines the incoming tangent
  2180. * @param amount defines the interpolation factor
  2181. * @returns a new Vector2
  2182. */
  2183. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2184. /**
  2185. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2186. * @param start defines the start vector
  2187. * @param end defines the end vector
  2188. * @param amount defines the interpolation factor
  2189. * @returns a new Vector2
  2190. */
  2191. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2192. /**
  2193. * Gets the dot product of the vector "left" and the vector "right"
  2194. * @param left defines first vector
  2195. * @param right defines second vector
  2196. * @returns the dot product (float)
  2197. */
  2198. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2199. /**
  2200. * Returns a new Vector2 equal to the normalized given vector
  2201. * @param vector defines the vector to normalize
  2202. * @returns a new Vector2
  2203. */
  2204. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2207. * @param left defines 1st vector
  2208. * @param right defines 2nd vector
  2209. * @returns a new Vector2
  2210. */
  2211. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2221. * @param vector defines the vector to transform
  2222. * @param transformation defines the matrix to apply
  2223. * @returns a new Vector2
  2224. */
  2225. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2226. /**
  2227. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @param result defines the target vector
  2231. */
  2232. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2233. /**
  2234. * Determines if a given vector is included in a triangle
  2235. * @param p defines the vector to test
  2236. * @param p0 defines 1st triangle point
  2237. * @param p1 defines 2nd triangle point
  2238. * @param p2 defines 3rd triangle point
  2239. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2240. */
  2241. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2242. /**
  2243. * Gets the distance between the vectors "value1" and "value2"
  2244. * @param value1 defines first vector
  2245. * @param value2 defines second vector
  2246. * @returns the distance between vectors
  2247. */
  2248. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2249. /**
  2250. * Returns the squared distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the squared distance between vectors
  2254. */
  2255. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns a new Vector2
  2261. */
  2262. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2263. /**
  2264. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2265. * @param p defines the middle point
  2266. * @param segA defines one point of the segment
  2267. * @param segB defines the other point of the segment
  2268. * @returns the shortest distance
  2269. */
  2270. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2271. }
  2272. /**
  2273. * Class used to store (x,y,z) vector representation
  2274. * A Vector3 is the main object used in 3D geometry
  2275. * It can represent etiher the coordinates of a point the space, either a direction
  2276. * Reminder: js uses a left handed forward facing system
  2277. */
  2278. export class Vector3 {
  2279. /**
  2280. * Defines the first coordinates (on X axis)
  2281. */
  2282. x: number;
  2283. /**
  2284. * Defines the second coordinates (on Y axis)
  2285. */
  2286. y: number;
  2287. /**
  2288. * Defines the third coordinates (on Z axis)
  2289. */
  2290. z: number;
  2291. private static _UpReadOnly;
  2292. private static _ZeroReadOnly;
  2293. /**
  2294. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2295. * @param x defines the first coordinates (on X axis)
  2296. * @param y defines the second coordinates (on Y axis)
  2297. * @param z defines the third coordinates (on Z axis)
  2298. */
  2299. constructor(
  2300. /**
  2301. * Defines the first coordinates (on X axis)
  2302. */
  2303. x?: number,
  2304. /**
  2305. * Defines the second coordinates (on Y axis)
  2306. */
  2307. y?: number,
  2308. /**
  2309. * Defines the third coordinates (on Z axis)
  2310. */
  2311. z?: number);
  2312. /**
  2313. * Creates a string representation of the Vector3
  2314. * @returns a string with the Vector3 coordinates.
  2315. */
  2316. toString(): string;
  2317. /**
  2318. * Gets the class name
  2319. * @returns the string "Vector3"
  2320. */
  2321. getClassName(): string;
  2322. /**
  2323. * Creates the Vector3 hash code
  2324. * @returns a number which tends to be unique between Vector3 instances
  2325. */
  2326. getHashCode(): number;
  2327. /**
  2328. * Creates an array containing three elements : the coordinates of the Vector3
  2329. * @returns a new array of numbers
  2330. */
  2331. asArray(): number[];
  2332. /**
  2333. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2334. * @param array defines the destination array
  2335. * @param index defines the offset in the destination array
  2336. * @returns the current Vector3
  2337. */
  2338. toArray(array: FloatArray, index?: number): Vector3;
  2339. /**
  2340. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2341. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2342. */
  2343. toQuaternion(): Quaternion;
  2344. /**
  2345. * Adds the given vector to the current Vector3
  2346. * @param otherVector defines the second operand
  2347. * @returns the current updated Vector3
  2348. */
  2349. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2350. /**
  2351. * Adds the given coordinates to the current Vector3
  2352. * @param x defines the x coordinate of the operand
  2353. * @param y defines the y coordinate of the operand
  2354. * @param z defines the z coordinate of the operand
  2355. * @returns the current updated Vector3
  2356. */
  2357. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2358. /**
  2359. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2360. * @param otherVector defines the second operand
  2361. * @returns the resulting Vector3
  2362. */
  2363. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2366. * @param otherVector defines the second operand
  2367. * @param result defines the Vector3 object where to store the result
  2368. * @returns the current Vector3
  2369. */
  2370. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2371. /**
  2372. * Subtract the given vector from the current Vector3
  2373. * @param otherVector defines the second operand
  2374. * @returns the current updated Vector3
  2375. */
  2376. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2377. /**
  2378. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2379. * @param otherVector defines the second operand
  2380. * @returns the resulting Vector3
  2381. */
  2382. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2383. /**
  2384. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2385. * @param otherVector defines the second operand
  2386. * @param result defines the Vector3 object where to store the result
  2387. * @returns the current Vector3
  2388. */
  2389. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2390. /**
  2391. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2392. * @param x defines the x coordinate of the operand
  2393. * @param y defines the y coordinate of the operand
  2394. * @param z defines the z coordinate of the operand
  2395. * @returns the resulting Vector3
  2396. */
  2397. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2398. /**
  2399. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2400. * @param x defines the x coordinate of the operand
  2401. * @param y defines the y coordinate of the operand
  2402. * @param z defines the z coordinate of the operand
  2403. * @param result defines the Vector3 object where to store the result
  2404. * @returns the current Vector3
  2405. */
  2406. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2407. /**
  2408. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2409. * @returns a new Vector3
  2410. */
  2411. negate(): Vector3;
  2412. /**
  2413. * Negate this vector in place
  2414. * @returns this
  2415. */
  2416. negateInPlace(): Vector3;
  2417. /**
  2418. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2419. * @param result defines the Vector3 object where to store the result
  2420. * @returns the current Vector3
  2421. */
  2422. negateToRef(result: Vector3): Vector3;
  2423. /**
  2424. * Multiplies the Vector3 coordinates by the float "scale"
  2425. * @param scale defines the multiplier factor
  2426. * @returns the current updated Vector3
  2427. */
  2428. scaleInPlace(scale: number): Vector3;
  2429. /**
  2430. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2431. * @param scale defines the multiplier factor
  2432. * @returns a new Vector3
  2433. */
  2434. scale(scale: number): Vector3;
  2435. /**
  2436. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2437. * @param scale defines the multiplier factor
  2438. * @param result defines the Vector3 object where to store the result
  2439. * @returns the current Vector3
  2440. */
  2441. scaleToRef(scale: number, result: Vector3): Vector3;
  2442. /**
  2443. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2444. * @param scale defines the scale factor
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the unmodified current Vector3
  2447. */
  2448. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2449. /**
  2450. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2451. * @param otherVector defines the second operand
  2452. * @returns true if both vectors are equals
  2453. */
  2454. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2455. /**
  2456. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2457. * @param otherVector defines the second operand
  2458. * @param epsilon defines the minimal distance to define values as equals
  2459. * @returns true if both vectors are distant less than epsilon
  2460. */
  2461. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2462. /**
  2463. * Returns true if the current Vector3 coordinates equals the given floats
  2464. * @param x defines the x coordinate of the operand
  2465. * @param y defines the y coordinate of the operand
  2466. * @param z defines the z coordinate of the operand
  2467. * @returns true if both vectors are equals
  2468. */
  2469. equalsToFloats(x: number, y: number, z: number): boolean;
  2470. /**
  2471. * Multiplies the current Vector3 coordinates by the given ones
  2472. * @param otherVector defines the second operand
  2473. * @returns the current updated Vector3
  2474. */
  2475. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2476. /**
  2477. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2478. * @param otherVector defines the second operand
  2479. * @returns the new Vector3
  2480. */
  2481. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2484. * @param otherVector defines the second operand
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the current Vector3
  2487. */
  2488. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2489. /**
  2490. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2491. * @param x defines the x coordinate of the operand
  2492. * @param y defines the y coordinate of the operand
  2493. * @param z defines the z coordinate of the operand
  2494. * @returns the new Vector3
  2495. */
  2496. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2497. /**
  2498. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2499. * @param otherVector defines the second operand
  2500. * @returns the new Vector3
  2501. */
  2502. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2503. /**
  2504. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2505. * @param otherVector defines the second operand
  2506. * @param result defines the Vector3 object where to store the result
  2507. * @returns the current Vector3
  2508. */
  2509. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2510. /**
  2511. * Divides the current Vector3 coordinates by the given ones.
  2512. * @param otherVector defines the second operand
  2513. * @returns the current updated Vector3
  2514. */
  2515. divideInPlace(otherVector: Vector3): Vector3;
  2516. /**
  2517. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2518. * @param other defines the second operand
  2519. * @returns the current updated Vector3
  2520. */
  2521. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2522. /**
  2523. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2524. * @param other defines the second operand
  2525. * @returns the current updated Vector3
  2526. */
  2527. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2528. /**
  2529. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2530. * @param x defines the x coordinate of the operand
  2531. * @param y defines the y coordinate of the operand
  2532. * @param z defines the z coordinate of the operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2538. * @param x defines the x coordinate of the operand
  2539. * @param y defines the y coordinate of the operand
  2540. * @param z defines the z coordinate of the operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2544. /**
  2545. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2546. * Check if is non uniform within a certain amount of decimal places to account for this
  2547. * @param epsilon the amount the values can differ
  2548. * @returns if the the vector is non uniform to a certain number of decimal places
  2549. */
  2550. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2551. /**
  2552. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2553. */
  2554. get isNonUniform(): boolean;
  2555. /**
  2556. * Gets a new Vector3 from current Vector3 floored values
  2557. * @returns a new Vector3
  2558. */
  2559. floor(): Vector3;
  2560. /**
  2561. * Gets a new Vector3 from current Vector3 floored values
  2562. * @returns a new Vector3
  2563. */
  2564. fract(): Vector3;
  2565. /**
  2566. * Gets the length of the Vector3
  2567. * @returns the length of the Vector3
  2568. */
  2569. length(): number;
  2570. /**
  2571. * Gets the squared length of the Vector3
  2572. * @returns squared length of the Vector3
  2573. */
  2574. lengthSquared(): number;
  2575. /**
  2576. * Normalize the current Vector3.
  2577. * Please note that this is an in place operation.
  2578. * @returns the current updated Vector3
  2579. */
  2580. normalize(): Vector3;
  2581. /**
  2582. * Reorders the x y z properties of the vector in place
  2583. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2584. * @returns the current updated vector
  2585. */
  2586. reorderInPlace(order: string): this;
  2587. /**
  2588. * Rotates the vector around 0,0,0 by a quaternion
  2589. * @param quaternion the rotation quaternion
  2590. * @param result vector to store the result
  2591. * @returns the resulting vector
  2592. */
  2593. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2594. /**
  2595. * Rotates a vector around a given point
  2596. * @param quaternion the rotation quaternion
  2597. * @param point the point to rotate around
  2598. * @param result vector to store the result
  2599. * @returns the resulting vector
  2600. */
  2601. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2602. /**
  2603. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2604. * The cross product is then orthogonal to both current and "other"
  2605. * @param other defines the right operand
  2606. * @returns the cross product
  2607. */
  2608. cross(other: Vector3): Vector3;
  2609. /**
  2610. * Normalize the current Vector3 with the given input length.
  2611. * Please note that this is an in place operation.
  2612. * @param len the length of the vector
  2613. * @returns the current updated Vector3
  2614. */
  2615. normalizeFromLength(len: number): Vector3;
  2616. /**
  2617. * Normalize the current Vector3 to a new vector
  2618. * @returns the new Vector3
  2619. */
  2620. normalizeToNew(): Vector3;
  2621. /**
  2622. * Normalize the current Vector3 to the reference
  2623. * @param reference define the Vector3 to update
  2624. * @returns the updated Vector3
  2625. */
  2626. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2627. /**
  2628. * Creates a new Vector3 copied from the current Vector3
  2629. * @returns the new Vector3
  2630. */
  2631. clone(): Vector3;
  2632. /**
  2633. * Copies the given vector coordinates to the current Vector3 ones
  2634. * @param source defines the source Vector3
  2635. * @returns the current updated Vector3
  2636. */
  2637. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2638. /**
  2639. * Copies the given floats to the current Vector3 coordinates
  2640. * @param x defines the x coordinate of the operand
  2641. * @param y defines the y coordinate of the operand
  2642. * @param z defines the z coordinate of the operand
  2643. * @returns the current updated Vector3
  2644. */
  2645. copyFromFloats(x: number, y: number, z: number): Vector3;
  2646. /**
  2647. * Copies the given floats to the current Vector3 coordinates
  2648. * @param x defines the x coordinate of the operand
  2649. * @param y defines the y coordinate of the operand
  2650. * @param z defines the z coordinate of the operand
  2651. * @returns the current updated Vector3
  2652. */
  2653. set(x: number, y: number, z: number): Vector3;
  2654. /**
  2655. * Copies the given float to the current Vector3 coordinates
  2656. * @param v defines the x, y and z coordinates of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. setAll(v: number): Vector3;
  2660. /**
  2661. * Get the clip factor between two vectors
  2662. * @param vector0 defines the first operand
  2663. * @param vector1 defines the second operand
  2664. * @param axis defines the axis to use
  2665. * @param size defines the size along the axis
  2666. * @returns the clip factor
  2667. */
  2668. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2669. /**
  2670. * Get angle between two vectors
  2671. * @param vector0 angle between vector0 and vector1
  2672. * @param vector1 angle between vector0 and vector1
  2673. * @param normal direction of the normal
  2674. * @return the angle between vector0 and vector1
  2675. */
  2676. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2677. /**
  2678. * Returns a new Vector3 set from the index "offset" of the given array
  2679. * @param array defines the source array
  2680. * @param offset defines the offset in the source array
  2681. * @returns the new Vector3
  2682. */
  2683. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2684. /**
  2685. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @returns the new Vector3
  2689. * @deprecated Please use FromArray instead.
  2690. */
  2691. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2692. /**
  2693. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2694. * @param array defines the source array
  2695. * @param offset defines the offset in the source array
  2696. * @param result defines the Vector3 where to store the result
  2697. */
  2698. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2699. /**
  2700. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @param result defines the Vector3 where to store the result
  2704. * @deprecated Please use FromArrayToRef instead.
  2705. */
  2706. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2707. /**
  2708. * Sets the given vector "result" with the given floats.
  2709. * @param x defines the x coordinate of the source
  2710. * @param y defines the y coordinate of the source
  2711. * @param z defines the z coordinate of the source
  2712. * @param result defines the Vector3 where to store the result
  2713. */
  2714. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2715. /**
  2716. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2717. * @returns a new empty Vector3
  2718. */
  2719. static Zero(): Vector3;
  2720. /**
  2721. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2722. * @returns a new unit Vector3
  2723. */
  2724. static One(): Vector3;
  2725. /**
  2726. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2727. * @returns a new up Vector3
  2728. */
  2729. static Up(): Vector3;
  2730. /**
  2731. * Gets a up Vector3 that must not be updated
  2732. */
  2733. static get UpReadOnly(): DeepImmutable<Vector3>;
  2734. /**
  2735. * Gets a zero Vector3 that must not be updated
  2736. */
  2737. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2738. /**
  2739. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2740. * @returns a new down Vector3
  2741. */
  2742. static Down(): Vector3;
  2743. /**
  2744. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2745. * @returns a new forward Vector3
  2746. */
  2747. static Forward(): Vector3;
  2748. /**
  2749. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2750. * @returns a new forward Vector3
  2751. */
  2752. static Backward(): Vector3;
  2753. /**
  2754. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2755. * @returns a new right Vector3
  2756. */
  2757. static Right(): Vector3;
  2758. /**
  2759. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2760. * @returns a new left Vector3
  2761. */
  2762. static Left(): Vector3;
  2763. /**
  2764. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2765. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2766. * @param vector defines the Vector3 to transform
  2767. * @param transformation defines the transformation matrix
  2768. * @returns the transformed Vector3
  2769. */
  2770. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2771. /**
  2772. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2773. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2774. * @param vector defines the Vector3 to transform
  2775. * @param transformation defines the transformation matrix
  2776. * @param result defines the Vector3 where to store the result
  2777. */
  2778. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2779. /**
  2780. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2781. * This method computes tranformed coordinates only, not transformed direction vectors
  2782. * @param x define the x coordinate of the source vector
  2783. * @param y define the y coordinate of the source vector
  2784. * @param z define the z coordinate of the source vector
  2785. * @param transformation defines the transformation matrix
  2786. * @param result defines the Vector3 where to store the result
  2787. */
  2788. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2789. /**
  2790. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2791. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2792. * @param vector defines the Vector3 to transform
  2793. * @param transformation defines the transformation matrix
  2794. * @returns the new Vector3
  2795. */
  2796. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2797. /**
  2798. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2799. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2800. * @param vector defines the Vector3 to transform
  2801. * @param transformation defines the transformation matrix
  2802. * @param result defines the Vector3 where to store the result
  2803. */
  2804. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2805. /**
  2806. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2807. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2808. * @param x define the x coordinate of the source vector
  2809. * @param y define the y coordinate of the source vector
  2810. * @param z define the z coordinate of the source vector
  2811. * @param transformation defines the transformation matrix
  2812. * @param result defines the Vector3 where to store the result
  2813. */
  2814. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2815. /**
  2816. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2817. * @param value1 defines the first control point
  2818. * @param value2 defines the second control point
  2819. * @param value3 defines the third control point
  2820. * @param value4 defines the fourth control point
  2821. * @param amount defines the amount on the spline to use
  2822. * @returns the new Vector3
  2823. */
  2824. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2825. /**
  2826. * 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"
  2827. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2828. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2829. * @param value defines the current value
  2830. * @param min defines the lower range value
  2831. * @param max defines the upper range value
  2832. * @returns the new Vector3
  2833. */
  2834. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2835. /**
  2836. * 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"
  2837. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2838. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2839. * @param value defines the current value
  2840. * @param min defines the lower range value
  2841. * @param max defines the upper range value
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2845. /**
  2846. * Checks if a given vector is inside a specific range
  2847. * @param v defines the vector to test
  2848. * @param min defines the minimum range
  2849. * @param max defines the maximum range
  2850. */
  2851. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2852. /**
  2853. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2854. * @param value1 defines the first control point
  2855. * @param tangent1 defines the first tangent vector
  2856. * @param value2 defines the second control point
  2857. * @param tangent2 defines the second tangent vector
  2858. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2859. * @returns the new Vector3
  2860. */
  2861. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2862. /**
  2863. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2864. * @param start defines the start value
  2865. * @param end defines the end value
  2866. * @param amount max defines amount between both (between 0 and 1)
  2867. * @returns the new Vector3
  2868. */
  2869. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2870. /**
  2871. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2872. * @param start defines the start value
  2873. * @param end defines the end value
  2874. * @param amount max defines amount between both (between 0 and 1)
  2875. * @param result defines the Vector3 where to store the result
  2876. */
  2877. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2878. /**
  2879. * Returns the dot product (float) between the vectors "left" and "right"
  2880. * @param left defines the left operand
  2881. * @param right defines the right operand
  2882. * @returns the dot product
  2883. */
  2884. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2885. /**
  2886. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2887. * The cross product is then orthogonal to both "left" and "right"
  2888. * @param left defines the left operand
  2889. * @param right defines the right operand
  2890. * @returns the cross product
  2891. */
  2892. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2893. /**
  2894. * Sets the given vector "result" with the cross product of "left" and "right"
  2895. * The cross product is then orthogonal to both "left" and "right"
  2896. * @param left defines the left operand
  2897. * @param right defines the right operand
  2898. * @param result defines the Vector3 where to store the result
  2899. */
  2900. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2901. /**
  2902. * Returns a new Vector3 as the normalization of the given vector
  2903. * @param vector defines the Vector3 to normalize
  2904. * @returns the new Vector3
  2905. */
  2906. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the normalization of the given first vector
  2909. * @param vector defines the Vector3 to normalize
  2910. * @param result defines the Vector3 where to store the result
  2911. */
  2912. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2913. /**
  2914. * Project a Vector3 onto screen space
  2915. * @param vector defines the Vector3 to project
  2916. * @param world defines the world matrix to use
  2917. * @param transform defines the transform (view x projection) matrix to use
  2918. * @param viewport defines the screen viewport to use
  2919. * @returns the new Vector3
  2920. */
  2921. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2922. /** @hidden */
  2923. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2924. /**
  2925. * Unproject from screen space to object space
  2926. * @param source defines the screen space Vector3 to use
  2927. * @param viewportWidth defines the current width of the viewport
  2928. * @param viewportHeight defines the current height of the viewport
  2929. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2930. * @param transform defines the transform (view x projection) matrix to use
  2931. * @returns the new Vector3
  2932. */
  2933. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2934. /**
  2935. * Unproject from screen space to object space
  2936. * @param source defines the screen space Vector3 to use
  2937. * @param viewportWidth defines the current width of the viewport
  2938. * @param viewportHeight defines the current height of the viewport
  2939. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2940. * @param view defines the view matrix to use
  2941. * @param projection defines the projection matrix to use
  2942. * @returns the new Vector3
  2943. */
  2944. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2945. /**
  2946. * Unproject from screen space to object space
  2947. * @param source defines the screen space Vector3 to use
  2948. * @param viewportWidth defines the current width of the viewport
  2949. * @param viewportHeight defines the current height of the viewport
  2950. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2951. * @param view defines the view matrix to use
  2952. * @param projection defines the projection matrix to use
  2953. * @param result defines the Vector3 where to store the result
  2954. */
  2955. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2956. /**
  2957. * Unproject from screen space to object space
  2958. * @param sourceX defines the screen space x coordinate to use
  2959. * @param sourceY defines the screen space y coordinate to use
  2960. * @param sourceZ defines the screen space z coordinate to use
  2961. * @param viewportWidth defines the current width of the viewport
  2962. * @param viewportHeight defines the current height of the viewport
  2963. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2964. * @param view defines the view matrix to use
  2965. * @param projection defines the projection matrix to use
  2966. * @param result defines the Vector3 where to store the result
  2967. */
  2968. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2969. /**
  2970. * Gets the minimal coordinate values between two Vector3
  2971. * @param left defines the first operand
  2972. * @param right defines the second operand
  2973. * @returns the new Vector3
  2974. */
  2975. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2976. /**
  2977. * Gets the maximal coordinate values between two Vector3
  2978. * @param left defines the first operand
  2979. * @param right defines the second operand
  2980. * @returns the new Vector3
  2981. */
  2982. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Returns the distance between the vectors "value1" and "value2"
  2985. * @param value1 defines the first operand
  2986. * @param value2 defines the second operand
  2987. * @returns the distance
  2988. */
  2989. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2990. /**
  2991. * Returns the squared distance between the vectors "value1" and "value2"
  2992. * @param value1 defines the first operand
  2993. * @param value2 defines the second operand
  2994. * @returns the squared distance
  2995. */
  2996. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2997. /**
  2998. * Returns a new Vector3 located at the center between "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the new Vector3
  3002. */
  3003. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3004. /**
  3005. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3006. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3007. * to something in order to rotate it from its local system to the given target system
  3008. * Note: axis1, axis2 and axis3 are normalized during this operation
  3009. * @param axis1 defines the first axis
  3010. * @param axis2 defines the second axis
  3011. * @param axis3 defines the third axis
  3012. * @returns a new Vector3
  3013. */
  3014. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3015. /**
  3016. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3017. * @param axis1 defines the first axis
  3018. * @param axis2 defines the second axis
  3019. * @param axis3 defines the third axis
  3020. * @param ref defines the Vector3 where to store the result
  3021. */
  3022. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3023. }
  3024. /**
  3025. * Vector4 class created for EulerAngle class conversion to Quaternion
  3026. */
  3027. export class Vector4 {
  3028. /** x value of the vector */
  3029. x: number;
  3030. /** y value of the vector */
  3031. y: number;
  3032. /** z value of the vector */
  3033. z: number;
  3034. /** w value of the vector */
  3035. w: number;
  3036. /**
  3037. * Creates a Vector4 object from the given floats.
  3038. * @param x x value of the vector
  3039. * @param y y value of the vector
  3040. * @param z z value of the vector
  3041. * @param w w value of the vector
  3042. */
  3043. constructor(
  3044. /** x value of the vector */
  3045. x: number,
  3046. /** y value of the vector */
  3047. y: number,
  3048. /** z value of the vector */
  3049. z: number,
  3050. /** w value of the vector */
  3051. w: number);
  3052. /**
  3053. * Returns the string with the Vector4 coordinates.
  3054. * @returns a string containing all the vector values
  3055. */
  3056. toString(): string;
  3057. /**
  3058. * Returns the string "Vector4".
  3059. * @returns "Vector4"
  3060. */
  3061. getClassName(): string;
  3062. /**
  3063. * Returns the Vector4 hash code.
  3064. * @returns a unique hash code
  3065. */
  3066. getHashCode(): number;
  3067. /**
  3068. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3069. * @returns the resulting array
  3070. */
  3071. asArray(): number[];
  3072. /**
  3073. * Populates the given array from the given index with the Vector4 coordinates.
  3074. * @param array array to populate
  3075. * @param index index of the array to start at (default: 0)
  3076. * @returns the Vector4.
  3077. */
  3078. toArray(array: FloatArray, index?: number): Vector4;
  3079. /**
  3080. * Adds the given vector to the current Vector4.
  3081. * @param otherVector the vector to add
  3082. * @returns the updated Vector4.
  3083. */
  3084. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3085. /**
  3086. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3087. * @param otherVector the vector to add
  3088. * @returns the resulting vector
  3089. */
  3090. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3091. /**
  3092. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3093. * @param otherVector the vector to add
  3094. * @param result the vector to store the result
  3095. * @returns the current Vector4.
  3096. */
  3097. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3098. /**
  3099. * Subtract in place the given vector from the current Vector4.
  3100. * @param otherVector the vector to subtract
  3101. * @returns the updated Vector4.
  3102. */
  3103. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3104. /**
  3105. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3106. * @param otherVector the vector to add
  3107. * @returns the new vector with the result
  3108. */
  3109. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3110. /**
  3111. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3112. * @param otherVector the vector to subtract
  3113. * @param result the vector to store the result
  3114. * @returns the current Vector4.
  3115. */
  3116. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3117. /**
  3118. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3119. */
  3120. /**
  3121. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3122. * @param x value to subtract
  3123. * @param y value to subtract
  3124. * @param z value to subtract
  3125. * @param w value to subtract
  3126. * @returns new vector containing the result
  3127. */
  3128. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3129. /**
  3130. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3131. * @param x value to subtract
  3132. * @param y value to subtract
  3133. * @param z value to subtract
  3134. * @param w value to subtract
  3135. * @param result the vector to store the result in
  3136. * @returns the current Vector4.
  3137. */
  3138. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3139. /**
  3140. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3141. * @returns a new vector with the negated values
  3142. */
  3143. negate(): Vector4;
  3144. /**
  3145. * Negate this vector in place
  3146. * @returns this
  3147. */
  3148. negateInPlace(): Vector4;
  3149. /**
  3150. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3151. * @param result defines the Vector3 object where to store the result
  3152. * @returns the current Vector4
  3153. */
  3154. negateToRef(result: Vector4): Vector4;
  3155. /**
  3156. * Multiplies the current Vector4 coordinates by scale (float).
  3157. * @param scale the number to scale with
  3158. * @returns the updated Vector4.
  3159. */
  3160. scaleInPlace(scale: number): Vector4;
  3161. /**
  3162. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3163. * @param scale the number to scale with
  3164. * @returns a new vector with the result
  3165. */
  3166. scale(scale: number): Vector4;
  3167. /**
  3168. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3169. * @param scale the number to scale with
  3170. * @param result a vector to store the result in
  3171. * @returns the current Vector4.
  3172. */
  3173. scaleToRef(scale: number, result: Vector4): Vector4;
  3174. /**
  3175. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3176. * @param scale defines the scale factor
  3177. * @param result defines the Vector4 object where to store the result
  3178. * @returns the unmodified current Vector4
  3179. */
  3180. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3181. /**
  3182. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3183. * @param otherVector the vector to compare against
  3184. * @returns true if they are equal
  3185. */
  3186. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3187. /**
  3188. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3189. * @param otherVector vector to compare against
  3190. * @param epsilon (Default: very small number)
  3191. * @returns true if they are equal
  3192. */
  3193. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3194. /**
  3195. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3196. * @param x x value to compare against
  3197. * @param y y value to compare against
  3198. * @param z z value to compare against
  3199. * @param w w value to compare against
  3200. * @returns true if equal
  3201. */
  3202. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3203. /**
  3204. * Multiplies in place the current Vector4 by the given one.
  3205. * @param otherVector vector to multiple with
  3206. * @returns the updated Vector4.
  3207. */
  3208. multiplyInPlace(otherVector: Vector4): Vector4;
  3209. /**
  3210. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3211. * @param otherVector vector to multiple with
  3212. * @returns resulting new vector
  3213. */
  3214. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3215. /**
  3216. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3217. * @param otherVector vector to multiple with
  3218. * @param result vector to store the result
  3219. * @returns the current Vector4.
  3220. */
  3221. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3222. /**
  3223. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3224. * @param x x value multiply with
  3225. * @param y y value multiply with
  3226. * @param z z value multiply with
  3227. * @param w w value multiply with
  3228. * @returns resulting new vector
  3229. */
  3230. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3231. /**
  3232. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3233. * @param otherVector vector to devide with
  3234. * @returns resulting new vector
  3235. */
  3236. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3237. /**
  3238. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3239. * @param otherVector vector to devide with
  3240. * @param result vector to store the result
  3241. * @returns the current Vector4.
  3242. */
  3243. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3244. /**
  3245. * Divides the current Vector3 coordinates by the given ones.
  3246. * @param otherVector vector to devide with
  3247. * @returns the updated Vector3.
  3248. */
  3249. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3250. /**
  3251. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3252. * @param other defines the second operand
  3253. * @returns the current updated Vector4
  3254. */
  3255. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3256. /**
  3257. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3258. * @param other defines the second operand
  3259. * @returns the current updated Vector4
  3260. */
  3261. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3262. /**
  3263. * Gets a new Vector4 from current Vector4 floored values
  3264. * @returns a new Vector4
  3265. */
  3266. floor(): Vector4;
  3267. /**
  3268. * Gets a new Vector4 from current Vector3 floored values
  3269. * @returns a new Vector4
  3270. */
  3271. fract(): Vector4;
  3272. /**
  3273. * Returns the Vector4 length (float).
  3274. * @returns the length
  3275. */
  3276. length(): number;
  3277. /**
  3278. * Returns the Vector4 squared length (float).
  3279. * @returns the length squared
  3280. */
  3281. lengthSquared(): number;
  3282. /**
  3283. * Normalizes in place the Vector4.
  3284. * @returns the updated Vector4.
  3285. */
  3286. normalize(): Vector4;
  3287. /**
  3288. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3289. * @returns this converted to a new vector3
  3290. */
  3291. toVector3(): Vector3;
  3292. /**
  3293. * Returns a new Vector4 copied from the current one.
  3294. * @returns the new cloned vector
  3295. */
  3296. clone(): Vector4;
  3297. /**
  3298. * Updates the current Vector4 with the given one coordinates.
  3299. * @param source the source vector to copy from
  3300. * @returns the updated Vector4.
  3301. */
  3302. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3303. /**
  3304. * Updates the current Vector4 coordinates with the given floats.
  3305. * @param x float to copy from
  3306. * @param y float to copy from
  3307. * @param z float to copy from
  3308. * @param w float to copy from
  3309. * @returns the updated Vector4.
  3310. */
  3311. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3312. /**
  3313. * Updates the current Vector4 coordinates with the given floats.
  3314. * @param x float to set from
  3315. * @param y float to set from
  3316. * @param z float to set from
  3317. * @param w float to set from
  3318. * @returns the updated Vector4.
  3319. */
  3320. set(x: number, y: number, z: number, w: number): Vector4;
  3321. /**
  3322. * Copies the given float to the current Vector3 coordinates
  3323. * @param v defines the x, y, z and w coordinates of the operand
  3324. * @returns the current updated Vector3
  3325. */
  3326. setAll(v: number): Vector4;
  3327. /**
  3328. * Returns a new Vector4 set from the starting index of the given array.
  3329. * @param array the array to pull values from
  3330. * @param offset the offset into the array to start at
  3331. * @returns the new vector
  3332. */
  3333. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3334. /**
  3335. * Updates the given vector "result" from the starting index of the given array.
  3336. * @param array the array to pull values from
  3337. * @param offset the offset into the array to start at
  3338. * @param result the vector to store the result in
  3339. */
  3340. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3341. /**
  3342. * Updates the given vector "result" from the starting index of the given Float32Array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @param result the vector to store the result in
  3346. */
  3347. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3348. /**
  3349. * Updates the given vector "result" coordinates from the given floats.
  3350. * @param x float to set from
  3351. * @param y float to set from
  3352. * @param z float to set from
  3353. * @param w float to set from
  3354. * @param result the vector to the floats in
  3355. */
  3356. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3357. /**
  3358. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3359. * @returns the new vector
  3360. */
  3361. static Zero(): Vector4;
  3362. /**
  3363. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3364. * @returns the new vector
  3365. */
  3366. static One(): Vector4;
  3367. /**
  3368. * Returns a new normalized Vector4 from the given one.
  3369. * @param vector the vector to normalize
  3370. * @returns the vector
  3371. */
  3372. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3373. /**
  3374. * Updates the given vector "result" from the normalization of the given one.
  3375. * @param vector the vector to normalize
  3376. * @param result the vector to store the result in
  3377. */
  3378. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3379. /**
  3380. * Returns a vector with the minimum values from the left and right vectors
  3381. * @param left left vector to minimize
  3382. * @param right right vector to minimize
  3383. * @returns a new vector with the minimum of the left and right vector values
  3384. */
  3385. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3386. /**
  3387. * Returns a vector with the maximum values from the left and right vectors
  3388. * @param left left vector to maximize
  3389. * @param right right vector to maximize
  3390. * @returns a new vector with the maximum of the left and right vector values
  3391. */
  3392. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Returns the distance (float) between the vectors "value1" and "value2".
  3395. * @param value1 value to calulate the distance between
  3396. * @param value2 value to calulate the distance between
  3397. * @return the distance between the two vectors
  3398. */
  3399. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3400. /**
  3401. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3402. * @param value1 value to calulate the distance between
  3403. * @param value2 value to calulate the distance between
  3404. * @return the distance between the two vectors squared
  3405. */
  3406. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3407. /**
  3408. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the center between
  3410. * @param value2 value to calulate the center between
  3411. * @return the center between the two vectors
  3412. */
  3413. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3414. /**
  3415. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3416. * This methods computes transformed normalized direction vectors only.
  3417. * @param vector the vector to transform
  3418. * @param transformation the transformation matrix to apply
  3419. * @returns the new vector
  3420. */
  3421. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3422. /**
  3423. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3424. * This methods computes transformed normalized direction vectors only.
  3425. * @param vector the vector to transform
  3426. * @param transformation the transformation matrix to apply
  3427. * @param result the vector to store the result in
  3428. */
  3429. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3430. /**
  3431. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3432. * This methods computes transformed normalized direction vectors only.
  3433. * @param x value to transform
  3434. * @param y value to transform
  3435. * @param z value to transform
  3436. * @param w value to transform
  3437. * @param transformation the transformation matrix to apply
  3438. * @param result the vector to store the results in
  3439. */
  3440. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3441. /**
  3442. * Creates a new Vector4 from a Vector3
  3443. * @param source defines the source data
  3444. * @param w defines the 4th component (default is 0)
  3445. * @returns a new Vector4
  3446. */
  3447. static FromVector3(source: Vector3, w?: number): Vector4;
  3448. }
  3449. /**
  3450. * Class used to store quaternion data
  3451. * @see https://en.wikipedia.org/wiki/Quaternion
  3452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3453. */
  3454. export class Quaternion {
  3455. /** defines the first component (0 by default) */
  3456. x: number;
  3457. /** defines the second component (0 by default) */
  3458. y: number;
  3459. /** defines the third component (0 by default) */
  3460. z: number;
  3461. /** defines the fourth component (1.0 by default) */
  3462. w: number;
  3463. /**
  3464. * Creates a new Quaternion from the given floats
  3465. * @param x defines the first component (0 by default)
  3466. * @param y defines the second component (0 by default)
  3467. * @param z defines the third component (0 by default)
  3468. * @param w defines the fourth component (1.0 by default)
  3469. */
  3470. constructor(
  3471. /** defines the first component (0 by default) */
  3472. x?: number,
  3473. /** defines the second component (0 by default) */
  3474. y?: number,
  3475. /** defines the third component (0 by default) */
  3476. z?: number,
  3477. /** defines the fourth component (1.0 by default) */
  3478. w?: number);
  3479. /**
  3480. * Gets a string representation for the current quaternion
  3481. * @returns a string with the Quaternion coordinates
  3482. */
  3483. toString(): string;
  3484. /**
  3485. * Gets the class name of the quaternion
  3486. * @returns the string "Quaternion"
  3487. */
  3488. getClassName(): string;
  3489. /**
  3490. * Gets a hash code for this quaternion
  3491. * @returns the quaternion hash code
  3492. */
  3493. getHashCode(): number;
  3494. /**
  3495. * Copy the quaternion to an array
  3496. * @returns a new array populated with 4 elements from the quaternion coordinates
  3497. */
  3498. asArray(): number[];
  3499. /**
  3500. * Check if two quaternions are equals
  3501. * @param otherQuaternion defines the second operand
  3502. * @return true if the current quaternion and the given one coordinates are strictly equals
  3503. */
  3504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3505. /**
  3506. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3507. * @param otherQuaternion defines the other quaternion
  3508. * @param epsilon defines the minimal distance to consider equality
  3509. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3510. */
  3511. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3512. /**
  3513. * Clone the current quaternion
  3514. * @returns a new quaternion copied from the current one
  3515. */
  3516. clone(): Quaternion;
  3517. /**
  3518. * Copy a quaternion to the current one
  3519. * @param other defines the other quaternion
  3520. * @returns the updated current quaternion
  3521. */
  3522. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3523. /**
  3524. * Updates the current quaternion with the given float coordinates
  3525. * @param x defines the x coordinate
  3526. * @param y defines the y coordinate
  3527. * @param z defines the z coordinate
  3528. * @param w defines the w coordinate
  3529. * @returns the updated current quaternion
  3530. */
  3531. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3532. /**
  3533. * Updates the current quaternion from the given float coordinates
  3534. * @param x defines the x coordinate
  3535. * @param y defines the y coordinate
  3536. * @param z defines the z coordinate
  3537. * @param w defines the w coordinate
  3538. * @returns the updated current quaternion
  3539. */
  3540. set(x: number, y: number, z: number, w: number): Quaternion;
  3541. /**
  3542. * Adds two quaternions
  3543. * @param other defines the second operand
  3544. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3545. */
  3546. add(other: DeepImmutable<Quaternion>): Quaternion;
  3547. /**
  3548. * Add a quaternion to the current one
  3549. * @param other defines the quaternion to add
  3550. * @returns the current quaternion
  3551. */
  3552. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3553. /**
  3554. * Subtract two quaternions
  3555. * @param other defines the second operand
  3556. * @returns a new quaternion as the subtraction result of the given one from the current one
  3557. */
  3558. subtract(other: Quaternion): Quaternion;
  3559. /**
  3560. * Multiplies the current quaternion by a scale factor
  3561. * @param value defines the scale factor
  3562. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3563. */
  3564. scale(value: number): Quaternion;
  3565. /**
  3566. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3567. * @param scale defines the scale factor
  3568. * @param result defines the Quaternion object where to store the result
  3569. * @returns the unmodified current quaternion
  3570. */
  3571. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3572. /**
  3573. * Multiplies in place the current quaternion by a scale factor
  3574. * @param value defines the scale factor
  3575. * @returns the current modified quaternion
  3576. */
  3577. scaleInPlace(value: number): Quaternion;
  3578. /**
  3579. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3580. * @param scale defines the scale factor
  3581. * @param result defines the Quaternion object where to store the result
  3582. * @returns the unmodified current quaternion
  3583. */
  3584. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3585. /**
  3586. * Multiplies two quaternions
  3587. * @param q1 defines the second operand
  3588. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3589. */
  3590. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3591. /**
  3592. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3593. * @param q1 defines the second operand
  3594. * @param result defines the target quaternion
  3595. * @returns the current quaternion
  3596. */
  3597. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3598. /**
  3599. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3600. * @param q1 defines the second operand
  3601. * @returns the currentupdated quaternion
  3602. */
  3603. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3604. /**
  3605. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3606. * @param ref defines the target quaternion
  3607. * @returns the current quaternion
  3608. */
  3609. conjugateToRef(ref: Quaternion): Quaternion;
  3610. /**
  3611. * Conjugates in place (1-q) the current quaternion
  3612. * @returns the current updated quaternion
  3613. */
  3614. conjugateInPlace(): Quaternion;
  3615. /**
  3616. * Conjugates in place (1-q) the current quaternion
  3617. * @returns a new quaternion
  3618. */
  3619. conjugate(): Quaternion;
  3620. /**
  3621. * Gets length of current quaternion
  3622. * @returns the quaternion length (float)
  3623. */
  3624. length(): number;
  3625. /**
  3626. * Normalize in place the current quaternion
  3627. * @returns the current updated quaternion
  3628. */
  3629. normalize(): Quaternion;
  3630. /**
  3631. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3632. * @param order is a reserved parameter and is ignore for now
  3633. * @returns a new Vector3 containing the Euler angles
  3634. */
  3635. toEulerAngles(order?: string): Vector3;
  3636. /**
  3637. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3638. * @param result defines the vector which will be filled with the Euler angles
  3639. * @param order is a reserved parameter and is ignore for now
  3640. * @returns the current unchanged quaternion
  3641. */
  3642. toEulerAnglesToRef(result: Vector3): Quaternion;
  3643. /**
  3644. * Updates the given rotation matrix with the current quaternion values
  3645. * @param result defines the target matrix
  3646. * @returns the current unchanged quaternion
  3647. */
  3648. toRotationMatrix(result: Matrix): Quaternion;
  3649. /**
  3650. * Updates the current quaternion from the given rotation matrix values
  3651. * @param matrix defines the source matrix
  3652. * @returns the current updated quaternion
  3653. */
  3654. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3655. /**
  3656. * Creates a new quaternion from a rotation matrix
  3657. * @param matrix defines the source matrix
  3658. * @returns a new quaternion created from the given rotation matrix values
  3659. */
  3660. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3661. /**
  3662. * Updates the given quaternion with the given rotation matrix values
  3663. * @param matrix defines the source matrix
  3664. * @param result defines the target quaternion
  3665. */
  3666. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3667. /**
  3668. * Returns the dot product (float) between the quaternions "left" and "right"
  3669. * @param left defines the left operand
  3670. * @param right defines the right operand
  3671. * @returns the dot product
  3672. */
  3673. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3674. /**
  3675. * Checks if the two quaternions are close to each other
  3676. * @param quat0 defines the first quaternion to check
  3677. * @param quat1 defines the second quaternion to check
  3678. * @returns true if the two quaternions are close to each other
  3679. */
  3680. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3681. /**
  3682. * Creates an empty quaternion
  3683. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3684. */
  3685. static Zero(): Quaternion;
  3686. /**
  3687. * Inverse a given quaternion
  3688. * @param q defines the source quaternion
  3689. * @returns a new quaternion as the inverted current quaternion
  3690. */
  3691. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3692. /**
  3693. * Inverse a given quaternion
  3694. * @param q defines the source quaternion
  3695. * @param result the quaternion the result will be stored in
  3696. * @returns the result quaternion
  3697. */
  3698. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3699. /**
  3700. * Creates an identity quaternion
  3701. * @returns the identity quaternion
  3702. */
  3703. static Identity(): Quaternion;
  3704. /**
  3705. * Gets a boolean indicating if the given quaternion is identity
  3706. * @param quaternion defines the quaternion to check
  3707. * @returns true if the quaternion is identity
  3708. */
  3709. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3710. /**
  3711. * Creates a quaternion from a rotation around an axis
  3712. * @param axis defines the axis to use
  3713. * @param angle defines the angle to use
  3714. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3715. */
  3716. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3717. /**
  3718. * Creates a rotation around an axis and stores it into the given quaternion
  3719. * @param axis defines the axis to use
  3720. * @param angle defines the angle to use
  3721. * @param result defines the target quaternion
  3722. * @returns the target quaternion
  3723. */
  3724. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3725. /**
  3726. * Creates a new quaternion from data stored into an array
  3727. * @param array defines the data source
  3728. * @param offset defines the offset in the source array where the data starts
  3729. * @returns a new quaternion
  3730. */
  3731. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3732. /**
  3733. * Create a quaternion from Euler rotation angles
  3734. * @param x Pitch
  3735. * @param y Yaw
  3736. * @param z Roll
  3737. * @returns the new Quaternion
  3738. */
  3739. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3740. /**
  3741. * Updates a quaternion from Euler rotation angles
  3742. * @param x Pitch
  3743. * @param y Yaw
  3744. * @param z Roll
  3745. * @param result the quaternion to store the result
  3746. * @returns the updated quaternion
  3747. */
  3748. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3749. /**
  3750. * Create a quaternion from Euler rotation vector
  3751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3752. * @returns the new Quaternion
  3753. */
  3754. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3755. /**
  3756. * Updates a quaternion from Euler rotation vector
  3757. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3758. * @param result the quaternion to store the result
  3759. * @returns the updated quaternion
  3760. */
  3761. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3762. /**
  3763. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3764. * @param yaw defines the rotation around Y axis
  3765. * @param pitch defines the rotation around X axis
  3766. * @param roll defines the rotation around Z axis
  3767. * @returns the new quaternion
  3768. */
  3769. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3770. /**
  3771. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3772. * @param yaw defines the rotation around Y axis
  3773. * @param pitch defines the rotation around X axis
  3774. * @param roll defines the rotation around Z axis
  3775. * @param result defines the target quaternion
  3776. */
  3777. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3778. /**
  3779. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3780. * @param alpha defines the rotation around first axis
  3781. * @param beta defines the rotation around second axis
  3782. * @param gamma defines the rotation around third axis
  3783. * @returns the new quaternion
  3784. */
  3785. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3786. /**
  3787. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3788. * @param alpha defines the rotation around first axis
  3789. * @param beta defines the rotation around second axis
  3790. * @param gamma defines the rotation around third axis
  3791. * @param result defines the target quaternion
  3792. */
  3793. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3794. /**
  3795. * 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)
  3796. * @param axis1 defines the first axis
  3797. * @param axis2 defines the second axis
  3798. * @param axis3 defines the third axis
  3799. * @returns the new quaternion
  3800. */
  3801. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3802. /**
  3803. * 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
  3804. * @param axis1 defines the first axis
  3805. * @param axis2 defines the second axis
  3806. * @param axis3 defines the third axis
  3807. * @param ref defines the target quaternion
  3808. */
  3809. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3810. /**
  3811. * Interpolates between two quaternions
  3812. * @param left defines first quaternion
  3813. * @param right defines second quaternion
  3814. * @param amount defines the gradient to use
  3815. * @returns the new interpolated quaternion
  3816. */
  3817. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3818. /**
  3819. * Interpolates between two quaternions and stores it into a target quaternion
  3820. * @param left defines first quaternion
  3821. * @param right defines second quaternion
  3822. * @param amount defines the gradient to use
  3823. * @param result defines the target quaternion
  3824. */
  3825. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3826. /**
  3827. * Interpolate between two quaternions using Hermite interpolation
  3828. * @param value1 defines first quaternion
  3829. * @param tangent1 defines the incoming tangent
  3830. * @param value2 defines second quaternion
  3831. * @param tangent2 defines the outgoing tangent
  3832. * @param amount defines the target quaternion
  3833. * @returns the new interpolated quaternion
  3834. */
  3835. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3836. }
  3837. /**
  3838. * Class used to store matrix data (4x4)
  3839. */
  3840. export class Matrix {
  3841. private static _updateFlagSeed;
  3842. private static _identityReadOnly;
  3843. private _isIdentity;
  3844. private _isIdentityDirty;
  3845. private _isIdentity3x2;
  3846. private _isIdentity3x2Dirty;
  3847. /**
  3848. * Gets the update flag of the matrix which is an unique number for the matrix.
  3849. * It will be incremented every time the matrix data change.
  3850. * You can use it to speed the comparison between two versions of the same matrix.
  3851. */
  3852. updateFlag: number;
  3853. private readonly _m;
  3854. /**
  3855. * Gets the internal data of the matrix
  3856. */
  3857. get m(): DeepImmutable<Float32Array>;
  3858. /** @hidden */
  3859. _markAsUpdated(): void;
  3860. /** @hidden */
  3861. private _updateIdentityStatus;
  3862. /**
  3863. * Creates an empty matrix (filled with zeros)
  3864. */
  3865. constructor();
  3866. /**
  3867. * Check if the current matrix is identity
  3868. * @returns true is the matrix is the identity matrix
  3869. */
  3870. isIdentity(): boolean;
  3871. /**
  3872. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3873. * @returns true is the matrix is the identity matrix
  3874. */
  3875. isIdentityAs3x2(): boolean;
  3876. /**
  3877. * Gets the determinant of the matrix
  3878. * @returns the matrix determinant
  3879. */
  3880. determinant(): number;
  3881. /**
  3882. * Returns the matrix as a Float32Array
  3883. * @returns the matrix underlying array
  3884. */
  3885. toArray(): DeepImmutable<Float32Array>;
  3886. /**
  3887. * Returns the matrix as a Float32Array
  3888. * @returns the matrix underlying array.
  3889. */
  3890. asArray(): DeepImmutable<Float32Array>;
  3891. /**
  3892. * Inverts the current matrix in place
  3893. * @returns the current inverted matrix
  3894. */
  3895. invert(): Matrix;
  3896. /**
  3897. * Sets all the matrix elements to zero
  3898. * @returns the current matrix
  3899. */
  3900. reset(): Matrix;
  3901. /**
  3902. * Adds the current matrix with a second one
  3903. * @param other defines the matrix to add
  3904. * @returns a new matrix as the addition of the current matrix and the given one
  3905. */
  3906. add(other: DeepImmutable<Matrix>): Matrix;
  3907. /**
  3908. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3909. * @param other defines the matrix to add
  3910. * @param result defines the target matrix
  3911. * @returns the current matrix
  3912. */
  3913. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3914. /**
  3915. * Adds in place the given matrix to the current matrix
  3916. * @param other defines the second operand
  3917. * @returns the current updated matrix
  3918. */
  3919. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3920. /**
  3921. * Sets the given matrix to the current inverted Matrix
  3922. * @param other defines the target matrix
  3923. * @returns the unmodified current matrix
  3924. */
  3925. invertToRef(other: Matrix): Matrix;
  3926. /**
  3927. * add a value at the specified position in the current Matrix
  3928. * @param index the index of the value within the matrix. between 0 and 15.
  3929. * @param value the value to be added
  3930. * @returns the current updated matrix
  3931. */
  3932. addAtIndex(index: number, value: number): Matrix;
  3933. /**
  3934. * mutiply the specified position in the current Matrix by a value
  3935. * @param index the index of the value within the matrix. between 0 and 15.
  3936. * @param value the value to be added
  3937. * @returns the current updated matrix
  3938. */
  3939. multiplyAtIndex(index: number, value: number): Matrix;
  3940. /**
  3941. * Inserts the translation vector (using 3 floats) in the current matrix
  3942. * @param x defines the 1st component of the translation
  3943. * @param y defines the 2nd component of the translation
  3944. * @param z defines the 3rd component of the translation
  3945. * @returns the current updated matrix
  3946. */
  3947. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3948. /**
  3949. * Adds the translation vector (using 3 floats) in the current matrix
  3950. * @param x defines the 1st component of the translation
  3951. * @param y defines the 2nd component of the translation
  3952. * @param z defines the 3rd component of the translation
  3953. * @returns the current updated matrix
  3954. */
  3955. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3956. /**
  3957. * Inserts the translation vector in the current matrix
  3958. * @param vector3 defines the translation to insert
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3962. /**
  3963. * Gets the translation value of the current matrix
  3964. * @returns a new Vector3 as the extracted translation from the matrix
  3965. */
  3966. getTranslation(): Vector3;
  3967. /**
  3968. * Fill a Vector3 with the extracted translation from the matrix
  3969. * @param result defines the Vector3 where to store the translation
  3970. * @returns the current matrix
  3971. */
  3972. getTranslationToRef(result: Vector3): Matrix;
  3973. /**
  3974. * Remove rotation and scaling part from the matrix
  3975. * @returns the updated matrix
  3976. */
  3977. removeRotationAndScaling(): Matrix;
  3978. /**
  3979. * Multiply two matrices
  3980. * @param other defines the second operand
  3981. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3982. */
  3983. multiply(other: DeepImmutable<Matrix>): Matrix;
  3984. /**
  3985. * Copy the current matrix from the given one
  3986. * @param other defines the source matrix
  3987. * @returns the current updated matrix
  3988. */
  3989. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3990. /**
  3991. * Populates the given array from the starting index with the current matrix values
  3992. * @param array defines the target array
  3993. * @param offset defines the offset in the target array where to start storing values
  3994. * @returns the current matrix
  3995. */
  3996. copyToArray(array: Float32Array, offset?: number): Matrix;
  3997. /**
  3998. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3999. * @param other defines the second operand
  4000. * @param result defines the matrix where to store the multiplication
  4001. * @returns the current matrix
  4002. */
  4003. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4004. /**
  4005. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4006. * @param other defines the second operand
  4007. * @param result defines the array where to store the multiplication
  4008. * @param offset defines the offset in the target array where to start storing values
  4009. * @returns the current matrix
  4010. */
  4011. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4012. /**
  4013. * Check equality between this matrix and a second one
  4014. * @param value defines the second matrix to compare
  4015. * @returns true is the current matrix and the given one values are strictly equal
  4016. */
  4017. equals(value: DeepImmutable<Matrix>): boolean;
  4018. /**
  4019. * Clone the current matrix
  4020. * @returns a new matrix from the current matrix
  4021. */
  4022. clone(): Matrix;
  4023. /**
  4024. * Returns the name of the current matrix class
  4025. * @returns the string "Matrix"
  4026. */
  4027. getClassName(): string;
  4028. /**
  4029. * Gets the hash code of the current matrix
  4030. * @returns the hash code
  4031. */
  4032. getHashCode(): number;
  4033. /**
  4034. * Decomposes the current Matrix into a translation, rotation and scaling components
  4035. * @param scale defines the scale vector3 given as a reference to update
  4036. * @param rotation defines the rotation quaternion given as a reference to update
  4037. * @param translation defines the translation vector3 given as a reference to update
  4038. * @returns true if operation was successful
  4039. */
  4040. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4041. /**
  4042. * Gets specific row of the matrix
  4043. * @param index defines the number of the row to get
  4044. * @returns the index-th row of the current matrix as a new Vector4
  4045. */
  4046. getRow(index: number): Nullable<Vector4>;
  4047. /**
  4048. * Sets the index-th row of the current matrix to the vector4 values
  4049. * @param index defines the number of the row to set
  4050. * @param row defines the target vector4
  4051. * @returns the updated current matrix
  4052. */
  4053. setRow(index: number, row: Vector4): Matrix;
  4054. /**
  4055. * Compute the transpose of the matrix
  4056. * @returns the new transposed matrix
  4057. */
  4058. transpose(): Matrix;
  4059. /**
  4060. * Compute the transpose of the matrix and store it in a given matrix
  4061. * @param result defines the target matrix
  4062. * @returns the current matrix
  4063. */
  4064. transposeToRef(result: Matrix): Matrix;
  4065. /**
  4066. * Sets the index-th row of the current matrix with the given 4 x float values
  4067. * @param index defines the row index
  4068. * @param x defines the x component to set
  4069. * @param y defines the y component to set
  4070. * @param z defines the z component to set
  4071. * @param w defines the w component to set
  4072. * @returns the updated current matrix
  4073. */
  4074. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4075. /**
  4076. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4077. * @param scale defines the scale factor
  4078. * @returns a new matrix
  4079. */
  4080. scale(scale: number): Matrix;
  4081. /**
  4082. * Scale the current matrix values by a factor to a given result matrix
  4083. * @param scale defines the scale factor
  4084. * @param result defines the matrix to store the result
  4085. * @returns the current matrix
  4086. */
  4087. scaleToRef(scale: number, result: Matrix): Matrix;
  4088. /**
  4089. * Scale the current matrix values by a factor and add the result to a given matrix
  4090. * @param scale defines the scale factor
  4091. * @param result defines the Matrix to store the result
  4092. * @returns the current matrix
  4093. */
  4094. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4095. /**
  4096. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4097. * @param ref matrix to store the result
  4098. */
  4099. toNormalMatrix(ref: Matrix): void;
  4100. /**
  4101. * Gets only rotation part of the current matrix
  4102. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4103. */
  4104. getRotationMatrix(): Matrix;
  4105. /**
  4106. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4107. * @param result defines the target matrix to store data to
  4108. * @returns the current matrix
  4109. */
  4110. getRotationMatrixToRef(result: Matrix): Matrix;
  4111. /**
  4112. * Toggles model matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleModelMatrixHandInPlace(): void;
  4115. /**
  4116. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4117. */
  4118. toggleProjectionMatrixHandInPlace(): void;
  4119. /**
  4120. * Creates a matrix from an array
  4121. * @param array defines the source array
  4122. * @param offset defines an offset in the source array
  4123. * @returns a new Matrix set from the starting index of the given array
  4124. */
  4125. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4126. /**
  4127. * Copy the content of an array into a given matrix
  4128. * @param array defines the source array
  4129. * @param offset defines an offset in the source array
  4130. * @param result defines the target matrix
  4131. */
  4132. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4133. /**
  4134. * Stores an array into a matrix after having multiplied each component by a given factor
  4135. * @param array defines the source array
  4136. * @param offset defines the offset in the source array
  4137. * @param scale defines the scaling factor
  4138. * @param result defines the target matrix
  4139. */
  4140. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4141. /**
  4142. * Gets an identity matrix that must not be updated
  4143. */
  4144. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4145. /**
  4146. * Stores a list of values (16) inside a given matrix
  4147. * @param initialM11 defines 1st value of 1st row
  4148. * @param initialM12 defines 2nd value of 1st row
  4149. * @param initialM13 defines 3rd value of 1st row
  4150. * @param initialM14 defines 4th value of 1st row
  4151. * @param initialM21 defines 1st value of 2nd row
  4152. * @param initialM22 defines 2nd value of 2nd row
  4153. * @param initialM23 defines 3rd value of 2nd row
  4154. * @param initialM24 defines 4th value of 2nd row
  4155. * @param initialM31 defines 1st value of 3rd row
  4156. * @param initialM32 defines 2nd value of 3rd row
  4157. * @param initialM33 defines 3rd value of 3rd row
  4158. * @param initialM34 defines 4th value of 3rd row
  4159. * @param initialM41 defines 1st value of 4th row
  4160. * @param initialM42 defines 2nd value of 4th row
  4161. * @param initialM43 defines 3rd value of 4th row
  4162. * @param initialM44 defines 4th value of 4th row
  4163. * @param result defines the target matrix
  4164. */
  4165. 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;
  4166. /**
  4167. * Creates new matrix from a list of values (16)
  4168. * @param initialM11 defines 1st value of 1st row
  4169. * @param initialM12 defines 2nd value of 1st row
  4170. * @param initialM13 defines 3rd value of 1st row
  4171. * @param initialM14 defines 4th value of 1st row
  4172. * @param initialM21 defines 1st value of 2nd row
  4173. * @param initialM22 defines 2nd value of 2nd row
  4174. * @param initialM23 defines 3rd value of 2nd row
  4175. * @param initialM24 defines 4th value of 2nd row
  4176. * @param initialM31 defines 1st value of 3rd row
  4177. * @param initialM32 defines 2nd value of 3rd row
  4178. * @param initialM33 defines 3rd value of 3rd row
  4179. * @param initialM34 defines 4th value of 3rd row
  4180. * @param initialM41 defines 1st value of 4th row
  4181. * @param initialM42 defines 2nd value of 4th row
  4182. * @param initialM43 defines 3rd value of 4th row
  4183. * @param initialM44 defines 4th value of 4th row
  4184. * @returns the new matrix
  4185. */
  4186. 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;
  4187. /**
  4188. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4189. * @param scale defines the scale vector3
  4190. * @param rotation defines the rotation quaternion
  4191. * @param translation defines the translation vector3
  4192. * @returns a new matrix
  4193. */
  4194. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4195. /**
  4196. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4197. * @param scale defines the scale vector3
  4198. * @param rotation defines the rotation quaternion
  4199. * @param translation defines the translation vector3
  4200. * @param result defines the target matrix
  4201. */
  4202. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4203. /**
  4204. * Creates a new identity matrix
  4205. * @returns a new identity matrix
  4206. */
  4207. static Identity(): Matrix;
  4208. /**
  4209. * Creates a new identity matrix and stores the result in a given matrix
  4210. * @param result defines the target matrix
  4211. */
  4212. static IdentityToRef(result: Matrix): void;
  4213. /**
  4214. * Creates a new zero matrix
  4215. * @returns a new zero matrix
  4216. */
  4217. static Zero(): Matrix;
  4218. /**
  4219. * Creates a new rotation matrix for "angle" radians around the X axis
  4220. * @param angle defines the angle (in radians) to use
  4221. * @return the new matrix
  4222. */
  4223. static RotationX(angle: number): Matrix;
  4224. /**
  4225. * Creates a new matrix as the invert of a given matrix
  4226. * @param source defines the source matrix
  4227. * @returns the new matrix
  4228. */
  4229. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4230. /**
  4231. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4232. * @param angle defines the angle (in radians) to use
  4233. * @param result defines the target matrix
  4234. */
  4235. static RotationXToRef(angle: number, result: Matrix): void;
  4236. /**
  4237. * Creates a new rotation matrix for "angle" radians around the Y axis
  4238. * @param angle defines the angle (in radians) to use
  4239. * @return the new matrix
  4240. */
  4241. static RotationY(angle: number): Matrix;
  4242. /**
  4243. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4244. * @param angle defines the angle (in radians) to use
  4245. * @param result defines the target matrix
  4246. */
  4247. static RotationYToRef(angle: number, result: Matrix): void;
  4248. /**
  4249. * Creates a new rotation matrix for "angle" radians around the Z axis
  4250. * @param angle defines the angle (in radians) to use
  4251. * @return the new matrix
  4252. */
  4253. static RotationZ(angle: number): Matrix;
  4254. /**
  4255. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4256. * @param angle defines the angle (in radians) to use
  4257. * @param result defines the target matrix
  4258. */
  4259. static RotationZToRef(angle: number, result: Matrix): void;
  4260. /**
  4261. * Creates a new rotation matrix for "angle" radians around the given axis
  4262. * @param axis defines the axis to use
  4263. * @param angle defines the angle (in radians) to use
  4264. * @return the new matrix
  4265. */
  4266. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4267. /**
  4268. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4269. * @param axis defines the axis to use
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4274. /**
  4275. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4276. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4277. * @param from defines the vector to align
  4278. * @param to defines the vector to align to
  4279. * @param result defines the target matrix
  4280. */
  4281. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4282. /**
  4283. * Creates a rotation matrix
  4284. * @param yaw defines the yaw angle in radians (Y axis)
  4285. * @param pitch defines the pitch angle in radians (X axis)
  4286. * @param roll defines the roll angle in radians (X axis)
  4287. * @returns the new rotation matrix
  4288. */
  4289. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4290. /**
  4291. * Creates a rotation matrix and stores it in a given matrix
  4292. * @param yaw defines the yaw angle in radians (Y axis)
  4293. * @param pitch defines the pitch angle in radians (X axis)
  4294. * @param roll defines the roll angle in radians (X axis)
  4295. * @param result defines the target matrix
  4296. */
  4297. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4298. /**
  4299. * Creates a scaling matrix
  4300. * @param x defines the scale factor on X axis
  4301. * @param y defines the scale factor on Y axis
  4302. * @param z defines the scale factor on Z axis
  4303. * @returns the new matrix
  4304. */
  4305. static Scaling(x: number, y: number, z: number): Matrix;
  4306. /**
  4307. * Creates a scaling matrix and stores it in a given matrix
  4308. * @param x defines the scale factor on X axis
  4309. * @param y defines the scale factor on Y axis
  4310. * @param z defines the scale factor on Z axis
  4311. * @param result defines the target matrix
  4312. */
  4313. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4314. /**
  4315. * Creates a translation matrix
  4316. * @param x defines the translation on X axis
  4317. * @param y defines the translation on Y axis
  4318. * @param z defines the translationon Z axis
  4319. * @returns the new matrix
  4320. */
  4321. static Translation(x: number, y: number, z: number): Matrix;
  4322. /**
  4323. * Creates a translation matrix and stores it in a given matrix
  4324. * @param x defines the translation on X axis
  4325. * @param y defines the translation on Y axis
  4326. * @param z defines the translationon Z axis
  4327. * @param result defines the target matrix
  4328. */
  4329. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4330. /**
  4331. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4332. * @param startValue defines the start value
  4333. * @param endValue defines the end value
  4334. * @param gradient defines the gradient factor
  4335. * @returns the new matrix
  4336. */
  4337. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4338. /**
  4339. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4340. * @param startValue defines the start value
  4341. * @param endValue defines the end value
  4342. * @param gradient defines the gradient factor
  4343. * @param result defines the Matrix object where to store data
  4344. */
  4345. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4346. /**
  4347. * Builds a new matrix whose values are computed by:
  4348. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4349. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4350. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4351. * @param startValue defines the first matrix
  4352. * @param endValue defines the second matrix
  4353. * @param gradient defines the gradient between the two matrices
  4354. * @returns the new matrix
  4355. */
  4356. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4357. /**
  4358. * Update a matrix to values which are computed by:
  4359. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4360. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4361. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4362. * @param startValue defines the first matrix
  4363. * @param endValue defines the second matrix
  4364. * @param gradient defines the gradient between the two matrices
  4365. * @param result defines the target matrix
  4366. */
  4367. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4368. /**
  4369. * 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"
  4370. * This function works in left handed mode
  4371. * @param eye defines the final position of the entity
  4372. * @param target defines where the entity should look at
  4373. * @param up defines the up vector for the entity
  4374. * @returns the new matrix
  4375. */
  4376. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4377. /**
  4378. * 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".
  4379. * This function works in left handed mode
  4380. * @param eye defines the final position of the entity
  4381. * @param target defines where the entity should look at
  4382. * @param up defines the up vector for the entity
  4383. * @param result defines the target matrix
  4384. */
  4385. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4386. /**
  4387. * 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"
  4388. * This function works in right handed mode
  4389. * @param eye defines the final position of the entity
  4390. * @param target defines where the entity should look at
  4391. * @param up defines the up vector for the entity
  4392. * @returns the new matrix
  4393. */
  4394. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4395. /**
  4396. * 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".
  4397. * This function works in right handed mode
  4398. * @param eye defines the final position of the entity
  4399. * @param target defines where the entity should look at
  4400. * @param up defines the up vector for the entity
  4401. * @param result defines the target matrix
  4402. */
  4403. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4404. /**
  4405. * Create a left-handed orthographic projection matrix
  4406. * @param width defines the viewport width
  4407. * @param height defines the viewport height
  4408. * @param znear defines the near clip plane
  4409. * @param zfar defines the far clip plane
  4410. * @returns a new matrix as a left-handed orthographic projection matrix
  4411. */
  4412. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4413. /**
  4414. * Store a left-handed orthographic projection to a given matrix
  4415. * @param width defines the viewport width
  4416. * @param height defines the viewport height
  4417. * @param znear defines the near clip plane
  4418. * @param zfar defines the far clip plane
  4419. * @param result defines the target matrix
  4420. */
  4421. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4422. /**
  4423. * Create a left-handed orthographic projection matrix
  4424. * @param left defines the viewport left coordinate
  4425. * @param right defines the viewport right coordinate
  4426. * @param bottom defines the viewport bottom coordinate
  4427. * @param top defines the viewport top coordinate
  4428. * @param znear defines the near clip plane
  4429. * @param zfar defines the far clip plane
  4430. * @returns a new matrix as a left-handed orthographic projection matrix
  4431. */
  4432. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4433. /**
  4434. * Stores a left-handed orthographic projection into a given matrix
  4435. * @param left defines the viewport left coordinate
  4436. * @param right defines the viewport right coordinate
  4437. * @param bottom defines the viewport bottom coordinate
  4438. * @param top defines the viewport top coordinate
  4439. * @param znear defines the near clip plane
  4440. * @param zfar defines the far clip plane
  4441. * @param result defines the target matrix
  4442. */
  4443. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4444. /**
  4445. * Creates a right-handed orthographic projection matrix
  4446. * @param left defines the viewport left coordinate
  4447. * @param right defines the viewport right coordinate
  4448. * @param bottom defines the viewport bottom coordinate
  4449. * @param top defines the viewport top coordinate
  4450. * @param znear defines the near clip plane
  4451. * @param zfar defines the far clip plane
  4452. * @returns a new matrix as a right-handed orthographic projection matrix
  4453. */
  4454. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4455. /**
  4456. * Stores a right-handed orthographic projection into a given matrix
  4457. * @param left defines the viewport left coordinate
  4458. * @param right defines the viewport right coordinate
  4459. * @param bottom defines the viewport bottom coordinate
  4460. * @param top defines the viewport top coordinate
  4461. * @param znear defines the near clip plane
  4462. * @param zfar defines the far clip plane
  4463. * @param result defines the target matrix
  4464. */
  4465. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4466. /**
  4467. * Creates a left-handed perspective projection matrix
  4468. * @param width defines the viewport width
  4469. * @param height defines the viewport height
  4470. * @param znear defines the near clip plane
  4471. * @param zfar defines the far clip plane
  4472. * @returns a new matrix as a left-handed perspective projection matrix
  4473. */
  4474. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4475. /**
  4476. * Creates a left-handed perspective projection matrix
  4477. * @param fov defines the horizontal field of view
  4478. * @param aspect defines the aspect ratio
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a left-handed perspective projection matrix
  4482. */
  4483. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a left-handed perspective projection into a given matrix
  4486. * @param fov defines the horizontal field of view
  4487. * @param aspect defines the aspect ratio
  4488. * @param znear defines the near clip plane
  4489. * @param zfar defines the far clip plane
  4490. * @param result defines the target matrix
  4491. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4492. */
  4493. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4494. /**
  4495. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4496. * @param fov defines the horizontal field of view
  4497. * @param aspect defines the aspect ratio
  4498. * @param znear defines the near clip plane
  4499. * @param zfar not used as infinity is used as far clip
  4500. * @param result defines the target matrix
  4501. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4502. */
  4503. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4504. /**
  4505. * Creates a right-handed perspective projection matrix
  4506. * @param fov defines the horizontal field of view
  4507. * @param aspect defines the aspect ratio
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @returns a new matrix as a right-handed perspective projection matrix
  4511. */
  4512. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4513. /**
  4514. * Stores a right-handed perspective projection into a given matrix
  4515. * @param fov defines the horizontal field of view
  4516. * @param aspect defines the aspect ratio
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @param result defines the target matrix
  4520. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4521. */
  4522. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4523. /**
  4524. * Stores a right-handed perspective projection into a given matrix
  4525. * @param fov defines the horizontal field of view
  4526. * @param aspect defines the aspect ratio
  4527. * @param znear defines the near clip plane
  4528. * @param zfar not used as infinity is used as far clip
  4529. * @param result defines the target matrix
  4530. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4531. */
  4532. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4533. /**
  4534. * Stores a perspective projection for WebVR info a given matrix
  4535. * @param fov defines the field of view
  4536. * @param znear defines the near clip plane
  4537. * @param zfar defines the far clip plane
  4538. * @param result defines the target matrix
  4539. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4540. */
  4541. static PerspectiveFovWebVRToRef(fov: {
  4542. upDegrees: number;
  4543. downDegrees: number;
  4544. leftDegrees: number;
  4545. rightDegrees: number;
  4546. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4547. /**
  4548. * Computes a complete transformation matrix
  4549. * @param viewport defines the viewport to use
  4550. * @param world defines the world matrix
  4551. * @param view defines the view matrix
  4552. * @param projection defines the projection matrix
  4553. * @param zmin defines the near clip plane
  4554. * @param zmax defines the far clip plane
  4555. * @returns the transformation matrix
  4556. */
  4557. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4558. /**
  4559. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4560. * @param matrix defines the matrix to use
  4561. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4562. */
  4563. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4564. /**
  4565. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4566. * @param matrix defines the matrix to use
  4567. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4568. */
  4569. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4570. /**
  4571. * Compute the transpose of a given matrix
  4572. * @param matrix defines the matrix to transpose
  4573. * @returns the new matrix
  4574. */
  4575. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4576. /**
  4577. * Compute the transpose of a matrix and store it in a target matrix
  4578. * @param matrix defines the matrix to transpose
  4579. * @param result defines the target matrix
  4580. */
  4581. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4582. /**
  4583. * Computes a reflection matrix from a plane
  4584. * @param plane defines the reflection plane
  4585. * @returns a new matrix
  4586. */
  4587. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4588. /**
  4589. * Computes a reflection matrix from a plane
  4590. * @param plane defines the reflection plane
  4591. * @param result defines the target matrix
  4592. */
  4593. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4594. /**
  4595. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4596. * @param xaxis defines the value of the 1st axis
  4597. * @param yaxis defines the value of the 2nd axis
  4598. * @param zaxis defines the value of the 3rd axis
  4599. * @param result defines the target matrix
  4600. */
  4601. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4602. /**
  4603. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4604. * @param quat defines the quaternion to use
  4605. * @param result defines the target matrix
  4606. */
  4607. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4608. }
  4609. /**
  4610. * @hidden
  4611. */
  4612. export class TmpVectors {
  4613. static Vector2: Vector2[];
  4614. static Vector3: Vector3[];
  4615. static Vector4: Vector4[];
  4616. static Quaternion: Quaternion[];
  4617. static Matrix: Matrix[];
  4618. }
  4619. }
  4620. declare module BABYLON {
  4621. /**
  4622. * Defines potential orientation for back face culling
  4623. */
  4624. export enum Orientation {
  4625. /**
  4626. * Clockwise
  4627. */
  4628. CW = 0,
  4629. /** Counter clockwise */
  4630. CCW = 1
  4631. }
  4632. /** Class used to represent a Bezier curve */
  4633. export class BezierCurve {
  4634. /**
  4635. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4636. * @param t defines the time
  4637. * @param x1 defines the left coordinate on X axis
  4638. * @param y1 defines the left coordinate on Y axis
  4639. * @param x2 defines the right coordinate on X axis
  4640. * @param y2 defines the right coordinate on Y axis
  4641. * @returns the interpolated value
  4642. */
  4643. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4644. }
  4645. /**
  4646. * Defines angle representation
  4647. */
  4648. export class Angle {
  4649. private _radians;
  4650. /**
  4651. * Creates an Angle object of "radians" radians (float).
  4652. * @param radians the angle in radians
  4653. */
  4654. constructor(radians: number);
  4655. /**
  4656. * Get value in degrees
  4657. * @returns the Angle value in degrees (float)
  4658. */
  4659. degrees(): number;
  4660. /**
  4661. * Get value in radians
  4662. * @returns the Angle value in radians (float)
  4663. */
  4664. radians(): number;
  4665. /**
  4666. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4667. * @param a defines first vector
  4668. * @param b defines second vector
  4669. * @returns a new Angle
  4670. */
  4671. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4672. /**
  4673. * Gets a new Angle object from the given float in radians
  4674. * @param radians defines the angle value in radians
  4675. * @returns a new Angle
  4676. */
  4677. static FromRadians(radians: number): Angle;
  4678. /**
  4679. * Gets a new Angle object from the given float in degrees
  4680. * @param degrees defines the angle value in degrees
  4681. * @returns a new Angle
  4682. */
  4683. static FromDegrees(degrees: number): Angle;
  4684. }
  4685. /**
  4686. * This represents an arc in a 2d space.
  4687. */
  4688. export class Arc2 {
  4689. /** Defines the start point of the arc */
  4690. startPoint: Vector2;
  4691. /** Defines the mid point of the arc */
  4692. midPoint: Vector2;
  4693. /** Defines the end point of the arc */
  4694. endPoint: Vector2;
  4695. /**
  4696. * Defines the center point of the arc.
  4697. */
  4698. centerPoint: Vector2;
  4699. /**
  4700. * Defines the radius of the arc.
  4701. */
  4702. radius: number;
  4703. /**
  4704. * Defines the angle of the arc (from mid point to end point).
  4705. */
  4706. angle: Angle;
  4707. /**
  4708. * Defines the start angle of the arc (from start point to middle point).
  4709. */
  4710. startAngle: Angle;
  4711. /**
  4712. * Defines the orientation of the arc (clock wise/counter clock wise).
  4713. */
  4714. orientation: Orientation;
  4715. /**
  4716. * Creates an Arc object from the three given points : start, middle and end.
  4717. * @param startPoint Defines the start point of the arc
  4718. * @param midPoint Defines the midlle point of the arc
  4719. * @param endPoint Defines the end point of the arc
  4720. */
  4721. constructor(
  4722. /** Defines the start point of the arc */
  4723. startPoint: Vector2,
  4724. /** Defines the mid point of the arc */
  4725. midPoint: Vector2,
  4726. /** Defines the end point of the arc */
  4727. endPoint: Vector2);
  4728. }
  4729. /**
  4730. * Represents a 2D path made up of multiple 2D points
  4731. */
  4732. export class Path2 {
  4733. private _points;
  4734. private _length;
  4735. /**
  4736. * If the path start and end point are the same
  4737. */
  4738. closed: boolean;
  4739. /**
  4740. * Creates a Path2 object from the starting 2D coordinates x and y.
  4741. * @param x the starting points x value
  4742. * @param y the starting points y value
  4743. */
  4744. constructor(x: number, y: number);
  4745. /**
  4746. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4747. * @param x the added points x value
  4748. * @param y the added points y value
  4749. * @returns the updated Path2.
  4750. */
  4751. addLineTo(x: number, y: number): Path2;
  4752. /**
  4753. * 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.
  4754. * @param midX middle point x value
  4755. * @param midY middle point y value
  4756. * @param endX end point x value
  4757. * @param endY end point y value
  4758. * @param numberOfSegments (default: 36)
  4759. * @returns the updated Path2.
  4760. */
  4761. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4762. /**
  4763. * Closes the Path2.
  4764. * @returns the Path2.
  4765. */
  4766. close(): Path2;
  4767. /**
  4768. * Gets the sum of the distance between each sequential point in the path
  4769. * @returns the Path2 total length (float).
  4770. */
  4771. length(): number;
  4772. /**
  4773. * Gets the points which construct the path
  4774. * @returns the Path2 internal array of points.
  4775. */
  4776. getPoints(): Vector2[];
  4777. /**
  4778. * Retreives the point at the distance aways from the starting point
  4779. * @param normalizedLengthPosition the length along the path to retreive the point from
  4780. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4781. */
  4782. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4783. /**
  4784. * Creates a new path starting from an x and y position
  4785. * @param x starting x value
  4786. * @param y starting y value
  4787. * @returns a new Path2 starting at the coordinates (x, y).
  4788. */
  4789. static StartingAt(x: number, y: number): Path2;
  4790. }
  4791. /**
  4792. * Represents a 3D path made up of multiple 3D points
  4793. */
  4794. export class Path3D {
  4795. /**
  4796. * an array of Vector3, the curve axis of the Path3D
  4797. */
  4798. path: Vector3[];
  4799. private _curve;
  4800. private _distances;
  4801. private _tangents;
  4802. private _normals;
  4803. private _binormals;
  4804. private _raw;
  4805. private _alignTangentsWithPath;
  4806. private readonly _pointAtData;
  4807. /**
  4808. * new Path3D(path, normal, raw)
  4809. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4810. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4811. * @param path an array of Vector3, the curve axis of the Path3D
  4812. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4813. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4814. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4815. */
  4816. constructor(
  4817. /**
  4818. * an array of Vector3, the curve axis of the Path3D
  4819. */
  4820. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4821. /**
  4822. * Returns the Path3D array of successive Vector3 designing its curve.
  4823. * @returns the Path3D array of successive Vector3 designing its curve.
  4824. */
  4825. getCurve(): Vector3[];
  4826. /**
  4827. * Returns the Path3D array of successive Vector3 designing its curve.
  4828. * @returns the Path3D array of successive Vector3 designing its curve.
  4829. */
  4830. getPoints(): Vector3[];
  4831. /**
  4832. * @returns the computed length (float) of the path.
  4833. */
  4834. length(): number;
  4835. /**
  4836. * Returns an array populated with tangent vectors on each Path3D curve point.
  4837. * @returns an array populated with tangent vectors on each Path3D curve point.
  4838. */
  4839. getTangents(): Vector3[];
  4840. /**
  4841. * Returns an array populated with normal vectors on each Path3D curve point.
  4842. * @returns an array populated with normal vectors on each Path3D curve point.
  4843. */
  4844. getNormals(): Vector3[];
  4845. /**
  4846. * Returns an array populated with binormal vectors on each Path3D curve point.
  4847. * @returns an array populated with binormal vectors on each Path3D curve point.
  4848. */
  4849. getBinormals(): Vector3[];
  4850. /**
  4851. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4852. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4853. */
  4854. getDistances(): number[];
  4855. /**
  4856. * Returns an interpolated point along this path
  4857. * @param position the position of the point along this path, from 0.0 to 1.0
  4858. * @returns a new Vector3 as the point
  4859. */
  4860. getPointAt(position: number): Vector3;
  4861. /**
  4862. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4863. * @param position the position of the point along this path, from 0.0 to 1.0
  4864. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4865. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4866. */
  4867. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4868. /**
  4869. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4870. * @param position the position of the point along this path, from 0.0 to 1.0
  4871. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4872. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4873. */
  4874. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4875. /**
  4876. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4879. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4880. */
  4881. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4886. */
  4887. getDistanceAt(position: number): number;
  4888. /**
  4889. * Returns the array index of the previous point of an interpolated point along this path
  4890. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4891. * @returns the array index
  4892. */
  4893. getPreviousPointIndexAt(position: number): number;
  4894. /**
  4895. * 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)
  4896. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4897. * @returns the sub position
  4898. */
  4899. getSubPositionAt(position: number): number;
  4900. /**
  4901. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4902. * @param target the vector of which to get the closest position to
  4903. * @returns the position of the closest virtual point on this path to the target vector
  4904. */
  4905. getClosestPositionTo(target: Vector3): number;
  4906. /**
  4907. * Returns a sub path (slice) of this path
  4908. * @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
  4909. * @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
  4910. * @returns a sub path (slice) of this path
  4911. */
  4912. slice(start?: number, end?: number): Path3D;
  4913. /**
  4914. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4915. * @param path path which all values are copied into the curves points
  4916. * @param firstNormal which should be projected onto the curve
  4917. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4918. * @returns the same object updated.
  4919. */
  4920. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4921. private _compute;
  4922. private _getFirstNonNullVector;
  4923. private _getLastNonNullVector;
  4924. private _normalVector;
  4925. /**
  4926. * Updates the point at data for an interpolated point along this curve
  4927. * @param position the position of the point along this curve, from 0.0 to 1.0
  4928. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4929. * @returns the (updated) point at data
  4930. */
  4931. private _updatePointAtData;
  4932. /**
  4933. * Updates the point at data from the specified parameters
  4934. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4935. * @param point the interpolated point
  4936. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4937. */
  4938. private _setPointAtData;
  4939. /**
  4940. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4941. */
  4942. private _updateInterpolationMatrix;
  4943. }
  4944. /**
  4945. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4946. * A Curve3 is designed from a series of successive Vector3.
  4947. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4948. */
  4949. export class Curve3 {
  4950. private _points;
  4951. private _length;
  4952. /**
  4953. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4954. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4955. * @param v1 (Vector3) the control point
  4956. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4957. * @param nbPoints (integer) the wanted number of points in the curve
  4958. * @returns the created Curve3
  4959. */
  4960. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4961. /**
  4962. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4963. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4964. * @param v1 (Vector3) the first control point
  4965. * @param v2 (Vector3) the second control point
  4966. * @param v3 (Vector3) the end point of the Cubic Bezier
  4967. * @param nbPoints (integer) the wanted number of points in the curve
  4968. * @returns the created Curve3
  4969. */
  4970. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4971. /**
  4972. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4973. * @param p1 (Vector3) the origin point of the Hermite Spline
  4974. * @param t1 (Vector3) the tangent vector at the origin point
  4975. * @param p2 (Vector3) the end point of the Hermite Spline
  4976. * @param t2 (Vector3) the tangent vector at the end point
  4977. * @param nbPoints (integer) the wanted number of points in the curve
  4978. * @returns the created Curve3
  4979. */
  4980. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4981. /**
  4982. * Returns a Curve3 object along a CatmullRom Spline curve :
  4983. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4984. * @param nbPoints (integer) the wanted number of points between each curve control points
  4985. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4986. * @returns the created Curve3
  4987. */
  4988. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4989. /**
  4990. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4991. * A Curve3 is designed from a series of successive Vector3.
  4992. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4993. * @param points points which make up the curve
  4994. */
  4995. constructor(points: Vector3[]);
  4996. /**
  4997. * @returns the Curve3 stored array of successive Vector3
  4998. */
  4999. getPoints(): Vector3[];
  5000. /**
  5001. * @returns the computed length (float) of the curve.
  5002. */
  5003. length(): number;
  5004. /**
  5005. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5006. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5007. * curveA and curveB keep unchanged.
  5008. * @param curve the curve to continue from this curve
  5009. * @returns the newly constructed curve
  5010. */
  5011. continue(curve: DeepImmutable<Curve3>): Curve3;
  5012. private _computeLength;
  5013. }
  5014. }
  5015. declare module BABYLON {
  5016. /**
  5017. * This represents the main contract an easing function should follow.
  5018. * Easing functions are used throughout the animation system.
  5019. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5020. */
  5021. export interface IEasingFunction {
  5022. /**
  5023. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5024. * of the easing function.
  5025. * The link below provides some of the most common examples of easing functions.
  5026. * @see https://easings.net/
  5027. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5028. * @returns the corresponding value on the curve defined by the easing function
  5029. */
  5030. ease(gradient: number): number;
  5031. }
  5032. /**
  5033. * Base class used for every default easing function.
  5034. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5035. */
  5036. export class EasingFunction implements IEasingFunction {
  5037. /**
  5038. * Interpolation follows the mathematical formula associated with the easing function.
  5039. */
  5040. static readonly EASINGMODE_EASEIN: number;
  5041. /**
  5042. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5043. */
  5044. static readonly EASINGMODE_EASEOUT: number;
  5045. /**
  5046. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5047. */
  5048. static readonly EASINGMODE_EASEINOUT: number;
  5049. private _easingMode;
  5050. /**
  5051. * Sets the easing mode of the current function.
  5052. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5053. */
  5054. setEasingMode(easingMode: number): void;
  5055. /**
  5056. * Gets the current easing mode.
  5057. * @returns the easing mode
  5058. */
  5059. getEasingMode(): number;
  5060. /**
  5061. * @hidden
  5062. */
  5063. easeInCore(gradient: number): number;
  5064. /**
  5065. * Given an input gradient between 0 and 1, this returns the corresponding value
  5066. * of the easing function.
  5067. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5068. * @returns the corresponding value on the curve defined by the easing function
  5069. */
  5070. ease(gradient: number): number;
  5071. }
  5072. /**
  5073. * Easing function with a circle shape (see link below).
  5074. * @see https://easings.net/#easeInCirc
  5075. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5076. */
  5077. export class CircleEase extends EasingFunction implements IEasingFunction {
  5078. /** @hidden */
  5079. easeInCore(gradient: number): number;
  5080. }
  5081. /**
  5082. * Easing function with a ease back shape (see link below).
  5083. * @see https://easings.net/#easeInBack
  5084. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5085. */
  5086. export class BackEase extends EasingFunction implements IEasingFunction {
  5087. /** Defines the amplitude of the function */
  5088. amplitude: number;
  5089. /**
  5090. * Instantiates a back ease easing
  5091. * @see https://easings.net/#easeInBack
  5092. * @param amplitude Defines the amplitude of the function
  5093. */
  5094. constructor(
  5095. /** Defines the amplitude of the function */
  5096. amplitude?: number);
  5097. /** @hidden */
  5098. easeInCore(gradient: number): number;
  5099. }
  5100. /**
  5101. * Easing function with a bouncing shape (see link below).
  5102. * @see https://easings.net/#easeInBounce
  5103. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5104. */
  5105. export class BounceEase extends EasingFunction implements IEasingFunction {
  5106. /** Defines the number of bounces */
  5107. bounces: number;
  5108. /** Defines the amplitude of the bounce */
  5109. bounciness: number;
  5110. /**
  5111. * Instantiates a bounce easing
  5112. * @see https://easings.net/#easeInBounce
  5113. * @param bounces Defines the number of bounces
  5114. * @param bounciness Defines the amplitude of the bounce
  5115. */
  5116. constructor(
  5117. /** Defines the number of bounces */
  5118. bounces?: number,
  5119. /** Defines the amplitude of the bounce */
  5120. bounciness?: number);
  5121. /** @hidden */
  5122. easeInCore(gradient: number): number;
  5123. }
  5124. /**
  5125. * Easing function with a power of 3 shape (see link below).
  5126. * @see https://easings.net/#easeInCubic
  5127. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5128. */
  5129. export class CubicEase extends EasingFunction implements IEasingFunction {
  5130. /** @hidden */
  5131. easeInCore(gradient: number): number;
  5132. }
  5133. /**
  5134. * Easing function with an elastic shape (see link below).
  5135. * @see https://easings.net/#easeInElastic
  5136. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5137. */
  5138. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5139. /** Defines the number of oscillations*/
  5140. oscillations: number;
  5141. /** Defines the amplitude of the oscillations*/
  5142. springiness: number;
  5143. /**
  5144. * Instantiates an elastic easing function
  5145. * @see https://easings.net/#easeInElastic
  5146. * @param oscillations Defines the number of oscillations
  5147. * @param springiness Defines the amplitude of the oscillations
  5148. */
  5149. constructor(
  5150. /** Defines the number of oscillations*/
  5151. oscillations?: number,
  5152. /** Defines the amplitude of the oscillations*/
  5153. springiness?: number);
  5154. /** @hidden */
  5155. easeInCore(gradient: number): number;
  5156. }
  5157. /**
  5158. * Easing function with an exponential shape (see link below).
  5159. * @see https://easings.net/#easeInExpo
  5160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5161. */
  5162. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5163. /** Defines the exponent of the function */
  5164. exponent: number;
  5165. /**
  5166. * Instantiates an exponential easing function
  5167. * @see https://easings.net/#easeInExpo
  5168. * @param exponent Defines the exponent of the function
  5169. */
  5170. constructor(
  5171. /** Defines the exponent of the function */
  5172. exponent?: number);
  5173. /** @hidden */
  5174. easeInCore(gradient: number): number;
  5175. }
  5176. /**
  5177. * Easing function with a power shape (see link below).
  5178. * @see https://easings.net/#easeInQuad
  5179. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5180. */
  5181. export class PowerEase extends EasingFunction implements IEasingFunction {
  5182. /** Defines the power of the function */
  5183. power: number;
  5184. /**
  5185. * Instantiates an power base easing function
  5186. * @see https://easings.net/#easeInQuad
  5187. * @param power Defines the power of the function
  5188. */
  5189. constructor(
  5190. /** Defines the power of the function */
  5191. power?: number);
  5192. /** @hidden */
  5193. easeInCore(gradient: number): number;
  5194. }
  5195. /**
  5196. * Easing function with a power of 2 shape (see link below).
  5197. * @see https://easings.net/#easeInQuad
  5198. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5199. */
  5200. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5201. /** @hidden */
  5202. easeInCore(gradient: number): number;
  5203. }
  5204. /**
  5205. * Easing function with a power of 4 shape (see link below).
  5206. * @see https://easings.net/#easeInQuart
  5207. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5208. */
  5209. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5210. /** @hidden */
  5211. easeInCore(gradient: number): number;
  5212. }
  5213. /**
  5214. * Easing function with a power of 5 shape (see link below).
  5215. * @see https://easings.net/#easeInQuint
  5216. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5217. */
  5218. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5219. /** @hidden */
  5220. easeInCore(gradient: number): number;
  5221. }
  5222. /**
  5223. * Easing function with a sin shape (see link below).
  5224. * @see https://easings.net/#easeInSine
  5225. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5226. */
  5227. export class SineEase extends EasingFunction implements IEasingFunction {
  5228. /** @hidden */
  5229. easeInCore(gradient: number): number;
  5230. }
  5231. /**
  5232. * Easing function with a bezier shape (see link below).
  5233. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5235. */
  5236. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5237. /** Defines the x component of the start tangent in the bezier curve */
  5238. x1: number;
  5239. /** Defines the y component of the start tangent in the bezier curve */
  5240. y1: number;
  5241. /** Defines the x component of the end tangent in the bezier curve */
  5242. x2: number;
  5243. /** Defines the y component of the end tangent in the bezier curve */
  5244. y2: number;
  5245. /**
  5246. * Instantiates a bezier function
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @param x1 Defines the x component of the start tangent in the bezier curve
  5249. * @param y1 Defines the y component of the start tangent in the bezier curve
  5250. * @param x2 Defines the x component of the end tangent in the bezier curve
  5251. * @param y2 Defines the y component of the end tangent in the bezier curve
  5252. */
  5253. constructor(
  5254. /** Defines the x component of the start tangent in the bezier curve */
  5255. x1?: number,
  5256. /** Defines the y component of the start tangent in the bezier curve */
  5257. y1?: number,
  5258. /** Defines the x component of the end tangent in the bezier curve */
  5259. x2?: number,
  5260. /** Defines the y component of the end tangent in the bezier curve */
  5261. y2?: number);
  5262. /** @hidden */
  5263. easeInCore(gradient: number): number;
  5264. }
  5265. }
  5266. declare module BABYLON {
  5267. /**
  5268. * Class used to hold a RBG color
  5269. */
  5270. export class Color3 {
  5271. /**
  5272. * Defines the red component (between 0 and 1, default is 0)
  5273. */
  5274. r: number;
  5275. /**
  5276. * Defines the green component (between 0 and 1, default is 0)
  5277. */
  5278. g: number;
  5279. /**
  5280. * Defines the blue component (between 0 and 1, default is 0)
  5281. */
  5282. b: number;
  5283. /**
  5284. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5285. * @param r defines the red component (between 0 and 1, default is 0)
  5286. * @param g defines the green component (between 0 and 1, default is 0)
  5287. * @param b defines the blue component (between 0 and 1, default is 0)
  5288. */
  5289. constructor(
  5290. /**
  5291. * Defines the red component (between 0 and 1, default is 0)
  5292. */
  5293. r?: number,
  5294. /**
  5295. * Defines the green component (between 0 and 1, default is 0)
  5296. */
  5297. g?: number,
  5298. /**
  5299. * Defines the blue component (between 0 and 1, default is 0)
  5300. */
  5301. b?: number);
  5302. /**
  5303. * Creates a string with the Color3 current values
  5304. * @returns the string representation of the Color3 object
  5305. */
  5306. toString(): string;
  5307. /**
  5308. * Returns the string "Color3"
  5309. * @returns "Color3"
  5310. */
  5311. getClassName(): string;
  5312. /**
  5313. * Compute the Color3 hash code
  5314. * @returns an unique number that can be used to hash Color3 objects
  5315. */
  5316. getHashCode(): number;
  5317. /**
  5318. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5319. * @param array defines the array where to store the r,g,b components
  5320. * @param index defines an optional index in the target array to define where to start storing values
  5321. * @returns the current Color3 object
  5322. */
  5323. toArray(array: FloatArray, index?: number): Color3;
  5324. /**
  5325. * Returns a new Color4 object from the current Color3 and the given alpha
  5326. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5327. * @returns a new Color4 object
  5328. */
  5329. toColor4(alpha?: number): Color4;
  5330. /**
  5331. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5332. * @returns the new array
  5333. */
  5334. asArray(): number[];
  5335. /**
  5336. * Returns the luminance value
  5337. * @returns a float value
  5338. */
  5339. toLuminance(): number;
  5340. /**
  5341. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5342. * @param otherColor defines the second operand
  5343. * @returns the new Color3 object
  5344. */
  5345. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5346. /**
  5347. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5348. * @param otherColor defines the second operand
  5349. * @param result defines the Color3 object where to store the result
  5350. * @returns the current Color3
  5351. */
  5352. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5353. /**
  5354. * Determines equality between Color3 objects
  5355. * @param otherColor defines the second operand
  5356. * @returns true if the rgb values are equal to the given ones
  5357. */
  5358. equals(otherColor: DeepImmutable<Color3>): boolean;
  5359. /**
  5360. * Determines equality between the current Color3 object and a set of r,b,g values
  5361. * @param r defines the red component to check
  5362. * @param g defines the green component to check
  5363. * @param b defines the blue component to check
  5364. * @returns true if the rgb values are equal to the given ones
  5365. */
  5366. equalsFloats(r: number, g: number, b: number): boolean;
  5367. /**
  5368. * Multiplies in place each rgb value by scale
  5369. * @param scale defines the scaling factor
  5370. * @returns the updated Color3
  5371. */
  5372. scale(scale: number): Color3;
  5373. /**
  5374. * Multiplies the rgb values by scale and stores the result into "result"
  5375. * @param scale defines the scaling factor
  5376. * @param result defines the Color3 object where to store the result
  5377. * @returns the unmodified current Color3
  5378. */
  5379. scaleToRef(scale: number, result: Color3): Color3;
  5380. /**
  5381. * Scale the current Color3 values by a factor and add the result to a given Color3
  5382. * @param scale defines the scale factor
  5383. * @param result defines color to store the result into
  5384. * @returns the unmodified current Color3
  5385. */
  5386. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5387. /**
  5388. * Clamps the rgb values by the min and max values and stores the result into "result"
  5389. * @param min defines minimum clamping value (default is 0)
  5390. * @param max defines maximum clamping value (default is 1)
  5391. * @param result defines color to store the result into
  5392. * @returns the original Color3
  5393. */
  5394. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5395. /**
  5396. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5397. * @param otherColor defines the second operand
  5398. * @returns the new Color3
  5399. */
  5400. add(otherColor: DeepImmutable<Color3>): Color3;
  5401. /**
  5402. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5403. * @param otherColor defines the second operand
  5404. * @param result defines Color3 object to store the result into
  5405. * @returns the unmodified current Color3
  5406. */
  5407. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5408. /**
  5409. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5410. * @param otherColor defines the second operand
  5411. * @returns the new Color3
  5412. */
  5413. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5414. /**
  5415. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5416. * @param otherColor defines the second operand
  5417. * @param result defines Color3 object to store the result into
  5418. * @returns the unmodified current Color3
  5419. */
  5420. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5421. /**
  5422. * Copy the current object
  5423. * @returns a new Color3 copied the current one
  5424. */
  5425. clone(): Color3;
  5426. /**
  5427. * Copies the rgb values from the source in the current Color3
  5428. * @param source defines the source Color3 object
  5429. * @returns the updated Color3 object
  5430. */
  5431. copyFrom(source: DeepImmutable<Color3>): Color3;
  5432. /**
  5433. * Updates the Color3 rgb values from the given floats
  5434. * @param r defines the red component to read from
  5435. * @param g defines the green component to read from
  5436. * @param b defines the blue component to read from
  5437. * @returns the current Color3 object
  5438. */
  5439. copyFromFloats(r: number, g: number, b: number): Color3;
  5440. /**
  5441. * Updates the Color3 rgb values from the given floats
  5442. * @param r defines the red component to read from
  5443. * @param g defines the green component to read from
  5444. * @param b defines the blue component to read from
  5445. * @returns the current Color3 object
  5446. */
  5447. set(r: number, g: number, b: number): Color3;
  5448. /**
  5449. * Compute the Color3 hexadecimal code as a string
  5450. * @returns a string containing the hexadecimal representation of the Color3 object
  5451. */
  5452. toHexString(): string;
  5453. /**
  5454. * Computes a new Color3 converted from the current one to linear space
  5455. * @returns a new Color3 object
  5456. */
  5457. toLinearSpace(): Color3;
  5458. /**
  5459. * Converts current color in rgb space to HSV values
  5460. * @returns a new color3 representing the HSV values
  5461. */
  5462. toHSV(): Color3;
  5463. /**
  5464. * Converts current color in rgb space to HSV values
  5465. * @param result defines the Color3 where to store the HSV values
  5466. */
  5467. toHSVToRef(result: Color3): void;
  5468. /**
  5469. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5470. * @param convertedColor defines the Color3 object where to store the linear space version
  5471. * @returns the unmodified Color3
  5472. */
  5473. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5474. /**
  5475. * Computes a new Color3 converted from the current one to gamma space
  5476. * @returns a new Color3 object
  5477. */
  5478. toGammaSpace(): Color3;
  5479. /**
  5480. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5481. * @param convertedColor defines the Color3 object where to store the gamma space version
  5482. * @returns the unmodified Color3
  5483. */
  5484. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5485. private static _BlackReadOnly;
  5486. /**
  5487. * Convert Hue, saturation and value to a Color3 (RGB)
  5488. * @param hue defines the hue
  5489. * @param saturation defines the saturation
  5490. * @param value defines the value
  5491. * @param result defines the Color3 where to store the RGB values
  5492. */
  5493. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5494. /**
  5495. * Creates a new Color3 from the string containing valid hexadecimal values
  5496. * @param hex defines a string containing valid hexadecimal values
  5497. * @returns a new Color3 object
  5498. */
  5499. static FromHexString(hex: string): Color3;
  5500. /**
  5501. * Creates a new Color3 from the starting index of the given array
  5502. * @param array defines the source array
  5503. * @param offset defines an offset in the source array
  5504. * @returns a new Color3 object
  5505. */
  5506. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5507. /**
  5508. * Creates a new Color3 from integer values (< 256)
  5509. * @param r defines the red component to read from (value between 0 and 255)
  5510. * @param g defines the green component to read from (value between 0 and 255)
  5511. * @param b defines the blue component to read from (value between 0 and 255)
  5512. * @returns a new Color3 object
  5513. */
  5514. static FromInts(r: number, g: number, b: number): Color3;
  5515. /**
  5516. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5517. * @param start defines the start Color3 value
  5518. * @param end defines the end Color3 value
  5519. * @param amount defines the gradient value between start and end
  5520. * @returns a new Color3 object
  5521. */
  5522. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5523. /**
  5524. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5525. * @param left defines the start value
  5526. * @param right defines the end value
  5527. * @param amount defines the gradient factor
  5528. * @param result defines the Color3 object where to store the result
  5529. */
  5530. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5531. /**
  5532. * Returns a Color3 value containing a red color
  5533. * @returns a new Color3 object
  5534. */
  5535. static Red(): Color3;
  5536. /**
  5537. * Returns a Color3 value containing a green color
  5538. * @returns a new Color3 object
  5539. */
  5540. static Green(): Color3;
  5541. /**
  5542. * Returns a Color3 value containing a blue color
  5543. * @returns a new Color3 object
  5544. */
  5545. static Blue(): Color3;
  5546. /**
  5547. * Returns a Color3 value containing a black color
  5548. * @returns a new Color3 object
  5549. */
  5550. static Black(): Color3;
  5551. /**
  5552. * Gets a Color3 value containing a black color that must not be updated
  5553. */
  5554. static get BlackReadOnly(): DeepImmutable<Color3>;
  5555. /**
  5556. * Returns a Color3 value containing a white color
  5557. * @returns a new Color3 object
  5558. */
  5559. static White(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a purple color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Purple(): Color3;
  5565. /**
  5566. * Returns a Color3 value containing a magenta color
  5567. * @returns a new Color3 object
  5568. */
  5569. static Magenta(): Color3;
  5570. /**
  5571. * Returns a Color3 value containing a yellow color
  5572. * @returns a new Color3 object
  5573. */
  5574. static Yellow(): Color3;
  5575. /**
  5576. * Returns a Color3 value containing a gray color
  5577. * @returns a new Color3 object
  5578. */
  5579. static Gray(): Color3;
  5580. /**
  5581. * Returns a Color3 value containing a teal color
  5582. * @returns a new Color3 object
  5583. */
  5584. static Teal(): Color3;
  5585. /**
  5586. * Returns a Color3 value containing a random color
  5587. * @returns a new Color3 object
  5588. */
  5589. static Random(): Color3;
  5590. }
  5591. /**
  5592. * Class used to hold a RBGA color
  5593. */
  5594. export class Color4 {
  5595. /**
  5596. * Defines the red component (between 0 and 1, default is 0)
  5597. */
  5598. r: number;
  5599. /**
  5600. * Defines the green component (between 0 and 1, default is 0)
  5601. */
  5602. g: number;
  5603. /**
  5604. * Defines the blue component (between 0 and 1, default is 0)
  5605. */
  5606. b: number;
  5607. /**
  5608. * Defines the alpha component (between 0 and 1, default is 1)
  5609. */
  5610. a: number;
  5611. /**
  5612. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5613. * @param r defines the red component (between 0 and 1, default is 0)
  5614. * @param g defines the green component (between 0 and 1, default is 0)
  5615. * @param b defines the blue component (between 0 and 1, default is 0)
  5616. * @param a defines the alpha component (between 0 and 1, default is 1)
  5617. */
  5618. constructor(
  5619. /**
  5620. * Defines the red component (between 0 and 1, default is 0)
  5621. */
  5622. r?: number,
  5623. /**
  5624. * Defines the green component (between 0 and 1, default is 0)
  5625. */
  5626. g?: number,
  5627. /**
  5628. * Defines the blue component (between 0 and 1, default is 0)
  5629. */
  5630. b?: number,
  5631. /**
  5632. * Defines the alpha component (between 0 and 1, default is 1)
  5633. */
  5634. a?: number);
  5635. /**
  5636. * Adds in place the given Color4 values to the current Color4 object
  5637. * @param right defines the second operand
  5638. * @returns the current updated Color4 object
  5639. */
  5640. addInPlace(right: DeepImmutable<Color4>): Color4;
  5641. /**
  5642. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5643. * @returns the new array
  5644. */
  5645. asArray(): number[];
  5646. /**
  5647. * Stores from the starting index in the given array the Color4 successive values
  5648. * @param array defines the array where to store the r,g,b components
  5649. * @param index defines an optional index in the target array to define where to start storing values
  5650. * @returns the current Color4 object
  5651. */
  5652. toArray(array: number[], index?: number): Color4;
  5653. /**
  5654. * Determines equality between Color4 objects
  5655. * @param otherColor defines the second operand
  5656. * @returns true if the rgba values are equal to the given ones
  5657. */
  5658. equals(otherColor: DeepImmutable<Color4>): boolean;
  5659. /**
  5660. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5661. * @param right defines the second operand
  5662. * @returns a new Color4 object
  5663. */
  5664. add(right: DeepImmutable<Color4>): Color4;
  5665. /**
  5666. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5667. * @param right defines the second operand
  5668. * @returns a new Color4 object
  5669. */
  5670. subtract(right: DeepImmutable<Color4>): Color4;
  5671. /**
  5672. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5673. * @param right defines the second operand
  5674. * @param result defines the Color4 object where to store the result
  5675. * @returns the current Color4 object
  5676. */
  5677. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5678. /**
  5679. * Creates a new Color4 with the current Color4 values multiplied by scale
  5680. * @param scale defines the scaling factor to apply
  5681. * @returns a new Color4 object
  5682. */
  5683. scale(scale: number): Color4;
  5684. /**
  5685. * Multiplies the current Color4 values by scale and stores the result in "result"
  5686. * @param scale defines the scaling factor to apply
  5687. * @param result defines the Color4 object where to store the result
  5688. * @returns the current unmodified Color4
  5689. */
  5690. scaleToRef(scale: number, result: Color4): Color4;
  5691. /**
  5692. * Scale the current Color4 values by a factor and add the result to a given Color4
  5693. * @param scale defines the scale factor
  5694. * @param result defines the Color4 object where to store the result
  5695. * @returns the unmodified current Color4
  5696. */
  5697. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5698. /**
  5699. * Clamps the rgb values by the min and max values and stores the result into "result"
  5700. * @param min defines minimum clamping value (default is 0)
  5701. * @param max defines maximum clamping value (default is 1)
  5702. * @param result defines color to store the result into.
  5703. * @returns the cuurent Color4
  5704. */
  5705. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5706. /**
  5707. * Multipy an Color4 value by another and return a new Color4 object
  5708. * @param color defines the Color4 value to multiply by
  5709. * @returns a new Color4 object
  5710. */
  5711. multiply(color: Color4): Color4;
  5712. /**
  5713. * Multipy a Color4 value by another and push the result in a reference value
  5714. * @param color defines the Color4 value to multiply by
  5715. * @param result defines the Color4 to fill the result in
  5716. * @returns the result Color4
  5717. */
  5718. multiplyToRef(color: Color4, result: Color4): Color4;
  5719. /**
  5720. * Creates a string with the Color4 current values
  5721. * @returns the string representation of the Color4 object
  5722. */
  5723. toString(): string;
  5724. /**
  5725. * Returns the string "Color4"
  5726. * @returns "Color4"
  5727. */
  5728. getClassName(): string;
  5729. /**
  5730. * Compute the Color4 hash code
  5731. * @returns an unique number that can be used to hash Color4 objects
  5732. */
  5733. getHashCode(): number;
  5734. /**
  5735. * Creates a new Color4 copied from the current one
  5736. * @returns a new Color4 object
  5737. */
  5738. clone(): Color4;
  5739. /**
  5740. * Copies the given Color4 values into the current one
  5741. * @param source defines the source Color4 object
  5742. * @returns the current updated Color4 object
  5743. */
  5744. copyFrom(source: Color4): Color4;
  5745. /**
  5746. * Copies the given float values into the current one
  5747. * @param r defines the red component to read from
  5748. * @param g defines the green component to read from
  5749. * @param b defines the blue component to read from
  5750. * @param a defines the alpha component to read from
  5751. * @returns the current updated Color4 object
  5752. */
  5753. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5754. /**
  5755. * Copies the given float values into the current one
  5756. * @param r defines the red component to read from
  5757. * @param g defines the green component to read from
  5758. * @param b defines the blue component to read from
  5759. * @param a defines the alpha component to read from
  5760. * @returns the current updated Color4 object
  5761. */
  5762. set(r: number, g: number, b: number, a: number): Color4;
  5763. /**
  5764. * Compute the Color4 hexadecimal code as a string
  5765. * @returns a string containing the hexadecimal representation of the Color4 object
  5766. */
  5767. toHexString(): string;
  5768. /**
  5769. * Computes a new Color4 converted from the current one to linear space
  5770. * @returns a new Color4 object
  5771. */
  5772. toLinearSpace(): Color4;
  5773. /**
  5774. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5775. * @param convertedColor defines the Color4 object where to store the linear space version
  5776. * @returns the unmodified Color4
  5777. */
  5778. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5779. /**
  5780. * Computes a new Color4 converted from the current one to gamma space
  5781. * @returns a new Color4 object
  5782. */
  5783. toGammaSpace(): Color4;
  5784. /**
  5785. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5786. * @param convertedColor defines the Color4 object where to store the gamma space version
  5787. * @returns the unmodified Color4
  5788. */
  5789. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5790. /**
  5791. * Creates a new Color4 from the string containing valid hexadecimal values
  5792. * @param hex defines a string containing valid hexadecimal values
  5793. * @returns a new Color4 object
  5794. */
  5795. static FromHexString(hex: string): Color4;
  5796. /**
  5797. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5798. * @param left defines the start value
  5799. * @param right defines the end value
  5800. * @param amount defines the gradient factor
  5801. * @returns a new Color4 object
  5802. */
  5803. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5804. /**
  5805. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5806. * @param left defines the start value
  5807. * @param right defines the end value
  5808. * @param amount defines the gradient factor
  5809. * @param result defines the Color4 object where to store data
  5810. */
  5811. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5812. /**
  5813. * Creates a new Color4 from a Color3 and an alpha value
  5814. * @param color3 defines the source Color3 to read from
  5815. * @param alpha defines the alpha component (1.0 by default)
  5816. * @returns a new Color4 object
  5817. */
  5818. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5819. /**
  5820. * Creates a new Color4 from the starting index element of the given array
  5821. * @param array defines the source array to read from
  5822. * @param offset defines the offset in the source array
  5823. * @returns a new Color4 object
  5824. */
  5825. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5826. /**
  5827. * Creates a new Color3 from integer values (< 256)
  5828. * @param r defines the red component to read from (value between 0 and 255)
  5829. * @param g defines the green component to read from (value between 0 and 255)
  5830. * @param b defines the blue component to read from (value between 0 and 255)
  5831. * @param a defines the alpha component to read from (value between 0 and 255)
  5832. * @returns a new Color3 object
  5833. */
  5834. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5835. /**
  5836. * Check the content of a given array and convert it to an array containing RGBA data
  5837. * If the original array was already containing count * 4 values then it is returned directly
  5838. * @param colors defines the array to check
  5839. * @param count defines the number of RGBA data to expect
  5840. * @returns an array containing count * 4 values (RGBA)
  5841. */
  5842. static CheckColors4(colors: number[], count: number): number[];
  5843. }
  5844. /**
  5845. * @hidden
  5846. */
  5847. export class TmpColors {
  5848. static Color3: Color3[];
  5849. static Color4: Color4[];
  5850. }
  5851. }
  5852. declare module BABYLON {
  5853. /**
  5854. * Defines an interface which represents an animation key frame
  5855. */
  5856. export interface IAnimationKey {
  5857. /**
  5858. * Frame of the key frame
  5859. */
  5860. frame: number;
  5861. /**
  5862. * Value at the specifies key frame
  5863. */
  5864. value: any;
  5865. /**
  5866. * The input tangent for the cubic hermite spline
  5867. */
  5868. inTangent?: any;
  5869. /**
  5870. * The output tangent for the cubic hermite spline
  5871. */
  5872. outTangent?: any;
  5873. /**
  5874. * The animation interpolation type
  5875. */
  5876. interpolation?: AnimationKeyInterpolation;
  5877. }
  5878. /**
  5879. * Enum for the animation key frame interpolation type
  5880. */
  5881. export enum AnimationKeyInterpolation {
  5882. /**
  5883. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5884. */
  5885. STEP = 1
  5886. }
  5887. }
  5888. declare module BABYLON {
  5889. /**
  5890. * Represents the range of an animation
  5891. */
  5892. export class AnimationRange {
  5893. /**The name of the animation range**/
  5894. name: string;
  5895. /**The starting frame of the animation */
  5896. from: number;
  5897. /**The ending frame of the animation*/
  5898. to: number;
  5899. /**
  5900. * Initializes the range of an animation
  5901. * @param name The name of the animation range
  5902. * @param from The starting frame of the animation
  5903. * @param to The ending frame of the animation
  5904. */
  5905. constructor(
  5906. /**The name of the animation range**/
  5907. name: string,
  5908. /**The starting frame of the animation */
  5909. from: number,
  5910. /**The ending frame of the animation*/
  5911. to: number);
  5912. /**
  5913. * Makes a copy of the animation range
  5914. * @returns A copy of the animation range
  5915. */
  5916. clone(): AnimationRange;
  5917. }
  5918. }
  5919. declare module BABYLON {
  5920. /**
  5921. * Composed of a frame, and an action function
  5922. */
  5923. export class AnimationEvent {
  5924. /** The frame for which the event is triggered **/
  5925. frame: number;
  5926. /** The event to perform when triggered **/
  5927. action: (currentFrame: number) => void;
  5928. /** Specifies if the event should be triggered only once**/
  5929. onlyOnce?: boolean | undefined;
  5930. /**
  5931. * Specifies if the animation event is done
  5932. */
  5933. isDone: boolean;
  5934. /**
  5935. * Initializes the animation event
  5936. * @param frame The frame for which the event is triggered
  5937. * @param action The event to perform when triggered
  5938. * @param onlyOnce Specifies if the event should be triggered only once
  5939. */
  5940. constructor(
  5941. /** The frame for which the event is triggered **/
  5942. frame: number,
  5943. /** The event to perform when triggered **/
  5944. action: (currentFrame: number) => void,
  5945. /** Specifies if the event should be triggered only once**/
  5946. onlyOnce?: boolean | undefined);
  5947. /** @hidden */
  5948. _clone(): AnimationEvent;
  5949. }
  5950. }
  5951. declare module BABYLON {
  5952. /**
  5953. * Interface used to define a behavior
  5954. */
  5955. export interface Behavior<T> {
  5956. /** gets or sets behavior's name */
  5957. name: string;
  5958. /**
  5959. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5960. */
  5961. init(): void;
  5962. /**
  5963. * Called when the behavior is attached to a target
  5964. * @param target defines the target where the behavior is attached to
  5965. */
  5966. attach(target: T): void;
  5967. /**
  5968. * Called when the behavior is detached from its target
  5969. */
  5970. detach(): void;
  5971. }
  5972. /**
  5973. * Interface implemented by classes supporting behaviors
  5974. */
  5975. export interface IBehaviorAware<T> {
  5976. /**
  5977. * Attach a behavior
  5978. * @param behavior defines the behavior to attach
  5979. * @returns the current host
  5980. */
  5981. addBehavior(behavior: Behavior<T>): T;
  5982. /**
  5983. * Remove a behavior from the current object
  5984. * @param behavior defines the behavior to detach
  5985. * @returns the current host
  5986. */
  5987. removeBehavior(behavior: Behavior<T>): T;
  5988. /**
  5989. * Gets a behavior using its name to search
  5990. * @param name defines the name to search
  5991. * @returns the behavior or null if not found
  5992. */
  5993. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5994. }
  5995. }
  5996. declare module BABYLON {
  5997. /**
  5998. * Defines an array and its length.
  5999. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6000. */
  6001. export interface ISmartArrayLike<T> {
  6002. /**
  6003. * The data of the array.
  6004. */
  6005. data: Array<T>;
  6006. /**
  6007. * The active length of the array.
  6008. */
  6009. length: number;
  6010. }
  6011. /**
  6012. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6013. */
  6014. export class SmartArray<T> implements ISmartArrayLike<T> {
  6015. /**
  6016. * The full set of data from the array.
  6017. */
  6018. data: Array<T>;
  6019. /**
  6020. * The active length of the array.
  6021. */
  6022. length: number;
  6023. protected _id: number;
  6024. /**
  6025. * Instantiates a Smart Array.
  6026. * @param capacity defines the default capacity of the array.
  6027. */
  6028. constructor(capacity: number);
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * @param value defines the object to push in the array.
  6032. */
  6033. push(value: T): void;
  6034. /**
  6035. * Iterates over the active data and apply the lambda to them.
  6036. * @param func defines the action to apply on each value.
  6037. */
  6038. forEach(func: (content: T) => void): void;
  6039. /**
  6040. * Sorts the full sets of data.
  6041. * @param compareFn defines the comparison function to apply.
  6042. */
  6043. sort(compareFn: (a: T, b: T) => number): void;
  6044. /**
  6045. * Resets the active data to an empty array.
  6046. */
  6047. reset(): void;
  6048. /**
  6049. * Releases all the data from the array as well as the array.
  6050. */
  6051. dispose(): void;
  6052. /**
  6053. * Concats the active data with a given array.
  6054. * @param array defines the data to concatenate with.
  6055. */
  6056. concat(array: any): void;
  6057. /**
  6058. * Returns the position of a value in the active data.
  6059. * @param value defines the value to find the index for
  6060. * @returns the index if found in the active data otherwise -1
  6061. */
  6062. indexOf(value: T): number;
  6063. /**
  6064. * Returns whether an element is part of the active data.
  6065. * @param value defines the value to look for
  6066. * @returns true if found in the active data otherwise false
  6067. */
  6068. contains(value: T): boolean;
  6069. private static _GlobalId;
  6070. }
  6071. /**
  6072. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6073. * The data in this array can only be present once
  6074. */
  6075. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6076. private _duplicateId;
  6077. /**
  6078. * Pushes a value at the end of the active data.
  6079. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6080. * @param value defines the object to push in the array.
  6081. */
  6082. push(value: T): void;
  6083. /**
  6084. * Pushes a value at the end of the active data.
  6085. * If the data is already present, it won t be added again
  6086. * @param value defines the object to push in the array.
  6087. * @returns true if added false if it was already present
  6088. */
  6089. pushNoDuplicate(value: T): boolean;
  6090. /**
  6091. * Resets the active data to an empty array.
  6092. */
  6093. reset(): void;
  6094. /**
  6095. * Concats the active data with a given array.
  6096. * This ensures no dupplicate will be present in the result.
  6097. * @param array defines the data to concatenate with.
  6098. */
  6099. concatWithNoDuplicate(array: any): void;
  6100. }
  6101. }
  6102. declare module BABYLON {
  6103. /**
  6104. * @ignore
  6105. * This is a list of all the different input types that are available in the application.
  6106. * Fo instance: ArcRotateCameraGamepadInput...
  6107. */
  6108. export var CameraInputTypes: {};
  6109. /**
  6110. * This is the contract to implement in order to create a new input class.
  6111. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6112. */
  6113. export interface ICameraInput<TCamera extends Camera> {
  6114. /**
  6115. * Defines the camera the input is attached to.
  6116. */
  6117. camera: Nullable<TCamera>;
  6118. /**
  6119. * Gets the class name of the current intput.
  6120. * @returns the class name
  6121. */
  6122. getClassName(): string;
  6123. /**
  6124. * Get the friendly name associated with the input class.
  6125. * @returns the input friendly name
  6126. */
  6127. getSimpleName(): string;
  6128. /**
  6129. * Attach the input controls to a specific dom element to get the input from.
  6130. * @param element Defines the element the controls should be listened from
  6131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6132. */
  6133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6134. /**
  6135. * Detach the current controls from the specified dom element.
  6136. * @param element Defines the element to stop listening the inputs from
  6137. */
  6138. detachControl(element: Nullable<HTMLElement>): void;
  6139. /**
  6140. * Update the current camera state depending on the inputs that have been used this frame.
  6141. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6142. */
  6143. checkInputs?: () => void;
  6144. }
  6145. /**
  6146. * Represents a map of input types to input instance or input index to input instance.
  6147. */
  6148. export interface CameraInputsMap<TCamera extends Camera> {
  6149. /**
  6150. * Accessor to the input by input type.
  6151. */
  6152. [name: string]: ICameraInput<TCamera>;
  6153. /**
  6154. * Accessor to the input by input index.
  6155. */
  6156. [idx: number]: ICameraInput<TCamera>;
  6157. }
  6158. /**
  6159. * This represents the input manager used within a camera.
  6160. * It helps dealing with all the different kind of input attached to a camera.
  6161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6162. */
  6163. export class CameraInputsManager<TCamera extends Camera> {
  6164. /**
  6165. * Defines the list of inputs attahed to the camera.
  6166. */
  6167. attached: CameraInputsMap<TCamera>;
  6168. /**
  6169. * Defines the dom element the camera is collecting inputs from.
  6170. * This is null if the controls have not been attached.
  6171. */
  6172. attachedElement: Nullable<HTMLElement>;
  6173. /**
  6174. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6175. */
  6176. noPreventDefault: boolean;
  6177. /**
  6178. * Defined the camera the input manager belongs to.
  6179. */
  6180. camera: TCamera;
  6181. /**
  6182. * Update the current camera state depending on the inputs that have been used this frame.
  6183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6184. */
  6185. checkInputs: () => void;
  6186. /**
  6187. * Instantiate a new Camera Input Manager.
  6188. * @param camera Defines the camera the input manager blongs to
  6189. */
  6190. constructor(camera: TCamera);
  6191. /**
  6192. * Add an input method to a camera
  6193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6194. * @param input camera input method
  6195. */
  6196. add(input: ICameraInput<TCamera>): void;
  6197. /**
  6198. * Remove a specific input method from a camera
  6199. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6200. * @param inputToRemove camera input method
  6201. */
  6202. remove(inputToRemove: ICameraInput<TCamera>): void;
  6203. /**
  6204. * Remove a specific input type from a camera
  6205. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6206. * @param inputType the type of the input to remove
  6207. */
  6208. removeByType(inputType: string): void;
  6209. private _addCheckInputs;
  6210. /**
  6211. * Attach the input controls to the currently attached dom element to listen the events from.
  6212. * @param input Defines the input to attach
  6213. */
  6214. attachInput(input: ICameraInput<TCamera>): void;
  6215. /**
  6216. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6217. * @param element Defines the dom element to collect the events from
  6218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6219. */
  6220. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6221. /**
  6222. * Detach the current manager inputs controls from a specific dom element.
  6223. * @param element Defines the dom element to collect the events from
  6224. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6225. */
  6226. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6227. /**
  6228. * Rebuild the dynamic inputCheck function from the current list of
  6229. * defined inputs in the manager.
  6230. */
  6231. rebuildInputCheck(): void;
  6232. /**
  6233. * Remove all attached input methods from a camera
  6234. */
  6235. clear(): void;
  6236. /**
  6237. * Serialize the current input manager attached to a camera.
  6238. * This ensures than once parsed,
  6239. * the input associated to the camera will be identical to the current ones
  6240. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6241. */
  6242. serialize(serializedCamera: any): void;
  6243. /**
  6244. * Parses an input manager serialized JSON to restore the previous list of inputs
  6245. * and states associated to a camera.
  6246. * @param parsedCamera Defines the JSON to parse
  6247. */
  6248. parse(parsedCamera: any): void;
  6249. }
  6250. }
  6251. declare module BABYLON {
  6252. /**
  6253. * Class used to store data that will be store in GPU memory
  6254. */
  6255. export class Buffer {
  6256. private _engine;
  6257. private _buffer;
  6258. /** @hidden */
  6259. _data: Nullable<DataArray>;
  6260. private _updatable;
  6261. private _instanced;
  6262. private _divisor;
  6263. /**
  6264. * Gets the byte stride.
  6265. */
  6266. readonly byteStride: number;
  6267. /**
  6268. * Constructor
  6269. * @param engine the engine
  6270. * @param data the data to use for this buffer
  6271. * @param updatable whether the data is updatable
  6272. * @param stride the stride (optional)
  6273. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6274. * @param instanced whether the buffer is instanced (optional)
  6275. * @param useBytes set to true if the stride in in bytes (optional)
  6276. * @param divisor sets an optional divisor for instances (1 by default)
  6277. */
  6278. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6279. /**
  6280. * Create a new VertexBuffer based on the current buffer
  6281. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6282. * @param offset defines offset in the buffer (0 by default)
  6283. * @param size defines the size in floats of attributes (position is 3 for instance)
  6284. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6285. * @param instanced defines if the vertex buffer contains indexed data
  6286. * @param useBytes defines if the offset and stride are in bytes *
  6287. * @param divisor sets an optional divisor for instances (1 by default)
  6288. * @returns the new vertex buffer
  6289. */
  6290. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6291. /**
  6292. * Gets a boolean indicating if the Buffer is updatable?
  6293. * @returns true if the buffer is updatable
  6294. */
  6295. isUpdatable(): boolean;
  6296. /**
  6297. * Gets current buffer's data
  6298. * @returns a DataArray or null
  6299. */
  6300. getData(): Nullable<DataArray>;
  6301. /**
  6302. * Gets underlying native buffer
  6303. * @returns underlying native buffer
  6304. */
  6305. getBuffer(): Nullable<DataBuffer>;
  6306. /**
  6307. * Gets the stride in float32 units (i.e. byte stride / 4).
  6308. * May not be an integer if the byte stride is not divisible by 4.
  6309. * @returns the stride in float32 units
  6310. * @deprecated Please use byteStride instead.
  6311. */
  6312. getStrideSize(): number;
  6313. /**
  6314. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6315. * @param data defines the data to store
  6316. */
  6317. create(data?: Nullable<DataArray>): void;
  6318. /** @hidden */
  6319. _rebuild(): void;
  6320. /**
  6321. * Update current buffer data
  6322. * @param data defines the data to store
  6323. */
  6324. update(data: DataArray): void;
  6325. /**
  6326. * Updates the data directly.
  6327. * @param data the new data
  6328. * @param offset the new offset
  6329. * @param vertexCount the vertex count (optional)
  6330. * @param useBytes set to true if the offset is in bytes
  6331. */
  6332. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6333. /**
  6334. * Release all resources
  6335. */
  6336. dispose(): void;
  6337. }
  6338. /**
  6339. * Specialized buffer used to store vertex data
  6340. */
  6341. export class VertexBuffer {
  6342. /** @hidden */
  6343. _buffer: Buffer;
  6344. private _kind;
  6345. private _size;
  6346. private _ownsBuffer;
  6347. private _instanced;
  6348. private _instanceDivisor;
  6349. /**
  6350. * The byte type.
  6351. */
  6352. static readonly BYTE: number;
  6353. /**
  6354. * The unsigned byte type.
  6355. */
  6356. static readonly UNSIGNED_BYTE: number;
  6357. /**
  6358. * The short type.
  6359. */
  6360. static readonly SHORT: number;
  6361. /**
  6362. * The unsigned short type.
  6363. */
  6364. static readonly UNSIGNED_SHORT: number;
  6365. /**
  6366. * The integer type.
  6367. */
  6368. static readonly INT: number;
  6369. /**
  6370. * The unsigned integer type.
  6371. */
  6372. static readonly UNSIGNED_INT: number;
  6373. /**
  6374. * The float type.
  6375. */
  6376. static readonly FLOAT: number;
  6377. /**
  6378. * Gets or sets the instance divisor when in instanced mode
  6379. */
  6380. get instanceDivisor(): number;
  6381. set instanceDivisor(value: number);
  6382. /**
  6383. * Gets the byte stride.
  6384. */
  6385. readonly byteStride: number;
  6386. /**
  6387. * Gets the byte offset.
  6388. */
  6389. readonly byteOffset: number;
  6390. /**
  6391. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6392. */
  6393. readonly normalized: boolean;
  6394. /**
  6395. * Gets the data type of each component in the array.
  6396. */
  6397. readonly type: number;
  6398. /**
  6399. * Constructor
  6400. * @param engine the engine
  6401. * @param data the data to use for this vertex buffer
  6402. * @param kind the vertex buffer kind
  6403. * @param updatable whether the data is updatable
  6404. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6405. * @param stride the stride (optional)
  6406. * @param instanced whether the buffer is instanced (optional)
  6407. * @param offset the offset of the data (optional)
  6408. * @param size the number of components (optional)
  6409. * @param type the type of the component (optional)
  6410. * @param normalized whether the data contains normalized data (optional)
  6411. * @param useBytes set to true if stride and offset are in bytes (optional)
  6412. * @param divisor defines the instance divisor to use (1 by default)
  6413. */
  6414. 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);
  6415. /** @hidden */
  6416. _rebuild(): void;
  6417. /**
  6418. * Returns the kind of the VertexBuffer (string)
  6419. * @returns a string
  6420. */
  6421. getKind(): string;
  6422. /**
  6423. * Gets a boolean indicating if the VertexBuffer is updatable?
  6424. * @returns true if the buffer is updatable
  6425. */
  6426. isUpdatable(): boolean;
  6427. /**
  6428. * Gets current buffer's data
  6429. * @returns a DataArray or null
  6430. */
  6431. getData(): Nullable<DataArray>;
  6432. /**
  6433. * Gets underlying native buffer
  6434. * @returns underlying native buffer
  6435. */
  6436. getBuffer(): Nullable<DataBuffer>;
  6437. /**
  6438. * Gets the stride in float32 units (i.e. byte stride / 4).
  6439. * May not be an integer if the byte stride is not divisible by 4.
  6440. * @returns the stride in float32 units
  6441. * @deprecated Please use byteStride instead.
  6442. */
  6443. getStrideSize(): number;
  6444. /**
  6445. * Returns the offset as a multiple of the type byte length.
  6446. * @returns the offset in bytes
  6447. * @deprecated Please use byteOffset instead.
  6448. */
  6449. getOffset(): number;
  6450. /**
  6451. * Returns the number of components per vertex attribute (integer)
  6452. * @returns the size in float
  6453. */
  6454. getSize(): number;
  6455. /**
  6456. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6457. * @returns true if this buffer is instanced
  6458. */
  6459. getIsInstanced(): boolean;
  6460. /**
  6461. * Returns the instancing divisor, zero for non-instanced (integer).
  6462. * @returns a number
  6463. */
  6464. getInstanceDivisor(): number;
  6465. /**
  6466. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6467. * @param data defines the data to store
  6468. */
  6469. create(data?: DataArray): void;
  6470. /**
  6471. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6472. * This function will create a new buffer if the current one is not updatable
  6473. * @param data defines the data to store
  6474. */
  6475. update(data: DataArray): void;
  6476. /**
  6477. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6478. * Returns the directly updated WebGLBuffer.
  6479. * @param data the new data
  6480. * @param offset the new offset
  6481. * @param useBytes set to true if the offset is in bytes
  6482. */
  6483. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6484. /**
  6485. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6486. */
  6487. dispose(): void;
  6488. /**
  6489. * Enumerates each value of this vertex buffer as numbers.
  6490. * @param count the number of values to enumerate
  6491. * @param callback the callback function called for each value
  6492. */
  6493. forEach(count: number, callback: (value: number, index: number) => void): void;
  6494. /**
  6495. * Positions
  6496. */
  6497. static readonly PositionKind: string;
  6498. /**
  6499. * Normals
  6500. */
  6501. static readonly NormalKind: string;
  6502. /**
  6503. * Tangents
  6504. */
  6505. static readonly TangentKind: string;
  6506. /**
  6507. * Texture coordinates
  6508. */
  6509. static readonly UVKind: string;
  6510. /**
  6511. * Texture coordinates 2
  6512. */
  6513. static readonly UV2Kind: string;
  6514. /**
  6515. * Texture coordinates 3
  6516. */
  6517. static readonly UV3Kind: string;
  6518. /**
  6519. * Texture coordinates 4
  6520. */
  6521. static readonly UV4Kind: string;
  6522. /**
  6523. * Texture coordinates 5
  6524. */
  6525. static readonly UV5Kind: string;
  6526. /**
  6527. * Texture coordinates 6
  6528. */
  6529. static readonly UV6Kind: string;
  6530. /**
  6531. * Colors
  6532. */
  6533. static readonly ColorKind: string;
  6534. /**
  6535. * Matrix indices (for bones)
  6536. */
  6537. static readonly MatricesIndicesKind: string;
  6538. /**
  6539. * Matrix weights (for bones)
  6540. */
  6541. static readonly MatricesWeightsKind: string;
  6542. /**
  6543. * Additional matrix indices (for bones)
  6544. */
  6545. static readonly MatricesIndicesExtraKind: string;
  6546. /**
  6547. * Additional matrix weights (for bones)
  6548. */
  6549. static readonly MatricesWeightsExtraKind: string;
  6550. /**
  6551. * Deduces the stride given a kind.
  6552. * @param kind The kind string to deduce
  6553. * @returns The deduced stride
  6554. */
  6555. static DeduceStride(kind: string): number;
  6556. /**
  6557. * Gets the byte length of the given type.
  6558. * @param type the type
  6559. * @returns the number of bytes
  6560. */
  6561. static GetTypeByteLength(type: number): number;
  6562. /**
  6563. * Enumerates each value of the given parameters as numbers.
  6564. * @param data the data to enumerate
  6565. * @param byteOffset the byte offset of the data
  6566. * @param byteStride the byte stride of the data
  6567. * @param componentCount the number of components per element
  6568. * @param componentType the type of the component
  6569. * @param count the number of values to enumerate
  6570. * @param normalized whether the data is normalized
  6571. * @param callback the callback function called for each value
  6572. */
  6573. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6574. private static _GetFloatValue;
  6575. }
  6576. }
  6577. declare module BABYLON {
  6578. /**
  6579. * @hidden
  6580. */
  6581. export class IntersectionInfo {
  6582. bu: Nullable<number>;
  6583. bv: Nullable<number>;
  6584. distance: number;
  6585. faceId: number;
  6586. subMeshId: number;
  6587. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6588. }
  6589. }
  6590. declare module BABYLON {
  6591. /**
  6592. * Represens a plane by the equation ax + by + cz + d = 0
  6593. */
  6594. export class Plane {
  6595. private static _TmpMatrix;
  6596. /**
  6597. * Normal of the plane (a,b,c)
  6598. */
  6599. normal: Vector3;
  6600. /**
  6601. * d component of the plane
  6602. */
  6603. d: number;
  6604. /**
  6605. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6606. * @param a a component of the plane
  6607. * @param b b component of the plane
  6608. * @param c c component of the plane
  6609. * @param d d component of the plane
  6610. */
  6611. constructor(a: number, b: number, c: number, d: number);
  6612. /**
  6613. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6614. */
  6615. asArray(): number[];
  6616. /**
  6617. * @returns a new plane copied from the current Plane.
  6618. */
  6619. clone(): Plane;
  6620. /**
  6621. * @returns the string "Plane".
  6622. */
  6623. getClassName(): string;
  6624. /**
  6625. * @returns the Plane hash code.
  6626. */
  6627. getHashCode(): number;
  6628. /**
  6629. * Normalize the current Plane in place.
  6630. * @returns the updated Plane.
  6631. */
  6632. normalize(): Plane;
  6633. /**
  6634. * Applies a transformation the plane and returns the result
  6635. * @param transformation the transformation matrix to be applied to the plane
  6636. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6637. */
  6638. transform(transformation: DeepImmutable<Matrix>): Plane;
  6639. /**
  6640. * Calcualtte the dot product between the point and the plane normal
  6641. * @param point point to calculate the dot product with
  6642. * @returns the dot product (float) of the point coordinates and the plane normal.
  6643. */
  6644. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6645. /**
  6646. * Updates the current Plane from the plane defined by the three given points.
  6647. * @param point1 one of the points used to contruct the plane
  6648. * @param point2 one of the points used to contruct the plane
  6649. * @param point3 one of the points used to contruct the plane
  6650. * @returns the updated Plane.
  6651. */
  6652. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6653. /**
  6654. * Checks if the plane is facing a given direction
  6655. * @param direction the direction to check if the plane is facing
  6656. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6657. * @returns True is the vector "direction" is the same side than the plane normal.
  6658. */
  6659. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6660. /**
  6661. * Calculates the distance to a point
  6662. * @param point point to calculate distance to
  6663. * @returns the signed distance (float) from the given point to the Plane.
  6664. */
  6665. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6666. /**
  6667. * Creates a plane from an array
  6668. * @param array the array to create a plane from
  6669. * @returns a new Plane from the given array.
  6670. */
  6671. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6672. /**
  6673. * Creates a plane from three points
  6674. * @param point1 point used to create the plane
  6675. * @param point2 point used to create the plane
  6676. * @param point3 point used to create the plane
  6677. * @returns a new Plane defined by the three given points.
  6678. */
  6679. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6680. /**
  6681. * Creates a plane from an origin point and a normal
  6682. * @param origin origin of the plane to be constructed
  6683. * @param normal normal of the plane to be constructed
  6684. * @returns a new Plane the normal vector to this plane at the given origin point.
  6685. * Note : the vector "normal" is updated because normalized.
  6686. */
  6687. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6688. /**
  6689. * Calculates the distance from a plane and a point
  6690. * @param origin origin of the plane to be constructed
  6691. * @param normal normal of the plane to be constructed
  6692. * @param point point to calculate distance to
  6693. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6694. */
  6695. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6696. }
  6697. }
  6698. declare module BABYLON {
  6699. /**
  6700. * Class used to store bounding sphere information
  6701. */
  6702. export class BoundingSphere {
  6703. /**
  6704. * Gets the center of the bounding sphere in local space
  6705. */
  6706. readonly center: Vector3;
  6707. /**
  6708. * Radius of the bounding sphere in local space
  6709. */
  6710. radius: number;
  6711. /**
  6712. * Gets the center of the bounding sphere in world space
  6713. */
  6714. readonly centerWorld: Vector3;
  6715. /**
  6716. * Radius of the bounding sphere in world space
  6717. */
  6718. radiusWorld: number;
  6719. /**
  6720. * Gets the minimum vector in local space
  6721. */
  6722. readonly minimum: Vector3;
  6723. /**
  6724. * Gets the maximum vector in local space
  6725. */
  6726. readonly maximum: Vector3;
  6727. private _worldMatrix;
  6728. private static readonly TmpVector3;
  6729. /**
  6730. * Creates a new bounding sphere
  6731. * @param min defines the minimum vector (in local space)
  6732. * @param max defines the maximum vector (in local space)
  6733. * @param worldMatrix defines the new world matrix
  6734. */
  6735. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6736. /**
  6737. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6738. * @param min defines the new minimum vector (in local space)
  6739. * @param max defines the new maximum vector (in local space)
  6740. * @param worldMatrix defines the new world matrix
  6741. */
  6742. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6743. /**
  6744. * Scale the current bounding sphere by applying a scale factor
  6745. * @param factor defines the scale factor to apply
  6746. * @returns the current bounding box
  6747. */
  6748. scale(factor: number): BoundingSphere;
  6749. /**
  6750. * Gets the world matrix of the bounding box
  6751. * @returns a matrix
  6752. */
  6753. getWorldMatrix(): DeepImmutable<Matrix>;
  6754. /** @hidden */
  6755. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6756. /**
  6757. * Tests if the bounding sphere is intersecting the frustum planes
  6758. * @param frustumPlanes defines the frustum planes to test
  6759. * @returns true if there is an intersection
  6760. */
  6761. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6762. /**
  6763. * Tests if the bounding sphere center is in between the frustum planes.
  6764. * Used for optimistic fast inclusion.
  6765. * @param frustumPlanes defines the frustum planes to test
  6766. * @returns true if the sphere center is in between the frustum planes
  6767. */
  6768. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6769. /**
  6770. * Tests if a point is inside the bounding sphere
  6771. * @param point defines the point to test
  6772. * @returns true if the point is inside the bounding sphere
  6773. */
  6774. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6775. /**
  6776. * Checks if two sphere intersct
  6777. * @param sphere0 sphere 0
  6778. * @param sphere1 sphere 1
  6779. * @returns true if the speres intersect
  6780. */
  6781. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6782. }
  6783. }
  6784. declare module BABYLON {
  6785. /**
  6786. * Class used to store bounding box information
  6787. */
  6788. export class BoundingBox implements ICullable {
  6789. /**
  6790. * Gets the 8 vectors representing the bounding box in local space
  6791. */
  6792. readonly vectors: Vector3[];
  6793. /**
  6794. * Gets the center of the bounding box in local space
  6795. */
  6796. readonly center: Vector3;
  6797. /**
  6798. * Gets the center of the bounding box in world space
  6799. */
  6800. readonly centerWorld: Vector3;
  6801. /**
  6802. * Gets the extend size in local space
  6803. */
  6804. readonly extendSize: Vector3;
  6805. /**
  6806. * Gets the extend size in world space
  6807. */
  6808. readonly extendSizeWorld: Vector3;
  6809. /**
  6810. * Gets the OBB (object bounding box) directions
  6811. */
  6812. readonly directions: Vector3[];
  6813. /**
  6814. * Gets the 8 vectors representing the bounding box in world space
  6815. */
  6816. readonly vectorsWorld: Vector3[];
  6817. /**
  6818. * Gets the minimum vector in world space
  6819. */
  6820. readonly minimumWorld: Vector3;
  6821. /**
  6822. * Gets the maximum vector in world space
  6823. */
  6824. readonly maximumWorld: Vector3;
  6825. /**
  6826. * Gets the minimum vector in local space
  6827. */
  6828. readonly minimum: Vector3;
  6829. /**
  6830. * Gets the maximum vector in local space
  6831. */
  6832. readonly maximum: Vector3;
  6833. private _worldMatrix;
  6834. private static readonly TmpVector3;
  6835. /**
  6836. * @hidden
  6837. */
  6838. _tag: number;
  6839. /**
  6840. * Creates a new bounding box
  6841. * @param min defines the minimum vector (in local space)
  6842. * @param max defines the maximum vector (in local space)
  6843. * @param worldMatrix defines the new world matrix
  6844. */
  6845. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6846. /**
  6847. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6848. * @param min defines the new minimum vector (in local space)
  6849. * @param max defines the new maximum vector (in local space)
  6850. * @param worldMatrix defines the new world matrix
  6851. */
  6852. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6853. /**
  6854. * Scale the current bounding box by applying a scale factor
  6855. * @param factor defines the scale factor to apply
  6856. * @returns the current bounding box
  6857. */
  6858. scale(factor: number): BoundingBox;
  6859. /**
  6860. * Gets the world matrix of the bounding box
  6861. * @returns a matrix
  6862. */
  6863. getWorldMatrix(): DeepImmutable<Matrix>;
  6864. /** @hidden */
  6865. _update(world: DeepImmutable<Matrix>): void;
  6866. /**
  6867. * Tests if the bounding box is intersecting the frustum planes
  6868. * @param frustumPlanes defines the frustum planes to test
  6869. * @returns true if there is an intersection
  6870. */
  6871. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6872. /**
  6873. * Tests if the bounding box is entirely inside the frustum planes
  6874. * @param frustumPlanes defines the frustum planes to test
  6875. * @returns true if there is an inclusion
  6876. */
  6877. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6878. /**
  6879. * Tests if a point is inside the bounding box
  6880. * @param point defines the point to test
  6881. * @returns true if the point is inside the bounding box
  6882. */
  6883. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6884. /**
  6885. * Tests if the bounding box intersects with a bounding sphere
  6886. * @param sphere defines the sphere to test
  6887. * @returns true if there is an intersection
  6888. */
  6889. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6890. /**
  6891. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6892. * @param min defines the min vector to use
  6893. * @param max defines the max vector to use
  6894. * @returns true if there is an intersection
  6895. */
  6896. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6897. /**
  6898. * Tests if two bounding boxes are intersections
  6899. * @param box0 defines the first box to test
  6900. * @param box1 defines the second box to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6904. /**
  6905. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6906. * @param minPoint defines the minimum vector of the bounding box
  6907. * @param maxPoint defines the maximum vector of the bounding box
  6908. * @param sphereCenter defines the sphere center
  6909. * @param sphereRadius defines the sphere radius
  6910. * @returns true if there is an intersection
  6911. */
  6912. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6913. /**
  6914. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6915. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @return true if there is an inclusion
  6918. */
  6919. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6922. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6923. * @param frustumPlanes defines the frustum planes to test
  6924. * @return true if there is an intersection
  6925. */
  6926. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6927. }
  6928. }
  6929. declare module BABYLON {
  6930. /** @hidden */
  6931. export class Collider {
  6932. /** Define if a collision was found */
  6933. collisionFound: boolean;
  6934. /**
  6935. * Define last intersection point in local space
  6936. */
  6937. intersectionPoint: Vector3;
  6938. /**
  6939. * Define last collided mesh
  6940. */
  6941. collidedMesh: Nullable<AbstractMesh>;
  6942. private _collisionPoint;
  6943. private _planeIntersectionPoint;
  6944. private _tempVector;
  6945. private _tempVector2;
  6946. private _tempVector3;
  6947. private _tempVector4;
  6948. private _edge;
  6949. private _baseToVertex;
  6950. private _destinationPoint;
  6951. private _slidePlaneNormal;
  6952. private _displacementVector;
  6953. /** @hidden */
  6954. _radius: Vector3;
  6955. /** @hidden */
  6956. _retry: number;
  6957. private _velocity;
  6958. private _basePoint;
  6959. private _epsilon;
  6960. /** @hidden */
  6961. _velocityWorldLength: number;
  6962. /** @hidden */
  6963. _basePointWorld: Vector3;
  6964. private _velocityWorld;
  6965. private _normalizedVelocity;
  6966. /** @hidden */
  6967. _initialVelocity: Vector3;
  6968. /** @hidden */
  6969. _initialPosition: Vector3;
  6970. private _nearestDistance;
  6971. private _collisionMask;
  6972. get collisionMask(): number;
  6973. set collisionMask(mask: number);
  6974. /**
  6975. * Gets the plane normal used to compute the sliding response (in local space)
  6976. */
  6977. get slidePlaneNormal(): Vector3;
  6978. /** @hidden */
  6979. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6980. /** @hidden */
  6981. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6982. /** @hidden */
  6983. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6984. /** @hidden */
  6985. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6986. /** @hidden */
  6987. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6988. /** @hidden */
  6989. _getResponse(pos: Vector3, vel: Vector3): void;
  6990. }
  6991. }
  6992. declare module BABYLON {
  6993. /**
  6994. * Interface for cullable objects
  6995. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6996. */
  6997. export interface ICullable {
  6998. /**
  6999. * Checks if the object or part of the object is in the frustum
  7000. * @param frustumPlanes Camera near/planes
  7001. * @returns true if the object is in frustum otherwise false
  7002. */
  7003. isInFrustum(frustumPlanes: Plane[]): boolean;
  7004. /**
  7005. * Checks if a cullable object (mesh...) is in the camera frustum
  7006. * Unlike isInFrustum this cheks the full bounding box
  7007. * @param frustumPlanes Camera near/planes
  7008. * @returns true if the object is in frustum otherwise false
  7009. */
  7010. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7011. }
  7012. /**
  7013. * Info for a bounding data of a mesh
  7014. */
  7015. export class BoundingInfo implements ICullable {
  7016. /**
  7017. * Bounding box for the mesh
  7018. */
  7019. readonly boundingBox: BoundingBox;
  7020. /**
  7021. * Bounding sphere for the mesh
  7022. */
  7023. readonly boundingSphere: BoundingSphere;
  7024. private _isLocked;
  7025. private static readonly TmpVector3;
  7026. /**
  7027. * Constructs bounding info
  7028. * @param minimum min vector of the bounding box/sphere
  7029. * @param maximum max vector of the bounding box/sphere
  7030. * @param worldMatrix defines the new world matrix
  7031. */
  7032. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7033. /**
  7034. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7035. * @param min defines the new minimum vector (in local space)
  7036. * @param max defines the new maximum vector (in local space)
  7037. * @param worldMatrix defines the new world matrix
  7038. */
  7039. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7040. /**
  7041. * min vector of the bounding box/sphere
  7042. */
  7043. get minimum(): Vector3;
  7044. /**
  7045. * max vector of the bounding box/sphere
  7046. */
  7047. get maximum(): Vector3;
  7048. /**
  7049. * If the info is locked and won't be updated to avoid perf overhead
  7050. */
  7051. get isLocked(): boolean;
  7052. set isLocked(value: boolean);
  7053. /**
  7054. * Updates the bounding sphere and box
  7055. * @param world world matrix to be used to update
  7056. */
  7057. update(world: DeepImmutable<Matrix>): void;
  7058. /**
  7059. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7060. * @param center New center of the bounding info
  7061. * @param extend New extend of the bounding info
  7062. * @returns the current bounding info
  7063. */
  7064. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7065. /**
  7066. * Scale the current bounding info by applying a scale factor
  7067. * @param factor defines the scale factor to apply
  7068. * @returns the current bounding info
  7069. */
  7070. scale(factor: number): BoundingInfo;
  7071. /**
  7072. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7073. * @param frustumPlanes defines the frustum to test
  7074. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7075. * @returns true if the bounding info is in the frustum planes
  7076. */
  7077. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7078. /**
  7079. * Gets the world distance between the min and max points of the bounding box
  7080. */
  7081. get diagonalLength(): number;
  7082. /**
  7083. * Checks if a cullable object (mesh...) is in the camera frustum
  7084. * Unlike isInFrustum this cheks the full bounding box
  7085. * @param frustumPlanes Camera near/planes
  7086. * @returns true if the object is in frustum otherwise false
  7087. */
  7088. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7089. /** @hidden */
  7090. _checkCollision(collider: Collider): boolean;
  7091. /**
  7092. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7093. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7094. * @param point the point to check intersection with
  7095. * @returns if the point intersects
  7096. */
  7097. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7098. /**
  7099. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7100. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7101. * @param boundingInfo the bounding info to check intersection with
  7102. * @param precise if the intersection should be done using OBB
  7103. * @returns if the bounding info intersects
  7104. */
  7105. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7106. }
  7107. }
  7108. declare module BABYLON {
  7109. /**
  7110. * Extracts minimum and maximum values from a list of indexed positions
  7111. * @param positions defines the positions to use
  7112. * @param indices defines the indices to the positions
  7113. * @param indexStart defines the start index
  7114. * @param indexCount defines the end index
  7115. * @param bias defines bias value to add to the result
  7116. * @return minimum and maximum values
  7117. */
  7118. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7119. minimum: Vector3;
  7120. maximum: Vector3;
  7121. };
  7122. /**
  7123. * Extracts minimum and maximum values from a list of positions
  7124. * @param positions defines the positions to use
  7125. * @param start defines the start index in the positions array
  7126. * @param count defines the number of positions to handle
  7127. * @param bias defines bias value to add to the result
  7128. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7129. * @return minimum and maximum values
  7130. */
  7131. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7132. minimum: Vector3;
  7133. maximum: Vector3;
  7134. };
  7135. }
  7136. declare module BABYLON {
  7137. /** @hidden */
  7138. export class WebGLDataBuffer extends DataBuffer {
  7139. private _buffer;
  7140. constructor(resource: WebGLBuffer);
  7141. get underlyingResource(): any;
  7142. }
  7143. }
  7144. declare module BABYLON {
  7145. /** @hidden */
  7146. export class WebGLPipelineContext implements IPipelineContext {
  7147. engine: ThinEngine;
  7148. program: Nullable<WebGLProgram>;
  7149. context?: WebGLRenderingContext;
  7150. vertexShader?: WebGLShader;
  7151. fragmentShader?: WebGLShader;
  7152. isParallelCompiled: boolean;
  7153. onCompiled?: () => void;
  7154. transformFeedback?: WebGLTransformFeedback | null;
  7155. vertexCompilationError: Nullable<string>;
  7156. fragmentCompilationError: Nullable<string>;
  7157. programLinkError: Nullable<string>;
  7158. programValidationError: Nullable<string>;
  7159. get isAsync(): boolean;
  7160. get isReady(): boolean;
  7161. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7162. _getVertexShaderCode(): string | null;
  7163. _getFragmentShaderCode(): string | null;
  7164. }
  7165. }
  7166. declare module BABYLON {
  7167. interface ThinEngine {
  7168. /**
  7169. * Create an uniform buffer
  7170. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7171. * @param elements defines the content of the uniform buffer
  7172. * @returns the webGL uniform buffer
  7173. */
  7174. createUniformBuffer(elements: FloatArray): DataBuffer;
  7175. /**
  7176. * Create a dynamic uniform buffer
  7177. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7178. * @param elements defines the content of the uniform buffer
  7179. * @returns the webGL uniform buffer
  7180. */
  7181. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7182. /**
  7183. * Update an existing uniform buffer
  7184. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7185. * @param uniformBuffer defines the target uniform buffer
  7186. * @param elements defines the content to update
  7187. * @param offset defines the offset in the uniform buffer where update should start
  7188. * @param count defines the size of the data to update
  7189. */
  7190. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7191. /**
  7192. * Bind an uniform buffer to the current webGL context
  7193. * @param buffer defines the buffer to bind
  7194. */
  7195. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7196. /**
  7197. * Bind a buffer to the current webGL context at a given location
  7198. * @param buffer defines the buffer to bind
  7199. * @param location defines the index where to bind the buffer
  7200. */
  7201. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7202. /**
  7203. * Bind a specific block at a given index in a specific shader program
  7204. * @param pipelineContext defines the pipeline context to use
  7205. * @param blockName defines the block name
  7206. * @param index defines the index where to bind the block
  7207. */
  7208. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7209. }
  7210. }
  7211. declare module BABYLON {
  7212. /**
  7213. * Uniform buffer objects.
  7214. *
  7215. * Handles blocks of uniform on the GPU.
  7216. *
  7217. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7218. *
  7219. * For more information, please refer to :
  7220. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7221. */
  7222. export class UniformBuffer {
  7223. private _engine;
  7224. private _buffer;
  7225. private _data;
  7226. private _bufferData;
  7227. private _dynamic?;
  7228. private _uniformLocations;
  7229. private _uniformSizes;
  7230. private _uniformLocationPointer;
  7231. private _needSync;
  7232. private _noUBO;
  7233. private _currentEffect;
  7234. /** @hidden */
  7235. _alreadyBound: boolean;
  7236. private static _MAX_UNIFORM_SIZE;
  7237. private static _tempBuffer;
  7238. /**
  7239. * Lambda to Update a 3x3 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7244. /**
  7245. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7250. /**
  7251. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  7256. /**
  7257. * Lambda to Update a vec2 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7262. /**
  7263. * Lambda to Update a vec3 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7268. /**
  7269. * Lambda to Update a vec4 of float in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7274. /**
  7275. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7280. /**
  7281. * Lambda to Update vec3 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. updateVector3: (name: string, vector: Vector3) => void;
  7286. /**
  7287. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7292. /**
  7293. * Lambda to Update vec3 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7298. /**
  7299. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7304. /**
  7305. * Instantiates a new Uniform buffer objects.
  7306. *
  7307. * Handles blocks of uniform on the GPU.
  7308. *
  7309. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7310. *
  7311. * For more information, please refer to :
  7312. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7313. * @param engine Define the engine the buffer is associated with
  7314. * @param data Define the data contained in the buffer
  7315. * @param dynamic Define if the buffer is updatable
  7316. */
  7317. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7318. /**
  7319. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7320. * or just falling back on setUniformXXX calls.
  7321. */
  7322. get useUbo(): boolean;
  7323. /**
  7324. * Indicates if the WebGL underlying uniform buffer is in sync
  7325. * with the javascript cache data.
  7326. */
  7327. get isSync(): boolean;
  7328. /**
  7329. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7330. * Also, a dynamic UniformBuffer will disable cache verification and always
  7331. * update the underlying WebGL uniform buffer to the GPU.
  7332. * @returns if Dynamic, otherwise false
  7333. */
  7334. isDynamic(): boolean;
  7335. /**
  7336. * The data cache on JS side.
  7337. * @returns the underlying data as a float array
  7338. */
  7339. getData(): Float32Array;
  7340. /**
  7341. * The underlying WebGL Uniform buffer.
  7342. * @returns the webgl buffer
  7343. */
  7344. getBuffer(): Nullable<DataBuffer>;
  7345. /**
  7346. * std140 layout specifies how to align data within an UBO structure.
  7347. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7348. * for specs.
  7349. */
  7350. private _fillAlignment;
  7351. /**
  7352. * Adds an uniform in the buffer.
  7353. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7354. * for the layout to be correct !
  7355. * @param name Name of the uniform, as used in the uniform block in the shader.
  7356. * @param size Data size, or data directly.
  7357. */
  7358. addUniform(name: string, size: number | number[]): void;
  7359. /**
  7360. * Adds a Matrix 4x4 to the uniform buffer.
  7361. * @param name Name of the uniform, as used in the uniform block in the shader.
  7362. * @param mat A 4x4 matrix.
  7363. */
  7364. addMatrix(name: string, mat: Matrix): void;
  7365. /**
  7366. * Adds a vec2 to the uniform buffer.
  7367. * @param name Name of the uniform, as used in the uniform block in the shader.
  7368. * @param x Define the x component value of the vec2
  7369. * @param y Define the y component value of the vec2
  7370. */
  7371. addFloat2(name: string, x: number, y: number): void;
  7372. /**
  7373. * Adds a vec3 to the uniform buffer.
  7374. * @param name Name of the uniform, as used in the uniform block in the shader.
  7375. * @param x Define the x component value of the vec3
  7376. * @param y Define the y component value of the vec3
  7377. * @param z Define the z component value of the vec3
  7378. */
  7379. addFloat3(name: string, x: number, y: number, z: number): void;
  7380. /**
  7381. * Adds a vec3 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 vec3 from a Color
  7384. */
  7385. addColor3(name: string, color: Color3): void;
  7386. /**
  7387. * Adds a vec4 to the uniform buffer.
  7388. * @param name Name of the uniform, as used in the uniform block in the shader.
  7389. * @param color Define the rgb components from a Color
  7390. * @param alpha Define the a component of the vec4
  7391. */
  7392. addColor4(name: string, color: Color3, alpha: number): void;
  7393. /**
  7394. * Adds a vec3 to the uniform buffer.
  7395. * @param name Name of the uniform, as used in the uniform block in the shader.
  7396. * @param vector Define the vec3 components from a Vector
  7397. */
  7398. addVector3(name: string, vector: Vector3): void;
  7399. /**
  7400. * Adds a Matrix 3x3 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. */
  7403. addMatrix3x3(name: string): void;
  7404. /**
  7405. * Adds a Matrix 2x2 to the uniform buffer.
  7406. * @param name Name of the uniform, as used in the uniform block in the shader.
  7407. */
  7408. addMatrix2x2(name: string): void;
  7409. /**
  7410. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7411. */
  7412. create(): void;
  7413. /** @hidden */
  7414. _rebuild(): void;
  7415. /**
  7416. * Updates the WebGL Uniform Buffer on the GPU.
  7417. * If the `dynamic` flag is set to true, no cache comparison is done.
  7418. * Otherwise, the buffer will be updated only if the cache differs.
  7419. */
  7420. update(): void;
  7421. /**
  7422. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7423. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7424. * @param data Define the flattened data
  7425. * @param size Define the size of the data.
  7426. */
  7427. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7428. private _valueCache;
  7429. private _cacheMatrix;
  7430. private _updateMatrix3x3ForUniform;
  7431. private _updateMatrix3x3ForEffect;
  7432. private _updateMatrix2x2ForEffect;
  7433. private _updateMatrix2x2ForUniform;
  7434. private _updateFloatForEffect;
  7435. private _updateFloatForUniform;
  7436. private _updateFloat2ForEffect;
  7437. private _updateFloat2ForUniform;
  7438. private _updateFloat3ForEffect;
  7439. private _updateFloat3ForUniform;
  7440. private _updateFloat4ForEffect;
  7441. private _updateFloat4ForUniform;
  7442. private _updateMatrixForEffect;
  7443. private _updateMatrixForUniform;
  7444. private _updateVector3ForEffect;
  7445. private _updateVector3ForUniform;
  7446. private _updateVector4ForEffect;
  7447. private _updateVector4ForUniform;
  7448. private _updateColor3ForEffect;
  7449. private _updateColor3ForUniform;
  7450. private _updateColor4ForEffect;
  7451. private _updateColor4ForUniform;
  7452. /**
  7453. * Sets a sampler uniform on the effect.
  7454. * @param name Define the name of the sampler.
  7455. * @param texture Define the texture to set in the sampler
  7456. */
  7457. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7458. /**
  7459. * Directly updates the value of the uniform in the cache AND on the GPU.
  7460. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7461. * @param data Define the flattened data
  7462. */
  7463. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7464. /**
  7465. * Binds this uniform buffer to an effect.
  7466. * @param effect Define the effect to bind the buffer to
  7467. * @param name Name of the uniform block in the shader.
  7468. */
  7469. bindToEffect(effect: Effect, name: string): void;
  7470. /**
  7471. * Disposes the uniform buffer.
  7472. */
  7473. dispose(): void;
  7474. }
  7475. }
  7476. declare module BABYLON {
  7477. /**
  7478. * Enum that determines the text-wrapping mode to use.
  7479. */
  7480. export enum InspectableType {
  7481. /**
  7482. * Checkbox for booleans
  7483. */
  7484. Checkbox = 0,
  7485. /**
  7486. * Sliders for numbers
  7487. */
  7488. Slider = 1,
  7489. /**
  7490. * Vector3
  7491. */
  7492. Vector3 = 2,
  7493. /**
  7494. * Quaternions
  7495. */
  7496. Quaternion = 3,
  7497. /**
  7498. * Color3
  7499. */
  7500. Color3 = 4,
  7501. /**
  7502. * String
  7503. */
  7504. String = 5
  7505. }
  7506. /**
  7507. * Interface used to define custom inspectable properties.
  7508. * This interface is used by the inspector to display custom property grids
  7509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7510. */
  7511. export interface IInspectable {
  7512. /**
  7513. * Gets the label to display
  7514. */
  7515. label: string;
  7516. /**
  7517. * Gets the name of the property to edit
  7518. */
  7519. propertyName: string;
  7520. /**
  7521. * Gets the type of the editor to use
  7522. */
  7523. type: InspectableType;
  7524. /**
  7525. * Gets the minimum value of the property when using in "slider" mode
  7526. */
  7527. min?: number;
  7528. /**
  7529. * Gets the maximum value of the property when using in "slider" mode
  7530. */
  7531. max?: number;
  7532. /**
  7533. * Gets the setp to use when using in "slider" mode
  7534. */
  7535. step?: number;
  7536. }
  7537. }
  7538. declare module BABYLON {
  7539. /**
  7540. * Class used to provide helper for timing
  7541. */
  7542. export class TimingTools {
  7543. /**
  7544. * Polyfill for setImmediate
  7545. * @param action defines the action to execute after the current execution block
  7546. */
  7547. static SetImmediate(action: () => void): void;
  7548. }
  7549. }
  7550. declare module BABYLON {
  7551. /**
  7552. * Class used to enable instatition of objects by class name
  7553. */
  7554. export class InstantiationTools {
  7555. /**
  7556. * Use this object to register external classes like custom textures or material
  7557. * to allow the laoders to instantiate them
  7558. */
  7559. static RegisteredExternalClasses: {
  7560. [key: string]: Object;
  7561. };
  7562. /**
  7563. * Tries to instantiate a new object from a given class name
  7564. * @param className defines the class name to instantiate
  7565. * @returns the new object or null if the system was not able to do the instantiation
  7566. */
  7567. static Instantiate(className: string): any;
  7568. }
  7569. }
  7570. declare module BABYLON {
  7571. /**
  7572. * Define options used to create a depth texture
  7573. */
  7574. export class DepthTextureCreationOptions {
  7575. /** Specifies whether or not a stencil should be allocated in the texture */
  7576. generateStencil?: boolean;
  7577. /** Specifies whether or not bilinear filtering is enable on the texture */
  7578. bilinearFiltering?: boolean;
  7579. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7580. comparisonFunction?: number;
  7581. /** Specifies if the created texture is a cube texture */
  7582. isCube?: boolean;
  7583. }
  7584. }
  7585. declare module BABYLON {
  7586. interface ThinEngine {
  7587. /**
  7588. * Creates a depth stencil cube texture.
  7589. * This is only available in WebGL 2.
  7590. * @param size The size of face edge in the cube texture.
  7591. * @param options The options defining the cube texture.
  7592. * @returns The cube texture
  7593. */
  7594. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7595. /**
  7596. * Creates a cube texture
  7597. * @param rootUrl defines the url where the files to load is located
  7598. * @param scene defines the current scene
  7599. * @param files defines the list of files to load (1 per face)
  7600. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7601. * @param onLoad defines an optional callback raised when the texture is loaded
  7602. * @param onError defines an optional callback raised if there is an issue to load the texture
  7603. * @param format defines the format of the data
  7604. * @param forcedExtension defines the extension to use to pick the right loader
  7605. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7606. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7607. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7608. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7609. * @returns the cube texture as an InternalTexture
  7610. */
  7611. 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;
  7612. /**
  7613. * Creates a cube texture
  7614. * @param rootUrl defines the url where the files to load is located
  7615. * @param scene defines the current scene
  7616. * @param files defines the list of files to load (1 per face)
  7617. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7618. * @param onLoad defines an optional callback raised when the texture is loaded
  7619. * @param onError defines an optional callback raised if there is an issue to load the texture
  7620. * @param format defines the format of the data
  7621. * @param forcedExtension defines the extension to use to pick the right loader
  7622. * @returns the cube texture as an InternalTexture
  7623. */
  7624. 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;
  7625. /**
  7626. * Creates a cube texture
  7627. * @param rootUrl defines the url where the files to load is located
  7628. * @param scene defines the current scene
  7629. * @param files defines the list of files to load (1 per face)
  7630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7631. * @param onLoad defines an optional callback raised when the texture is loaded
  7632. * @param onError defines an optional callback raised if there is an issue to load the texture
  7633. * @param format defines the format of the data
  7634. * @param forcedExtension defines the extension to use to pick the right loader
  7635. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7636. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7637. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7638. * @returns the cube texture as an InternalTexture
  7639. */
  7640. 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;
  7641. /** @hidden */
  7642. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7643. /** @hidden */
  7644. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7645. /** @hidden */
  7646. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7647. /** @hidden */
  7648. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7649. /**
  7650. * @hidden
  7651. */
  7652. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7653. }
  7654. }
  7655. declare module BABYLON {
  7656. /**
  7657. * Class for creating a cube texture
  7658. */
  7659. export class CubeTexture extends BaseTexture {
  7660. private _delayedOnLoad;
  7661. /**
  7662. * Observable triggered once the texture has been loaded.
  7663. */
  7664. onLoadObservable: Observable<CubeTexture>;
  7665. /**
  7666. * The url of the texture
  7667. */
  7668. url: string;
  7669. /**
  7670. * Gets or sets the center of the bounding box associated with the cube texture.
  7671. * It must define where the camera used to render the texture was set
  7672. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7673. */
  7674. boundingBoxPosition: Vector3;
  7675. private _boundingBoxSize;
  7676. /**
  7677. * Gets or sets the size of the bounding box associated with the cube texture
  7678. * When defined, the cubemap will switch to local mode
  7679. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7680. * @example https://www.babylonjs-playground.com/#RNASML
  7681. */
  7682. set boundingBoxSize(value: Vector3);
  7683. /**
  7684. * Returns the bounding box size
  7685. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7686. */
  7687. get boundingBoxSize(): Vector3;
  7688. protected _rotationY: number;
  7689. /**
  7690. * Sets texture matrix rotation angle around Y axis in radians.
  7691. */
  7692. set rotationY(value: number);
  7693. /**
  7694. * Gets texture matrix rotation angle around Y axis radians.
  7695. */
  7696. get rotationY(): number;
  7697. /**
  7698. * Are mip maps generated for this texture or not.
  7699. */
  7700. get noMipmap(): boolean;
  7701. private _noMipmap;
  7702. private _files;
  7703. protected _forcedExtension: Nullable<string>;
  7704. private _extensions;
  7705. private _textureMatrix;
  7706. private _format;
  7707. private _createPolynomials;
  7708. /** @hidden */
  7709. _prefiltered: boolean;
  7710. /**
  7711. * Creates a cube texture from an array of image urls
  7712. * @param files defines an array of image urls
  7713. * @param scene defines the hosting scene
  7714. * @param noMipmap specifies if mip maps are not used
  7715. * @returns a cube texture
  7716. */
  7717. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7718. /**
  7719. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7720. * @param url defines the url of the prefiltered texture
  7721. * @param scene defines the scene the texture is attached to
  7722. * @param forcedExtension defines the extension of the file if different from the url
  7723. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7724. * @return the prefiltered texture
  7725. */
  7726. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7727. /**
  7728. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7729. * as prefiltered data.
  7730. * @param rootUrl defines the url of the texture or the root name of the six images
  7731. * @param scene defines the scene the texture is attached to
  7732. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7733. * @param noMipmap defines if mipmaps should be created or not
  7734. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7735. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7736. * @param onError defines a callback triggered in case of error during load
  7737. * @param format defines the internal format to use for the texture once loaded
  7738. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7739. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7740. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7743. * @return the cube texture
  7744. */
  7745. 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);
  7746. /**
  7747. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7748. */
  7749. get isPrefiltered(): boolean;
  7750. /**
  7751. * Get the current class name of the texture useful for serialization or dynamic coding.
  7752. * @returns "CubeTexture"
  7753. */
  7754. getClassName(): string;
  7755. /**
  7756. * Update the url (and optional buffer) of this texture if url was null during construction.
  7757. * @param url the url of the texture
  7758. * @param forcedExtension defines the extension to use
  7759. * @param onLoad callback called when the texture is loaded (defaults to null)
  7760. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7761. */
  7762. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7763. /**
  7764. * Delays loading of the cube texture
  7765. * @param forcedExtension defines the extension to use
  7766. */
  7767. delayLoad(forcedExtension?: string): void;
  7768. /**
  7769. * Returns the reflection texture matrix
  7770. * @returns the reflection texture matrix
  7771. */
  7772. getReflectionTextureMatrix(): Matrix;
  7773. /**
  7774. * Sets the reflection texture matrix
  7775. * @param value Reflection texture matrix
  7776. */
  7777. setReflectionTextureMatrix(value: Matrix): void;
  7778. /**
  7779. * Parses text to create a cube texture
  7780. * @param parsedTexture define the serialized text to read from
  7781. * @param scene defines the hosting scene
  7782. * @param rootUrl defines the root url of the cube texture
  7783. * @returns a cube texture
  7784. */
  7785. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7786. /**
  7787. * Makes a clone, or deep copy, of the cube texture
  7788. * @returns a new cube texture
  7789. */
  7790. clone(): CubeTexture;
  7791. }
  7792. }
  7793. declare module BABYLON {
  7794. /**
  7795. * Manages the defines for the Material
  7796. */
  7797. export class MaterialDefines {
  7798. /** @hidden */
  7799. protected _keys: string[];
  7800. private _isDirty;
  7801. /** @hidden */
  7802. _renderId: number;
  7803. /** @hidden */
  7804. _areLightsDirty: boolean;
  7805. /** @hidden */
  7806. _areLightsDisposed: boolean;
  7807. /** @hidden */
  7808. _areAttributesDirty: boolean;
  7809. /** @hidden */
  7810. _areTexturesDirty: boolean;
  7811. /** @hidden */
  7812. _areFresnelDirty: boolean;
  7813. /** @hidden */
  7814. _areMiscDirty: boolean;
  7815. /** @hidden */
  7816. _areImageProcessingDirty: boolean;
  7817. /** @hidden */
  7818. _normals: boolean;
  7819. /** @hidden */
  7820. _uvs: boolean;
  7821. /** @hidden */
  7822. _needNormals: boolean;
  7823. /** @hidden */
  7824. _needUVs: boolean;
  7825. [id: string]: any;
  7826. /**
  7827. * Specifies if the material needs to be re-calculated
  7828. */
  7829. get isDirty(): boolean;
  7830. /**
  7831. * Marks the material to indicate that it has been re-calculated
  7832. */
  7833. markAsProcessed(): void;
  7834. /**
  7835. * Marks the material to indicate that it needs to be re-calculated
  7836. */
  7837. markAsUnprocessed(): void;
  7838. /**
  7839. * Marks the material to indicate all of its defines need to be re-calculated
  7840. */
  7841. markAllAsDirty(): void;
  7842. /**
  7843. * Marks the material to indicate that image processing needs to be re-calculated
  7844. */
  7845. markAsImageProcessingDirty(): void;
  7846. /**
  7847. * Marks the material to indicate the lights need to be re-calculated
  7848. * @param disposed Defines whether the light is dirty due to dispose or not
  7849. */
  7850. markAsLightDirty(disposed?: boolean): void;
  7851. /**
  7852. * Marks the attribute state as changed
  7853. */
  7854. markAsAttributesDirty(): void;
  7855. /**
  7856. * Marks the texture state as changed
  7857. */
  7858. markAsTexturesDirty(): void;
  7859. /**
  7860. * Marks the fresnel state as changed
  7861. */
  7862. markAsFresnelDirty(): void;
  7863. /**
  7864. * Marks the misc state as changed
  7865. */
  7866. markAsMiscDirty(): void;
  7867. /**
  7868. * Rebuilds the material defines
  7869. */
  7870. rebuild(): void;
  7871. /**
  7872. * Specifies if two material defines are equal
  7873. * @param other - A material define instance to compare to
  7874. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7875. */
  7876. isEqual(other: MaterialDefines): boolean;
  7877. /**
  7878. * Clones this instance's defines to another instance
  7879. * @param other - material defines to clone values to
  7880. */
  7881. cloneTo(other: MaterialDefines): void;
  7882. /**
  7883. * Resets the material define values
  7884. */
  7885. reset(): void;
  7886. /**
  7887. * Converts the material define values to a string
  7888. * @returns - String of material define information
  7889. */
  7890. toString(): string;
  7891. }
  7892. }
  7893. declare module BABYLON {
  7894. /**
  7895. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7896. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7897. * 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;
  7898. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7899. */
  7900. export class ColorCurves {
  7901. private _dirty;
  7902. private _tempColor;
  7903. private _globalCurve;
  7904. private _highlightsCurve;
  7905. private _midtonesCurve;
  7906. private _shadowsCurve;
  7907. private _positiveCurve;
  7908. private _negativeCurve;
  7909. private _globalHue;
  7910. private _globalDensity;
  7911. private _globalSaturation;
  7912. private _globalExposure;
  7913. /**
  7914. * Gets the global Hue value.
  7915. * 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).
  7916. */
  7917. get globalHue(): number;
  7918. /**
  7919. * Sets the global Hue value.
  7920. * 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).
  7921. */
  7922. set globalHue(value: number);
  7923. /**
  7924. * Gets 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. get globalDensity(): number;
  7929. /**
  7930. * Sets the global Density value.
  7931. * 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.
  7932. * Values less than zero provide a filter of opposite hue.
  7933. */
  7934. set globalDensity(value: number);
  7935. /**
  7936. * Gets the global Saturation value.
  7937. * 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.
  7938. */
  7939. get globalSaturation(): number;
  7940. /**
  7941. * Sets the global Saturation value.
  7942. * 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.
  7943. */
  7944. set globalSaturation(value: number);
  7945. /**
  7946. * Gets the global Exposure value.
  7947. * 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.
  7948. */
  7949. get globalExposure(): number;
  7950. /**
  7951. * Sets the global Exposure value.
  7952. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7953. */
  7954. set globalExposure(value: number);
  7955. private _highlightsHue;
  7956. private _highlightsDensity;
  7957. private _highlightsSaturation;
  7958. private _highlightsExposure;
  7959. /**
  7960. * Gets the highlights Hue value.
  7961. * 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).
  7962. */
  7963. get highlightsHue(): number;
  7964. /**
  7965. * Sets the highlights Hue value.
  7966. * 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).
  7967. */
  7968. set highlightsHue(value: number);
  7969. /**
  7970. * Gets 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. get highlightsDensity(): number;
  7975. /**
  7976. * Sets the highlights Density value.
  7977. * 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.
  7978. * Values less than zero provide a filter of opposite hue.
  7979. */
  7980. set highlightsDensity(value: number);
  7981. /**
  7982. * Gets the highlights Saturation value.
  7983. * 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.
  7984. */
  7985. get highlightsSaturation(): number;
  7986. /**
  7987. * Sets the highlights Saturation value.
  7988. * 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.
  7989. */
  7990. set highlightsSaturation(value: number);
  7991. /**
  7992. * Gets the highlights Exposure value.
  7993. * 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.
  7994. */
  7995. get highlightsExposure(): number;
  7996. /**
  7997. * Sets the highlights Exposure value.
  7998. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7999. */
  8000. set highlightsExposure(value: number);
  8001. private _midtonesHue;
  8002. private _midtonesDensity;
  8003. private _midtonesSaturation;
  8004. private _midtonesExposure;
  8005. /**
  8006. * Gets the midtones Hue value.
  8007. * 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).
  8008. */
  8009. get midtonesHue(): number;
  8010. /**
  8011. * Sets the midtones Hue value.
  8012. * 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).
  8013. */
  8014. set midtonesHue(value: number);
  8015. /**
  8016. * Gets 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. get midtonesDensity(): number;
  8021. /**
  8022. * Sets the midtones Density value.
  8023. * 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.
  8024. * Values less than zero provide a filter of opposite hue.
  8025. */
  8026. set midtonesDensity(value: number);
  8027. /**
  8028. * Gets the midtones Saturation value.
  8029. * 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.
  8030. */
  8031. get midtonesSaturation(): number;
  8032. /**
  8033. * Sets the midtones Saturation value.
  8034. * 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.
  8035. */
  8036. set midtonesSaturation(value: number);
  8037. /**
  8038. * Gets the midtones Exposure value.
  8039. * 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.
  8040. */
  8041. get midtonesExposure(): number;
  8042. /**
  8043. * Sets the midtones Exposure value.
  8044. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8045. */
  8046. set midtonesExposure(value: number);
  8047. private _shadowsHue;
  8048. private _shadowsDensity;
  8049. private _shadowsSaturation;
  8050. private _shadowsExposure;
  8051. /**
  8052. * Gets the shadows Hue value.
  8053. * 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).
  8054. */
  8055. get shadowsHue(): number;
  8056. /**
  8057. * Sets the shadows Hue value.
  8058. * 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).
  8059. */
  8060. set shadowsHue(value: number);
  8061. /**
  8062. * Gets 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. get shadowsDensity(): number;
  8067. /**
  8068. * Sets the shadows Density value.
  8069. * 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.
  8070. * Values less than zero provide a filter of opposite hue.
  8071. */
  8072. set shadowsDensity(value: number);
  8073. /**
  8074. * Gets the shadows Saturation value.
  8075. * 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.
  8076. */
  8077. get shadowsSaturation(): number;
  8078. /**
  8079. * Sets the shadows Saturation value.
  8080. * 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.
  8081. */
  8082. set shadowsSaturation(value: number);
  8083. /**
  8084. * Gets the shadows Exposure value.
  8085. * 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.
  8086. */
  8087. get shadowsExposure(): number;
  8088. /**
  8089. * Sets the shadows Exposure value.
  8090. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8091. */
  8092. set shadowsExposure(value: number);
  8093. /**
  8094. * Returns the class name
  8095. * @returns The class name
  8096. */
  8097. getClassName(): string;
  8098. /**
  8099. * Binds the color curves to the shader.
  8100. * @param colorCurves The color curve to bind
  8101. * @param effect The effect to bind to
  8102. * @param positiveUniform The positive uniform shader parameter
  8103. * @param neutralUniform The neutral uniform shader parameter
  8104. * @param negativeUniform The negative uniform shader parameter
  8105. */
  8106. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8107. /**
  8108. * Prepare the list of uniforms associated with the ColorCurves effects.
  8109. * @param uniformsList The list of uniforms used in the effect
  8110. */
  8111. static PrepareUniforms(uniformsList: string[]): void;
  8112. /**
  8113. * Returns color grading data based on a hue, density, saturation and exposure value.
  8114. * @param filterHue The hue of the color filter.
  8115. * @param filterDensity The density of the color filter.
  8116. * @param saturation The saturation.
  8117. * @param exposure The exposure.
  8118. * @param result The result data container.
  8119. */
  8120. private getColorGradingDataToRef;
  8121. /**
  8122. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8123. * @param value The input slider value in range [-100,100].
  8124. * @returns Adjusted value.
  8125. */
  8126. private static applyColorGradingSliderNonlinear;
  8127. /**
  8128. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8129. * @param hue The hue (H) input.
  8130. * @param saturation The saturation (S) input.
  8131. * @param brightness The brightness (B) input.
  8132. * @result An RGBA color represented as Vector4.
  8133. */
  8134. private static fromHSBToRef;
  8135. /**
  8136. * Returns a value clamped between min and max
  8137. * @param value The value to clamp
  8138. * @param min The minimum of value
  8139. * @param max The maximum of value
  8140. * @returns The clamped value.
  8141. */
  8142. private static clamp;
  8143. /**
  8144. * Clones the current color curve instance.
  8145. * @return The cloned curves
  8146. */
  8147. clone(): ColorCurves;
  8148. /**
  8149. * Serializes the current color curve instance to a json representation.
  8150. * @return a JSON representation
  8151. */
  8152. serialize(): any;
  8153. /**
  8154. * Parses the color curve from a json representation.
  8155. * @param source the JSON source to parse
  8156. * @return The parsed curves
  8157. */
  8158. static Parse(source: any): ColorCurves;
  8159. }
  8160. }
  8161. declare module BABYLON {
  8162. /**
  8163. * Interface to follow in your material defines to integrate easily the
  8164. * Image proccessing functions.
  8165. * @hidden
  8166. */
  8167. export interface IImageProcessingConfigurationDefines {
  8168. IMAGEPROCESSING: boolean;
  8169. VIGNETTE: boolean;
  8170. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8171. VIGNETTEBLENDMODEOPAQUE: boolean;
  8172. TONEMAPPING: boolean;
  8173. TONEMAPPING_ACES: boolean;
  8174. CONTRAST: boolean;
  8175. EXPOSURE: boolean;
  8176. COLORCURVES: boolean;
  8177. COLORGRADING: boolean;
  8178. COLORGRADING3D: boolean;
  8179. SAMPLER3DGREENDEPTH: boolean;
  8180. SAMPLER3DBGRMAP: boolean;
  8181. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8182. }
  8183. /**
  8184. * @hidden
  8185. */
  8186. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8187. IMAGEPROCESSING: boolean;
  8188. VIGNETTE: boolean;
  8189. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8190. VIGNETTEBLENDMODEOPAQUE: boolean;
  8191. TONEMAPPING: boolean;
  8192. TONEMAPPING_ACES: boolean;
  8193. CONTRAST: boolean;
  8194. COLORCURVES: boolean;
  8195. COLORGRADING: boolean;
  8196. COLORGRADING3D: boolean;
  8197. SAMPLER3DGREENDEPTH: boolean;
  8198. SAMPLER3DBGRMAP: boolean;
  8199. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8200. EXPOSURE: boolean;
  8201. constructor();
  8202. }
  8203. /**
  8204. * This groups together the common properties used for image processing either in direct forward pass
  8205. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8206. * or not.
  8207. */
  8208. export class ImageProcessingConfiguration {
  8209. /**
  8210. * Default tone mapping applied in BabylonJS.
  8211. */
  8212. static readonly TONEMAPPING_STANDARD: number;
  8213. /**
  8214. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8215. * to other engines rendering to increase portability.
  8216. */
  8217. static readonly TONEMAPPING_ACES: number;
  8218. /**
  8219. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8220. */
  8221. colorCurves: Nullable<ColorCurves>;
  8222. private _colorCurvesEnabled;
  8223. /**
  8224. * Gets wether the color curves effect is enabled.
  8225. */
  8226. get colorCurvesEnabled(): boolean;
  8227. /**
  8228. * Sets wether the color curves effect is enabled.
  8229. */
  8230. set colorCurvesEnabled(value: boolean);
  8231. private _colorGradingTexture;
  8232. /**
  8233. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8234. */
  8235. get colorGradingTexture(): Nullable<BaseTexture>;
  8236. /**
  8237. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8238. */
  8239. set colorGradingTexture(value: Nullable<BaseTexture>);
  8240. private _colorGradingEnabled;
  8241. /**
  8242. * Gets wether the color grading effect is enabled.
  8243. */
  8244. get colorGradingEnabled(): boolean;
  8245. /**
  8246. * Sets wether the color grading effect is enabled.
  8247. */
  8248. set colorGradingEnabled(value: boolean);
  8249. private _colorGradingWithGreenDepth;
  8250. /**
  8251. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8252. */
  8253. get colorGradingWithGreenDepth(): boolean;
  8254. /**
  8255. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8256. */
  8257. set colorGradingWithGreenDepth(value: boolean);
  8258. private _colorGradingBGR;
  8259. /**
  8260. * Gets wether the color grading texture contains BGR values.
  8261. */
  8262. get colorGradingBGR(): boolean;
  8263. /**
  8264. * Sets wether the color grading texture contains BGR values.
  8265. */
  8266. set colorGradingBGR(value: boolean);
  8267. /** @hidden */
  8268. _exposure: number;
  8269. /**
  8270. * Gets the Exposure used in the effect.
  8271. */
  8272. get exposure(): number;
  8273. /**
  8274. * Sets the Exposure used in the effect.
  8275. */
  8276. set exposure(value: number);
  8277. private _toneMappingEnabled;
  8278. /**
  8279. * Gets wether the tone mapping effect is enabled.
  8280. */
  8281. get toneMappingEnabled(): boolean;
  8282. /**
  8283. * Sets wether the tone mapping effect is enabled.
  8284. */
  8285. set toneMappingEnabled(value: boolean);
  8286. private _toneMappingType;
  8287. /**
  8288. * Gets the type of tone mapping effect.
  8289. */
  8290. get toneMappingType(): number;
  8291. /**
  8292. * Sets the type of tone mapping effect used in BabylonJS.
  8293. */
  8294. set toneMappingType(value: number);
  8295. protected _contrast: number;
  8296. /**
  8297. * Gets the contrast used in the effect.
  8298. */
  8299. get contrast(): number;
  8300. /**
  8301. * Sets the contrast used in the effect.
  8302. */
  8303. set contrast(value: number);
  8304. /**
  8305. * Vignette stretch size.
  8306. */
  8307. vignetteStretch: number;
  8308. /**
  8309. * Vignette centre X Offset.
  8310. */
  8311. vignetteCentreX: number;
  8312. /**
  8313. * Vignette centre Y Offset.
  8314. */
  8315. vignetteCentreY: number;
  8316. /**
  8317. * Vignette weight or intensity of the vignette effect.
  8318. */
  8319. vignetteWeight: number;
  8320. /**
  8321. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8322. * if vignetteEnabled is set to true.
  8323. */
  8324. vignetteColor: Color4;
  8325. /**
  8326. * Camera field of view used by the Vignette effect.
  8327. */
  8328. vignetteCameraFov: number;
  8329. private _vignetteBlendMode;
  8330. /**
  8331. * Gets the vignette blend mode allowing different kind of effect.
  8332. */
  8333. get vignetteBlendMode(): number;
  8334. /**
  8335. * Sets the vignette blend mode allowing different kind of effect.
  8336. */
  8337. set vignetteBlendMode(value: number);
  8338. private _vignetteEnabled;
  8339. /**
  8340. * Gets wether the vignette effect is enabled.
  8341. */
  8342. get vignetteEnabled(): boolean;
  8343. /**
  8344. * Sets wether the vignette effect is enabled.
  8345. */
  8346. set vignetteEnabled(value: boolean);
  8347. private _applyByPostProcess;
  8348. /**
  8349. * Gets wether the image processing is applied through a post process or not.
  8350. */
  8351. get applyByPostProcess(): boolean;
  8352. /**
  8353. * Sets wether the image processing is applied through a post process or not.
  8354. */
  8355. set applyByPostProcess(value: boolean);
  8356. private _isEnabled;
  8357. /**
  8358. * Gets wether the image processing is enabled or not.
  8359. */
  8360. get isEnabled(): boolean;
  8361. /**
  8362. * Sets wether the image processing is enabled or not.
  8363. */
  8364. set isEnabled(value: boolean);
  8365. /**
  8366. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8367. */
  8368. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8369. /**
  8370. * Method called each time the image processing information changes requires to recompile the effect.
  8371. */
  8372. protected _updateParameters(): void;
  8373. /**
  8374. * Gets the current class name.
  8375. * @return "ImageProcessingConfiguration"
  8376. */
  8377. getClassName(): string;
  8378. /**
  8379. * Prepare the list of uniforms associated with the Image Processing effects.
  8380. * @param uniforms The list of uniforms used in the effect
  8381. * @param defines the list of defines currently in use
  8382. */
  8383. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8384. /**
  8385. * Prepare the list of samplers associated with the Image Processing effects.
  8386. * @param samplersList The list of uniforms used in the effect
  8387. * @param defines the list of defines currently in use
  8388. */
  8389. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8390. /**
  8391. * Prepare the list of defines associated to the shader.
  8392. * @param defines the list of defines to complete
  8393. * @param forPostProcess Define if we are currently in post process mode or not
  8394. */
  8395. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8396. /**
  8397. * Returns true if all the image processing information are ready.
  8398. * @returns True if ready, otherwise, false
  8399. */
  8400. isReady(): boolean;
  8401. /**
  8402. * Binds the image processing to the shader.
  8403. * @param effect The effect to bind to
  8404. * @param overrideAspectRatio Override the aspect ratio of the effect
  8405. */
  8406. bind(effect: Effect, overrideAspectRatio?: number): void;
  8407. /**
  8408. * Clones the current image processing instance.
  8409. * @return The cloned image processing
  8410. */
  8411. clone(): ImageProcessingConfiguration;
  8412. /**
  8413. * Serializes the current image processing instance to a json representation.
  8414. * @return a JSON representation
  8415. */
  8416. serialize(): any;
  8417. /**
  8418. * Parses the image processing from a json representation.
  8419. * @param source the JSON source to parse
  8420. * @return The parsed image processing
  8421. */
  8422. static Parse(source: any): ImageProcessingConfiguration;
  8423. private static _VIGNETTEMODE_MULTIPLY;
  8424. private static _VIGNETTEMODE_OPAQUE;
  8425. /**
  8426. * Used to apply the vignette as a mix with the pixel color.
  8427. */
  8428. static get VIGNETTEMODE_MULTIPLY(): number;
  8429. /**
  8430. * Used to apply the vignette as a replacement of the pixel color.
  8431. */
  8432. static get VIGNETTEMODE_OPAQUE(): number;
  8433. }
  8434. }
  8435. declare module BABYLON {
  8436. /** @hidden */
  8437. export var postprocessVertexShader: {
  8438. name: string;
  8439. shader: string;
  8440. };
  8441. }
  8442. declare module BABYLON {
  8443. interface ThinEngine {
  8444. /**
  8445. * Creates a new render target texture
  8446. * @param size defines the size of the texture
  8447. * @param options defines the options used to create the texture
  8448. * @returns a new render target texture stored in an InternalTexture
  8449. */
  8450. createRenderTargetTexture(size: number | {
  8451. width: number;
  8452. height: number;
  8453. layers?: number;
  8454. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8455. /**
  8456. * Creates a depth stencil texture.
  8457. * This is only available in WebGL 2 or with the depth texture extension available.
  8458. * @param size The size of face edge in the texture.
  8459. * @param options The options defining the texture.
  8460. * @returns The texture
  8461. */
  8462. createDepthStencilTexture(size: number | {
  8463. width: number;
  8464. height: number;
  8465. layers?: number;
  8466. }, options: DepthTextureCreationOptions): InternalTexture;
  8467. /** @hidden */
  8468. _createDepthStencilTexture(size: number | {
  8469. width: number;
  8470. height: number;
  8471. layers?: number;
  8472. }, options: DepthTextureCreationOptions): InternalTexture;
  8473. }
  8474. }
  8475. declare module BABYLON {
  8476. /** Defines supported spaces */
  8477. export enum Space {
  8478. /** Local (object) space */
  8479. LOCAL = 0,
  8480. /** World space */
  8481. WORLD = 1,
  8482. /** Bone space */
  8483. BONE = 2
  8484. }
  8485. /** Defines the 3 main axes */
  8486. export class Axis {
  8487. /** X axis */
  8488. static X: Vector3;
  8489. /** Y axis */
  8490. static Y: Vector3;
  8491. /** Z axis */
  8492. static Z: Vector3;
  8493. }
  8494. }
  8495. declare module BABYLON {
  8496. /**
  8497. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8498. * This is the base of the follow, arc rotate cameras and Free camera
  8499. * @see http://doc.babylonjs.com/features/cameras
  8500. */
  8501. export class TargetCamera extends Camera {
  8502. private static _RigCamTransformMatrix;
  8503. private static _TargetTransformMatrix;
  8504. private static _TargetFocalPoint;
  8505. /**
  8506. * Define the current direction the camera is moving to
  8507. */
  8508. cameraDirection: Vector3;
  8509. /**
  8510. * Define the current rotation the camera is rotating to
  8511. */
  8512. cameraRotation: Vector2;
  8513. /**
  8514. * When set, the up vector of the camera will be updated by the rotation of the camera
  8515. */
  8516. updateUpVectorFromRotation: boolean;
  8517. private _tmpQuaternion;
  8518. /**
  8519. * Define the current rotation of the camera
  8520. */
  8521. rotation: Vector3;
  8522. /**
  8523. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8524. */
  8525. rotationQuaternion: Quaternion;
  8526. /**
  8527. * Define the current speed of the camera
  8528. */
  8529. speed: number;
  8530. /**
  8531. * Add constraint to the camera to prevent it to move freely in all directions and
  8532. * around all axis.
  8533. */
  8534. noRotationConstraint: boolean;
  8535. /**
  8536. * Define the current target of the camera as an object or a position.
  8537. */
  8538. lockedTarget: any;
  8539. /** @hidden */
  8540. _currentTarget: Vector3;
  8541. /** @hidden */
  8542. _initialFocalDistance: number;
  8543. /** @hidden */
  8544. _viewMatrix: Matrix;
  8545. /** @hidden */
  8546. _camMatrix: Matrix;
  8547. /** @hidden */
  8548. _cameraTransformMatrix: Matrix;
  8549. /** @hidden */
  8550. _cameraRotationMatrix: Matrix;
  8551. /** @hidden */
  8552. _referencePoint: Vector3;
  8553. /** @hidden */
  8554. _transformedReferencePoint: Vector3;
  8555. protected _globalCurrentTarget: Vector3;
  8556. protected _globalCurrentUpVector: Vector3;
  8557. /** @hidden */
  8558. _reset: () => void;
  8559. private _defaultUp;
  8560. /**
  8561. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8562. * This is the base of the follow, arc rotate cameras and Free camera
  8563. * @see http://doc.babylonjs.com/features/cameras
  8564. * @param name Defines the name of the camera in the scene
  8565. * @param position Defines the start position of the camera in the scene
  8566. * @param scene Defines the scene the camera belongs to
  8567. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8568. */
  8569. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8570. /**
  8571. * Gets the position in front of the camera at a given distance.
  8572. * @param distance The distance from the camera we want the position to be
  8573. * @returns the position
  8574. */
  8575. getFrontPosition(distance: number): Vector3;
  8576. /** @hidden */
  8577. _getLockedTargetPosition(): Nullable<Vector3>;
  8578. private _storedPosition;
  8579. private _storedRotation;
  8580. private _storedRotationQuaternion;
  8581. /**
  8582. * Store current camera state of the camera (fov, position, rotation, etc..)
  8583. * @returns the camera
  8584. */
  8585. storeState(): Camera;
  8586. /**
  8587. * Restored camera state. You must call storeState() first
  8588. * @returns whether it was successful or not
  8589. * @hidden
  8590. */
  8591. _restoreStateValues(): boolean;
  8592. /** @hidden */
  8593. _initCache(): void;
  8594. /** @hidden */
  8595. _updateCache(ignoreParentClass?: boolean): void;
  8596. /** @hidden */
  8597. _isSynchronizedViewMatrix(): boolean;
  8598. /** @hidden */
  8599. _computeLocalCameraSpeed(): number;
  8600. /**
  8601. * Defines the target the camera should look at.
  8602. * @param target Defines the new target as a Vector or a mesh
  8603. */
  8604. setTarget(target: Vector3): void;
  8605. /**
  8606. * Return the current target position of the camera. This value is expressed in local space.
  8607. * @returns the target position
  8608. */
  8609. getTarget(): Vector3;
  8610. /** @hidden */
  8611. _decideIfNeedsToMove(): boolean;
  8612. /** @hidden */
  8613. _updatePosition(): void;
  8614. /** @hidden */
  8615. _checkInputs(): void;
  8616. protected _updateCameraRotationMatrix(): void;
  8617. /**
  8618. * 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)
  8619. * @returns the current camera
  8620. */
  8621. private _rotateUpVectorWithCameraRotationMatrix;
  8622. private _cachedRotationZ;
  8623. private _cachedQuaternionRotationZ;
  8624. /** @hidden */
  8625. _getViewMatrix(): Matrix;
  8626. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8627. /**
  8628. * @hidden
  8629. */
  8630. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8631. /**
  8632. * @hidden
  8633. */
  8634. _updateRigCameras(): void;
  8635. private _getRigCamPositionAndTarget;
  8636. /**
  8637. * Gets the current object class name.
  8638. * @return the class name
  8639. */
  8640. getClassName(): string;
  8641. }
  8642. }
  8643. declare module BABYLON {
  8644. /**
  8645. * Gather the list of keyboard event types as constants.
  8646. */
  8647. export class KeyboardEventTypes {
  8648. /**
  8649. * The keydown event is fired when a key becomes active (pressed).
  8650. */
  8651. static readonly KEYDOWN: number;
  8652. /**
  8653. * The keyup event is fired when a key has been released.
  8654. */
  8655. static readonly KEYUP: number;
  8656. }
  8657. /**
  8658. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8659. */
  8660. export class KeyboardInfo {
  8661. /**
  8662. * Defines the type of event (KeyboardEventTypes)
  8663. */
  8664. type: number;
  8665. /**
  8666. * Defines the related dom event
  8667. */
  8668. event: KeyboardEvent;
  8669. /**
  8670. * Instantiates a new keyboard info.
  8671. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8672. * @param type Defines the type of event (KeyboardEventTypes)
  8673. * @param event Defines the related dom event
  8674. */
  8675. constructor(
  8676. /**
  8677. * Defines the type of event (KeyboardEventTypes)
  8678. */
  8679. type: number,
  8680. /**
  8681. * Defines the related dom event
  8682. */
  8683. event: KeyboardEvent);
  8684. }
  8685. /**
  8686. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8687. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8688. */
  8689. export class KeyboardInfoPre extends KeyboardInfo {
  8690. /**
  8691. * Defines the type of event (KeyboardEventTypes)
  8692. */
  8693. type: number;
  8694. /**
  8695. * Defines the related dom event
  8696. */
  8697. event: KeyboardEvent;
  8698. /**
  8699. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8700. */
  8701. skipOnPointerObservable: boolean;
  8702. /**
  8703. * Instantiates a new keyboard pre info.
  8704. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8705. * @param type Defines the type of event (KeyboardEventTypes)
  8706. * @param event Defines the related dom event
  8707. */
  8708. constructor(
  8709. /**
  8710. * Defines the type of event (KeyboardEventTypes)
  8711. */
  8712. type: number,
  8713. /**
  8714. * Defines the related dom event
  8715. */
  8716. event: KeyboardEvent);
  8717. }
  8718. }
  8719. declare module BABYLON {
  8720. /**
  8721. * Manage the keyboard inputs to control the movement of a free camera.
  8722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8723. */
  8724. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8725. /**
  8726. * Defines the camera the input is attached to.
  8727. */
  8728. camera: FreeCamera;
  8729. /**
  8730. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8731. */
  8732. keysUp: number[];
  8733. /**
  8734. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8735. */
  8736. keysDown: number[];
  8737. /**
  8738. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8739. */
  8740. keysLeft: number[];
  8741. /**
  8742. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8743. */
  8744. keysRight: number[];
  8745. private _keys;
  8746. private _onCanvasBlurObserver;
  8747. private _onKeyboardObserver;
  8748. private _engine;
  8749. private _scene;
  8750. /**
  8751. * Attach the input controls to a specific dom element to get the input from.
  8752. * @param element Defines the element the controls should be listened from
  8753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8754. */
  8755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8756. /**
  8757. * Detach the current controls from the specified dom element.
  8758. * @param element Defines the element to stop listening the inputs from
  8759. */
  8760. detachControl(element: Nullable<HTMLElement>): void;
  8761. /**
  8762. * Update the current camera state depending on the inputs that have been used this frame.
  8763. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8764. */
  8765. checkInputs(): void;
  8766. /**
  8767. * Gets the class name of the current intput.
  8768. * @returns the class name
  8769. */
  8770. getClassName(): string;
  8771. /** @hidden */
  8772. _onLostFocus(): void;
  8773. /**
  8774. * Get the friendly name associated with the input class.
  8775. * @returns the input friendly name
  8776. */
  8777. getSimpleName(): string;
  8778. }
  8779. }
  8780. declare module BABYLON {
  8781. /**
  8782. * Interface describing all the common properties and methods a shadow light needs to implement.
  8783. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8784. * as well as binding the different shadow properties to the effects.
  8785. */
  8786. export interface IShadowLight extends Light {
  8787. /**
  8788. * The light id in the scene (used in scene.findLighById for instance)
  8789. */
  8790. id: string;
  8791. /**
  8792. * The position the shdow will be casted from.
  8793. */
  8794. position: Vector3;
  8795. /**
  8796. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8797. */
  8798. direction: Vector3;
  8799. /**
  8800. * The transformed position. Position of the light in world space taking parenting in account.
  8801. */
  8802. transformedPosition: Vector3;
  8803. /**
  8804. * The transformed direction. Direction of the light in world space taking parenting in account.
  8805. */
  8806. transformedDirection: Vector3;
  8807. /**
  8808. * The friendly name of the light in the scene.
  8809. */
  8810. name: string;
  8811. /**
  8812. * Defines the shadow projection clipping minimum z value.
  8813. */
  8814. shadowMinZ: number;
  8815. /**
  8816. * Defines the shadow projection clipping maximum z value.
  8817. */
  8818. shadowMaxZ: number;
  8819. /**
  8820. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8821. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8822. */
  8823. computeTransformedInformation(): boolean;
  8824. /**
  8825. * Gets the scene the light belongs to.
  8826. * @returns The scene
  8827. */
  8828. getScene(): Scene;
  8829. /**
  8830. * Callback defining a custom Projection Matrix Builder.
  8831. * This can be used to override the default projection matrix computation.
  8832. */
  8833. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8834. /**
  8835. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8836. * @param matrix The materix to updated with the projection information
  8837. * @param viewMatrix The transform matrix of the light
  8838. * @param renderList The list of mesh to render in the map
  8839. * @returns The current light
  8840. */
  8841. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8842. /**
  8843. * Gets the current depth scale used in ESM.
  8844. * @returns The scale
  8845. */
  8846. getDepthScale(): number;
  8847. /**
  8848. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8849. * @returns true if a cube texture needs to be use
  8850. */
  8851. needCube(): boolean;
  8852. /**
  8853. * Detects if the projection matrix requires to be recomputed this frame.
  8854. * @returns true if it requires to be recomputed otherwise, false.
  8855. */
  8856. needProjectionMatrixCompute(): boolean;
  8857. /**
  8858. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8859. */
  8860. forceProjectionMatrixCompute(): void;
  8861. /**
  8862. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8863. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8864. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8865. */
  8866. getShadowDirection(faceIndex?: number): Vector3;
  8867. /**
  8868. * Gets the minZ used for shadow according to both the scene and the light.
  8869. * @param activeCamera The camera we are returning the min for
  8870. * @returns the depth min z
  8871. */
  8872. getDepthMinZ(activeCamera: Camera): number;
  8873. /**
  8874. * Gets the maxZ used for shadow according to both the scene and the light.
  8875. * @param activeCamera The camera we are returning the max for
  8876. * @returns the depth max z
  8877. */
  8878. getDepthMaxZ(activeCamera: Camera): number;
  8879. }
  8880. /**
  8881. * Base implementation IShadowLight
  8882. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8883. */
  8884. export abstract class ShadowLight extends Light implements IShadowLight {
  8885. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8886. protected _position: Vector3;
  8887. protected _setPosition(value: Vector3): void;
  8888. /**
  8889. * Sets the position the shadow will be casted from. Also use as the light position for both
  8890. * point and spot lights.
  8891. */
  8892. get position(): Vector3;
  8893. /**
  8894. * Sets the position the shadow will be casted from. Also use as the light position for both
  8895. * point and spot lights.
  8896. */
  8897. set position(value: Vector3);
  8898. protected _direction: Vector3;
  8899. protected _setDirection(value: Vector3): void;
  8900. /**
  8901. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8902. * Also use as the light direction on spot and directional lights.
  8903. */
  8904. get direction(): Vector3;
  8905. /**
  8906. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8907. * Also use as the light direction on spot and directional lights.
  8908. */
  8909. set direction(value: Vector3);
  8910. protected _shadowMinZ: number;
  8911. /**
  8912. * Gets the shadow projection clipping minimum z value.
  8913. */
  8914. get shadowMinZ(): number;
  8915. /**
  8916. * Sets the shadow projection clipping minimum z value.
  8917. */
  8918. set shadowMinZ(value: number);
  8919. protected _shadowMaxZ: number;
  8920. /**
  8921. * Sets the shadow projection clipping maximum z value.
  8922. */
  8923. get shadowMaxZ(): number;
  8924. /**
  8925. * Gets the shadow projection clipping maximum z value.
  8926. */
  8927. set shadowMaxZ(value: number);
  8928. /**
  8929. * Callback defining a custom Projection Matrix Builder.
  8930. * This can be used to override the default projection matrix computation.
  8931. */
  8932. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8933. /**
  8934. * The transformed position. Position of the light in world space taking parenting in account.
  8935. */
  8936. transformedPosition: Vector3;
  8937. /**
  8938. * The transformed direction. Direction of the light in world space taking parenting in account.
  8939. */
  8940. transformedDirection: Vector3;
  8941. private _needProjectionMatrixCompute;
  8942. /**
  8943. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8944. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8945. */
  8946. computeTransformedInformation(): boolean;
  8947. /**
  8948. * Return the depth scale used for the shadow map.
  8949. * @returns the depth scale.
  8950. */
  8951. getDepthScale(): number;
  8952. /**
  8953. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8954. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8955. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8956. */
  8957. getShadowDirection(faceIndex?: number): Vector3;
  8958. /**
  8959. * Returns the ShadowLight absolute position in the World.
  8960. * @returns the position vector in world space
  8961. */
  8962. getAbsolutePosition(): Vector3;
  8963. /**
  8964. * Sets the ShadowLight direction toward the passed target.
  8965. * @param target The point to target in local space
  8966. * @returns the updated ShadowLight direction
  8967. */
  8968. setDirectionToTarget(target: Vector3): Vector3;
  8969. /**
  8970. * Returns the light rotation in euler definition.
  8971. * @returns the x y z rotation in local space.
  8972. */
  8973. getRotation(): Vector3;
  8974. /**
  8975. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8976. * @returns true if a cube texture needs to be use
  8977. */
  8978. needCube(): boolean;
  8979. /**
  8980. * Detects if the projection matrix requires to be recomputed this frame.
  8981. * @returns true if it requires to be recomputed otherwise, false.
  8982. */
  8983. needProjectionMatrixCompute(): boolean;
  8984. /**
  8985. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8986. */
  8987. forceProjectionMatrixCompute(): void;
  8988. /** @hidden */
  8989. _initCache(): void;
  8990. /** @hidden */
  8991. _isSynchronized(): boolean;
  8992. /**
  8993. * Computes the world matrix of the node
  8994. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8995. * @returns the world matrix
  8996. */
  8997. computeWorldMatrix(force?: boolean): Matrix;
  8998. /**
  8999. * Gets the minZ used for shadow according to both the scene and the light.
  9000. * @param activeCamera The camera we are returning the min for
  9001. * @returns the depth min z
  9002. */
  9003. getDepthMinZ(activeCamera: Camera): number;
  9004. /**
  9005. * Gets the maxZ used for shadow according to both the scene and the light.
  9006. * @param activeCamera The camera we are returning the max for
  9007. * @returns the depth max z
  9008. */
  9009. getDepthMaxZ(activeCamera: Camera): number;
  9010. /**
  9011. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9012. * @param matrix The materix to updated with the projection information
  9013. * @param viewMatrix The transform matrix of the light
  9014. * @param renderList The list of mesh to render in the map
  9015. * @returns The current light
  9016. */
  9017. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9018. }
  9019. }
  9020. declare module BABYLON {
  9021. /**
  9022. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9023. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9024. */
  9025. export class EffectFallbacks implements IEffectFallbacks {
  9026. private _defines;
  9027. private _currentRank;
  9028. private _maxRank;
  9029. private _mesh;
  9030. /**
  9031. * Removes the fallback from the bound mesh.
  9032. */
  9033. unBindMesh(): void;
  9034. /**
  9035. * Adds a fallback on the specified property.
  9036. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9037. * @param define The name of the define in the shader
  9038. */
  9039. addFallback(rank: number, define: string): void;
  9040. /**
  9041. * Sets the mesh to use CPU skinning when needing to fallback.
  9042. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9043. * @param mesh The mesh to use the fallbacks.
  9044. */
  9045. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9046. /**
  9047. * Checks to see if more fallbacks are still availible.
  9048. */
  9049. get hasMoreFallbacks(): boolean;
  9050. /**
  9051. * Removes the defines that should be removed when falling back.
  9052. * @param currentDefines defines the current define statements for the shader.
  9053. * @param effect defines the current effect we try to compile
  9054. * @returns The resulting defines with defines of the current rank removed.
  9055. */
  9056. reduce(currentDefines: string, effect: Effect): string;
  9057. }
  9058. }
  9059. declare module BABYLON {
  9060. /**
  9061. * "Static Class" containing the most commonly used helper while dealing with material for
  9062. * rendering purpose.
  9063. *
  9064. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9065. *
  9066. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9067. */
  9068. export class MaterialHelper {
  9069. /**
  9070. * Bind the current view position to an effect.
  9071. * @param effect The effect to be bound
  9072. * @param scene The scene the eyes position is used from
  9073. */
  9074. static BindEyePosition(effect: Effect, scene: Scene): void;
  9075. /**
  9076. * Helps preparing the defines values about the UVs in used in the effect.
  9077. * UVs are shared as much as we can accross channels in the shaders.
  9078. * @param texture The texture we are preparing the UVs for
  9079. * @param defines The defines to update
  9080. * @param key The channel key "diffuse", "specular"... used in the shader
  9081. */
  9082. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9083. /**
  9084. * Binds a texture matrix value to its corrsponding uniform
  9085. * @param texture The texture to bind the matrix for
  9086. * @param uniformBuffer The uniform buffer receivin the data
  9087. * @param key The channel key "diffuse", "specular"... used in the shader
  9088. */
  9089. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9090. /**
  9091. * Gets the current status of the fog (should it be enabled?)
  9092. * @param mesh defines the mesh to evaluate for fog support
  9093. * @param scene defines the hosting scene
  9094. * @returns true if fog must be enabled
  9095. */
  9096. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9097. /**
  9098. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9099. * @param mesh defines the current mesh
  9100. * @param scene defines the current scene
  9101. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9102. * @param pointsCloud defines if point cloud rendering has to be turned on
  9103. * @param fogEnabled defines if fog has to be turned on
  9104. * @param alphaTest defines if alpha testing has to be turned on
  9105. * @param defines defines the current list of defines
  9106. */
  9107. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9108. /**
  9109. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9110. * @param scene defines the current scene
  9111. * @param engine defines the current engine
  9112. * @param defines specifies the list of active defines
  9113. * @param useInstances defines if instances have to be turned on
  9114. * @param useClipPlane defines if clip plane have to be turned on
  9115. */
  9116. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9117. /**
  9118. * Prepares the defines for bones
  9119. * @param mesh The mesh containing the geometry data we will draw
  9120. * @param defines The defines to update
  9121. */
  9122. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9123. /**
  9124. * Prepares the defines for morph targets
  9125. * @param mesh The mesh containing the geometry data we will draw
  9126. * @param defines The defines to update
  9127. */
  9128. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9129. /**
  9130. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9131. * @param mesh The mesh containing the geometry data we will draw
  9132. * @param defines The defines to update
  9133. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9134. * @param useBones Precise whether bones should be used or not (override mesh info)
  9135. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9136. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9137. * @returns false if defines are considered not dirty and have not been checked
  9138. */
  9139. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9140. /**
  9141. * Prepares the defines related to multiview
  9142. * @param scene The scene we are intending to draw
  9143. * @param defines The defines to update
  9144. */
  9145. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9146. /**
  9147. * Prepares the defines related to the light information passed in parameter
  9148. * @param scene The scene we are intending to draw
  9149. * @param mesh The mesh the effect is compiling for
  9150. * @param light The light the effect is compiling for
  9151. * @param lightIndex The index of the light
  9152. * @param defines The defines to update
  9153. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9154. * @param state Defines the current state regarding what is needed (normals, etc...)
  9155. */
  9156. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9157. needNormals: boolean;
  9158. needRebuild: boolean;
  9159. shadowEnabled: boolean;
  9160. specularEnabled: boolean;
  9161. lightmapMode: boolean;
  9162. }): void;
  9163. /**
  9164. * Prepares the defines related to the light information passed in parameter
  9165. * @param scene The scene we are intending to draw
  9166. * @param mesh The mesh the effect is compiling for
  9167. * @param defines The defines to update
  9168. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9169. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9170. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9171. * @returns true if normals will be required for the rest of the effect
  9172. */
  9173. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9174. /**
  9175. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9176. * @param lightIndex defines the light index
  9177. * @param uniformsList The uniform list
  9178. * @param samplersList The sampler list
  9179. * @param projectedLightTexture defines if projected texture must be used
  9180. * @param uniformBuffersList defines an optional list of uniform buffers
  9181. */
  9182. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9183. /**
  9184. * Prepares the uniforms and samplers list to be used in the effect
  9185. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9186. * @param samplersList The sampler list
  9187. * @param defines The defines helping in the list generation
  9188. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9189. */
  9190. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9191. /**
  9192. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9193. * @param defines The defines to update while falling back
  9194. * @param fallbacks The authorized effect fallbacks
  9195. * @param maxSimultaneousLights The maximum number of lights allowed
  9196. * @param rank the current rank of the Effect
  9197. * @returns The newly affected rank
  9198. */
  9199. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9200. private static _TmpMorphInfluencers;
  9201. /**
  9202. * Prepares the list of attributes required for morph targets according to the effect defines.
  9203. * @param attribs The current list of supported attribs
  9204. * @param mesh The mesh to prepare the morph targets attributes for
  9205. * @param influencers The number of influencers
  9206. */
  9207. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9208. /**
  9209. * Prepares the list of attributes required for morph targets according to the effect defines.
  9210. * @param attribs The current list of supported attribs
  9211. * @param mesh The mesh to prepare the morph targets attributes for
  9212. * @param defines The current Defines of the effect
  9213. */
  9214. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9215. /**
  9216. * Prepares the list of attributes required for bones according to the effect defines.
  9217. * @param attribs The current list of supported attribs
  9218. * @param mesh The mesh to prepare the bones attributes for
  9219. * @param defines The current Defines of the effect
  9220. * @param fallbacks The current efffect fallback strategy
  9221. */
  9222. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9223. /**
  9224. * Check and prepare the list of attributes required for instances according to the effect defines.
  9225. * @param attribs The current list of supported attribs
  9226. * @param defines The current MaterialDefines of the effect
  9227. */
  9228. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9229. /**
  9230. * Add the list of attributes required for instances to the attribs array.
  9231. * @param attribs The current list of supported attribs
  9232. */
  9233. static PushAttributesForInstances(attribs: string[]): void;
  9234. /**
  9235. * Binds the light information to the effect.
  9236. * @param light The light containing the generator
  9237. * @param effect The effect we are binding the data to
  9238. * @param lightIndex The light index in the effect used to render
  9239. */
  9240. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9241. /**
  9242. * Binds the lights information from the scene to the effect for the given mesh.
  9243. * @param light Light to bind
  9244. * @param lightIndex Light index
  9245. * @param scene The scene where the light belongs to
  9246. * @param effect The effect we are binding the data to
  9247. * @param useSpecular Defines if specular is supported
  9248. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9249. */
  9250. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9251. /**
  9252. * Binds the lights information from the scene to the effect for the given mesh.
  9253. * @param scene The scene the lights belongs to
  9254. * @param mesh The mesh we are binding the information to render
  9255. * @param effect The effect we are binding the data to
  9256. * @param defines The generated defines for the effect
  9257. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9258. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9259. */
  9260. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9261. private static _tempFogColor;
  9262. /**
  9263. * Binds the fog information from the scene to the effect for the given mesh.
  9264. * @param scene The scene the lights belongs to
  9265. * @param mesh The mesh we are binding the information to render
  9266. * @param effect The effect we are binding the data to
  9267. * @param linearSpace Defines if the fog effect is applied in linear space
  9268. */
  9269. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9270. /**
  9271. * Binds the bones information from the mesh to the effect.
  9272. * @param mesh The mesh we are binding the information to render
  9273. * @param effect The effect we are binding the data to
  9274. */
  9275. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9276. /**
  9277. * Binds the morph targets information from the mesh to the effect.
  9278. * @param abstractMesh The mesh we are binding the information to render
  9279. * @param effect The effect we are binding the data to
  9280. */
  9281. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9282. /**
  9283. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9284. * @param defines The generated defines used in the effect
  9285. * @param effect The effect we are binding the data to
  9286. * @param scene The scene we are willing to render with logarithmic scale for
  9287. */
  9288. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9289. /**
  9290. * Binds the clip plane information from the scene to the effect.
  9291. * @param scene The scene the clip plane information are extracted from
  9292. * @param effect The effect we are binding the data to
  9293. */
  9294. static BindClipPlane(effect: Effect, scene: Scene): void;
  9295. }
  9296. }
  9297. declare module BABYLON {
  9298. /** @hidden */
  9299. export var packingFunctions: {
  9300. name: string;
  9301. shader: string;
  9302. };
  9303. }
  9304. declare module BABYLON {
  9305. /** @hidden */
  9306. export var clipPlaneFragmentDeclaration: {
  9307. name: string;
  9308. shader: string;
  9309. };
  9310. }
  9311. declare module BABYLON {
  9312. /** @hidden */
  9313. export var clipPlaneFragment: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module BABYLON {
  9319. /** @hidden */
  9320. export var shadowMapPixelShader: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module BABYLON {
  9326. /** @hidden */
  9327. export var bonesDeclaration: {
  9328. name: string;
  9329. shader: string;
  9330. };
  9331. }
  9332. declare module BABYLON {
  9333. /** @hidden */
  9334. export var morphTargetsVertexGlobalDeclaration: {
  9335. name: string;
  9336. shader: string;
  9337. };
  9338. }
  9339. declare module BABYLON {
  9340. /** @hidden */
  9341. export var morphTargetsVertexDeclaration: {
  9342. name: string;
  9343. shader: string;
  9344. };
  9345. }
  9346. declare module BABYLON {
  9347. /** @hidden */
  9348. export var instancesDeclaration: {
  9349. name: string;
  9350. shader: string;
  9351. };
  9352. }
  9353. declare module BABYLON {
  9354. /** @hidden */
  9355. export var helperFunctions: {
  9356. name: string;
  9357. shader: string;
  9358. };
  9359. }
  9360. declare module BABYLON {
  9361. /** @hidden */
  9362. export var clipPlaneVertexDeclaration: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module BABYLON {
  9368. /** @hidden */
  9369. export var morphTargetsVertex: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module BABYLON {
  9375. /** @hidden */
  9376. export var instancesVertex: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module BABYLON {
  9382. /** @hidden */
  9383. export var bonesVertex: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module BABYLON {
  9389. /** @hidden */
  9390. export var clipPlaneVertex: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module BABYLON {
  9396. /** @hidden */
  9397. export var shadowMapVertexShader: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module BABYLON {
  9403. /** @hidden */
  9404. export var depthBoxBlurPixelShader: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module BABYLON {
  9410. /**
  9411. * Class representing a ray with position and direction
  9412. */
  9413. export class Ray {
  9414. /** origin point */
  9415. origin: Vector3;
  9416. /** direction */
  9417. direction: Vector3;
  9418. /** length of the ray */
  9419. length: number;
  9420. private static readonly TmpVector3;
  9421. private _tmpRay;
  9422. /**
  9423. * Creates a new ray
  9424. * @param origin origin point
  9425. * @param direction direction
  9426. * @param length length of the ray
  9427. */
  9428. constructor(
  9429. /** origin point */
  9430. origin: Vector3,
  9431. /** direction */
  9432. direction: Vector3,
  9433. /** length of the ray */
  9434. length?: number);
  9435. /**
  9436. * Checks if the ray intersects a box
  9437. * @param minimum bound of the box
  9438. * @param maximum bound of the box
  9439. * @param intersectionTreshold extra extend to be added to the box in all direction
  9440. * @returns if the box was hit
  9441. */
  9442. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9443. /**
  9444. * Checks if the ray intersects a box
  9445. * @param box the bounding box to check
  9446. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9447. * @returns if the box was hit
  9448. */
  9449. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9450. /**
  9451. * If the ray hits a sphere
  9452. * @param sphere the bounding sphere to check
  9453. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9454. * @returns true if it hits the sphere
  9455. */
  9456. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9457. /**
  9458. * If the ray hits a triange
  9459. * @param vertex0 triangle vertex
  9460. * @param vertex1 triangle vertex
  9461. * @param vertex2 triangle vertex
  9462. * @returns intersection information if hit
  9463. */
  9464. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9465. /**
  9466. * Checks if ray intersects a plane
  9467. * @param plane the plane to check
  9468. * @returns the distance away it was hit
  9469. */
  9470. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9471. /**
  9472. * Calculate the intercept of a ray on a given axis
  9473. * @param axis to check 'x' | 'y' | 'z'
  9474. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9475. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9476. */
  9477. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9478. /**
  9479. * Checks if ray intersects a mesh
  9480. * @param mesh the mesh to check
  9481. * @param fastCheck if only the bounding box should checked
  9482. * @returns picking info of the intersecton
  9483. */
  9484. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9485. /**
  9486. * Checks if ray intersects a mesh
  9487. * @param meshes the meshes to check
  9488. * @param fastCheck if only the bounding box should checked
  9489. * @param results array to store result in
  9490. * @returns Array of picking infos
  9491. */
  9492. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9493. private _comparePickingInfo;
  9494. private static smallnum;
  9495. private static rayl;
  9496. /**
  9497. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9498. * @param sega the first point of the segment to test the intersection against
  9499. * @param segb the second point of the segment to test the intersection against
  9500. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9501. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9502. */
  9503. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9504. /**
  9505. * Update the ray from viewport position
  9506. * @param x position
  9507. * @param y y position
  9508. * @param viewportWidth viewport width
  9509. * @param viewportHeight viewport height
  9510. * @param world world matrix
  9511. * @param view view matrix
  9512. * @param projection projection matrix
  9513. * @returns this ray updated
  9514. */
  9515. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9516. /**
  9517. * Creates a ray with origin and direction of 0,0,0
  9518. * @returns the new ray
  9519. */
  9520. static Zero(): Ray;
  9521. /**
  9522. * Creates a new ray from screen space and viewport
  9523. * @param x position
  9524. * @param y y position
  9525. * @param viewportWidth viewport width
  9526. * @param viewportHeight viewport height
  9527. * @param world world matrix
  9528. * @param view view matrix
  9529. * @param projection projection matrix
  9530. * @returns new ray
  9531. */
  9532. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9533. /**
  9534. * 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
  9535. * transformed to the given world matrix.
  9536. * @param origin The origin point
  9537. * @param end The end point
  9538. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9539. * @returns the new ray
  9540. */
  9541. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9542. /**
  9543. * Transforms a ray by a matrix
  9544. * @param ray ray to transform
  9545. * @param matrix matrix to apply
  9546. * @returns the resulting new ray
  9547. */
  9548. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9549. /**
  9550. * Transforms a ray by a matrix
  9551. * @param ray ray to transform
  9552. * @param matrix matrix to apply
  9553. * @param result ray to store result in
  9554. */
  9555. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9556. /**
  9557. * Unproject a ray from screen space to object space
  9558. * @param sourceX defines the screen space x coordinate to use
  9559. * @param sourceY defines the screen space y coordinate to use
  9560. * @param viewportWidth defines the current width of the viewport
  9561. * @param viewportHeight defines the current height of the viewport
  9562. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9563. * @param view defines the view matrix to use
  9564. * @param projection defines the projection matrix to use
  9565. */
  9566. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9567. }
  9568. /**
  9569. * Type used to define predicate used to select faces when a mesh intersection is detected
  9570. */
  9571. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9572. interface Scene {
  9573. /** @hidden */
  9574. _tempPickingRay: Nullable<Ray>;
  9575. /** @hidden */
  9576. _cachedRayForTransform: Ray;
  9577. /** @hidden */
  9578. _pickWithRayInverseMatrix: Matrix;
  9579. /** @hidden */
  9580. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9581. /** @hidden */
  9582. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9583. }
  9584. }
  9585. declare module BABYLON {
  9586. /**
  9587. * Groups all the scene component constants in one place to ease maintenance.
  9588. * @hidden
  9589. */
  9590. export class SceneComponentConstants {
  9591. static readonly NAME_EFFECTLAYER: string;
  9592. static readonly NAME_LAYER: string;
  9593. static readonly NAME_LENSFLARESYSTEM: string;
  9594. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9595. static readonly NAME_PARTICLESYSTEM: string;
  9596. static readonly NAME_GAMEPAD: string;
  9597. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9598. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9599. static readonly NAME_DEPTHRENDERER: string;
  9600. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9601. static readonly NAME_SPRITE: string;
  9602. static readonly NAME_OUTLINERENDERER: string;
  9603. static readonly NAME_PROCEDURALTEXTURE: string;
  9604. static readonly NAME_SHADOWGENERATOR: string;
  9605. static readonly NAME_OCTREE: string;
  9606. static readonly NAME_PHYSICSENGINE: string;
  9607. static readonly NAME_AUDIO: string;
  9608. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9609. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9610. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9611. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9612. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9613. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9614. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9615. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9616. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9617. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9618. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9619. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9620. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9621. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9622. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9623. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9624. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9625. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9626. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9627. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9628. static readonly STEP_AFTERRENDER_AUDIO: number;
  9629. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9630. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9631. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9632. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9633. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9634. static readonly STEP_POINTERMOVE_SPRITE: number;
  9635. static readonly STEP_POINTERDOWN_SPRITE: number;
  9636. static readonly STEP_POINTERUP_SPRITE: number;
  9637. }
  9638. /**
  9639. * This represents a scene component.
  9640. *
  9641. * This is used to decouple the dependency the scene is having on the different workloads like
  9642. * layers, post processes...
  9643. */
  9644. export interface ISceneComponent {
  9645. /**
  9646. * The name of the component. Each component must have a unique name.
  9647. */
  9648. name: string;
  9649. /**
  9650. * The scene the component belongs to.
  9651. */
  9652. scene: Scene;
  9653. /**
  9654. * Register the component to one instance of a scene.
  9655. */
  9656. register(): void;
  9657. /**
  9658. * Rebuilds the elements related to this component in case of
  9659. * context lost for instance.
  9660. */
  9661. rebuild(): void;
  9662. /**
  9663. * Disposes the component and the associated ressources.
  9664. */
  9665. dispose(): void;
  9666. }
  9667. /**
  9668. * This represents a SERIALIZABLE scene component.
  9669. *
  9670. * This extends Scene Component to add Serialization methods on top.
  9671. */
  9672. export interface ISceneSerializableComponent extends ISceneComponent {
  9673. /**
  9674. * Adds all the elements from the container to the scene
  9675. * @param container the container holding the elements
  9676. */
  9677. addFromContainer(container: AbstractScene): void;
  9678. /**
  9679. * Removes all the elements in the container from the scene
  9680. * @param container contains the elements to remove
  9681. * @param dispose if the removed element should be disposed (default: false)
  9682. */
  9683. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9684. /**
  9685. * Serializes the component data to the specified json object
  9686. * @param serializationObject The object to serialize to
  9687. */
  9688. serialize(serializationObject: any): void;
  9689. }
  9690. /**
  9691. * Strong typing of a Mesh related stage step action
  9692. */
  9693. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9694. /**
  9695. * Strong typing of a Evaluate Sub Mesh related stage step action
  9696. */
  9697. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9698. /**
  9699. * Strong typing of a Active Mesh related stage step action
  9700. */
  9701. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9702. /**
  9703. * Strong typing of a Camera related stage step action
  9704. */
  9705. export type CameraStageAction = (camera: Camera) => void;
  9706. /**
  9707. * Strong typing of a Camera Frame buffer related stage step action
  9708. */
  9709. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9710. /**
  9711. * Strong typing of a Render Target related stage step action
  9712. */
  9713. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9714. /**
  9715. * Strong typing of a RenderingGroup related stage step action
  9716. */
  9717. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9718. /**
  9719. * Strong typing of a Mesh Render related stage step action
  9720. */
  9721. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9722. /**
  9723. * Strong typing of a simple stage step action
  9724. */
  9725. export type SimpleStageAction = () => void;
  9726. /**
  9727. * Strong typing of a render target action.
  9728. */
  9729. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9730. /**
  9731. * Strong typing of a pointer move action.
  9732. */
  9733. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9734. /**
  9735. * Strong typing of a pointer up/down action.
  9736. */
  9737. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9738. /**
  9739. * Representation of a stage in the scene (Basically a list of ordered steps)
  9740. * @hidden
  9741. */
  9742. export class Stage<T extends Function> extends Array<{
  9743. index: number;
  9744. component: ISceneComponent;
  9745. action: T;
  9746. }> {
  9747. /**
  9748. * Hide ctor from the rest of the world.
  9749. * @param items The items to add.
  9750. */
  9751. private constructor();
  9752. /**
  9753. * Creates a new Stage.
  9754. * @returns A new instance of a Stage
  9755. */
  9756. static Create<T extends Function>(): Stage<T>;
  9757. /**
  9758. * Registers a step in an ordered way in the targeted stage.
  9759. * @param index Defines the position to register the step in
  9760. * @param component Defines the component attached to the step
  9761. * @param action Defines the action to launch during the step
  9762. */
  9763. registerStep(index: number, component: ISceneComponent, action: T): void;
  9764. /**
  9765. * Clears all the steps from the stage.
  9766. */
  9767. clear(): void;
  9768. }
  9769. }
  9770. declare module BABYLON {
  9771. interface Scene {
  9772. /** @hidden */
  9773. _pointerOverSprite: Nullable<Sprite>;
  9774. /** @hidden */
  9775. _pickedDownSprite: Nullable<Sprite>;
  9776. /** @hidden */
  9777. _tempSpritePickingRay: Nullable<Ray>;
  9778. /**
  9779. * All of the sprite managers added to this scene
  9780. * @see http://doc.babylonjs.com/babylon101/sprites
  9781. */
  9782. spriteManagers: Array<ISpriteManager>;
  9783. /**
  9784. * An event triggered when sprites rendering is about to start
  9785. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9786. */
  9787. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9788. /**
  9789. * An event triggered when sprites rendering is done
  9790. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9791. */
  9792. onAfterSpritesRenderingObservable: Observable<Scene>;
  9793. /** @hidden */
  9794. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9795. /** Launch a ray to try to pick a sprite in the scene
  9796. * @param x position on screen
  9797. * @param y position on screen
  9798. * @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
  9799. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9800. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9801. * @returns a PickingInfo
  9802. */
  9803. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9804. /** Use the given ray to pick a sprite in the scene
  9805. * @param ray The ray (in world space) to use to pick meshes
  9806. * @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
  9807. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9808. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9809. * @returns a PickingInfo
  9810. */
  9811. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9812. /** @hidden */
  9813. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9814. /** Launch a ray to try to pick sprites in the scene
  9815. * @param x position on screen
  9816. * @param y position on screen
  9817. * @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
  9818. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9819. * @returns a PickingInfo array
  9820. */
  9821. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9822. /** Use the given ray to pick sprites in the scene
  9823. * @param ray The ray (in world space) to use to pick meshes
  9824. * @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
  9825. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9826. * @returns a PickingInfo array
  9827. */
  9828. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9829. /**
  9830. * Force the sprite under the pointer
  9831. * @param sprite defines the sprite to use
  9832. */
  9833. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9834. /**
  9835. * Gets the sprite under the pointer
  9836. * @returns a Sprite or null if no sprite is under the pointer
  9837. */
  9838. getPointerOverSprite(): Nullable<Sprite>;
  9839. }
  9840. /**
  9841. * Defines the sprite scene component responsible to manage sprites
  9842. * in a given scene.
  9843. */
  9844. export class SpriteSceneComponent implements ISceneComponent {
  9845. /**
  9846. * The component name helpfull to identify the component in the list of scene components.
  9847. */
  9848. readonly name: string;
  9849. /**
  9850. * The scene the component belongs to.
  9851. */
  9852. scene: Scene;
  9853. /** @hidden */
  9854. private _spritePredicate;
  9855. /**
  9856. * Creates a new instance of the component for the given scene
  9857. * @param scene Defines the scene to register the component in
  9858. */
  9859. constructor(scene: Scene);
  9860. /**
  9861. * Registers the component in a given scene
  9862. */
  9863. register(): void;
  9864. /**
  9865. * Rebuilds the elements related to this component in case of
  9866. * context lost for instance.
  9867. */
  9868. rebuild(): void;
  9869. /**
  9870. * Disposes the component and the associated ressources.
  9871. */
  9872. dispose(): void;
  9873. private _pickSpriteButKeepRay;
  9874. private _pointerMove;
  9875. private _pointerDown;
  9876. private _pointerUp;
  9877. }
  9878. }
  9879. declare module BABYLON {
  9880. /** @hidden */
  9881. export var fogFragmentDeclaration: {
  9882. name: string;
  9883. shader: string;
  9884. };
  9885. }
  9886. declare module BABYLON {
  9887. /** @hidden */
  9888. export var fogFragment: {
  9889. name: string;
  9890. shader: string;
  9891. };
  9892. }
  9893. declare module BABYLON {
  9894. /** @hidden */
  9895. export var spritesPixelShader: {
  9896. name: string;
  9897. shader: string;
  9898. };
  9899. }
  9900. declare module BABYLON {
  9901. /** @hidden */
  9902. export var fogVertexDeclaration: {
  9903. name: string;
  9904. shader: string;
  9905. };
  9906. }
  9907. declare module BABYLON {
  9908. /** @hidden */
  9909. export var spritesVertexShader: {
  9910. name: string;
  9911. shader: string;
  9912. };
  9913. }
  9914. declare module BABYLON {
  9915. /**
  9916. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9917. */
  9918. export interface ISpriteManager extends IDisposable {
  9919. /**
  9920. * Restricts the camera to viewing objects with the same layerMask.
  9921. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9922. */
  9923. layerMask: number;
  9924. /**
  9925. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9926. */
  9927. isPickable: boolean;
  9928. /**
  9929. * Specifies the rendering group id for this mesh (0 by default)
  9930. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9931. */
  9932. renderingGroupId: number;
  9933. /**
  9934. * Defines the list of sprites managed by the manager.
  9935. */
  9936. sprites: Array<Sprite>;
  9937. /**
  9938. * Tests the intersection of a sprite with a specific ray.
  9939. * @param ray The ray we are sending to test the collision
  9940. * @param camera The camera space we are sending rays in
  9941. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9942. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9943. * @returns picking info or null.
  9944. */
  9945. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9946. /**
  9947. * Intersects the sprites with a ray
  9948. * @param ray defines the ray to intersect with
  9949. * @param camera defines the current active camera
  9950. * @param predicate defines a predicate used to select candidate sprites
  9951. * @returns null if no hit or a PickingInfo array
  9952. */
  9953. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9954. /**
  9955. * Renders the list of sprites on screen.
  9956. */
  9957. render(): void;
  9958. }
  9959. /**
  9960. * Class used to manage multiple sprites on the same spritesheet
  9961. * @see http://doc.babylonjs.com/babylon101/sprites
  9962. */
  9963. export class SpriteManager implements ISpriteManager {
  9964. /** defines the manager's name */
  9965. name: string;
  9966. /** Gets the list of sprites */
  9967. sprites: Sprite[];
  9968. /** Gets or sets the rendering group id (0 by default) */
  9969. renderingGroupId: number;
  9970. /** Gets or sets camera layer mask */
  9971. layerMask: number;
  9972. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  9973. fogEnabled: boolean;
  9974. /** Gets or sets a boolean indicating if the sprites are pickable */
  9975. isPickable: boolean;
  9976. /** Defines the default width of a cell in the spritesheet */
  9977. cellWidth: number;
  9978. /** Defines the default height of a cell in the spritesheet */
  9979. cellHeight: number;
  9980. /** Associative array from JSON sprite data file */
  9981. private _cellData;
  9982. /** Array of sprite names from JSON sprite data file */
  9983. private _spriteMap;
  9984. /** True when packed cell data from JSON file is ready*/
  9985. private _packedAndReady;
  9986. /**
  9987. * An event triggered when the manager is disposed.
  9988. */
  9989. onDisposeObservable: Observable<SpriteManager>;
  9990. private _onDisposeObserver;
  9991. /**
  9992. * Callback called when the manager is disposed
  9993. */
  9994. set onDispose(callback: () => void);
  9995. private _capacity;
  9996. private _fromPacked;
  9997. private _spriteTexture;
  9998. private _epsilon;
  9999. private _scene;
  10000. private _vertexData;
  10001. private _buffer;
  10002. private _vertexBuffers;
  10003. private _indexBuffer;
  10004. private _effectBase;
  10005. private _effectFog;
  10006. /**
  10007. * Gets or sets the spritesheet texture
  10008. */
  10009. get texture(): Texture;
  10010. set texture(value: Texture);
  10011. private _blendMode;
  10012. /**
  10013. * Blend mode use to render the particle, it can be any of
  10014. * the static Constants.ALPHA_x properties provided in this class.
  10015. * Default value is Constants.ALPHA_COMBINE
  10016. */
  10017. get blendMode(): number;
  10018. set blendMode(blendMode: number);
  10019. /** Disables writing to the depth buffer when rendering the sprites.
  10020. * It can be handy to disable depth writing when using textures without alpha channel
  10021. * and setting some specific blend modes.
  10022. */
  10023. disableDepthWrite: boolean;
  10024. /**
  10025. * Creates a new sprite manager
  10026. * @param name defines the manager's name
  10027. * @param imgUrl defines the sprite sheet url
  10028. * @param capacity defines the maximum allowed number of sprites
  10029. * @param cellSize defines the size of a sprite cell
  10030. * @param scene defines the hosting scene
  10031. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10032. * @param samplingMode defines the smapling mode to use with spritesheet
  10033. * @param fromPacked set to false; do not alter
  10034. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10035. */
  10036. constructor(
  10037. /** defines the manager's name */
  10038. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10039. private _makePacked;
  10040. private _appendSpriteVertex;
  10041. /**
  10042. * Intersects the sprites with a ray
  10043. * @param ray defines the ray to intersect with
  10044. * @param camera defines the current active camera
  10045. * @param predicate defines a predicate used to select candidate sprites
  10046. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10047. * @returns null if no hit or a PickingInfo
  10048. */
  10049. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10050. /**
  10051. * Intersects the sprites with a ray
  10052. * @param ray defines the ray to intersect with
  10053. * @param camera defines the current active camera
  10054. * @param predicate defines a predicate used to select candidate sprites
  10055. * @returns null if no hit or a PickingInfo array
  10056. */
  10057. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10058. /**
  10059. * Render all child sprites
  10060. */
  10061. render(): void;
  10062. /**
  10063. * Release associated resources
  10064. */
  10065. dispose(): void;
  10066. }
  10067. }
  10068. declare module BABYLON {
  10069. /** Interface used by value gradients (color, factor, ...) */
  10070. export interface IValueGradient {
  10071. /**
  10072. * Gets or sets the gradient value (between 0 and 1)
  10073. */
  10074. gradient: number;
  10075. }
  10076. /** Class used to store color4 gradient */
  10077. export class ColorGradient implements IValueGradient {
  10078. /**
  10079. * Gets or sets the gradient value (between 0 and 1)
  10080. */
  10081. gradient: number;
  10082. /**
  10083. * Gets or sets first associated color
  10084. */
  10085. color1: Color4;
  10086. /**
  10087. * Gets or sets second associated color
  10088. */
  10089. color2?: Color4;
  10090. /**
  10091. * Will get a color picked randomly between color1 and color2.
  10092. * If color2 is undefined then color1 will be used
  10093. * @param result defines the target Color4 to store the result in
  10094. */
  10095. getColorToRef(result: Color4): void;
  10096. }
  10097. /** Class used to store color 3 gradient */
  10098. export class Color3Gradient implements IValueGradient {
  10099. /**
  10100. * Gets or sets the gradient value (between 0 and 1)
  10101. */
  10102. gradient: number;
  10103. /**
  10104. * Gets or sets the associated color
  10105. */
  10106. color: Color3;
  10107. }
  10108. /** Class used to store factor gradient */
  10109. export class FactorGradient implements IValueGradient {
  10110. /**
  10111. * Gets or sets the gradient value (between 0 and 1)
  10112. */
  10113. gradient: number;
  10114. /**
  10115. * Gets or sets first associated factor
  10116. */
  10117. factor1: number;
  10118. /**
  10119. * Gets or sets second associated factor
  10120. */
  10121. factor2?: number;
  10122. /**
  10123. * Will get a number picked randomly between factor1 and factor2.
  10124. * If factor2 is undefined then factor1 will be used
  10125. * @returns the picked number
  10126. */
  10127. getFactor(): number;
  10128. }
  10129. /**
  10130. * Helper used to simplify some generic gradient tasks
  10131. */
  10132. export class GradientHelper {
  10133. /**
  10134. * Gets the current gradient from an array of IValueGradient
  10135. * @param ratio defines the current ratio to get
  10136. * @param gradients defines the array of IValueGradient
  10137. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10138. */
  10139. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Interface for the size containing width and height
  10145. */
  10146. export interface ISize {
  10147. /**
  10148. * Width
  10149. */
  10150. width: number;
  10151. /**
  10152. * Heighht
  10153. */
  10154. height: number;
  10155. }
  10156. /**
  10157. * Size containing widht and height
  10158. */
  10159. export class Size implements ISize {
  10160. /**
  10161. * Width
  10162. */
  10163. width: number;
  10164. /**
  10165. * Height
  10166. */
  10167. height: number;
  10168. /**
  10169. * Creates a Size object from the given width and height (floats).
  10170. * @param width width of the new size
  10171. * @param height height of the new size
  10172. */
  10173. constructor(width: number, height: number);
  10174. /**
  10175. * Returns a string with the Size width and height
  10176. * @returns a string with the Size width and height
  10177. */
  10178. toString(): string;
  10179. /**
  10180. * "Size"
  10181. * @returns the string "Size"
  10182. */
  10183. getClassName(): string;
  10184. /**
  10185. * Returns the Size hash code.
  10186. * @returns a hash code for a unique width and height
  10187. */
  10188. getHashCode(): number;
  10189. /**
  10190. * Updates the current size from the given one.
  10191. * @param src the given size
  10192. */
  10193. copyFrom(src: Size): void;
  10194. /**
  10195. * Updates in place the current Size from the given floats.
  10196. * @param width width of the new size
  10197. * @param height height of the new size
  10198. * @returns the updated Size.
  10199. */
  10200. copyFromFloats(width: number, height: number): Size;
  10201. /**
  10202. * Updates in place the current Size from the given floats.
  10203. * @param width width to set
  10204. * @param height height to set
  10205. * @returns the updated Size.
  10206. */
  10207. set(width: number, height: number): Size;
  10208. /**
  10209. * Multiplies the width and height by numbers
  10210. * @param w factor to multiple the width by
  10211. * @param h factor to multiple the height by
  10212. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10213. */
  10214. multiplyByFloats(w: number, h: number): Size;
  10215. /**
  10216. * Clones the size
  10217. * @returns a new Size copied from the given one.
  10218. */
  10219. clone(): Size;
  10220. /**
  10221. * True if the current Size and the given one width and height are strictly equal.
  10222. * @param other the other size to compare against
  10223. * @returns True if the current Size and the given one width and height are strictly equal.
  10224. */
  10225. equals(other: Size): boolean;
  10226. /**
  10227. * The surface of the Size : width * height (float).
  10228. */
  10229. get surface(): number;
  10230. /**
  10231. * Create a new size of zero
  10232. * @returns a new Size set to (0.0, 0.0)
  10233. */
  10234. static Zero(): Size;
  10235. /**
  10236. * Sums the width and height of two sizes
  10237. * @param otherSize size to add to this size
  10238. * @returns a new Size set as the addition result of the current Size and the given one.
  10239. */
  10240. add(otherSize: Size): Size;
  10241. /**
  10242. * Subtracts the width and height of two
  10243. * @param otherSize size to subtract to this size
  10244. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10245. */
  10246. subtract(otherSize: Size): Size;
  10247. /**
  10248. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10249. * @param start starting size to lerp between
  10250. * @param end end size to lerp between
  10251. * @param amount amount to lerp between the start and end values
  10252. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10253. */
  10254. static Lerp(start: Size, end: Size, amount: number): Size;
  10255. }
  10256. }
  10257. declare module BABYLON {
  10258. interface ThinEngine {
  10259. /**
  10260. * Creates a dynamic texture
  10261. * @param width defines the width of the texture
  10262. * @param height defines the height of the texture
  10263. * @param generateMipMaps defines if the engine should generate the mip levels
  10264. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10265. * @returns the dynamic texture inside an InternalTexture
  10266. */
  10267. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10268. /**
  10269. * Update the content of a dynamic texture
  10270. * @param texture defines the texture to update
  10271. * @param canvas defines the canvas containing the source
  10272. * @param invertY defines if data must be stored with Y axis inverted
  10273. * @param premulAlpha defines if alpha is stored as premultiplied
  10274. * @param format defines the format of the data
  10275. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10276. */
  10277. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. /**
  10282. * Helper class used to generate a canvas to manipulate images
  10283. */
  10284. export class CanvasGenerator {
  10285. /**
  10286. * Create a new canvas (or offscreen canvas depending on the context)
  10287. * @param width defines the expected width
  10288. * @param height defines the expected height
  10289. * @return a new canvas or offscreen canvas
  10290. */
  10291. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10292. }
  10293. }
  10294. declare module BABYLON {
  10295. /**
  10296. * A class extending Texture allowing drawing on a texture
  10297. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10298. */
  10299. export class DynamicTexture extends Texture {
  10300. private _generateMipMaps;
  10301. private _canvas;
  10302. private _context;
  10303. private _engine;
  10304. /**
  10305. * Creates a DynamicTexture
  10306. * @param name defines the name of the texture
  10307. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10308. * @param scene defines the scene where you want the texture
  10309. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10310. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10311. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10312. */
  10313. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10314. /**
  10315. * Get the current class name of the texture useful for serialization or dynamic coding.
  10316. * @returns "DynamicTexture"
  10317. */
  10318. getClassName(): string;
  10319. /**
  10320. * Gets the current state of canRescale
  10321. */
  10322. get canRescale(): boolean;
  10323. private _recreate;
  10324. /**
  10325. * Scales the texture
  10326. * @param ratio the scale factor to apply to both width and height
  10327. */
  10328. scale(ratio: number): void;
  10329. /**
  10330. * Resizes the texture
  10331. * @param width the new width
  10332. * @param height the new height
  10333. */
  10334. scaleTo(width: number, height: number): void;
  10335. /**
  10336. * Gets the context of the canvas used by the texture
  10337. * @returns the canvas context of the dynamic texture
  10338. */
  10339. getContext(): CanvasRenderingContext2D;
  10340. /**
  10341. * Clears the texture
  10342. */
  10343. clear(): void;
  10344. /**
  10345. * Updates the texture
  10346. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10347. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10348. */
  10349. update(invertY?: boolean, premulAlpha?: boolean): void;
  10350. /**
  10351. * Draws text onto the texture
  10352. * @param text defines the text to be drawn
  10353. * @param x defines the placement of the text from the left
  10354. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10355. * @param font defines the font to be used with font-style, font-size, font-name
  10356. * @param color defines the color used for the text
  10357. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10358. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10359. * @param update defines whether texture is immediately update (default is true)
  10360. */
  10361. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10362. /**
  10363. * Clones the texture
  10364. * @returns the clone of the texture.
  10365. */
  10366. clone(): DynamicTexture;
  10367. /**
  10368. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10369. * @returns a serialized dynamic texture object
  10370. */
  10371. serialize(): any;
  10372. /** @hidden */
  10373. _rebuild(): void;
  10374. }
  10375. }
  10376. declare module BABYLON {
  10377. interface Engine {
  10378. /**
  10379. * Creates a raw texture
  10380. * @param data defines the data to store in the texture
  10381. * @param width defines the width of the texture
  10382. * @param height defines the height of the texture
  10383. * @param format defines the format of the data
  10384. * @param generateMipMaps defines if the engine should generate the mip levels
  10385. * @param invertY defines if data must be stored with Y axis inverted
  10386. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10387. * @param compression defines the compression used (null by default)
  10388. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10389. * @returns the raw texture inside an InternalTexture
  10390. */
  10391. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10392. /**
  10393. * Update a raw texture
  10394. * @param texture defines the texture to update
  10395. * @param data defines the data to store in the texture
  10396. * @param format defines the format of the data
  10397. * @param invertY defines if data must be stored with Y axis inverted
  10398. */
  10399. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10400. /**
  10401. * Update a raw texture
  10402. * @param texture defines the texture to update
  10403. * @param data defines the data to store in the texture
  10404. * @param format defines the format of the data
  10405. * @param invertY defines if data must be stored with Y axis inverted
  10406. * @param compression defines the compression used (null by default)
  10407. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10408. */
  10409. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10410. /**
  10411. * Creates a new raw cube texture
  10412. * @param data defines the array of data to use to create each face
  10413. * @param size defines the size of the textures
  10414. * @param format defines the format of the data
  10415. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10416. * @param generateMipMaps defines if the engine should generate the mip levels
  10417. * @param invertY defines if data must be stored with Y axis inverted
  10418. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10419. * @param compression defines the compression used (null by default)
  10420. * @returns the cube texture as an InternalTexture
  10421. */
  10422. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10423. /**
  10424. * Update a raw cube texture
  10425. * @param texture defines the texture to udpdate
  10426. * @param data defines the data to store
  10427. * @param format defines the data format
  10428. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10429. * @param invertY defines if data must be stored with Y axis inverted
  10430. */
  10431. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10432. /**
  10433. * Update a raw cube texture
  10434. * @param texture defines the texture to udpdate
  10435. * @param data defines the data to store
  10436. * @param format defines the data format
  10437. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10438. * @param invertY defines if data must be stored with Y axis inverted
  10439. * @param compression defines the compression used (null by default)
  10440. */
  10441. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10442. /**
  10443. * Update a raw cube texture
  10444. * @param texture defines the texture to udpdate
  10445. * @param data defines the data to store
  10446. * @param format defines the data format
  10447. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10448. * @param invertY defines if data must be stored with Y axis inverted
  10449. * @param compression defines the compression used (null by default)
  10450. * @param level defines which level of the texture to update
  10451. */
  10452. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10453. /**
  10454. * Creates a new raw cube texture from a specified url
  10455. * @param url defines the url where the data is located
  10456. * @param scene defines the current scene
  10457. * @param size defines the size of the textures
  10458. * @param format defines the format of the data
  10459. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10460. * @param noMipmap defines if the engine should avoid generating the mip levels
  10461. * @param callback defines a callback used to extract texture data from loaded data
  10462. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10463. * @param onLoad defines a callback called when texture is loaded
  10464. * @param onError defines a callback called if there is an error
  10465. * @returns the cube texture as an InternalTexture
  10466. */
  10467. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10468. /**
  10469. * Creates a new raw cube texture from a specified url
  10470. * @param url defines the url where the data is located
  10471. * @param scene defines the current scene
  10472. * @param size defines the size of the textures
  10473. * @param format defines the format of the data
  10474. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10475. * @param noMipmap defines if the engine should avoid generating the mip levels
  10476. * @param callback defines a callback used to extract texture data from loaded data
  10477. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10478. * @param onLoad defines a callback called when texture is loaded
  10479. * @param onError defines a callback called if there is an error
  10480. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10481. * @param invertY defines if data must be stored with Y axis inverted
  10482. * @returns the cube texture as an InternalTexture
  10483. */
  10484. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10485. /**
  10486. * Creates a new raw 3D texture
  10487. * @param data defines the data used to create the texture
  10488. * @param width defines the width of the texture
  10489. * @param height defines the height of the texture
  10490. * @param depth defines the depth of the texture
  10491. * @param format defines the format of the texture
  10492. * @param generateMipMaps defines if the engine must generate mip levels
  10493. * @param invertY defines if data must be stored with Y axis inverted
  10494. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10495. * @param compression defines the compressed used (can be null)
  10496. * @param textureType defines the compressed used (can be null)
  10497. * @returns a new raw 3D texture (stored in an InternalTexture)
  10498. */
  10499. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10500. /**
  10501. * Update a raw 3D texture
  10502. * @param texture defines the texture to update
  10503. * @param data defines the data to store
  10504. * @param format defines the data format
  10505. * @param invertY defines if data must be stored with Y axis inverted
  10506. */
  10507. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10508. /**
  10509. * Update a raw 3D texture
  10510. * @param texture defines the texture to update
  10511. * @param data defines the data to store
  10512. * @param format defines the data format
  10513. * @param invertY defines if data must be stored with Y axis inverted
  10514. * @param compression defines the used compression (can be null)
  10515. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10516. */
  10517. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10518. /**
  10519. * Creates a new raw 2D array texture
  10520. * @param data defines the data used to create the texture
  10521. * @param width defines the width of the texture
  10522. * @param height defines the height of the texture
  10523. * @param depth defines the number of layers of the texture
  10524. * @param format defines the format of the texture
  10525. * @param generateMipMaps defines if the engine must generate mip levels
  10526. * @param invertY defines if data must be stored with Y axis inverted
  10527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10528. * @param compression defines the compressed used (can be null)
  10529. * @param textureType defines the compressed used (can be null)
  10530. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10531. */
  10532. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10533. /**
  10534. * Update a raw 2D array texture
  10535. * @param texture defines the texture to update
  10536. * @param data defines the data to store
  10537. * @param format defines the data format
  10538. * @param invertY defines if data must be stored with Y axis inverted
  10539. */
  10540. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10541. /**
  10542. * Update a raw 2D array texture
  10543. * @param texture defines the texture to update
  10544. * @param data defines the data to store
  10545. * @param format defines the data format
  10546. * @param invertY defines if data must be stored with Y axis inverted
  10547. * @param compression defines the used compression (can be null)
  10548. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10549. */
  10550. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10551. }
  10552. }
  10553. declare module BABYLON {
  10554. /**
  10555. * Raw texture can help creating a texture directly from an array of data.
  10556. * This can be super useful if you either get the data from an uncompressed source or
  10557. * if you wish to create your texture pixel by pixel.
  10558. */
  10559. export class RawTexture extends Texture {
  10560. /**
  10561. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10562. */
  10563. format: number;
  10564. private _engine;
  10565. /**
  10566. * Instantiates a new RawTexture.
  10567. * Raw texture can help creating a texture directly from an array of data.
  10568. * This can be super useful if you either get the data from an uncompressed source or
  10569. * if you wish to create your texture pixel by pixel.
  10570. * @param data define the array of data to use to create the texture
  10571. * @param width define the width of the texture
  10572. * @param height define the height of the texture
  10573. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10574. * @param scene define the scene the texture belongs to
  10575. * @param generateMipMaps define whether mip maps should be generated or not
  10576. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10577. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10578. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10579. */
  10580. constructor(data: ArrayBufferView, width: number, height: number,
  10581. /**
  10582. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10583. */
  10584. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10585. /**
  10586. * Updates the texture underlying data.
  10587. * @param data Define the new data of the texture
  10588. */
  10589. update(data: ArrayBufferView): void;
  10590. /**
  10591. * Creates a luminance texture from some data.
  10592. * @param data Define the texture data
  10593. * @param width Define the width of the texture
  10594. * @param height Define the height of the texture
  10595. * @param scene Define the scene the texture belongs to
  10596. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10597. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10598. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10599. * @returns the luminance texture
  10600. */
  10601. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10602. /**
  10603. * Creates a luminance alpha texture from some data.
  10604. * @param data Define the texture data
  10605. * @param width Define the width of the texture
  10606. * @param height Define the height of the texture
  10607. * @param scene Define the scene the texture belongs to
  10608. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10609. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10610. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10611. * @returns the luminance alpha texture
  10612. */
  10613. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10614. /**
  10615. * Creates an alpha texture from some data.
  10616. * @param data Define the texture data
  10617. * @param width Define the width of the texture
  10618. * @param height Define the height of the texture
  10619. * @param scene Define the scene the texture belongs to
  10620. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10621. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10622. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10623. * @returns the alpha texture
  10624. */
  10625. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10626. /**
  10627. * Creates a RGB texture from some data.
  10628. * @param data Define the texture data
  10629. * @param width Define the width of the texture
  10630. * @param height Define the height of the texture
  10631. * @param scene Define the scene the texture belongs to
  10632. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10633. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10634. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10635. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10636. * @returns the RGB alpha texture
  10637. */
  10638. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10639. /**
  10640. * Creates a RGBA texture from some data.
  10641. * @param data Define the texture data
  10642. * @param width Define the width of the texture
  10643. * @param height Define the height of the texture
  10644. * @param scene Define the scene the texture belongs to
  10645. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10648. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10649. * @returns the RGBA texture
  10650. */
  10651. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10652. /**
  10653. * Creates a R texture from some data.
  10654. * @param data Define the texture data
  10655. * @param width Define the width of the texture
  10656. * @param height Define the height of the texture
  10657. * @param scene Define the scene the texture belongs to
  10658. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10659. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10660. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10661. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10662. * @returns the R texture
  10663. */
  10664. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10665. }
  10666. }
  10667. declare module BABYLON {
  10668. interface AbstractScene {
  10669. /**
  10670. * The list of procedural textures added to the scene
  10671. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10672. */
  10673. proceduralTextures: Array<ProceduralTexture>;
  10674. }
  10675. /**
  10676. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10677. * in a given scene.
  10678. */
  10679. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10680. /**
  10681. * The component name helpfull to identify the component in the list of scene components.
  10682. */
  10683. readonly name: string;
  10684. /**
  10685. * The scene the component belongs to.
  10686. */
  10687. scene: Scene;
  10688. /**
  10689. * Creates a new instance of the component for the given scene
  10690. * @param scene Defines the scene to register the component in
  10691. */
  10692. constructor(scene: Scene);
  10693. /**
  10694. * Registers the component in a given scene
  10695. */
  10696. register(): void;
  10697. /**
  10698. * Rebuilds the elements related to this component in case of
  10699. * context lost for instance.
  10700. */
  10701. rebuild(): void;
  10702. /**
  10703. * Disposes the component and the associated ressources.
  10704. */
  10705. dispose(): void;
  10706. private _beforeClear;
  10707. }
  10708. }
  10709. declare module BABYLON {
  10710. interface ThinEngine {
  10711. /**
  10712. * Creates a new render target cube texture
  10713. * @param size defines the size of the texture
  10714. * @param options defines the options used to create the texture
  10715. * @returns a new render target cube texture stored in an InternalTexture
  10716. */
  10717. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10718. }
  10719. }
  10720. declare module BABYLON {
  10721. /** @hidden */
  10722. export var proceduralVertexShader: {
  10723. name: string;
  10724. shader: string;
  10725. };
  10726. }
  10727. declare module BABYLON {
  10728. /**
  10729. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  10730. * This is the base class of any Procedural texture and contains most of the shareable code.
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10732. */
  10733. export class ProceduralTexture extends Texture {
  10734. isCube: boolean;
  10735. /**
  10736. * Define if the texture is enabled or not (disabled texture will not render)
  10737. */
  10738. isEnabled: boolean;
  10739. /**
  10740. * Define if the texture must be cleared before rendering (default is true)
  10741. */
  10742. autoClear: boolean;
  10743. /**
  10744. * Callback called when the texture is generated
  10745. */
  10746. onGenerated: () => void;
  10747. /**
  10748. * Event raised when the texture is generated
  10749. */
  10750. onGeneratedObservable: Observable<ProceduralTexture>;
  10751. /** @hidden */
  10752. _generateMipMaps: boolean;
  10753. /** @hidden **/
  10754. _effect: Effect;
  10755. /** @hidden */
  10756. _textures: {
  10757. [key: string]: Texture;
  10758. };
  10759. private _size;
  10760. private _currentRefreshId;
  10761. private _frameId;
  10762. private _refreshRate;
  10763. private _vertexBuffers;
  10764. private _indexBuffer;
  10765. private _uniforms;
  10766. private _samplers;
  10767. private _fragment;
  10768. private _floats;
  10769. private _ints;
  10770. private _floatsArrays;
  10771. private _colors3;
  10772. private _colors4;
  10773. private _vectors2;
  10774. private _vectors3;
  10775. private _matrices;
  10776. private _fallbackTexture;
  10777. private _fallbackTextureUsed;
  10778. private _engine;
  10779. private _cachedDefines;
  10780. private _contentUpdateId;
  10781. private _contentData;
  10782. /**
  10783. * Instantiates a new procedural texture.
  10784. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  10785. * This is the base class of any Procedural texture and contains most of the shareable code.
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10787. * @param name Define the name of the texture
  10788. * @param size Define the size of the texture to create
  10789. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10790. * @param scene Define the scene the texture belongs to
  10791. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10792. * @param generateMipMaps Define if the texture should creates mip maps or not
  10793. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10794. */
  10795. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10796. /**
  10797. * The effect that is created when initializing the post process.
  10798. * @returns The created effect corresponding the the postprocess.
  10799. */
  10800. getEffect(): Effect;
  10801. /**
  10802. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10803. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10804. */
  10805. getContent(): Nullable<ArrayBufferView>;
  10806. private _createIndexBuffer;
  10807. /** @hidden */
  10808. _rebuild(): void;
  10809. /**
  10810. * Resets the texture in order to recreate its associated resources.
  10811. * This can be called in case of context loss
  10812. */
  10813. reset(): void;
  10814. protected _getDefines(): string;
  10815. /**
  10816. * Is the texture ready to be used ? (rendered at least once)
  10817. * @returns true if ready, otherwise, false.
  10818. */
  10819. isReady(): boolean;
  10820. /**
  10821. * Resets the refresh counter of the texture and start bak from scratch.
  10822. * Could be useful to regenerate the texture if it is setup to render only once.
  10823. */
  10824. resetRefreshCounter(): void;
  10825. /**
  10826. * Set the fragment shader to use in order to render the texture.
  10827. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10828. */
  10829. setFragment(fragment: any): void;
  10830. /**
  10831. * Define the refresh rate of the texture or the rendering frequency.
  10832. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10833. */
  10834. get refreshRate(): number;
  10835. set refreshRate(value: number);
  10836. /** @hidden */
  10837. _shouldRender(): boolean;
  10838. /**
  10839. * Get the size the texture is rendering at.
  10840. * @returns the size (texture is always squared)
  10841. */
  10842. getRenderSize(): number;
  10843. /**
  10844. * Resize the texture to new value.
  10845. * @param size Define the new size the texture should have
  10846. * @param generateMipMaps Define whether the new texture should create mip maps
  10847. */
  10848. resize(size: number, generateMipMaps: boolean): void;
  10849. private _checkUniform;
  10850. /**
  10851. * Set a texture in the shader program used to render.
  10852. * @param name Define the name of the uniform samplers as defined in the shader
  10853. * @param texture Define the texture to bind to this sampler
  10854. * @return the texture itself allowing "fluent" like uniform updates
  10855. */
  10856. setTexture(name: string, texture: Texture): ProceduralTexture;
  10857. /**
  10858. * Set a float in the shader.
  10859. * @param name Define the name of the uniform as defined in the shader
  10860. * @param value Define the value to give to the uniform
  10861. * @return the texture itself allowing "fluent" like uniform updates
  10862. */
  10863. setFloat(name: string, value: number): ProceduralTexture;
  10864. /**
  10865. * Set a int in the shader.
  10866. * @param name Define the name of the uniform as defined in the shader
  10867. * @param value Define the value to give to the uniform
  10868. * @return the texture itself allowing "fluent" like uniform updates
  10869. */
  10870. setInt(name: string, value: number): ProceduralTexture;
  10871. /**
  10872. * Set an array of floats in the shader.
  10873. * @param name Define the name of the uniform as defined in the shader
  10874. * @param value Define the value to give to the uniform
  10875. * @return the texture itself allowing "fluent" like uniform updates
  10876. */
  10877. setFloats(name: string, value: number[]): ProceduralTexture;
  10878. /**
  10879. * Set a vec3 in the shader from a Color3.
  10880. * @param name Define the name of the uniform as defined in the shader
  10881. * @param value Define the value to give to the uniform
  10882. * @return the texture itself allowing "fluent" like uniform updates
  10883. */
  10884. setColor3(name: string, value: Color3): ProceduralTexture;
  10885. /**
  10886. * Set a vec4 in the shader from a Color4.
  10887. * @param name Define the name of the uniform as defined in the shader
  10888. * @param value Define the value to give to the uniform
  10889. * @return the texture itself allowing "fluent" like uniform updates
  10890. */
  10891. setColor4(name: string, value: Color4): ProceduralTexture;
  10892. /**
  10893. * Set a vec2 in the shader from a Vector2.
  10894. * @param name Define the name of the uniform as defined in the shader
  10895. * @param value Define the value to give to the uniform
  10896. * @return the texture itself allowing "fluent" like uniform updates
  10897. */
  10898. setVector2(name: string, value: Vector2): ProceduralTexture;
  10899. /**
  10900. * Set a vec3 in the shader from a Vector3.
  10901. * @param name Define the name of the uniform as defined in the shader
  10902. * @param value Define the value to give to the uniform
  10903. * @return the texture itself allowing "fluent" like uniform updates
  10904. */
  10905. setVector3(name: string, value: Vector3): ProceduralTexture;
  10906. /**
  10907. * Set a mat4 in the shader from a MAtrix.
  10908. * @param name Define the name of the uniform as defined in the shader
  10909. * @param value Define the value to give to the uniform
  10910. * @return the texture itself allowing "fluent" like uniform updates
  10911. */
  10912. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10913. /**
  10914. * Render the texture to its associated render target.
  10915. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10916. */
  10917. render(useCameraPostProcess?: boolean): void;
  10918. /**
  10919. * Clone the texture.
  10920. * @returns the cloned texture
  10921. */
  10922. clone(): ProceduralTexture;
  10923. /**
  10924. * Dispose the texture and release its asoociated resources.
  10925. */
  10926. dispose(): void;
  10927. }
  10928. }
  10929. declare module BABYLON {
  10930. /**
  10931. * This represents the base class for particle system in Babylon.
  10932. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  10933. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10934. * @example https://doc.babylonjs.com/babylon101/particles
  10935. */
  10936. export class BaseParticleSystem {
  10937. /**
  10938. * Source color is added to the destination color without alpha affecting the result
  10939. */
  10940. static BLENDMODE_ONEONE: number;
  10941. /**
  10942. * Blend current color and particle color using particle’s alpha
  10943. */
  10944. static BLENDMODE_STANDARD: number;
  10945. /**
  10946. * Add current color and particle color multiplied by particle’s alpha
  10947. */
  10948. static BLENDMODE_ADD: number;
  10949. /**
  10950. * Multiply current color with particle color
  10951. */
  10952. static BLENDMODE_MULTIPLY: number;
  10953. /**
  10954. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10955. */
  10956. static BLENDMODE_MULTIPLYADD: number;
  10957. /**
  10958. * List of animations used by the particle system.
  10959. */
  10960. animations: Animation[];
  10961. /**
  10962. * The id of the Particle system.
  10963. */
  10964. id: string;
  10965. /**
  10966. * The friendly name of the Particle system.
  10967. */
  10968. name: string;
  10969. /**
  10970. * The rendering group used by the Particle system to chose when to render.
  10971. */
  10972. renderingGroupId: number;
  10973. /**
  10974. * The emitter represents the Mesh or position we are attaching the particle system to.
  10975. */
  10976. emitter: Nullable<AbstractMesh | Vector3>;
  10977. /**
  10978. * The maximum number of particles to emit per frame
  10979. */
  10980. emitRate: number;
  10981. /**
  10982. * If you want to launch only a few particles at once, that can be done, as well.
  10983. */
  10984. manualEmitCount: number;
  10985. /**
  10986. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  10987. */
  10988. updateSpeed: number;
  10989. /**
  10990. * The amount of time the particle system is running (depends of the overall update speed).
  10991. */
  10992. targetStopDuration: number;
  10993. /**
  10994. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  10995. */
  10996. disposeOnStop: boolean;
  10997. /**
  10998. * Minimum power of emitting particles.
  10999. */
  11000. minEmitPower: number;
  11001. /**
  11002. * Maximum power of emitting particles.
  11003. */
  11004. maxEmitPower: number;
  11005. /**
  11006. * Minimum life time of emitting particles.
  11007. */
  11008. minLifeTime: number;
  11009. /**
  11010. * Maximum life time of emitting particles.
  11011. */
  11012. maxLifeTime: number;
  11013. /**
  11014. * Minimum Size of emitting particles.
  11015. */
  11016. minSize: number;
  11017. /**
  11018. * Maximum Size of emitting particles.
  11019. */
  11020. maxSize: number;
  11021. /**
  11022. * Minimum scale of emitting particles on X axis.
  11023. */
  11024. minScaleX: number;
  11025. /**
  11026. * Maximum scale of emitting particles on X axis.
  11027. */
  11028. maxScaleX: number;
  11029. /**
  11030. * Minimum scale of emitting particles on Y axis.
  11031. */
  11032. minScaleY: number;
  11033. /**
  11034. * Maximum scale of emitting particles on Y axis.
  11035. */
  11036. maxScaleY: number;
  11037. /**
  11038. * Gets or sets the minimal initial rotation in radians.
  11039. */
  11040. minInitialRotation: number;
  11041. /**
  11042. * Gets or sets the maximal initial rotation in radians.
  11043. */
  11044. maxInitialRotation: number;
  11045. /**
  11046. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11047. */
  11048. minAngularSpeed: number;
  11049. /**
  11050. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11051. */
  11052. maxAngularSpeed: number;
  11053. /**
  11054. * The texture used to render each particle. (this can be a spritesheet)
  11055. */
  11056. particleTexture: Nullable<Texture>;
  11057. /**
  11058. * The layer mask we are rendering the particles through.
  11059. */
  11060. layerMask: number;
  11061. /**
  11062. * This can help using your own shader to render the particle system.
  11063. * The according effect will be created
  11064. */
  11065. customShader: any;
  11066. /**
  11067. * By default particle system starts as soon as they are created. This prevents the
  11068. * automatic start to happen and let you decide when to start emitting particles.
  11069. */
  11070. preventAutoStart: boolean;
  11071. private _noiseTexture;
  11072. /**
  11073. * Gets or sets a texture used to add random noise to particle positions
  11074. */
  11075. get noiseTexture(): Nullable<ProceduralTexture>;
  11076. set noiseTexture(value: Nullable<ProceduralTexture>);
  11077. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11078. noiseStrength: Vector3;
  11079. /**
  11080. * Callback triggered when the particle animation is ending.
  11081. */
  11082. onAnimationEnd: Nullable<() => void>;
  11083. /**
  11084. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11085. */
  11086. blendMode: number;
  11087. /**
  11088. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11089. * to override the particles.
  11090. */
  11091. forceDepthWrite: boolean;
  11092. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11093. preWarmCycles: number;
  11094. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11095. preWarmStepOffset: number;
  11096. /**
  11097. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11098. */
  11099. spriteCellChangeSpeed: number;
  11100. /**
  11101. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11102. */
  11103. startSpriteCellID: number;
  11104. /**
  11105. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11106. */
  11107. endSpriteCellID: number;
  11108. /**
  11109. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11110. */
  11111. spriteCellWidth: number;
  11112. /**
  11113. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11114. */
  11115. spriteCellHeight: number;
  11116. /**
  11117. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11118. */
  11119. spriteRandomStartCell: boolean;
  11120. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11121. translationPivot: Vector2;
  11122. /** @hidden */
  11123. protected _isAnimationSheetEnabled: boolean;
  11124. /**
  11125. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11126. */
  11127. beginAnimationOnStart: boolean;
  11128. /**
  11129. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11130. */
  11131. beginAnimationFrom: number;
  11132. /**
  11133. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11134. */
  11135. beginAnimationTo: number;
  11136. /**
  11137. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11138. */
  11139. beginAnimationLoop: boolean;
  11140. /**
  11141. * Gets or sets a world offset applied to all particles
  11142. */
  11143. worldOffset: Vector3;
  11144. /**
  11145. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11146. */
  11147. get isAnimationSheetEnabled(): boolean;
  11148. set isAnimationSheetEnabled(value: boolean);
  11149. /**
  11150. * Get hosting scene
  11151. * @returns the scene
  11152. */
  11153. getScene(): Scene;
  11154. /**
  11155. * You can use gravity if you want to give an orientation to your particles.
  11156. */
  11157. gravity: Vector3;
  11158. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11159. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11160. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11161. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11162. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11163. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11164. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11165. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11166. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11167. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11168. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11169. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11170. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11171. /**
  11172. * Defines the delay in milliseconds before starting the system (0 by default)
  11173. */
  11174. startDelay: number;
  11175. /**
  11176. * Gets the current list of drag gradients.
  11177. * You must use addDragGradient and removeDragGradient to udpate this list
  11178. * @returns the list of drag gradients
  11179. */
  11180. getDragGradients(): Nullable<Array<FactorGradient>>;
  11181. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11182. limitVelocityDamping: number;
  11183. /**
  11184. * Gets the current list of limit velocity gradients.
  11185. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11186. * @returns the list of limit velocity gradients
  11187. */
  11188. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11189. /**
  11190. * Gets the current list of color gradients.
  11191. * You must use addColorGradient and removeColorGradient to udpate this list
  11192. * @returns the list of color gradients
  11193. */
  11194. getColorGradients(): Nullable<Array<ColorGradient>>;
  11195. /**
  11196. * Gets the current list of size gradients.
  11197. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11198. * @returns the list of size gradients
  11199. */
  11200. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11201. /**
  11202. * Gets the current list of color remap gradients.
  11203. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11204. * @returns the list of color remap gradients
  11205. */
  11206. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11207. /**
  11208. * Gets the current list of alpha remap gradients.
  11209. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11210. * @returns the list of alpha remap gradients
  11211. */
  11212. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11213. /**
  11214. * Gets the current list of life time gradients.
  11215. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11216. * @returns the list of life time gradients
  11217. */
  11218. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11219. /**
  11220. * Gets the current list of angular speed gradients.
  11221. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11222. * @returns the list of angular speed gradients
  11223. */
  11224. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11225. /**
  11226. * Gets the current list of velocity gradients.
  11227. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11228. * @returns the list of velocity gradients
  11229. */
  11230. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11231. /**
  11232. * Gets the current list of start size gradients.
  11233. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11234. * @returns the list of start size gradients
  11235. */
  11236. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11237. /**
  11238. * Gets the current list of emit rate gradients.
  11239. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11240. * @returns the list of emit rate gradients
  11241. */
  11242. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11243. /**
  11244. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11245. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11246. */
  11247. get direction1(): Vector3;
  11248. set direction1(value: Vector3);
  11249. /**
  11250. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11251. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11252. */
  11253. get direction2(): Vector3;
  11254. set direction2(value: Vector3);
  11255. /**
  11256. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11257. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11258. */
  11259. get minEmitBox(): Vector3;
  11260. set minEmitBox(value: Vector3);
  11261. /**
  11262. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11263. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11264. */
  11265. get maxEmitBox(): Vector3;
  11266. set maxEmitBox(value: Vector3);
  11267. /**
  11268. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11269. */
  11270. color1: Color4;
  11271. /**
  11272. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11273. */
  11274. color2: Color4;
  11275. /**
  11276. * Color the particle will have at the end of its lifetime
  11277. */
  11278. colorDead: Color4;
  11279. /**
  11280. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11281. */
  11282. textureMask: Color4;
  11283. /**
  11284. * The particle emitter type defines the emitter used by the particle system.
  11285. * It can be for example box, sphere, or cone...
  11286. */
  11287. particleEmitterType: IParticleEmitterType;
  11288. /** @hidden */
  11289. _isSubEmitter: boolean;
  11290. /**
  11291. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11292. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11293. */
  11294. billboardMode: number;
  11295. protected _isBillboardBased: boolean;
  11296. /**
  11297. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11298. */
  11299. get isBillboardBased(): boolean;
  11300. set isBillboardBased(value: boolean);
  11301. /**
  11302. * The scene the particle system belongs to.
  11303. */
  11304. protected _scene: Scene;
  11305. /**
  11306. * Local cache of defines for image processing.
  11307. */
  11308. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11309. /**
  11310. * Default configuration related to image processing available in the standard Material.
  11311. */
  11312. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11313. /**
  11314. * Gets the image processing configuration used either in this material.
  11315. */
  11316. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11317. /**
  11318. * Sets the Default image processing configuration used either in the this material.
  11319. *
  11320. * If sets to null, the scene one is in use.
  11321. */
  11322. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11323. /**
  11324. * Attaches a new image processing configuration to the Standard Material.
  11325. * @param configuration
  11326. */
  11327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11328. /** @hidden */
  11329. protected _reset(): void;
  11330. /** @hidden */
  11331. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11332. /**
  11333. * Instantiates a particle system.
  11334. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11335. * @param name The name of the particle system
  11336. */
  11337. constructor(name: string);
  11338. /**
  11339. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11342. * @returns the emitter
  11343. */
  11344. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11345. /**
  11346. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11347. * @param radius The radius of the hemisphere to emit from
  11348. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11349. * @returns the emitter
  11350. */
  11351. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11352. /**
  11353. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11354. * @param radius The radius of the sphere to emit from
  11355. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11356. * @returns the emitter
  11357. */
  11358. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11359. /**
  11360. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11361. * @param radius The radius of the sphere to emit from
  11362. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11363. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11364. * @returns the emitter
  11365. */
  11366. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11367. /**
  11368. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11369. * @param radius The radius of the emission cylinder
  11370. * @param height The height of the emission cylinder
  11371. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11372. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11373. * @returns the emitter
  11374. */
  11375. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11376. /**
  11377. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11378. * @param radius The radius of the cylinder to emit from
  11379. * @param height The height of the emission cylinder
  11380. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11381. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11382. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11383. * @returns the emitter
  11384. */
  11385. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11386. /**
  11387. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11388. * @param radius The radius of the cone to emit from
  11389. * @param angle The base angle of the cone
  11390. * @returns the emitter
  11391. */
  11392. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11393. /**
  11394. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11395. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11396. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11397. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11398. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11399. * @returns the emitter
  11400. */
  11401. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11402. }
  11403. }
  11404. declare module BABYLON {
  11405. /**
  11406. * Type of sub emitter
  11407. */
  11408. export enum SubEmitterType {
  11409. /**
  11410. * Attached to the particle over it's lifetime
  11411. */
  11412. ATTACHED = 0,
  11413. /**
  11414. * Created when the particle dies
  11415. */
  11416. END = 1
  11417. }
  11418. /**
  11419. * Sub emitter class used to emit particles from an existing particle
  11420. */
  11421. export class SubEmitter {
  11422. /**
  11423. * the particle system to be used by the sub emitter
  11424. */
  11425. particleSystem: ParticleSystem;
  11426. /**
  11427. * Type of the submitter (Default: END)
  11428. */
  11429. type: SubEmitterType;
  11430. /**
  11431. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11432. * Note: This only is supported when using an emitter of type Mesh
  11433. */
  11434. inheritDirection: boolean;
  11435. /**
  11436. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11437. */
  11438. inheritedVelocityAmount: number;
  11439. /**
  11440. * Creates a sub emitter
  11441. * @param particleSystem the particle system to be used by the sub emitter
  11442. */
  11443. constructor(
  11444. /**
  11445. * the particle system to be used by the sub emitter
  11446. */
  11447. particleSystem: ParticleSystem);
  11448. /**
  11449. * Clones the sub emitter
  11450. * @returns the cloned sub emitter
  11451. */
  11452. clone(): SubEmitter;
  11453. /**
  11454. * Serialize current object to a JSON object
  11455. * @returns the serialized object
  11456. */
  11457. serialize(): any;
  11458. /** @hidden */
  11459. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11460. /**
  11461. * Creates a new SubEmitter from a serialized JSON version
  11462. * @param serializationObject defines the JSON object to read from
  11463. * @param scene defines the hosting scene
  11464. * @param rootUrl defines the rootUrl for data loading
  11465. * @returns a new SubEmitter
  11466. */
  11467. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11468. /** Release associated resources */
  11469. dispose(): void;
  11470. }
  11471. }
  11472. declare module BABYLON {
  11473. /** @hidden */
  11474. export var imageProcessingDeclaration: {
  11475. name: string;
  11476. shader: string;
  11477. };
  11478. }
  11479. declare module BABYLON {
  11480. /** @hidden */
  11481. export var imageProcessingFunctions: {
  11482. name: string;
  11483. shader: string;
  11484. };
  11485. }
  11486. declare module BABYLON {
  11487. /** @hidden */
  11488. export var particlesPixelShader: {
  11489. name: string;
  11490. shader: string;
  11491. };
  11492. }
  11493. declare module BABYLON {
  11494. /** @hidden */
  11495. export var particlesVertexShader: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module BABYLON {
  11501. /**
  11502. * This represents a particle system in Babylon.
  11503. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11504. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11505. * @example https://doc.babylonjs.com/babylon101/particles
  11506. */
  11507. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11508. /**
  11509. * Billboard mode will only apply to Y axis
  11510. */
  11511. static readonly BILLBOARDMODE_Y: number;
  11512. /**
  11513. * Billboard mode will apply to all axes
  11514. */
  11515. static readonly BILLBOARDMODE_ALL: number;
  11516. /**
  11517. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11518. */
  11519. static readonly BILLBOARDMODE_STRETCHED: number;
  11520. /**
  11521. * This function can be defined to provide custom update for active particles.
  11522. * This function will be called instead of regular update (age, position, color, etc.).
  11523. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11524. */
  11525. updateFunction: (particles: Particle[]) => void;
  11526. private _emitterWorldMatrix;
  11527. /**
  11528. * This function can be defined to specify initial direction for every new particle.
  11529. * It by default use the emitterType defined function
  11530. */
  11531. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11532. /**
  11533. * This function can be defined to specify initial position for every new particle.
  11534. * It by default use the emitterType defined function
  11535. */
  11536. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11537. /**
  11538. * @hidden
  11539. */
  11540. _inheritedVelocityOffset: Vector3;
  11541. /**
  11542. * An event triggered when the system is disposed
  11543. */
  11544. onDisposeObservable: Observable<ParticleSystem>;
  11545. private _onDisposeObserver;
  11546. /**
  11547. * Sets a callback that will be triggered when the system is disposed
  11548. */
  11549. set onDispose(callback: () => void);
  11550. private _particles;
  11551. private _epsilon;
  11552. private _capacity;
  11553. private _stockParticles;
  11554. private _newPartsExcess;
  11555. private _vertexData;
  11556. private _vertexBuffer;
  11557. private _vertexBuffers;
  11558. private _spriteBuffer;
  11559. private _indexBuffer;
  11560. private _effect;
  11561. private _customEffect;
  11562. private _cachedDefines;
  11563. private _scaledColorStep;
  11564. private _colorDiff;
  11565. private _scaledDirection;
  11566. private _scaledGravity;
  11567. private _currentRenderId;
  11568. private _alive;
  11569. private _useInstancing;
  11570. private _started;
  11571. private _stopped;
  11572. private _actualFrame;
  11573. private _scaledUpdateSpeed;
  11574. private _vertexBufferSize;
  11575. /** @hidden */
  11576. _currentEmitRateGradient: Nullable<FactorGradient>;
  11577. /** @hidden */
  11578. _currentEmitRate1: number;
  11579. /** @hidden */
  11580. _currentEmitRate2: number;
  11581. /** @hidden */
  11582. _currentStartSizeGradient: Nullable<FactorGradient>;
  11583. /** @hidden */
  11584. _currentStartSize1: number;
  11585. /** @hidden */
  11586. _currentStartSize2: number;
  11587. private readonly _rawTextureWidth;
  11588. private _rampGradientsTexture;
  11589. private _useRampGradients;
  11590. /** Gets or sets a boolean indicating that ramp gradients must be used
  11591. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11592. */
  11593. get useRampGradients(): boolean;
  11594. set useRampGradients(value: boolean);
  11595. /**
  11596. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  11597. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  11598. */
  11599. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11600. private _subEmitters;
  11601. /**
  11602. * @hidden
  11603. * If the particle systems emitter should be disposed when the particle system is disposed
  11604. */
  11605. _disposeEmitterOnDispose: boolean;
  11606. /**
  11607. * The current active Sub-systems, this property is used by the root particle system only.
  11608. */
  11609. activeSubSystems: Array<ParticleSystem>;
  11610. /**
  11611. * Specifies if the particles are updated in emitter local space or world space
  11612. */
  11613. isLocal: boolean;
  11614. private _rootParticleSystem;
  11615. /**
  11616. * Gets the current list of active particles
  11617. */
  11618. get particles(): Particle[];
  11619. /**
  11620. * Returns the string "ParticleSystem"
  11621. * @returns a string containing the class name
  11622. */
  11623. getClassName(): string;
  11624. /**
  11625. * Instantiates a particle system.
  11626. * 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.
  11627. * @param name The name of the particle system
  11628. * @param capacity The max number of particles alive at the same time
  11629. * @param scene The scene the particle system belongs to
  11630. * @param customEffect a custom effect used to change the way particles are rendered by default
  11631. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11632. * @param epsilon Offset used to render the particles
  11633. */
  11634. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11635. private _addFactorGradient;
  11636. private _removeFactorGradient;
  11637. /**
  11638. * Adds a new life time gradient
  11639. * @param gradient defines the gradient to use (between 0 and 1)
  11640. * @param factor defines the life time factor to affect to the specified gradient
  11641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11642. * @returns the current particle system
  11643. */
  11644. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11645. /**
  11646. * Remove a specific life time gradient
  11647. * @param gradient defines the gradient to remove
  11648. * @returns the current particle system
  11649. */
  11650. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11651. /**
  11652. * Adds a new size gradient
  11653. * @param gradient defines the gradient to use (between 0 and 1)
  11654. * @param factor defines the size factor to affect to the specified gradient
  11655. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11656. * @returns the current particle system
  11657. */
  11658. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11659. /**
  11660. * Remove a specific size gradient
  11661. * @param gradient defines the gradient to remove
  11662. * @returns the current particle system
  11663. */
  11664. removeSizeGradient(gradient: number): IParticleSystem;
  11665. /**
  11666. * Adds a new color remap gradient
  11667. * @param gradient defines the gradient to use (between 0 and 1)
  11668. * @param min defines the color remap minimal range
  11669. * @param max defines the color remap maximal range
  11670. * @returns the current particle system
  11671. */
  11672. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11673. /**
  11674. * Remove a specific color remap gradient
  11675. * @param gradient defines the gradient to remove
  11676. * @returns the current particle system
  11677. */
  11678. removeColorRemapGradient(gradient: number): IParticleSystem;
  11679. /**
  11680. * Adds a new alpha remap gradient
  11681. * @param gradient defines the gradient to use (between 0 and 1)
  11682. * @param min defines the alpha remap minimal range
  11683. * @param max defines the alpha remap maximal range
  11684. * @returns the current particle system
  11685. */
  11686. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11687. /**
  11688. * Remove a specific alpha remap gradient
  11689. * @param gradient defines the gradient to remove
  11690. * @returns the current particle system
  11691. */
  11692. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11693. /**
  11694. * Adds a new angular speed gradient
  11695. * @param gradient defines the gradient to use (between 0 and 1)
  11696. * @param factor defines the angular speed to affect to the specified gradient
  11697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11698. * @returns the current particle system
  11699. */
  11700. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11701. /**
  11702. * Remove a specific angular speed gradient
  11703. * @param gradient defines the gradient to remove
  11704. * @returns the current particle system
  11705. */
  11706. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11707. /**
  11708. * Adds a new velocity gradient
  11709. * @param gradient defines the gradient to use (between 0 and 1)
  11710. * @param factor defines the velocity to affect to the specified gradient
  11711. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11712. * @returns the current particle system
  11713. */
  11714. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11715. /**
  11716. * Remove a specific velocity gradient
  11717. * @param gradient defines the gradient to remove
  11718. * @returns the current particle system
  11719. */
  11720. removeVelocityGradient(gradient: number): IParticleSystem;
  11721. /**
  11722. * Adds a new limit velocity gradient
  11723. * @param gradient defines the gradient to use (between 0 and 1)
  11724. * @param factor defines the limit velocity value to affect to the specified gradient
  11725. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11726. * @returns the current particle system
  11727. */
  11728. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11729. /**
  11730. * Remove a specific limit velocity gradient
  11731. * @param gradient defines the gradient to remove
  11732. * @returns the current particle system
  11733. */
  11734. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11735. /**
  11736. * Adds a new drag gradient
  11737. * @param gradient defines the gradient to use (between 0 and 1)
  11738. * @param factor defines the drag value to affect to the specified gradient
  11739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11740. * @returns the current particle system
  11741. */
  11742. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11743. /**
  11744. * Remove a specific drag gradient
  11745. * @param gradient defines the gradient to remove
  11746. * @returns the current particle system
  11747. */
  11748. removeDragGradient(gradient: number): IParticleSystem;
  11749. /**
  11750. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11751. * @param gradient defines the gradient to use (between 0 and 1)
  11752. * @param factor defines the emit rate value to affect to the specified gradient
  11753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11754. * @returns the current particle system
  11755. */
  11756. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11757. /**
  11758. * Remove a specific emit rate gradient
  11759. * @param gradient defines the gradient to remove
  11760. * @returns the current particle system
  11761. */
  11762. removeEmitRateGradient(gradient: number): IParticleSystem;
  11763. /**
  11764. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11765. * @param gradient defines the gradient to use (between 0 and 1)
  11766. * @param factor defines the start size value to affect to the specified gradient
  11767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11768. * @returns the current particle system
  11769. */
  11770. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11771. /**
  11772. * Remove a specific start size gradient
  11773. * @param gradient defines the gradient to remove
  11774. * @returns the current particle system
  11775. */
  11776. removeStartSizeGradient(gradient: number): IParticleSystem;
  11777. private _createRampGradientTexture;
  11778. /**
  11779. * Gets the current list of ramp gradients.
  11780. * You must use addRampGradient and removeRampGradient to udpate this list
  11781. * @returns the list of ramp gradients
  11782. */
  11783. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11784. /**
  11785. * Adds a new ramp gradient used to remap particle colors
  11786. * @param gradient defines the gradient to use (between 0 and 1)
  11787. * @param color defines the color to affect to the specified gradient
  11788. * @returns the current particle system
  11789. */
  11790. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11791. /**
  11792. * Remove a specific ramp gradient
  11793. * @param gradient defines the gradient to remove
  11794. * @returns the current particle system
  11795. */
  11796. removeRampGradient(gradient: number): ParticleSystem;
  11797. /**
  11798. * Adds a new color gradient
  11799. * @param gradient defines the gradient to use (between 0 and 1)
  11800. * @param color1 defines the color to affect to the specified gradient
  11801. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11802. * @returns this particle system
  11803. */
  11804. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11805. /**
  11806. * Remove a specific color gradient
  11807. * @param gradient defines the gradient to remove
  11808. * @returns this particle system
  11809. */
  11810. removeColorGradient(gradient: number): IParticleSystem;
  11811. private _fetchR;
  11812. protected _reset(): void;
  11813. private _resetEffect;
  11814. private _createVertexBuffers;
  11815. private _createIndexBuffer;
  11816. /**
  11817. * Gets the maximum number of particles active at the same time.
  11818. * @returns The max number of active particles.
  11819. */
  11820. getCapacity(): number;
  11821. /**
  11822. * Gets whether there are still active particles in the system.
  11823. * @returns True if it is alive, otherwise false.
  11824. */
  11825. isAlive(): boolean;
  11826. /**
  11827. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11828. * @returns True if it has been started, otherwise false.
  11829. */
  11830. isStarted(): boolean;
  11831. private _prepareSubEmitterInternalArray;
  11832. /**
  11833. * Starts the particle system and begins to emit
  11834. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11835. */
  11836. start(delay?: number): void;
  11837. /**
  11838. * Stops the particle system.
  11839. * @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.
  11840. */
  11841. stop(stopSubEmitters?: boolean): void;
  11842. /**
  11843. * Remove all active particles
  11844. */
  11845. reset(): void;
  11846. /**
  11847. * @hidden (for internal use only)
  11848. */
  11849. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11850. /**
  11851. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11852. * Its lifetime will start back at 0.
  11853. */
  11854. recycleParticle: (particle: Particle) => void;
  11855. private _stopSubEmitters;
  11856. private _createParticle;
  11857. private _removeFromRoot;
  11858. private _emitFromParticle;
  11859. private _update;
  11860. /** @hidden */
  11861. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11862. /** @hidden */
  11863. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11864. /** @hidden */
  11865. private _getEffect;
  11866. /**
  11867. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11868. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11869. */
  11870. animate(preWarmOnly?: boolean): void;
  11871. private _appendParticleVertices;
  11872. /**
  11873. * Rebuilds the particle system.
  11874. */
  11875. rebuild(): void;
  11876. /**
  11877. * Is this system ready to be used/rendered
  11878. * @return true if the system is ready
  11879. */
  11880. isReady(): boolean;
  11881. private _render;
  11882. /**
  11883. * Renders the particle system in its current state.
  11884. * @returns the current number of particles
  11885. */
  11886. render(): number;
  11887. /**
  11888. * Disposes the particle system and free the associated resources
  11889. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11890. */
  11891. dispose(disposeTexture?: boolean): void;
  11892. /**
  11893. * Clones the particle system.
  11894. * @param name The name of the cloned object
  11895. * @param newEmitter The new emitter to use
  11896. * @returns the cloned particle system
  11897. */
  11898. clone(name: string, newEmitter: any): ParticleSystem;
  11899. /**
  11900. * Serializes the particle system to a JSON object.
  11901. * @returns the JSON object
  11902. */
  11903. serialize(): any;
  11904. /** @hidden */
  11905. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11906. /** @hidden */
  11907. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11908. /**
  11909. * Parses a JSON object to create a particle system.
  11910. * @param parsedParticleSystem The JSON object to parse
  11911. * @param scene The scene to create the particle system in
  11912. * @param rootUrl The root url to use to load external dependencies like texture
  11913. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11914. * @returns the Parsed particle system
  11915. */
  11916. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11917. }
  11918. }
  11919. declare module BABYLON {
  11920. /**
  11921. * A particle represents one of the element emitted by a particle system.
  11922. * This is mainly define by its coordinates, direction, velocity and age.
  11923. */
  11924. export class Particle {
  11925. /**
  11926. * The particle system the particle belongs to.
  11927. */
  11928. particleSystem: ParticleSystem;
  11929. private static _Count;
  11930. /**
  11931. * Unique ID of the particle
  11932. */
  11933. id: number;
  11934. /**
  11935. * The world position of the particle in the scene.
  11936. */
  11937. position: Vector3;
  11938. /**
  11939. * The world direction of the particle in the scene.
  11940. */
  11941. direction: Vector3;
  11942. /**
  11943. * The color of the particle.
  11944. */
  11945. color: Color4;
  11946. /**
  11947. * The color change of the particle per step.
  11948. */
  11949. colorStep: Color4;
  11950. /**
  11951. * Defines how long will the life of the particle be.
  11952. */
  11953. lifeTime: number;
  11954. /**
  11955. * The current age of the particle.
  11956. */
  11957. age: number;
  11958. /**
  11959. * The current size of the particle.
  11960. */
  11961. size: number;
  11962. /**
  11963. * The current scale of the particle.
  11964. */
  11965. scale: Vector2;
  11966. /**
  11967. * The current angle of the particle.
  11968. */
  11969. angle: number;
  11970. /**
  11971. * Defines how fast is the angle changing.
  11972. */
  11973. angularSpeed: number;
  11974. /**
  11975. * Defines the cell index used by the particle to be rendered from a sprite.
  11976. */
  11977. cellIndex: number;
  11978. /**
  11979. * The information required to support color remapping
  11980. */
  11981. remapData: Vector4;
  11982. /** @hidden */
  11983. _randomCellOffset?: number;
  11984. /** @hidden */
  11985. _initialDirection: Nullable<Vector3>;
  11986. /** @hidden */
  11987. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  11988. /** @hidden */
  11989. _initialStartSpriteCellID: number;
  11990. /** @hidden */
  11991. _initialEndSpriteCellID: number;
  11992. /** @hidden */
  11993. _currentColorGradient: Nullable<ColorGradient>;
  11994. /** @hidden */
  11995. _currentColor1: Color4;
  11996. /** @hidden */
  11997. _currentColor2: Color4;
  11998. /** @hidden */
  11999. _currentSizeGradient: Nullable<FactorGradient>;
  12000. /** @hidden */
  12001. _currentSize1: number;
  12002. /** @hidden */
  12003. _currentSize2: number;
  12004. /** @hidden */
  12005. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12006. /** @hidden */
  12007. _currentAngularSpeed1: number;
  12008. /** @hidden */
  12009. _currentAngularSpeed2: number;
  12010. /** @hidden */
  12011. _currentVelocityGradient: Nullable<FactorGradient>;
  12012. /** @hidden */
  12013. _currentVelocity1: number;
  12014. /** @hidden */
  12015. _currentVelocity2: number;
  12016. /** @hidden */
  12017. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12018. /** @hidden */
  12019. _currentLimitVelocity1: number;
  12020. /** @hidden */
  12021. _currentLimitVelocity2: number;
  12022. /** @hidden */
  12023. _currentDragGradient: Nullable<FactorGradient>;
  12024. /** @hidden */
  12025. _currentDrag1: number;
  12026. /** @hidden */
  12027. _currentDrag2: number;
  12028. /** @hidden */
  12029. _randomNoiseCoordinates1: Vector3;
  12030. /** @hidden */
  12031. _randomNoiseCoordinates2: Vector3;
  12032. /** @hidden */
  12033. _localPosition?: Vector3;
  12034. /**
  12035. * Creates a new instance Particle
  12036. * @param particleSystem the particle system the particle belongs to
  12037. */
  12038. constructor(
  12039. /**
  12040. * The particle system the particle belongs to.
  12041. */
  12042. particleSystem: ParticleSystem);
  12043. private updateCellInfoFromSystem;
  12044. /**
  12045. * Defines how the sprite cell index is updated for the particle
  12046. */
  12047. updateCellIndex(): void;
  12048. /** @hidden */
  12049. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12050. /** @hidden */
  12051. _inheritParticleInfoToSubEmitters(): void;
  12052. /** @hidden */
  12053. _reset(): void;
  12054. /**
  12055. * Copy the properties of particle to another one.
  12056. * @param other the particle to copy the information to.
  12057. */
  12058. copyTo(other: Particle): void;
  12059. }
  12060. }
  12061. declare module BABYLON {
  12062. /**
  12063. * Particle emitter represents a volume emitting particles.
  12064. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12065. */
  12066. export interface IParticleEmitterType {
  12067. /**
  12068. * Called by the particle System when the direction is computed for the created particle.
  12069. * @param worldMatrix is the world matrix of the particle system
  12070. * @param directionToUpdate is the direction vector to update with the result
  12071. * @param particle is the particle we are computed the direction for
  12072. * @param isLocal defines if the direction should be set in local space
  12073. */
  12074. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12075. /**
  12076. * Called by the particle System when the position is computed for the created particle.
  12077. * @param worldMatrix is the world matrix of the particle system
  12078. * @param positionToUpdate is the position vector to update with the result
  12079. * @param particle is the particle we are computed the position for
  12080. * @param isLocal defines if the position should be set in local space
  12081. */
  12082. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12083. /**
  12084. * Clones the current emitter and returns a copy of it
  12085. * @returns the new emitter
  12086. */
  12087. clone(): IParticleEmitterType;
  12088. /**
  12089. * Called by the GPUParticleSystem to setup the update shader
  12090. * @param effect defines the update shader
  12091. */
  12092. applyToShader(effect: Effect): void;
  12093. /**
  12094. * Returns a string to use to update the GPU particles update shader
  12095. * @returns the effect defines string
  12096. */
  12097. getEffectDefines(): string;
  12098. /**
  12099. * Returns a string representing the class name
  12100. * @returns a string containing the class name
  12101. */
  12102. getClassName(): string;
  12103. /**
  12104. * Serializes the particle system to a JSON object.
  12105. * @returns the JSON object
  12106. */
  12107. serialize(): any;
  12108. /**
  12109. * Parse properties from a JSON object
  12110. * @param serializationObject defines the JSON object
  12111. * @param scene defines the hosting scene
  12112. */
  12113. parse(serializationObject: any, scene: Scene): void;
  12114. }
  12115. }
  12116. declare module BABYLON {
  12117. /**
  12118. * Particle emitter emitting particles from the inside of a box.
  12119. * It emits the particles randomly between 2 given directions.
  12120. */
  12121. export class BoxParticleEmitter implements IParticleEmitterType {
  12122. /**
  12123. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12124. */
  12125. direction1: Vector3;
  12126. /**
  12127. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12128. */
  12129. direction2: Vector3;
  12130. /**
  12131. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12132. */
  12133. minEmitBox: Vector3;
  12134. /**
  12135. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12136. */
  12137. maxEmitBox: Vector3;
  12138. /**
  12139. * Creates a new instance BoxParticleEmitter
  12140. */
  12141. constructor();
  12142. /**
  12143. * Called by the particle System when the direction is computed for the created particle.
  12144. * @param worldMatrix is the world matrix of the particle system
  12145. * @param directionToUpdate is the direction vector to update with the result
  12146. * @param particle is the particle we are computed the direction for
  12147. * @param isLocal defines if the direction should be set in local space
  12148. */
  12149. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12150. /**
  12151. * Called by the particle System when the position is computed for the created particle.
  12152. * @param worldMatrix is the world matrix of the particle system
  12153. * @param positionToUpdate is the position vector to update with the result
  12154. * @param particle is the particle we are computed the position for
  12155. * @param isLocal defines if the position should be set in local space
  12156. */
  12157. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12158. /**
  12159. * Clones the current emitter and returns a copy of it
  12160. * @returns the new emitter
  12161. */
  12162. clone(): BoxParticleEmitter;
  12163. /**
  12164. * Called by the GPUParticleSystem to setup the update shader
  12165. * @param effect defines the update shader
  12166. */
  12167. applyToShader(effect: Effect): void;
  12168. /**
  12169. * Returns a string to use to update the GPU particles update shader
  12170. * @returns a string containng the defines string
  12171. */
  12172. getEffectDefines(): string;
  12173. /**
  12174. * Returns the string "BoxParticleEmitter"
  12175. * @returns a string containing the class name
  12176. */
  12177. getClassName(): string;
  12178. /**
  12179. * Serializes the particle system to a JSON object.
  12180. * @returns the JSON object
  12181. */
  12182. serialize(): any;
  12183. /**
  12184. * Parse properties from a JSON object
  12185. * @param serializationObject defines the JSON object
  12186. */
  12187. parse(serializationObject: any): void;
  12188. }
  12189. }
  12190. declare module BABYLON {
  12191. /**
  12192. * Particle emitter emitting particles from the inside of a cone.
  12193. * It emits the particles alongside the cone volume from the base to the particle.
  12194. * The emission direction might be randomized.
  12195. */
  12196. export class ConeParticleEmitter implements IParticleEmitterType {
  12197. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12198. directionRandomizer: number;
  12199. private _radius;
  12200. private _angle;
  12201. private _height;
  12202. /**
  12203. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12204. */
  12205. radiusRange: number;
  12206. /**
  12207. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12208. */
  12209. heightRange: number;
  12210. /**
  12211. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12212. */
  12213. emitFromSpawnPointOnly: boolean;
  12214. /**
  12215. * Gets or sets the radius of the emission cone
  12216. */
  12217. get radius(): number;
  12218. set radius(value: number);
  12219. /**
  12220. * Gets or sets the angle of the emission cone
  12221. */
  12222. get angle(): number;
  12223. set angle(value: number);
  12224. private _buildHeight;
  12225. /**
  12226. * Creates a new instance ConeParticleEmitter
  12227. * @param radius the radius of the emission cone (1 by default)
  12228. * @param angle the cone base angle (PI by default)
  12229. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12230. */
  12231. constructor(radius?: number, angle?: number,
  12232. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12233. directionRandomizer?: number);
  12234. /**
  12235. * Called by the particle System when the direction is computed for the created particle.
  12236. * @param worldMatrix is the world matrix of the particle system
  12237. * @param directionToUpdate is the direction vector to update with the result
  12238. * @param particle is the particle we are computed the direction for
  12239. * @param isLocal defines if the direction should be set in local space
  12240. */
  12241. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12242. /**
  12243. * Called by the particle System when the position is computed for the created particle.
  12244. * @param worldMatrix is the world matrix of the particle system
  12245. * @param positionToUpdate is the position vector to update with the result
  12246. * @param particle is the particle we are computed the position for
  12247. * @param isLocal defines if the position should be set in local space
  12248. */
  12249. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12250. /**
  12251. * Clones the current emitter and returns a copy of it
  12252. * @returns the new emitter
  12253. */
  12254. clone(): ConeParticleEmitter;
  12255. /**
  12256. * Called by the GPUParticleSystem to setup the update shader
  12257. * @param effect defines the update shader
  12258. */
  12259. applyToShader(effect: Effect): void;
  12260. /**
  12261. * Returns a string to use to update the GPU particles update shader
  12262. * @returns a string containng the defines string
  12263. */
  12264. getEffectDefines(): string;
  12265. /**
  12266. * Returns the string "ConeParticleEmitter"
  12267. * @returns a string containing the class name
  12268. */
  12269. getClassName(): string;
  12270. /**
  12271. * Serializes the particle system to a JSON object.
  12272. * @returns the JSON object
  12273. */
  12274. serialize(): any;
  12275. /**
  12276. * Parse properties from a JSON object
  12277. * @param serializationObject defines the JSON object
  12278. */
  12279. parse(serializationObject: any): void;
  12280. }
  12281. }
  12282. declare module BABYLON {
  12283. /**
  12284. * Particle emitter emitting particles from the inside of a cylinder.
  12285. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12286. */
  12287. export class CylinderParticleEmitter implements IParticleEmitterType {
  12288. /**
  12289. * The radius of the emission cylinder.
  12290. */
  12291. radius: number;
  12292. /**
  12293. * The height of the emission cylinder.
  12294. */
  12295. height: number;
  12296. /**
  12297. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12298. */
  12299. radiusRange: number;
  12300. /**
  12301. * How much to randomize the particle direction [0-1].
  12302. */
  12303. directionRandomizer: number;
  12304. /**
  12305. * Creates a new instance CylinderParticleEmitter
  12306. * @param radius the radius of the emission cylinder (1 by default)
  12307. * @param height the height of the emission cylinder (1 by default)
  12308. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12309. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12310. */
  12311. constructor(
  12312. /**
  12313. * The radius of the emission cylinder.
  12314. */
  12315. radius?: number,
  12316. /**
  12317. * The height of the emission cylinder.
  12318. */
  12319. height?: number,
  12320. /**
  12321. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12322. */
  12323. radiusRange?: number,
  12324. /**
  12325. * How much to randomize the particle direction [0-1].
  12326. */
  12327. directionRandomizer?: number);
  12328. /**
  12329. * Called by the particle System when the direction is computed for the created particle.
  12330. * @param worldMatrix is the world matrix of the particle system
  12331. * @param directionToUpdate is the direction vector to update with the result
  12332. * @param particle is the particle we are computed the direction for
  12333. * @param isLocal defines if the direction should be set in local space
  12334. */
  12335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12336. /**
  12337. * Called by the particle System when the position is computed for the created particle.
  12338. * @param worldMatrix is the world matrix of the particle system
  12339. * @param positionToUpdate is the position vector to update with the result
  12340. * @param particle is the particle we are computed the position for
  12341. * @param isLocal defines if the position should be set in local space
  12342. */
  12343. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12344. /**
  12345. * Clones the current emitter and returns a copy of it
  12346. * @returns the new emitter
  12347. */
  12348. clone(): CylinderParticleEmitter;
  12349. /**
  12350. * Called by the GPUParticleSystem to setup the update shader
  12351. * @param effect defines the update shader
  12352. */
  12353. applyToShader(effect: Effect): void;
  12354. /**
  12355. * Returns a string to use to update the GPU particles update shader
  12356. * @returns a string containng the defines string
  12357. */
  12358. getEffectDefines(): string;
  12359. /**
  12360. * Returns the string "CylinderParticleEmitter"
  12361. * @returns a string containing the class name
  12362. */
  12363. getClassName(): string;
  12364. /**
  12365. * Serializes the particle system to a JSON object.
  12366. * @returns the JSON object
  12367. */
  12368. serialize(): any;
  12369. /**
  12370. * Parse properties from a JSON object
  12371. * @param serializationObject defines the JSON object
  12372. */
  12373. parse(serializationObject: any): void;
  12374. }
  12375. /**
  12376. * Particle emitter emitting particles from the inside of a cylinder.
  12377. * It emits the particles randomly between two vectors.
  12378. */
  12379. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12380. /**
  12381. * The min limit of the emission direction.
  12382. */
  12383. direction1: Vector3;
  12384. /**
  12385. * The max limit of the emission direction.
  12386. */
  12387. direction2: Vector3;
  12388. /**
  12389. * Creates a new instance CylinderDirectedParticleEmitter
  12390. * @param radius the radius of the emission cylinder (1 by default)
  12391. * @param height the height of the emission cylinder (1 by default)
  12392. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12393. * @param direction1 the min limit of the emission direction (up vector by default)
  12394. * @param direction2 the max limit of the emission direction (up vector by default)
  12395. */
  12396. constructor(radius?: number, height?: number, radiusRange?: number,
  12397. /**
  12398. * The min limit of the emission direction.
  12399. */
  12400. direction1?: Vector3,
  12401. /**
  12402. * The max limit of the emission direction.
  12403. */
  12404. direction2?: Vector3);
  12405. /**
  12406. * Called by the particle System when the direction is computed for the created particle.
  12407. * @param worldMatrix is the world matrix of the particle system
  12408. * @param directionToUpdate is the direction vector to update with the result
  12409. * @param particle is the particle we are computed the direction for
  12410. */
  12411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12412. /**
  12413. * Clones the current emitter and returns a copy of it
  12414. * @returns the new emitter
  12415. */
  12416. clone(): CylinderDirectedParticleEmitter;
  12417. /**
  12418. * Called by the GPUParticleSystem to setup the update shader
  12419. * @param effect defines the update shader
  12420. */
  12421. applyToShader(effect: Effect): void;
  12422. /**
  12423. * Returns a string to use to update the GPU particles update shader
  12424. * @returns a string containng the defines string
  12425. */
  12426. getEffectDefines(): string;
  12427. /**
  12428. * Returns the string "CylinderDirectedParticleEmitter"
  12429. * @returns a string containing the class name
  12430. */
  12431. getClassName(): string;
  12432. /**
  12433. * Serializes the particle system to a JSON object.
  12434. * @returns the JSON object
  12435. */
  12436. serialize(): any;
  12437. /**
  12438. * Parse properties from a JSON object
  12439. * @param serializationObject defines the JSON object
  12440. */
  12441. parse(serializationObject: any): void;
  12442. }
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * Particle emitter emitting particles from the inside of a hemisphere.
  12447. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12448. */
  12449. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12450. /**
  12451. * The radius of the emission hemisphere.
  12452. */
  12453. radius: number;
  12454. /**
  12455. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12456. */
  12457. radiusRange: number;
  12458. /**
  12459. * How much to randomize the particle direction [0-1].
  12460. */
  12461. directionRandomizer: number;
  12462. /**
  12463. * Creates a new instance HemisphericParticleEmitter
  12464. * @param radius the radius of the emission hemisphere (1 by default)
  12465. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12466. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12467. */
  12468. constructor(
  12469. /**
  12470. * The radius of the emission hemisphere.
  12471. */
  12472. radius?: number,
  12473. /**
  12474. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12475. */
  12476. radiusRange?: number,
  12477. /**
  12478. * How much to randomize the particle direction [0-1].
  12479. */
  12480. directionRandomizer?: number);
  12481. /**
  12482. * Called by the particle System when the direction is computed for the created particle.
  12483. * @param worldMatrix is the world matrix of the particle system
  12484. * @param directionToUpdate is the direction vector to update with the result
  12485. * @param particle is the particle we are computed the direction for
  12486. * @param isLocal defines if the direction should be set in local space
  12487. */
  12488. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12489. /**
  12490. * Called by the particle System when the position is computed for the created particle.
  12491. * @param worldMatrix is the world matrix of the particle system
  12492. * @param positionToUpdate is the position vector to update with the result
  12493. * @param particle is the particle we are computed the position for
  12494. * @param isLocal defines if the position should be set in local space
  12495. */
  12496. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12497. /**
  12498. * Clones the current emitter and returns a copy of it
  12499. * @returns the new emitter
  12500. */
  12501. clone(): HemisphericParticleEmitter;
  12502. /**
  12503. * Called by the GPUParticleSystem to setup the update shader
  12504. * @param effect defines the update shader
  12505. */
  12506. applyToShader(effect: Effect): void;
  12507. /**
  12508. * Returns a string to use to update the GPU particles update shader
  12509. * @returns a string containng the defines string
  12510. */
  12511. getEffectDefines(): string;
  12512. /**
  12513. * Returns the string "HemisphericParticleEmitter"
  12514. * @returns a string containing the class name
  12515. */
  12516. getClassName(): string;
  12517. /**
  12518. * Serializes the particle system to a JSON object.
  12519. * @returns the JSON object
  12520. */
  12521. serialize(): any;
  12522. /**
  12523. * Parse properties from a JSON object
  12524. * @param serializationObject defines the JSON object
  12525. */
  12526. parse(serializationObject: any): void;
  12527. }
  12528. }
  12529. declare module BABYLON {
  12530. /**
  12531. * Particle emitter emitting particles from a point.
  12532. * It emits the particles randomly between 2 given directions.
  12533. */
  12534. export class PointParticleEmitter implements IParticleEmitterType {
  12535. /**
  12536. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12537. */
  12538. direction1: Vector3;
  12539. /**
  12540. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12541. */
  12542. direction2: Vector3;
  12543. /**
  12544. * Creates a new instance PointParticleEmitter
  12545. */
  12546. constructor();
  12547. /**
  12548. * Called by the particle System when the direction is computed for the created particle.
  12549. * @param worldMatrix is the world matrix of the particle system
  12550. * @param directionToUpdate is the direction vector to update with the result
  12551. * @param particle is the particle we are computed the direction for
  12552. * @param isLocal defines if the direction should be set in local space
  12553. */
  12554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12555. /**
  12556. * Called by the particle System when the position is computed for the created particle.
  12557. * @param worldMatrix is the world matrix of the particle system
  12558. * @param positionToUpdate is the position vector to update with the result
  12559. * @param particle is the particle we are computed the position for
  12560. * @param isLocal defines if the position should be set in local space
  12561. */
  12562. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12563. /**
  12564. * Clones the current emitter and returns a copy of it
  12565. * @returns the new emitter
  12566. */
  12567. clone(): PointParticleEmitter;
  12568. /**
  12569. * Called by the GPUParticleSystem to setup the update shader
  12570. * @param effect defines the update shader
  12571. */
  12572. applyToShader(effect: Effect): void;
  12573. /**
  12574. * Returns a string to use to update the GPU particles update shader
  12575. * @returns a string containng the defines string
  12576. */
  12577. getEffectDefines(): string;
  12578. /**
  12579. * Returns the string "PointParticleEmitter"
  12580. * @returns a string containing the class name
  12581. */
  12582. getClassName(): string;
  12583. /**
  12584. * Serializes the particle system to a JSON object.
  12585. * @returns the JSON object
  12586. */
  12587. serialize(): any;
  12588. /**
  12589. * Parse properties from a JSON object
  12590. * @param serializationObject defines the JSON object
  12591. */
  12592. parse(serializationObject: any): void;
  12593. }
  12594. }
  12595. declare module BABYLON {
  12596. /**
  12597. * Particle emitter emitting particles from the inside of a sphere.
  12598. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12599. */
  12600. export class SphereParticleEmitter implements IParticleEmitterType {
  12601. /**
  12602. * The radius of the emission sphere.
  12603. */
  12604. radius: number;
  12605. /**
  12606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12607. */
  12608. radiusRange: number;
  12609. /**
  12610. * How much to randomize the particle direction [0-1].
  12611. */
  12612. directionRandomizer: number;
  12613. /**
  12614. * Creates a new instance SphereParticleEmitter
  12615. * @param radius the radius of the emission sphere (1 by default)
  12616. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12617. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12618. */
  12619. constructor(
  12620. /**
  12621. * The radius of the emission sphere.
  12622. */
  12623. radius?: number,
  12624. /**
  12625. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12626. */
  12627. radiusRange?: number,
  12628. /**
  12629. * How much to randomize the particle direction [0-1].
  12630. */
  12631. directionRandomizer?: number);
  12632. /**
  12633. * Called by the particle System when the direction is computed for the created particle.
  12634. * @param worldMatrix is the world matrix of the particle system
  12635. * @param directionToUpdate is the direction vector to update with the result
  12636. * @param particle is the particle we are computed the direction for
  12637. * @param isLocal defines if the direction should be set in local space
  12638. */
  12639. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12640. /**
  12641. * Called by the particle System when the position is computed for the created particle.
  12642. * @param worldMatrix is the world matrix of the particle system
  12643. * @param positionToUpdate is the position vector to update with the result
  12644. * @param particle is the particle we are computed the position for
  12645. * @param isLocal defines if the position should be set in local space
  12646. */
  12647. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12648. /**
  12649. * Clones the current emitter and returns a copy of it
  12650. * @returns the new emitter
  12651. */
  12652. clone(): SphereParticleEmitter;
  12653. /**
  12654. * Called by the GPUParticleSystem to setup the update shader
  12655. * @param effect defines the update shader
  12656. */
  12657. applyToShader(effect: Effect): void;
  12658. /**
  12659. * Returns a string to use to update the GPU particles update shader
  12660. * @returns a string containng the defines string
  12661. */
  12662. getEffectDefines(): string;
  12663. /**
  12664. * Returns the string "SphereParticleEmitter"
  12665. * @returns a string containing the class name
  12666. */
  12667. getClassName(): string;
  12668. /**
  12669. * Serializes the particle system to a JSON object.
  12670. * @returns the JSON object
  12671. */
  12672. serialize(): any;
  12673. /**
  12674. * Parse properties from a JSON object
  12675. * @param serializationObject defines the JSON object
  12676. */
  12677. parse(serializationObject: any): void;
  12678. }
  12679. /**
  12680. * Particle emitter emitting particles from the inside of a sphere.
  12681. * It emits the particles randomly between two vectors.
  12682. */
  12683. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12684. /**
  12685. * The min limit of the emission direction.
  12686. */
  12687. direction1: Vector3;
  12688. /**
  12689. * The max limit of the emission direction.
  12690. */
  12691. direction2: Vector3;
  12692. /**
  12693. * Creates a new instance SphereDirectedParticleEmitter
  12694. * @param radius the radius of the emission sphere (1 by default)
  12695. * @param direction1 the min limit of the emission direction (up vector by default)
  12696. * @param direction2 the max limit of the emission direction (up vector by default)
  12697. */
  12698. constructor(radius?: number,
  12699. /**
  12700. * The min limit of the emission direction.
  12701. */
  12702. direction1?: Vector3,
  12703. /**
  12704. * The max limit of the emission direction.
  12705. */
  12706. direction2?: Vector3);
  12707. /**
  12708. * Called by the particle System when the direction is computed for the created particle.
  12709. * @param worldMatrix is the world matrix of the particle system
  12710. * @param directionToUpdate is the direction vector to update with the result
  12711. * @param particle is the particle we are computed the direction for
  12712. */
  12713. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12714. /**
  12715. * Clones the current emitter and returns a copy of it
  12716. * @returns the new emitter
  12717. */
  12718. clone(): SphereDirectedParticleEmitter;
  12719. /**
  12720. * Called by the GPUParticleSystem to setup the update shader
  12721. * @param effect defines the update shader
  12722. */
  12723. applyToShader(effect: Effect): void;
  12724. /**
  12725. * Returns a string to use to update the GPU particles update shader
  12726. * @returns a string containng the defines string
  12727. */
  12728. getEffectDefines(): string;
  12729. /**
  12730. * Returns the string "SphereDirectedParticleEmitter"
  12731. * @returns a string containing the class name
  12732. */
  12733. getClassName(): string;
  12734. /**
  12735. * Serializes the particle system to a JSON object.
  12736. * @returns the JSON object
  12737. */
  12738. serialize(): any;
  12739. /**
  12740. * Parse properties from a JSON object
  12741. * @param serializationObject defines the JSON object
  12742. */
  12743. parse(serializationObject: any): void;
  12744. }
  12745. }
  12746. declare module BABYLON {
  12747. /**
  12748. * Particle emitter emitting particles from a custom list of positions.
  12749. */
  12750. export class CustomParticleEmitter implements IParticleEmitterType {
  12751. /**
  12752. * Gets or sets the position generator that will create the inital position of each particle.
  12753. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12754. */
  12755. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12756. /**
  12757. * Gets or sets the destination generator that will create the final destination of each particle.
  12758. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12759. */
  12760. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12761. /**
  12762. * Creates a new instance CustomParticleEmitter
  12763. */
  12764. constructor();
  12765. /**
  12766. * Called by the particle System when the direction is computed for the created particle.
  12767. * @param worldMatrix is the world matrix of the particle system
  12768. * @param directionToUpdate is the direction vector to update with the result
  12769. * @param particle is the particle we are computed the direction for
  12770. * @param isLocal defines if the direction should be set in local space
  12771. */
  12772. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12773. /**
  12774. * Called by the particle System when the position is computed for the created particle.
  12775. * @param worldMatrix is the world matrix of the particle system
  12776. * @param positionToUpdate is the position vector to update with the result
  12777. * @param particle is the particle we are computed the position for
  12778. * @param isLocal defines if the position should be set in local space
  12779. */
  12780. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12781. /**
  12782. * Clones the current emitter and returns a copy of it
  12783. * @returns the new emitter
  12784. */
  12785. clone(): CustomParticleEmitter;
  12786. /**
  12787. * Called by the GPUParticleSystem to setup the update shader
  12788. * @param effect defines the update shader
  12789. */
  12790. applyToShader(effect: Effect): void;
  12791. /**
  12792. * Returns a string to use to update the GPU particles update shader
  12793. * @returns a string containng the defines string
  12794. */
  12795. getEffectDefines(): string;
  12796. /**
  12797. * Returns the string "PointParticleEmitter"
  12798. * @returns a string containing the class name
  12799. */
  12800. getClassName(): string;
  12801. /**
  12802. * Serializes the particle system to a JSON object.
  12803. * @returns the JSON object
  12804. */
  12805. serialize(): any;
  12806. /**
  12807. * Parse properties from a JSON object
  12808. * @param serializationObject defines the JSON object
  12809. */
  12810. parse(serializationObject: any): void;
  12811. }
  12812. }
  12813. declare module BABYLON {
  12814. /**
  12815. * Particle emitter emitting particles from the inside of a box.
  12816. * It emits the particles randomly between 2 given directions.
  12817. */
  12818. export class MeshParticleEmitter implements IParticleEmitterType {
  12819. /** Defines the mesh to use as source */
  12820. mesh?: AbstractMesh | undefined;
  12821. private _indices;
  12822. private _positions;
  12823. private _normals;
  12824. private _storedNormal;
  12825. /**
  12826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12827. */
  12828. direction1: Vector3;
  12829. /**
  12830. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12831. */
  12832. direction2: Vector3;
  12833. /**
  12834. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12835. */
  12836. useMeshNormalsForDirection: boolean;
  12837. /**
  12838. * Creates a new instance MeshParticleEmitter
  12839. * @param mesh defines the mesh to use as source
  12840. */
  12841. constructor(
  12842. /** Defines the mesh to use as source */
  12843. mesh?: AbstractMesh | undefined);
  12844. /**
  12845. * Called by the particle System when the direction is computed for the created particle.
  12846. * @param worldMatrix is the world matrix of the particle system
  12847. * @param directionToUpdate is the direction vector to update with the result
  12848. * @param particle is the particle we are computed the direction for
  12849. * @param isLocal defines if the direction should be set in local space
  12850. */
  12851. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12852. /**
  12853. * Called by the particle System when the position is computed for the created particle.
  12854. * @param worldMatrix is the world matrix of the particle system
  12855. * @param positionToUpdate is the position vector to update with the result
  12856. * @param particle is the particle we are computed the position for
  12857. * @param isLocal defines if the position should be set in local space
  12858. */
  12859. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12860. /**
  12861. * Clones the current emitter and returns a copy of it
  12862. * @returns the new emitter
  12863. */
  12864. clone(): MeshParticleEmitter;
  12865. /**
  12866. * Called by the GPUParticleSystem to setup the update shader
  12867. * @param effect defines the update shader
  12868. */
  12869. applyToShader(effect: Effect): void;
  12870. /**
  12871. * Returns a string to use to update the GPU particles update shader
  12872. * @returns a string containng the defines string
  12873. */
  12874. getEffectDefines(): string;
  12875. /**
  12876. * Returns the string "BoxParticleEmitter"
  12877. * @returns a string containing the class name
  12878. */
  12879. getClassName(): string;
  12880. /**
  12881. * Serializes the particle system to a JSON object.
  12882. * @returns the JSON object
  12883. */
  12884. serialize(): any;
  12885. /**
  12886. * Parse properties from a JSON object
  12887. * @param serializationObject defines the JSON object
  12888. * @param scene defines the hosting scene
  12889. */
  12890. parse(serializationObject: any, scene: Scene): void;
  12891. }
  12892. }
  12893. declare module BABYLON {
  12894. /**
  12895. * Interface representing a particle system in Babylon.js.
  12896. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12897. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12898. */
  12899. export interface IParticleSystem {
  12900. /**
  12901. * List of animations used by the particle system.
  12902. */
  12903. animations: Animation[];
  12904. /**
  12905. * The id of the Particle system.
  12906. */
  12907. id: string;
  12908. /**
  12909. * The name of the Particle system.
  12910. */
  12911. name: string;
  12912. /**
  12913. * The emitter represents the Mesh or position we are attaching the particle system to.
  12914. */
  12915. emitter: Nullable<AbstractMesh | Vector3>;
  12916. /**
  12917. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12918. */
  12919. isBillboardBased: boolean;
  12920. /**
  12921. * The rendering group used by the Particle system to chose when to render.
  12922. */
  12923. renderingGroupId: number;
  12924. /**
  12925. * The layer mask we are rendering the particles through.
  12926. */
  12927. layerMask: number;
  12928. /**
  12929. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12930. */
  12931. updateSpeed: number;
  12932. /**
  12933. * The amount of time the particle system is running (depends of the overall update speed).
  12934. */
  12935. targetStopDuration: number;
  12936. /**
  12937. * The texture used to render each particle. (this can be a spritesheet)
  12938. */
  12939. particleTexture: Nullable<Texture>;
  12940. /**
  12941. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12942. */
  12943. blendMode: number;
  12944. /**
  12945. * Minimum life time of emitting particles.
  12946. */
  12947. minLifeTime: number;
  12948. /**
  12949. * Maximum life time of emitting particles.
  12950. */
  12951. maxLifeTime: number;
  12952. /**
  12953. * Minimum Size of emitting particles.
  12954. */
  12955. minSize: number;
  12956. /**
  12957. * Maximum Size of emitting particles.
  12958. */
  12959. maxSize: number;
  12960. /**
  12961. * Minimum scale of emitting particles on X axis.
  12962. */
  12963. minScaleX: number;
  12964. /**
  12965. * Maximum scale of emitting particles on X axis.
  12966. */
  12967. maxScaleX: number;
  12968. /**
  12969. * Minimum scale of emitting particles on Y axis.
  12970. */
  12971. minScaleY: number;
  12972. /**
  12973. * Maximum scale of emitting particles on Y axis.
  12974. */
  12975. maxScaleY: number;
  12976. /**
  12977. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12978. */
  12979. color1: Color4;
  12980. /**
  12981. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12982. */
  12983. color2: Color4;
  12984. /**
  12985. * Color the particle will have at the end of its lifetime.
  12986. */
  12987. colorDead: Color4;
  12988. /**
  12989. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  12990. */
  12991. emitRate: number;
  12992. /**
  12993. * You can use gravity if you want to give an orientation to your particles.
  12994. */
  12995. gravity: Vector3;
  12996. /**
  12997. * Minimum power of emitting particles.
  12998. */
  12999. minEmitPower: number;
  13000. /**
  13001. * Maximum power of emitting particles.
  13002. */
  13003. maxEmitPower: number;
  13004. /**
  13005. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13006. */
  13007. minAngularSpeed: number;
  13008. /**
  13009. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13010. */
  13011. maxAngularSpeed: number;
  13012. /**
  13013. * Gets or sets the minimal initial rotation in radians.
  13014. */
  13015. minInitialRotation: number;
  13016. /**
  13017. * Gets or sets the maximal initial rotation in radians.
  13018. */
  13019. maxInitialRotation: number;
  13020. /**
  13021. * The particle emitter type defines the emitter used by the particle system.
  13022. * It can be for example box, sphere, or cone...
  13023. */
  13024. particleEmitterType: Nullable<IParticleEmitterType>;
  13025. /**
  13026. * Defines the delay in milliseconds before starting the system (0 by default)
  13027. */
  13028. startDelay: number;
  13029. /**
  13030. * 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
  13031. */
  13032. preWarmCycles: number;
  13033. /**
  13034. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13035. */
  13036. preWarmStepOffset: number;
  13037. /**
  13038. * 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)
  13039. */
  13040. spriteCellChangeSpeed: number;
  13041. /**
  13042. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13043. */
  13044. startSpriteCellID: number;
  13045. /**
  13046. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13047. */
  13048. endSpriteCellID: number;
  13049. /**
  13050. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13051. */
  13052. spriteCellWidth: number;
  13053. /**
  13054. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13055. */
  13056. spriteCellHeight: number;
  13057. /**
  13058. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13059. */
  13060. spriteRandomStartCell: boolean;
  13061. /**
  13062. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13063. */
  13064. isAnimationSheetEnabled: boolean;
  13065. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13066. translationPivot: Vector2;
  13067. /**
  13068. * Gets or sets a texture used to add random noise to particle positions
  13069. */
  13070. noiseTexture: Nullable<BaseTexture>;
  13071. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13072. noiseStrength: Vector3;
  13073. /**
  13074. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13075. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13076. */
  13077. billboardMode: number;
  13078. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13079. limitVelocityDamping: number;
  13080. /**
  13081. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13082. */
  13083. beginAnimationOnStart: boolean;
  13084. /**
  13085. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13086. */
  13087. beginAnimationFrom: number;
  13088. /**
  13089. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13090. */
  13091. beginAnimationTo: number;
  13092. /**
  13093. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13094. */
  13095. beginAnimationLoop: boolean;
  13096. /**
  13097. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13098. */
  13099. disposeOnStop: boolean;
  13100. /**
  13101. * Specifies if the particles are updated in emitter local space or world space
  13102. */
  13103. isLocal: boolean;
  13104. /**
  13105. * Gets the maximum number of particles active at the same time.
  13106. * @returns The max number of active particles.
  13107. */
  13108. getCapacity(): number;
  13109. /**
  13110. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13111. * @returns True if it has been started, otherwise false.
  13112. */
  13113. isStarted(): boolean;
  13114. /**
  13115. * Animates the particle system for this frame.
  13116. */
  13117. animate(): void;
  13118. /**
  13119. * Renders the particle system in its current state.
  13120. * @returns the current number of particles
  13121. */
  13122. render(): number;
  13123. /**
  13124. * Dispose the particle system and frees its associated resources.
  13125. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13126. */
  13127. dispose(disposeTexture?: boolean): void;
  13128. /**
  13129. * Clones the particle system.
  13130. * @param name The name of the cloned object
  13131. * @param newEmitter The new emitter to use
  13132. * @returns the cloned particle system
  13133. */
  13134. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13135. /**
  13136. * Serializes the particle system to a JSON object.
  13137. * @returns the JSON object
  13138. */
  13139. serialize(): any;
  13140. /**
  13141. * Rebuild the particle system
  13142. */
  13143. rebuild(): void;
  13144. /**
  13145. * Starts the particle system and begins to emit
  13146. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13147. */
  13148. start(delay?: number): void;
  13149. /**
  13150. * Stops the particle system.
  13151. */
  13152. stop(): void;
  13153. /**
  13154. * Remove all active particles
  13155. */
  13156. reset(): void;
  13157. /**
  13158. * Is this system ready to be used/rendered
  13159. * @return true if the system is ready
  13160. */
  13161. isReady(): boolean;
  13162. /**
  13163. * Adds a new color gradient
  13164. * @param gradient defines the gradient to use (between 0 and 1)
  13165. * @param color1 defines the color to affect to the specified gradient
  13166. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13167. * @returns the current particle system
  13168. */
  13169. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13170. /**
  13171. * Remove a specific color gradient
  13172. * @param gradient defines the gradient to remove
  13173. * @returns the current particle system
  13174. */
  13175. removeColorGradient(gradient: number): IParticleSystem;
  13176. /**
  13177. * Adds a new size gradient
  13178. * @param gradient defines the gradient to use (between 0 and 1)
  13179. * @param factor defines the size factor to affect to the specified gradient
  13180. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13181. * @returns the current particle system
  13182. */
  13183. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13184. /**
  13185. * Remove a specific size gradient
  13186. * @param gradient defines the gradient to remove
  13187. * @returns the current particle system
  13188. */
  13189. removeSizeGradient(gradient: number): IParticleSystem;
  13190. /**
  13191. * Gets the current list of color gradients.
  13192. * You must use addColorGradient and removeColorGradient to udpate this list
  13193. * @returns the list of color gradients
  13194. */
  13195. getColorGradients(): Nullable<Array<ColorGradient>>;
  13196. /**
  13197. * Gets the current list of size gradients.
  13198. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13199. * @returns the list of size gradients
  13200. */
  13201. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13202. /**
  13203. * Gets the current list of angular speed gradients.
  13204. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13205. * @returns the list of angular speed gradients
  13206. */
  13207. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13208. /**
  13209. * Adds a new angular speed gradient
  13210. * @param gradient defines the gradient to use (between 0 and 1)
  13211. * @param factor defines the angular speed to affect to the specified gradient
  13212. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13213. * @returns the current particle system
  13214. */
  13215. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13216. /**
  13217. * Remove a specific angular speed gradient
  13218. * @param gradient defines the gradient to remove
  13219. * @returns the current particle system
  13220. */
  13221. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13222. /**
  13223. * Gets the current list of velocity gradients.
  13224. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13225. * @returns the list of velocity gradients
  13226. */
  13227. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13228. /**
  13229. * Adds a new velocity gradient
  13230. * @param gradient defines the gradient to use (between 0 and 1)
  13231. * @param factor defines the velocity to affect to the specified gradient
  13232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13233. * @returns the current particle system
  13234. */
  13235. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13236. /**
  13237. * Remove a specific velocity gradient
  13238. * @param gradient defines the gradient to remove
  13239. * @returns the current particle system
  13240. */
  13241. removeVelocityGradient(gradient: number): IParticleSystem;
  13242. /**
  13243. * Gets the current list of limit velocity gradients.
  13244. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13245. * @returns the list of limit velocity gradients
  13246. */
  13247. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13248. /**
  13249. * Adds a new limit velocity gradient
  13250. * @param gradient defines the gradient to use (between 0 and 1)
  13251. * @param factor defines the limit velocity to affect to the specified gradient
  13252. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13253. * @returns the current particle system
  13254. */
  13255. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13256. /**
  13257. * Remove a specific limit velocity gradient
  13258. * @param gradient defines the gradient to remove
  13259. * @returns the current particle system
  13260. */
  13261. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13262. /**
  13263. * Adds a new drag gradient
  13264. * @param gradient defines the gradient to use (between 0 and 1)
  13265. * @param factor defines the drag to affect to the specified gradient
  13266. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13267. * @returns the current particle system
  13268. */
  13269. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13270. /**
  13271. * Remove a specific drag gradient
  13272. * @param gradient defines the gradient to remove
  13273. * @returns the current particle system
  13274. */
  13275. removeDragGradient(gradient: number): IParticleSystem;
  13276. /**
  13277. * Gets the current list of drag gradients.
  13278. * You must use addDragGradient and removeDragGradient to udpate this list
  13279. * @returns the list of drag gradients
  13280. */
  13281. getDragGradients(): Nullable<Array<FactorGradient>>;
  13282. /**
  13283. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13284. * @param gradient defines the gradient to use (between 0 and 1)
  13285. * @param factor defines the emit rate to affect to the specified gradient
  13286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13287. * @returns the current particle system
  13288. */
  13289. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13290. /**
  13291. * Remove a specific emit rate gradient
  13292. * @param gradient defines the gradient to remove
  13293. * @returns the current particle system
  13294. */
  13295. removeEmitRateGradient(gradient: number): IParticleSystem;
  13296. /**
  13297. * Gets the current list of emit rate gradients.
  13298. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13299. * @returns the list of emit rate gradients
  13300. */
  13301. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13302. /**
  13303. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13304. * @param gradient defines the gradient to use (between 0 and 1)
  13305. * @param factor defines the start size to affect to the specified gradient
  13306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13307. * @returns the current particle system
  13308. */
  13309. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13310. /**
  13311. * Remove a specific start size gradient
  13312. * @param gradient defines the gradient to remove
  13313. * @returns the current particle system
  13314. */
  13315. removeStartSizeGradient(gradient: number): IParticleSystem;
  13316. /**
  13317. * Gets the current list of start size gradients.
  13318. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13319. * @returns the list of start size gradients
  13320. */
  13321. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13322. /**
  13323. * Adds a new life time gradient
  13324. * @param gradient defines the gradient to use (between 0 and 1)
  13325. * @param factor defines the life time factor to affect to the specified gradient
  13326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13327. * @returns the current particle system
  13328. */
  13329. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13330. /**
  13331. * Remove a specific life time gradient
  13332. * @param gradient defines the gradient to remove
  13333. * @returns the current particle system
  13334. */
  13335. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13336. /**
  13337. * Gets the current list of life time gradients.
  13338. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13339. * @returns the list of life time gradients
  13340. */
  13341. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13342. /**
  13343. * Gets the current list of color gradients.
  13344. * You must use addColorGradient and removeColorGradient to udpate this list
  13345. * @returns the list of color gradients
  13346. */
  13347. getColorGradients(): Nullable<Array<ColorGradient>>;
  13348. /**
  13349. * Adds a new ramp gradient used to remap particle colors
  13350. * @param gradient defines the gradient to use (between 0 and 1)
  13351. * @param color defines the color to affect to the specified gradient
  13352. * @returns the current particle system
  13353. */
  13354. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13355. /**
  13356. * Gets the current list of ramp gradients.
  13357. * You must use addRampGradient and removeRampGradient to udpate this list
  13358. * @returns the list of ramp gradients
  13359. */
  13360. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13361. /** Gets or sets a boolean indicating that ramp gradients must be used
  13362. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13363. */
  13364. useRampGradients: boolean;
  13365. /**
  13366. * Adds a new color remap gradient
  13367. * @param gradient defines the gradient to use (between 0 and 1)
  13368. * @param min defines the color remap minimal range
  13369. * @param max defines the color remap maximal range
  13370. * @returns the current particle system
  13371. */
  13372. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13373. /**
  13374. * Gets the current list of color remap gradients.
  13375. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13376. * @returns the list of color remap gradients
  13377. */
  13378. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13379. /**
  13380. * Adds a new alpha remap gradient
  13381. * @param gradient defines the gradient to use (between 0 and 1)
  13382. * @param min defines the alpha remap minimal range
  13383. * @param max defines the alpha remap maximal range
  13384. * @returns the current particle system
  13385. */
  13386. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13387. /**
  13388. * Gets the current list of alpha remap gradients.
  13389. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13390. * @returns the list of alpha remap gradients
  13391. */
  13392. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13393. /**
  13394. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13395. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13396. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13397. * @returns the emitter
  13398. */
  13399. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13400. /**
  13401. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13402. * @param radius The radius of the hemisphere to emit from
  13403. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13404. * @returns the emitter
  13405. */
  13406. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13407. /**
  13408. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13409. * @param radius The radius of the sphere to emit from
  13410. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13411. * @returns the emitter
  13412. */
  13413. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13414. /**
  13415. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13416. * @param radius The radius of the sphere to emit from
  13417. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13418. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13419. * @returns the emitter
  13420. */
  13421. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13422. /**
  13423. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13424. * @param radius The radius of the emission cylinder
  13425. * @param height The height of the emission cylinder
  13426. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13427. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13428. * @returns the emitter
  13429. */
  13430. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13431. /**
  13432. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13433. * @param radius The radius of the cylinder to emit from
  13434. * @param height The height of the emission cylinder
  13435. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13436. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13437. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13438. * @returns the emitter
  13439. */
  13440. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13441. /**
  13442. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13443. * @param radius The radius of the cone to emit from
  13444. * @param angle The base angle of the cone
  13445. * @returns the emitter
  13446. */
  13447. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13448. /**
  13449. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13450. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13451. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13452. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13453. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13454. * @returns the emitter
  13455. */
  13456. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13457. /**
  13458. * Get hosting scene
  13459. * @returns the scene
  13460. */
  13461. getScene(): Scene;
  13462. }
  13463. }
  13464. declare module BABYLON {
  13465. /**
  13466. * 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.
  13467. * @see https://doc.babylonjs.com/how_to/transformnode
  13468. */
  13469. export class TransformNode extends Node {
  13470. /**
  13471. * Object will not rotate to face the camera
  13472. */
  13473. static BILLBOARDMODE_NONE: number;
  13474. /**
  13475. * Object will rotate to face the camera but only on the x axis
  13476. */
  13477. static BILLBOARDMODE_X: number;
  13478. /**
  13479. * Object will rotate to face the camera but only on the y axis
  13480. */
  13481. static BILLBOARDMODE_Y: number;
  13482. /**
  13483. * Object will rotate to face the camera but only on the z axis
  13484. */
  13485. static BILLBOARDMODE_Z: number;
  13486. /**
  13487. * Object will rotate to face the camera
  13488. */
  13489. static BILLBOARDMODE_ALL: number;
  13490. /**
  13491. * Object will rotate to face the camera's position instead of orientation
  13492. */
  13493. static BILLBOARDMODE_USE_POSITION: number;
  13494. private _forward;
  13495. private _forwardInverted;
  13496. private _up;
  13497. private _right;
  13498. private _rightInverted;
  13499. private _position;
  13500. private _rotation;
  13501. private _rotationQuaternion;
  13502. protected _scaling: Vector3;
  13503. protected _isDirty: boolean;
  13504. private _transformToBoneReferal;
  13505. private _isAbsoluteSynced;
  13506. private _billboardMode;
  13507. /**
  13508. * Gets or sets the billboard mode. Default is 0.
  13509. *
  13510. * | Value | Type | Description |
  13511. * | --- | --- | --- |
  13512. * | 0 | BILLBOARDMODE_NONE | |
  13513. * | 1 | BILLBOARDMODE_X | |
  13514. * | 2 | BILLBOARDMODE_Y | |
  13515. * | 4 | BILLBOARDMODE_Z | |
  13516. * | 7 | BILLBOARDMODE_ALL | |
  13517. *
  13518. */
  13519. get billboardMode(): number;
  13520. set billboardMode(value: number);
  13521. private _preserveParentRotationForBillboard;
  13522. /**
  13523. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13524. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13525. */
  13526. get preserveParentRotationForBillboard(): boolean;
  13527. set preserveParentRotationForBillboard(value: boolean);
  13528. /**
  13529. * 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
  13530. */
  13531. scalingDeterminant: number;
  13532. private _infiniteDistance;
  13533. /**
  13534. * Gets or sets the distance of the object to max, often used by skybox
  13535. */
  13536. get infiniteDistance(): boolean;
  13537. set infiniteDistance(value: boolean);
  13538. /**
  13539. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13540. * By default the system will update normals to compensate
  13541. */
  13542. ignoreNonUniformScaling: boolean;
  13543. /**
  13544. * 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
  13545. */
  13546. reIntegrateRotationIntoRotationQuaternion: boolean;
  13547. /** @hidden */
  13548. _poseMatrix: Nullable<Matrix>;
  13549. /** @hidden */
  13550. _localMatrix: Matrix;
  13551. private _usePivotMatrix;
  13552. private _absolutePosition;
  13553. private _absoluteScaling;
  13554. private _absoluteRotationQuaternion;
  13555. private _pivotMatrix;
  13556. private _pivotMatrixInverse;
  13557. protected _postMultiplyPivotMatrix: boolean;
  13558. protected _isWorldMatrixFrozen: boolean;
  13559. /** @hidden */
  13560. _indexInSceneTransformNodesArray: number;
  13561. /**
  13562. * An event triggered after the world matrix is updated
  13563. */
  13564. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13565. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13566. /**
  13567. * Gets a string identifying the name of the class
  13568. * @returns "TransformNode" string
  13569. */
  13570. getClassName(): string;
  13571. /**
  13572. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13573. */
  13574. get position(): Vector3;
  13575. set position(newPosition: Vector3);
  13576. /**
  13577. * 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)).
  13578. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13579. */
  13580. get rotation(): Vector3;
  13581. set rotation(newRotation: Vector3);
  13582. /**
  13583. * 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)).
  13584. */
  13585. get scaling(): Vector3;
  13586. set scaling(newScaling: Vector3);
  13587. /**
  13588. * 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).
  13589. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13590. */
  13591. get rotationQuaternion(): Nullable<Quaternion>;
  13592. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13593. /**
  13594. * The forward direction of that transform in world space.
  13595. */
  13596. get forward(): Vector3;
  13597. /**
  13598. * The up direction of that transform in world space.
  13599. */
  13600. get up(): Vector3;
  13601. /**
  13602. * The right direction of that transform in world space.
  13603. */
  13604. get right(): Vector3;
  13605. /**
  13606. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13607. * @param matrix the matrix to copy the pose from
  13608. * @returns this TransformNode.
  13609. */
  13610. updatePoseMatrix(matrix: Matrix): TransformNode;
  13611. /**
  13612. * Returns the mesh Pose matrix.
  13613. * @returns the pose matrix
  13614. */
  13615. getPoseMatrix(): Matrix;
  13616. /** @hidden */
  13617. _isSynchronized(): boolean;
  13618. /** @hidden */
  13619. _initCache(): void;
  13620. /**
  13621. * Flag the transform node as dirty (Forcing it to update everything)
  13622. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13623. * @returns this transform node
  13624. */
  13625. markAsDirty(property: string): TransformNode;
  13626. /**
  13627. * Returns the current mesh absolute position.
  13628. * Returns a Vector3.
  13629. */
  13630. get absolutePosition(): Vector3;
  13631. /**
  13632. * Returns the current mesh absolute scaling.
  13633. * Returns a Vector3.
  13634. */
  13635. get absoluteScaling(): Vector3;
  13636. /**
  13637. * Returns the current mesh absolute rotation.
  13638. * Returns a Quaternion.
  13639. */
  13640. get absoluteRotationQuaternion(): Quaternion;
  13641. /**
  13642. * Sets a new matrix to apply before all other transformation
  13643. * @param matrix defines the transform matrix
  13644. * @returns the current TransformNode
  13645. */
  13646. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13647. /**
  13648. * Sets a new pivot matrix to the current node
  13649. * @param matrix defines the new pivot matrix to use
  13650. * @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
  13651. * @returns the current TransformNode
  13652. */
  13653. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13654. /**
  13655. * Returns the mesh pivot matrix.
  13656. * Default : Identity.
  13657. * @returns the matrix
  13658. */
  13659. getPivotMatrix(): Matrix;
  13660. /**
  13661. * Instantiate (when possible) or clone that node with its hierarchy
  13662. * @param newParent defines the new parent to use for the instance (or clone)
  13663. * @param options defines options to configure how copy is done
  13664. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13665. * @returns an instance (or a clone) of the current node with its hiearchy
  13666. */
  13667. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13668. doNotInstantiate: boolean;
  13669. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13670. /**
  13671. * Prevents the World matrix to be computed any longer
  13672. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13673. * @returns the TransformNode.
  13674. */
  13675. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13676. /**
  13677. * Allows back the World matrix computation.
  13678. * @returns the TransformNode.
  13679. */
  13680. unfreezeWorldMatrix(): this;
  13681. /**
  13682. * True if the World matrix has been frozen.
  13683. */
  13684. get isWorldMatrixFrozen(): boolean;
  13685. /**
  13686. * Retuns the mesh absolute position in the World.
  13687. * @returns a Vector3.
  13688. */
  13689. getAbsolutePosition(): Vector3;
  13690. /**
  13691. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13692. * @param absolutePosition the absolute position to set
  13693. * @returns the TransformNode.
  13694. */
  13695. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13696. /**
  13697. * Sets the mesh position in its local space.
  13698. * @param vector3 the position to set in localspace
  13699. * @returns the TransformNode.
  13700. */
  13701. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13702. /**
  13703. * Returns the mesh position in the local space from the current World matrix values.
  13704. * @returns a new Vector3.
  13705. */
  13706. getPositionExpressedInLocalSpace(): Vector3;
  13707. /**
  13708. * Translates the mesh along the passed Vector3 in its local space.
  13709. * @param vector3 the distance to translate in localspace
  13710. * @returns the TransformNode.
  13711. */
  13712. locallyTranslate(vector3: Vector3): TransformNode;
  13713. private static _lookAtVectorCache;
  13714. /**
  13715. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13716. * @param targetPoint the position (must be in same space as current mesh) to look at
  13717. * @param yawCor optional yaw (y-axis) correction in radians
  13718. * @param pitchCor optional pitch (x-axis) correction in radians
  13719. * @param rollCor optional roll (z-axis) correction in radians
  13720. * @param space the choosen space of the target
  13721. * @returns the TransformNode.
  13722. */
  13723. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13724. /**
  13725. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13726. * This Vector3 is expressed in the World space.
  13727. * @param localAxis axis to rotate
  13728. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13729. */
  13730. getDirection(localAxis: Vector3): Vector3;
  13731. /**
  13732. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13733. * localAxis is expressed in the mesh local space.
  13734. * result is computed in the Wordl space from the mesh World matrix.
  13735. * @param localAxis axis to rotate
  13736. * @param result the resulting transformnode
  13737. * @returns this TransformNode.
  13738. */
  13739. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13740. /**
  13741. * Sets this transform node rotation to the given local axis.
  13742. * @param localAxis the axis in local space
  13743. * @param yawCor optional yaw (y-axis) correction in radians
  13744. * @param pitchCor optional pitch (x-axis) correction in radians
  13745. * @param rollCor optional roll (z-axis) correction in radians
  13746. * @returns this TransformNode
  13747. */
  13748. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13749. /**
  13750. * Sets a new pivot point to the current node
  13751. * @param point defines the new pivot point to use
  13752. * @param space defines if the point is in world or local space (local by default)
  13753. * @returns the current TransformNode
  13754. */
  13755. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13756. /**
  13757. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13758. * @returns the pivot point
  13759. */
  13760. getPivotPoint(): Vector3;
  13761. /**
  13762. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13763. * @param result the vector3 to store the result
  13764. * @returns this TransformNode.
  13765. */
  13766. getPivotPointToRef(result: Vector3): TransformNode;
  13767. /**
  13768. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13769. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13770. */
  13771. getAbsolutePivotPoint(): Vector3;
  13772. /**
  13773. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13774. * @param result vector3 to store the result
  13775. * @returns this TransformNode.
  13776. */
  13777. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13778. /**
  13779. * Defines the passed node as the parent of the current node.
  13780. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13781. * @see https://doc.babylonjs.com/how_to/parenting
  13782. * @param node the node ot set as the parent
  13783. * @returns this TransformNode.
  13784. */
  13785. setParent(node: Nullable<Node>): TransformNode;
  13786. private _nonUniformScaling;
  13787. /**
  13788. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13789. */
  13790. get nonUniformScaling(): boolean;
  13791. /** @hidden */
  13792. _updateNonUniformScalingState(value: boolean): boolean;
  13793. /**
  13794. * Attach the current TransformNode to another TransformNode associated with a bone
  13795. * @param bone Bone affecting the TransformNode
  13796. * @param affectedTransformNode TransformNode associated with the bone
  13797. * @returns this object
  13798. */
  13799. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13800. /**
  13801. * Detach the transform node if its associated with a bone
  13802. * @returns this object
  13803. */
  13804. detachFromBone(): TransformNode;
  13805. private static _rotationAxisCache;
  13806. /**
  13807. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13808. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13809. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13810. * The passed axis is also normalized.
  13811. * @param axis the axis to rotate around
  13812. * @param amount the amount to rotate in radians
  13813. * @param space Space to rotate in (Default: local)
  13814. * @returns the TransformNode.
  13815. */
  13816. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13817. /**
  13818. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13819. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13820. * The passed axis is also normalized. .
  13821. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13822. * @param point the point to rotate around
  13823. * @param axis the axis to rotate around
  13824. * @param amount the amount to rotate in radians
  13825. * @returns the TransformNode
  13826. */
  13827. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13828. /**
  13829. * Translates the mesh along the axis vector for the passed distance in the given space.
  13830. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13831. * @param axis the axis to translate in
  13832. * @param distance the distance to translate
  13833. * @param space Space to rotate in (Default: local)
  13834. * @returns the TransformNode.
  13835. */
  13836. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13837. /**
  13838. * Adds a rotation step to the mesh current rotation.
  13839. * x, y, z are Euler angles expressed in radians.
  13840. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13841. * This means this rotation is made in the mesh local space only.
  13842. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13843. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13844. * ```javascript
  13845. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13846. * ```
  13847. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13848. * 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.
  13849. * @param x Rotation to add
  13850. * @param y Rotation to add
  13851. * @param z Rotation to add
  13852. * @returns the TransformNode.
  13853. */
  13854. addRotation(x: number, y: number, z: number): TransformNode;
  13855. /**
  13856. * @hidden
  13857. */
  13858. protected _getEffectiveParent(): Nullable<Node>;
  13859. /**
  13860. * Computes the world matrix of the node
  13861. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13862. * @returns the world matrix
  13863. */
  13864. computeWorldMatrix(force?: boolean): Matrix;
  13865. /**
  13866. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13867. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13868. */
  13869. resetLocalMatrix(independentOfChildren?: boolean): void;
  13870. protected _afterComputeWorldMatrix(): void;
  13871. /**
  13872. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13873. * @param func callback function to add
  13874. *
  13875. * @returns the TransformNode.
  13876. */
  13877. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13878. /**
  13879. * Removes a registered callback function.
  13880. * @param func callback function to remove
  13881. * @returns the TransformNode.
  13882. */
  13883. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13884. /**
  13885. * Gets the position of the current mesh in camera space
  13886. * @param camera defines the camera to use
  13887. * @returns a position
  13888. */
  13889. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13890. /**
  13891. * Returns the distance from the mesh to the active camera
  13892. * @param camera defines the camera to use
  13893. * @returns the distance
  13894. */
  13895. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13896. /**
  13897. * Clone the current transform node
  13898. * @param name Name of the new clone
  13899. * @param newParent New parent for the clone
  13900. * @param doNotCloneChildren Do not clone children hierarchy
  13901. * @returns the new transform node
  13902. */
  13903. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13904. /**
  13905. * Serializes the objects information.
  13906. * @param currentSerializationObject defines the object to serialize in
  13907. * @returns the serialized object
  13908. */
  13909. serialize(currentSerializationObject?: any): any;
  13910. /**
  13911. * Returns a new TransformNode object parsed from the source provided.
  13912. * @param parsedTransformNode is the source.
  13913. * @param scene the scne the object belongs to
  13914. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13915. * @returns a new TransformNode object parsed from the source provided.
  13916. */
  13917. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13918. /**
  13919. * Get all child-transformNodes of this node
  13920. * @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
  13921. * @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
  13922. * @returns an array of TransformNode
  13923. */
  13924. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13925. /**
  13926. * Releases resources associated with this transform node.
  13927. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13928. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13929. */
  13930. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13931. /**
  13932. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13933. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13934. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13935. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13936. * @returns the current mesh
  13937. */
  13938. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13939. private _syncAbsoluteScalingAndRotation;
  13940. }
  13941. }
  13942. declare module BABYLON {
  13943. /**
  13944. * Class used to override all child animations of a given target
  13945. */
  13946. export class AnimationPropertiesOverride {
  13947. /**
  13948. * Gets or sets a value indicating if animation blending must be used
  13949. */
  13950. enableBlending: boolean;
  13951. /**
  13952. * Gets or sets the blending speed to use when enableBlending is true
  13953. */
  13954. blendingSpeed: number;
  13955. /**
  13956. * Gets or sets the default loop mode to use
  13957. */
  13958. loopMode: number;
  13959. }
  13960. }
  13961. declare module BABYLON {
  13962. /**
  13963. * Class used to store bone information
  13964. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13965. */
  13966. export class Bone extends Node {
  13967. /**
  13968. * defines the bone name
  13969. */
  13970. name: string;
  13971. private static _tmpVecs;
  13972. private static _tmpQuat;
  13973. private static _tmpMats;
  13974. /**
  13975. * Gets the list of child bones
  13976. */
  13977. children: Bone[];
  13978. /** Gets the animations associated with this bone */
  13979. animations: Animation[];
  13980. /**
  13981. * Gets or sets bone length
  13982. */
  13983. length: number;
  13984. /**
  13985. * @hidden Internal only
  13986. * Set this value to map this bone to a different index in the transform matrices
  13987. * Set this value to -1 to exclude the bone from the transform matrices
  13988. */
  13989. _index: Nullable<number>;
  13990. private _skeleton;
  13991. private _localMatrix;
  13992. private _restPose;
  13993. private _baseMatrix;
  13994. private _absoluteTransform;
  13995. private _invertedAbsoluteTransform;
  13996. private _parent;
  13997. private _scalingDeterminant;
  13998. private _worldTransform;
  13999. private _localScaling;
  14000. private _localRotation;
  14001. private _localPosition;
  14002. private _needToDecompose;
  14003. private _needToCompose;
  14004. /** @hidden */
  14005. _linkedTransformNode: Nullable<TransformNode>;
  14006. /** @hidden */
  14007. _waitingTransformNodeId: Nullable<string>;
  14008. /** @hidden */
  14009. get _matrix(): Matrix;
  14010. /** @hidden */
  14011. set _matrix(value: Matrix);
  14012. /**
  14013. * Create a new bone
  14014. * @param name defines the bone name
  14015. * @param skeleton defines the parent skeleton
  14016. * @param parentBone defines the parent (can be null if the bone is the root)
  14017. * @param localMatrix defines the local matrix
  14018. * @param restPose defines the rest pose matrix
  14019. * @param baseMatrix defines the base matrix
  14020. * @param index defines index of the bone in the hiearchy
  14021. */
  14022. constructor(
  14023. /**
  14024. * defines the bone name
  14025. */
  14026. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14027. /**
  14028. * Gets the current object class name.
  14029. * @return the class name
  14030. */
  14031. getClassName(): string;
  14032. /**
  14033. * Gets the parent skeleton
  14034. * @returns a skeleton
  14035. */
  14036. getSkeleton(): Skeleton;
  14037. /**
  14038. * Gets parent bone
  14039. * @returns a bone or null if the bone is the root of the bone hierarchy
  14040. */
  14041. getParent(): Nullable<Bone>;
  14042. /**
  14043. * Returns an array containing the root bones
  14044. * @returns an array containing the root bones
  14045. */
  14046. getChildren(): Array<Bone>;
  14047. /**
  14048. * Gets the node index in matrix array generated for rendering
  14049. * @returns the node index
  14050. */
  14051. getIndex(): number;
  14052. /**
  14053. * Sets the parent bone
  14054. * @param parent defines the parent (can be null if the bone is the root)
  14055. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14056. */
  14057. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14058. /**
  14059. * Gets the local matrix
  14060. * @returns a matrix
  14061. */
  14062. getLocalMatrix(): Matrix;
  14063. /**
  14064. * Gets the base matrix (initial matrix which remains unchanged)
  14065. * @returns a matrix
  14066. */
  14067. getBaseMatrix(): Matrix;
  14068. /**
  14069. * Gets the rest pose matrix
  14070. * @returns a matrix
  14071. */
  14072. getRestPose(): Matrix;
  14073. /**
  14074. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14075. */
  14076. getWorldMatrix(): Matrix;
  14077. /**
  14078. * Sets the local matrix to rest pose matrix
  14079. */
  14080. returnToRest(): void;
  14081. /**
  14082. * Gets the inverse of the absolute transform matrix.
  14083. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14084. * @returns a matrix
  14085. */
  14086. getInvertedAbsoluteTransform(): Matrix;
  14087. /**
  14088. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14089. * @returns a matrix
  14090. */
  14091. getAbsoluteTransform(): Matrix;
  14092. /**
  14093. * Links with the given transform node.
  14094. * The local matrix of this bone is copied from the transform node every frame.
  14095. * @param transformNode defines the transform node to link to
  14096. */
  14097. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14098. /**
  14099. * Gets the node used to drive the bone's transformation
  14100. * @returns a transform node or null
  14101. */
  14102. getTransformNode(): Nullable<TransformNode>;
  14103. /** Gets or sets current position (in local space) */
  14104. get position(): Vector3;
  14105. set position(newPosition: Vector3);
  14106. /** Gets or sets current rotation (in local space) */
  14107. get rotation(): Vector3;
  14108. set rotation(newRotation: Vector3);
  14109. /** Gets or sets current rotation quaternion (in local space) */
  14110. get rotationQuaternion(): Quaternion;
  14111. set rotationQuaternion(newRotation: Quaternion);
  14112. /** Gets or sets current scaling (in local space) */
  14113. get scaling(): Vector3;
  14114. set scaling(newScaling: Vector3);
  14115. /**
  14116. * Gets the animation properties override
  14117. */
  14118. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14119. private _decompose;
  14120. private _compose;
  14121. /**
  14122. * Update the base and local matrices
  14123. * @param matrix defines the new base or local matrix
  14124. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14125. * @param updateLocalMatrix defines if the local matrix should be updated
  14126. */
  14127. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14128. /** @hidden */
  14129. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14130. /**
  14131. * Flag the bone as dirty (Forcing it to update everything)
  14132. */
  14133. markAsDirty(): void;
  14134. /** @hidden */
  14135. _markAsDirtyAndCompose(): void;
  14136. private _markAsDirtyAndDecompose;
  14137. /**
  14138. * Translate the bone in local or world space
  14139. * @param vec The amount to translate the bone
  14140. * @param space The space that the translation is in
  14141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14142. */
  14143. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14144. /**
  14145. * Set the postion of the bone in local or world space
  14146. * @param position The position to set the bone
  14147. * @param space The space that the position is in
  14148. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14149. */
  14150. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14151. /**
  14152. * Set the absolute position of the bone (world space)
  14153. * @param position The position to set the bone
  14154. * @param mesh The mesh that this bone is attached to
  14155. */
  14156. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14157. /**
  14158. * Scale the bone on the x, y and z axes (in local space)
  14159. * @param x The amount to scale the bone on the x axis
  14160. * @param y The amount to scale the bone on the y axis
  14161. * @param z The amount to scale the bone on the z axis
  14162. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14163. */
  14164. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14165. /**
  14166. * Set the bone scaling in local space
  14167. * @param scale defines the scaling vector
  14168. */
  14169. setScale(scale: Vector3): void;
  14170. /**
  14171. * Gets the current scaling in local space
  14172. * @returns the current scaling vector
  14173. */
  14174. getScale(): Vector3;
  14175. /**
  14176. * Gets the current scaling in local space and stores it in a target vector
  14177. * @param result defines the target vector
  14178. */
  14179. getScaleToRef(result: Vector3): void;
  14180. /**
  14181. * Set the yaw, pitch, and roll of the bone in local or world space
  14182. * @param yaw The rotation of the bone on the y axis
  14183. * @param pitch The rotation of the bone on the x axis
  14184. * @param roll The rotation of the bone on the z axis
  14185. * @param space The space that the axes of rotation are in
  14186. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14187. */
  14188. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14189. /**
  14190. * Add a rotation to the bone on an axis in local or world space
  14191. * @param axis The axis to rotate the bone on
  14192. * @param amount The amount to rotate the bone
  14193. * @param space The space that the axis is in
  14194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14195. */
  14196. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14197. /**
  14198. * Set the rotation of the bone to a particular axis angle in local or world space
  14199. * @param axis The axis to rotate the bone on
  14200. * @param angle The angle that the bone should be rotated to
  14201. * @param space The space that the axis is in
  14202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14203. */
  14204. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14205. /**
  14206. * Set the euler rotation of the bone in local of world space
  14207. * @param rotation The euler rotation that the bone should be set to
  14208. * @param space The space that the rotation is in
  14209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14210. */
  14211. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14212. /**
  14213. * Set the quaternion rotation of the bone in local of world space
  14214. * @param quat The quaternion rotation that the bone should be set to
  14215. * @param space The space that the rotation is in
  14216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14217. */
  14218. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14219. /**
  14220. * Set the rotation matrix of the bone in local of world space
  14221. * @param rotMat The rotation matrix that the bone should be set to
  14222. * @param space The space that the rotation is in
  14223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14224. */
  14225. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14226. private _rotateWithMatrix;
  14227. private _getNegativeRotationToRef;
  14228. /**
  14229. * Get the position of the bone in local or world space
  14230. * @param space The space that the returned position is in
  14231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14232. * @returns The position of the bone
  14233. */
  14234. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14235. /**
  14236. * Copy the position of the bone to a vector3 in local or world space
  14237. * @param space The space that the returned position is in
  14238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14239. * @param result The vector3 to copy the position to
  14240. */
  14241. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14242. /**
  14243. * Get the absolute position of the bone (world space)
  14244. * @param mesh The mesh that this bone is attached to
  14245. * @returns The absolute position of the bone
  14246. */
  14247. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14248. /**
  14249. * Copy the absolute position of the bone (world space) to the result param
  14250. * @param mesh The mesh that this bone is attached to
  14251. * @param result The vector3 to copy the absolute position to
  14252. */
  14253. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14254. /**
  14255. * Compute the absolute transforms of this bone and its children
  14256. */
  14257. computeAbsoluteTransforms(): void;
  14258. /**
  14259. * Get the world direction from an axis that is in the local space of the bone
  14260. * @param localAxis The local direction that is used to compute the world direction
  14261. * @param mesh The mesh that this bone is attached to
  14262. * @returns The world direction
  14263. */
  14264. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14265. /**
  14266. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14267. * @param localAxis The local direction that is used to compute the world direction
  14268. * @param mesh The mesh that this bone is attached to
  14269. * @param result The vector3 that the world direction will be copied to
  14270. */
  14271. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14272. /**
  14273. * Get the euler rotation of the bone in local or world space
  14274. * @param space The space that the rotation should be in
  14275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14276. * @returns The euler rotation
  14277. */
  14278. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14279. /**
  14280. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14281. * @param space The space that the rotation should be in
  14282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14283. * @param result The vector3 that the rotation should be copied to
  14284. */
  14285. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14286. /**
  14287. * Get the quaternion rotation of the bone in either local or world space
  14288. * @param space The space that the rotation should be in
  14289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14290. * @returns The quaternion rotation
  14291. */
  14292. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14293. /**
  14294. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14295. * @param space The space that the rotation should be in
  14296. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14297. * @param result The quaternion that the rotation should be copied to
  14298. */
  14299. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14300. /**
  14301. * Get the rotation matrix of the bone in local or world space
  14302. * @param space The space that the rotation should be in
  14303. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14304. * @returns The rotation matrix
  14305. */
  14306. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14307. /**
  14308. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14309. * @param space The space that the rotation should be in
  14310. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14311. * @param result The quaternion that the rotation should be copied to
  14312. */
  14313. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14314. /**
  14315. * Get the world position of a point that is in the local space of the bone
  14316. * @param position The local position
  14317. * @param mesh The mesh that this bone is attached to
  14318. * @returns The world position
  14319. */
  14320. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14321. /**
  14322. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14323. * @param position The local position
  14324. * @param mesh The mesh that this bone is attached to
  14325. * @param result The vector3 that the world position should be copied to
  14326. */
  14327. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14328. /**
  14329. * Get the local position of a point that is in world space
  14330. * @param position The world position
  14331. * @param mesh The mesh that this bone is attached to
  14332. * @returns The local position
  14333. */
  14334. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14335. /**
  14336. * Get the local position of a point that is in world space and copy it to the result param
  14337. * @param position The world position
  14338. * @param mesh The mesh that this bone is attached to
  14339. * @param result The vector3 that the local position should be copied to
  14340. */
  14341. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14342. }
  14343. }
  14344. declare module BABYLON {
  14345. /**
  14346. * Defines a runtime animation
  14347. */
  14348. export class RuntimeAnimation {
  14349. private _events;
  14350. /**
  14351. * The current frame of the runtime animation
  14352. */
  14353. private _currentFrame;
  14354. /**
  14355. * The animation used by the runtime animation
  14356. */
  14357. private _animation;
  14358. /**
  14359. * The target of the runtime animation
  14360. */
  14361. private _target;
  14362. /**
  14363. * The initiating animatable
  14364. */
  14365. private _host;
  14366. /**
  14367. * The original value of the runtime animation
  14368. */
  14369. private _originalValue;
  14370. /**
  14371. * The original blend value of the runtime animation
  14372. */
  14373. private _originalBlendValue;
  14374. /**
  14375. * The offsets cache of the runtime animation
  14376. */
  14377. private _offsetsCache;
  14378. /**
  14379. * The high limits cache of the runtime animation
  14380. */
  14381. private _highLimitsCache;
  14382. /**
  14383. * Specifies if the runtime animation has been stopped
  14384. */
  14385. private _stopped;
  14386. /**
  14387. * The blending factor of the runtime animation
  14388. */
  14389. private _blendingFactor;
  14390. /**
  14391. * The BabylonJS scene
  14392. */
  14393. private _scene;
  14394. /**
  14395. * The current value of the runtime animation
  14396. */
  14397. private _currentValue;
  14398. /** @hidden */
  14399. _animationState: _IAnimationState;
  14400. /**
  14401. * The active target of the runtime animation
  14402. */
  14403. private _activeTargets;
  14404. private _currentActiveTarget;
  14405. private _directTarget;
  14406. /**
  14407. * The target path of the runtime animation
  14408. */
  14409. private _targetPath;
  14410. /**
  14411. * The weight of the runtime animation
  14412. */
  14413. private _weight;
  14414. /**
  14415. * The ratio offset of the runtime animation
  14416. */
  14417. private _ratioOffset;
  14418. /**
  14419. * The previous delay of the runtime animation
  14420. */
  14421. private _previousDelay;
  14422. /**
  14423. * The previous ratio of the runtime animation
  14424. */
  14425. private _previousRatio;
  14426. private _enableBlending;
  14427. private _keys;
  14428. private _minFrame;
  14429. private _maxFrame;
  14430. private _minValue;
  14431. private _maxValue;
  14432. private _targetIsArray;
  14433. /**
  14434. * Gets the current frame of the runtime animation
  14435. */
  14436. get currentFrame(): number;
  14437. /**
  14438. * Gets the weight of the runtime animation
  14439. */
  14440. get weight(): number;
  14441. /**
  14442. * Gets the current value of the runtime animation
  14443. */
  14444. get currentValue(): any;
  14445. /**
  14446. * Gets the target path of the runtime animation
  14447. */
  14448. get targetPath(): string;
  14449. /**
  14450. * Gets the actual target of the runtime animation
  14451. */
  14452. get target(): any;
  14453. /** @hidden */
  14454. _onLoop: () => void;
  14455. /**
  14456. * Create a new RuntimeAnimation object
  14457. * @param target defines the target of the animation
  14458. * @param animation defines the source animation object
  14459. * @param scene defines the hosting scene
  14460. * @param host defines the initiating Animatable
  14461. */
  14462. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14463. private _preparePath;
  14464. /**
  14465. * Gets the animation from the runtime animation
  14466. */
  14467. get animation(): Animation;
  14468. /**
  14469. * Resets the runtime animation to the beginning
  14470. * @param restoreOriginal defines whether to restore the target property to the original value
  14471. */
  14472. reset(restoreOriginal?: boolean): void;
  14473. /**
  14474. * Specifies if the runtime animation is stopped
  14475. * @returns Boolean specifying if the runtime animation is stopped
  14476. */
  14477. isStopped(): boolean;
  14478. /**
  14479. * Disposes of the runtime animation
  14480. */
  14481. dispose(): void;
  14482. /**
  14483. * Apply the interpolated value to the target
  14484. * @param currentValue defines the value computed by the animation
  14485. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14486. */
  14487. setValue(currentValue: any, weight: number): void;
  14488. private _getOriginalValues;
  14489. private _setValue;
  14490. /**
  14491. * Gets the loop pmode of the runtime animation
  14492. * @returns Loop Mode
  14493. */
  14494. private _getCorrectLoopMode;
  14495. /**
  14496. * Move the current animation to a given frame
  14497. * @param frame defines the frame to move to
  14498. */
  14499. goToFrame(frame: number): void;
  14500. /**
  14501. * @hidden Internal use only
  14502. */
  14503. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14504. /**
  14505. * Execute the current animation
  14506. * @param delay defines the delay to add to the current frame
  14507. * @param from defines the lower bound of the animation range
  14508. * @param to defines the upper bound of the animation range
  14509. * @param loop defines if the current animation must loop
  14510. * @param speedRatio defines the current speed ratio
  14511. * @param weight defines the weight of the animation (default is -1 so no weight)
  14512. * @param onLoop optional callback called when animation loops
  14513. * @returns a boolean indicating if the animation is running
  14514. */
  14515. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14516. }
  14517. }
  14518. declare module BABYLON {
  14519. /**
  14520. * Class used to store an actual running animation
  14521. */
  14522. export class Animatable {
  14523. /** defines the target object */
  14524. target: any;
  14525. /** defines the starting frame number (default is 0) */
  14526. fromFrame: number;
  14527. /** defines the ending frame number (default is 100) */
  14528. toFrame: number;
  14529. /** defines if the animation must loop (default is false) */
  14530. loopAnimation: boolean;
  14531. /** defines a callback to call when animation ends if it is not looping */
  14532. onAnimationEnd?: (() => void) | null | undefined;
  14533. /** defines a callback to call when animation loops */
  14534. onAnimationLoop?: (() => void) | null | undefined;
  14535. private _localDelayOffset;
  14536. private _pausedDelay;
  14537. private _runtimeAnimations;
  14538. private _paused;
  14539. private _scene;
  14540. private _speedRatio;
  14541. private _weight;
  14542. private _syncRoot;
  14543. /**
  14544. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14545. * This will only apply for non looping animation (default is true)
  14546. */
  14547. disposeOnEnd: boolean;
  14548. /**
  14549. * Gets a boolean indicating if the animation has started
  14550. */
  14551. animationStarted: boolean;
  14552. /**
  14553. * Observer raised when the animation ends
  14554. */
  14555. onAnimationEndObservable: Observable<Animatable>;
  14556. /**
  14557. * Observer raised when the animation loops
  14558. */
  14559. onAnimationLoopObservable: Observable<Animatable>;
  14560. /**
  14561. * Gets the root Animatable used to synchronize and normalize animations
  14562. */
  14563. get syncRoot(): Nullable<Animatable>;
  14564. /**
  14565. * Gets the current frame of the first RuntimeAnimation
  14566. * Used to synchronize Animatables
  14567. */
  14568. get masterFrame(): number;
  14569. /**
  14570. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14571. */
  14572. get weight(): number;
  14573. set weight(value: number);
  14574. /**
  14575. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14576. */
  14577. get speedRatio(): number;
  14578. set speedRatio(value: number);
  14579. /**
  14580. * Creates a new Animatable
  14581. * @param scene defines the hosting scene
  14582. * @param target defines the target object
  14583. * @param fromFrame defines the starting frame number (default is 0)
  14584. * @param toFrame defines the ending frame number (default is 100)
  14585. * @param loopAnimation defines if the animation must loop (default is false)
  14586. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14587. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14588. * @param animations defines a group of animation to add to the new Animatable
  14589. * @param onAnimationLoop defines a callback to call when animation loops
  14590. */
  14591. constructor(scene: Scene,
  14592. /** defines the target object */
  14593. target: any,
  14594. /** defines the starting frame number (default is 0) */
  14595. fromFrame?: number,
  14596. /** defines the ending frame number (default is 100) */
  14597. toFrame?: number,
  14598. /** defines if the animation must loop (default is false) */
  14599. loopAnimation?: boolean, speedRatio?: number,
  14600. /** defines a callback to call when animation ends if it is not looping */
  14601. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14602. /** defines a callback to call when animation loops */
  14603. onAnimationLoop?: (() => void) | null | undefined);
  14604. /**
  14605. * Synchronize and normalize current Animatable with a source Animatable
  14606. * This is useful when using animation weights and when animations are not of the same length
  14607. * @param root defines the root Animatable to synchronize with
  14608. * @returns the current Animatable
  14609. */
  14610. syncWith(root: Animatable): Animatable;
  14611. /**
  14612. * Gets the list of runtime animations
  14613. * @returns an array of RuntimeAnimation
  14614. */
  14615. getAnimations(): RuntimeAnimation[];
  14616. /**
  14617. * Adds more animations to the current animatable
  14618. * @param target defines the target of the animations
  14619. * @param animations defines the new animations to add
  14620. */
  14621. appendAnimations(target: any, animations: Animation[]): void;
  14622. /**
  14623. * Gets the source animation for a specific property
  14624. * @param property defines the propertyu to look for
  14625. * @returns null or the source animation for the given property
  14626. */
  14627. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14628. /**
  14629. * Gets the runtime animation for a specific property
  14630. * @param property defines the propertyu to look for
  14631. * @returns null or the runtime animation for the given property
  14632. */
  14633. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14634. /**
  14635. * Resets the animatable to its original state
  14636. */
  14637. reset(): void;
  14638. /**
  14639. * Allows the animatable to blend with current running animations
  14640. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14641. * @param blendingSpeed defines the blending speed to use
  14642. */
  14643. enableBlending(blendingSpeed: number): void;
  14644. /**
  14645. * Disable animation blending
  14646. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14647. */
  14648. disableBlending(): void;
  14649. /**
  14650. * Jump directly to a given frame
  14651. * @param frame defines the frame to jump to
  14652. */
  14653. goToFrame(frame: number): void;
  14654. /**
  14655. * Pause the animation
  14656. */
  14657. pause(): void;
  14658. /**
  14659. * Restart the animation
  14660. */
  14661. restart(): void;
  14662. private _raiseOnAnimationEnd;
  14663. /**
  14664. * Stop and delete the current animation
  14665. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14666. * @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)
  14667. */
  14668. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14669. /**
  14670. * Wait asynchronously for the animation to end
  14671. * @returns a promise which will be fullfilled when the animation ends
  14672. */
  14673. waitAsync(): Promise<Animatable>;
  14674. /** @hidden */
  14675. _animate(delay: number): boolean;
  14676. }
  14677. interface Scene {
  14678. /** @hidden */
  14679. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14680. /** @hidden */
  14681. _processLateAnimationBindingsForMatrices(holder: {
  14682. totalWeight: number;
  14683. animations: RuntimeAnimation[];
  14684. originalValue: Matrix;
  14685. }): any;
  14686. /** @hidden */
  14687. _processLateAnimationBindingsForQuaternions(holder: {
  14688. totalWeight: number;
  14689. animations: RuntimeAnimation[];
  14690. originalValue: Quaternion;
  14691. }, refQuaternion: Quaternion): Quaternion;
  14692. /** @hidden */
  14693. _processLateAnimationBindings(): void;
  14694. /**
  14695. * Will start the animation sequence of a given target
  14696. * @param target defines the target
  14697. * @param from defines from which frame should animation start
  14698. * @param to defines until which frame should animation run.
  14699. * @param weight defines the weight to apply to the animation (1.0 by default)
  14700. * @param loop defines if the animation loops
  14701. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14702. * @param onAnimationEnd defines the function to be executed when the animation ends
  14703. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14704. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14705. * @param onAnimationLoop defines the callback to call when an animation loops
  14706. * @returns the animatable object created for this animation
  14707. */
  14708. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14709. /**
  14710. * Will start the animation sequence of a given target
  14711. * @param target defines the target
  14712. * @param from defines from which frame should animation start
  14713. * @param to defines until which frame should animation run.
  14714. * @param loop defines if the animation loops
  14715. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14716. * @param onAnimationEnd defines the function to be executed when the animation ends
  14717. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14718. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14719. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14720. * @param onAnimationLoop defines the callback to call when an animation loops
  14721. * @returns the animatable object created for this animation
  14722. */
  14723. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14724. /**
  14725. * Will start the animation sequence of a given target and its hierarchy
  14726. * @param target defines the target
  14727. * @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.
  14728. * @param from defines from which frame should animation start
  14729. * @param to defines until which frame should animation run.
  14730. * @param loop defines if the animation loops
  14731. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14732. * @param onAnimationEnd defines the function to be executed when the animation ends
  14733. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14734. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14735. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14736. * @param onAnimationLoop defines the callback to call when an animation loops
  14737. * @returns the list of created animatables
  14738. */
  14739. 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[];
  14740. /**
  14741. * Begin a new animation on a given node
  14742. * @param target defines the target where the animation will take place
  14743. * @param animations defines the list of animations to start
  14744. * @param from defines the initial value
  14745. * @param to defines the final value
  14746. * @param loop defines if you want animation to loop (off by default)
  14747. * @param speedRatio defines the speed ratio to apply to all animations
  14748. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14749. * @param onAnimationLoop defines the callback to call when an animation loops
  14750. * @returns the list of created animatables
  14751. */
  14752. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14753. /**
  14754. * Begin a new animation on a given node and its hierarchy
  14755. * @param target defines the root node where the animation will take place
  14756. * @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.
  14757. * @param animations defines the list of animations to start
  14758. * @param from defines the initial value
  14759. * @param to defines the final value
  14760. * @param loop defines if you want animation to loop (off by default)
  14761. * @param speedRatio defines the speed ratio to apply to all animations
  14762. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14763. * @param onAnimationLoop defines the callback to call when an animation loops
  14764. * @returns the list of animatables created for all nodes
  14765. */
  14766. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14767. /**
  14768. * Gets the animatable associated with a specific target
  14769. * @param target defines the target of the animatable
  14770. * @returns the required animatable if found
  14771. */
  14772. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14773. /**
  14774. * Gets all animatables associated with a given target
  14775. * @param target defines the target to look animatables for
  14776. * @returns an array of Animatables
  14777. */
  14778. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14779. /**
  14780. * Stops and removes all animations that have been applied to the scene
  14781. */
  14782. stopAllAnimations(): void;
  14783. /**
  14784. * Gets the current delta time used by animation engine
  14785. */
  14786. deltaTime: number;
  14787. }
  14788. interface Bone {
  14789. /**
  14790. * Copy an animation range from another bone
  14791. * @param source defines the source bone
  14792. * @param rangeName defines the range name to copy
  14793. * @param frameOffset defines the frame offset
  14794. * @param rescaleAsRequired defines if rescaling must be applied if required
  14795. * @param skelDimensionsRatio defines the scaling ratio
  14796. * @returns true if operation was successful
  14797. */
  14798. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14799. }
  14800. }
  14801. declare module BABYLON {
  14802. /**
  14803. * Class used to handle skinning animations
  14804. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14805. */
  14806. export class Skeleton implements IAnimatable {
  14807. /** defines the skeleton name */
  14808. name: string;
  14809. /** defines the skeleton Id */
  14810. id: string;
  14811. /**
  14812. * Defines the list of child bones
  14813. */
  14814. bones: Bone[];
  14815. /**
  14816. * Defines an estimate of the dimension of the skeleton at rest
  14817. */
  14818. dimensionsAtRest: Vector3;
  14819. /**
  14820. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14821. */
  14822. needInitialSkinMatrix: boolean;
  14823. /**
  14824. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14825. */
  14826. overrideMesh: Nullable<AbstractMesh>;
  14827. /**
  14828. * Gets the list of animations attached to this skeleton
  14829. */
  14830. animations: Array<Animation>;
  14831. private _scene;
  14832. private _isDirty;
  14833. private _transformMatrices;
  14834. private _transformMatrixTexture;
  14835. private _meshesWithPoseMatrix;
  14836. private _animatables;
  14837. private _identity;
  14838. private _synchronizedWithMesh;
  14839. private _ranges;
  14840. private _lastAbsoluteTransformsUpdateId;
  14841. private _canUseTextureForBones;
  14842. private _uniqueId;
  14843. /** @hidden */
  14844. _numBonesWithLinkedTransformNode: number;
  14845. /** @hidden */
  14846. _hasWaitingData: Nullable<boolean>;
  14847. /**
  14848. * Specifies if the skeleton should be serialized
  14849. */
  14850. doNotSerialize: boolean;
  14851. private _useTextureToStoreBoneMatrices;
  14852. /**
  14853. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14854. * Please note that this option is not available if the hardware does not support it
  14855. */
  14856. get useTextureToStoreBoneMatrices(): boolean;
  14857. set useTextureToStoreBoneMatrices(value: boolean);
  14858. private _animationPropertiesOverride;
  14859. /**
  14860. * Gets or sets the animation properties override
  14861. */
  14862. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14863. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14864. /**
  14865. * List of inspectable custom properties (used by the Inspector)
  14866. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14867. */
  14868. inspectableCustomProperties: IInspectable[];
  14869. /**
  14870. * An observable triggered before computing the skeleton's matrices
  14871. */
  14872. onBeforeComputeObservable: Observable<Skeleton>;
  14873. /**
  14874. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14875. */
  14876. get isUsingTextureForMatrices(): boolean;
  14877. /**
  14878. * Gets the unique ID of this skeleton
  14879. */
  14880. get uniqueId(): number;
  14881. /**
  14882. * Creates a new skeleton
  14883. * @param name defines the skeleton name
  14884. * @param id defines the skeleton Id
  14885. * @param scene defines the hosting scene
  14886. */
  14887. constructor(
  14888. /** defines the skeleton name */
  14889. name: string,
  14890. /** defines the skeleton Id */
  14891. id: string, scene: Scene);
  14892. /**
  14893. * Gets the current object class name.
  14894. * @return the class name
  14895. */
  14896. getClassName(): string;
  14897. /**
  14898. * Returns an array containing the root bones
  14899. * @returns an array containing the root bones
  14900. */
  14901. getChildren(): Array<Bone>;
  14902. /**
  14903. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14904. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14905. * @returns a Float32Array containing matrices data
  14906. */
  14907. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14908. /**
  14909. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14910. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14911. * @returns a raw texture containing the data
  14912. */
  14913. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14914. /**
  14915. * Gets the current hosting scene
  14916. * @returns a scene object
  14917. */
  14918. getScene(): Scene;
  14919. /**
  14920. * Gets a string representing the current skeleton data
  14921. * @param fullDetails defines a boolean indicating if we want a verbose version
  14922. * @returns a string representing the current skeleton data
  14923. */
  14924. toString(fullDetails?: boolean): string;
  14925. /**
  14926. * Get bone's index searching by name
  14927. * @param name defines bone's name to search for
  14928. * @return the indice of the bone. Returns -1 if not found
  14929. */
  14930. getBoneIndexByName(name: string): number;
  14931. /**
  14932. * Creater a new animation range
  14933. * @param name defines the name of the range
  14934. * @param from defines the start key
  14935. * @param to defines the end key
  14936. */
  14937. createAnimationRange(name: string, from: number, to: number): void;
  14938. /**
  14939. * Delete a specific animation range
  14940. * @param name defines the name of the range
  14941. * @param deleteFrames defines if frames must be removed as well
  14942. */
  14943. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14944. /**
  14945. * Gets a specific animation range
  14946. * @param name defines the name of the range to look for
  14947. * @returns the requested animation range or null if not found
  14948. */
  14949. getAnimationRange(name: string): Nullable<AnimationRange>;
  14950. /**
  14951. * Gets the list of all animation ranges defined on this skeleton
  14952. * @returns an array
  14953. */
  14954. getAnimationRanges(): Nullable<AnimationRange>[];
  14955. /**
  14956. * Copy animation range from a source skeleton.
  14957. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14958. * @param source defines the source skeleton
  14959. * @param name defines the name of the range to copy
  14960. * @param rescaleAsRequired defines if rescaling must be applied if required
  14961. * @returns true if operation was successful
  14962. */
  14963. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  14964. /**
  14965. * Forces the skeleton to go to rest pose
  14966. */
  14967. returnToRest(): void;
  14968. private _getHighestAnimationFrame;
  14969. /**
  14970. * Begin a specific animation range
  14971. * @param name defines the name of the range to start
  14972. * @param loop defines if looping must be turned on (false by default)
  14973. * @param speedRatio defines the speed ratio to apply (1 by default)
  14974. * @param onAnimationEnd defines a callback which will be called when animation will end
  14975. * @returns a new animatable
  14976. */
  14977. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  14978. /** @hidden */
  14979. _markAsDirty(): void;
  14980. /** @hidden */
  14981. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14982. /** @hidden */
  14983. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14984. private _computeTransformMatrices;
  14985. /**
  14986. * Build all resources required to render a skeleton
  14987. */
  14988. prepare(): void;
  14989. /**
  14990. * Gets the list of animatables currently running for this skeleton
  14991. * @returns an array of animatables
  14992. */
  14993. getAnimatables(): IAnimatable[];
  14994. /**
  14995. * Clone the current skeleton
  14996. * @param name defines the name of the new skeleton
  14997. * @param id defines the id of the new skeleton
  14998. * @returns the new skeleton
  14999. */
  15000. clone(name: string, id?: string): Skeleton;
  15001. /**
  15002. * Enable animation blending for this skeleton
  15003. * @param blendingSpeed defines the blending speed to apply
  15004. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15005. */
  15006. enableBlending(blendingSpeed?: number): void;
  15007. /**
  15008. * Releases all resources associated with the current skeleton
  15009. */
  15010. dispose(): void;
  15011. /**
  15012. * Serialize the skeleton in a JSON object
  15013. * @returns a JSON object
  15014. */
  15015. serialize(): any;
  15016. /**
  15017. * Creates a new skeleton from serialized data
  15018. * @param parsedSkeleton defines the serialized data
  15019. * @param scene defines the hosting scene
  15020. * @returns a new skeleton
  15021. */
  15022. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15023. /**
  15024. * Compute all node absolute transforms
  15025. * @param forceUpdate defines if computation must be done even if cache is up to date
  15026. */
  15027. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15028. /**
  15029. * Gets the root pose matrix
  15030. * @returns a matrix
  15031. */
  15032. getPoseMatrix(): Nullable<Matrix>;
  15033. /**
  15034. * Sorts bones per internal index
  15035. */
  15036. sortBones(): void;
  15037. private _sortBones;
  15038. }
  15039. }
  15040. declare module BABYLON {
  15041. /**
  15042. * Creates an instance based on a source mesh.
  15043. */
  15044. export class InstancedMesh extends AbstractMesh {
  15045. private _sourceMesh;
  15046. private _currentLOD;
  15047. /** @hidden */
  15048. _indexInSourceMeshInstanceArray: number;
  15049. constructor(name: string, source: Mesh);
  15050. /**
  15051. * Returns the string "InstancedMesh".
  15052. */
  15053. getClassName(): string;
  15054. /** Gets the list of lights affecting that mesh */
  15055. get lightSources(): Light[];
  15056. _resyncLightSources(): void;
  15057. _resyncLightSource(light: Light): void;
  15058. _removeLightSource(light: Light, dispose: boolean): void;
  15059. /**
  15060. * If the source mesh receives shadows
  15061. */
  15062. get receiveShadows(): boolean;
  15063. /**
  15064. * The material of the source mesh
  15065. */
  15066. get material(): Nullable<Material>;
  15067. /**
  15068. * Visibility of the source mesh
  15069. */
  15070. get visibility(): number;
  15071. /**
  15072. * Skeleton of the source mesh
  15073. */
  15074. get skeleton(): Nullable<Skeleton>;
  15075. /**
  15076. * Rendering ground id of the source mesh
  15077. */
  15078. get renderingGroupId(): number;
  15079. set renderingGroupId(value: number);
  15080. /**
  15081. * Returns the total number of vertices (integer).
  15082. */
  15083. getTotalVertices(): number;
  15084. /**
  15085. * Returns a positive integer : the total number of indices in this mesh geometry.
  15086. * @returns the numner of indices or zero if the mesh has no geometry.
  15087. */
  15088. getTotalIndices(): number;
  15089. /**
  15090. * The source mesh of the instance
  15091. */
  15092. get sourceMesh(): Mesh;
  15093. /**
  15094. * Is this node ready to be used/rendered
  15095. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15096. * @return {boolean} is it ready
  15097. */
  15098. isReady(completeCheck?: boolean): boolean;
  15099. /**
  15100. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15101. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15102. * @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.
  15103. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15104. */
  15105. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15106. /**
  15107. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15108. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15109. * The `data` are either a numeric array either a Float32Array.
  15110. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15111. * 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).
  15112. * Note that a new underlying VertexBuffer object is created each call.
  15113. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15114. *
  15115. * Possible `kind` values :
  15116. * - VertexBuffer.PositionKind
  15117. * - VertexBuffer.UVKind
  15118. * - VertexBuffer.UV2Kind
  15119. * - VertexBuffer.UV3Kind
  15120. * - VertexBuffer.UV4Kind
  15121. * - VertexBuffer.UV5Kind
  15122. * - VertexBuffer.UV6Kind
  15123. * - VertexBuffer.ColorKind
  15124. * - VertexBuffer.MatricesIndicesKind
  15125. * - VertexBuffer.MatricesIndicesExtraKind
  15126. * - VertexBuffer.MatricesWeightsKind
  15127. * - VertexBuffer.MatricesWeightsExtraKind
  15128. *
  15129. * Returns the Mesh.
  15130. */
  15131. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15132. /**
  15133. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15134. * If the mesh has no geometry, it is simply returned as it is.
  15135. * The `data` are either a numeric array either a Float32Array.
  15136. * No new underlying VertexBuffer object is created.
  15137. * 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.
  15138. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15139. *
  15140. * Possible `kind` values :
  15141. * - VertexBuffer.PositionKind
  15142. * - VertexBuffer.UVKind
  15143. * - VertexBuffer.UV2Kind
  15144. * - VertexBuffer.UV3Kind
  15145. * - VertexBuffer.UV4Kind
  15146. * - VertexBuffer.UV5Kind
  15147. * - VertexBuffer.UV6Kind
  15148. * - VertexBuffer.ColorKind
  15149. * - VertexBuffer.MatricesIndicesKind
  15150. * - VertexBuffer.MatricesIndicesExtraKind
  15151. * - VertexBuffer.MatricesWeightsKind
  15152. * - VertexBuffer.MatricesWeightsExtraKind
  15153. *
  15154. * Returns the Mesh.
  15155. */
  15156. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15157. /**
  15158. * Sets the mesh indices.
  15159. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15160. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15161. * This method creates a new index buffer each call.
  15162. * Returns the Mesh.
  15163. */
  15164. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15165. /**
  15166. * Boolean : True if the mesh owns the requested kind of data.
  15167. */
  15168. isVerticesDataPresent(kind: string): boolean;
  15169. /**
  15170. * Returns an array of indices (IndicesArray).
  15171. */
  15172. getIndices(): Nullable<IndicesArray>;
  15173. get _positions(): Nullable<Vector3[]>;
  15174. /**
  15175. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15176. * This means the mesh underlying bounding box and sphere are recomputed.
  15177. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15178. * @returns the current mesh
  15179. */
  15180. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15181. /** @hidden */
  15182. _preActivate(): InstancedMesh;
  15183. /** @hidden */
  15184. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15185. /** @hidden */
  15186. _postActivate(): void;
  15187. getWorldMatrix(): Matrix;
  15188. get isAnInstance(): boolean;
  15189. /**
  15190. * Returns the current associated LOD AbstractMesh.
  15191. */
  15192. getLOD(camera: Camera): AbstractMesh;
  15193. /** @hidden */
  15194. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15195. /** @hidden */
  15196. _syncSubMeshes(): InstancedMesh;
  15197. /** @hidden */
  15198. _generatePointsArray(): boolean;
  15199. /**
  15200. * Creates a new InstancedMesh from the current mesh.
  15201. * - name (string) : the cloned mesh name
  15202. * - newParent (optional Node) : the optional Node to parent the clone to.
  15203. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15204. *
  15205. * Returns the clone.
  15206. */
  15207. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15208. /**
  15209. * Disposes the InstancedMesh.
  15210. * Returns nothing.
  15211. */
  15212. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15213. }
  15214. interface Mesh {
  15215. /**
  15216. * Register a custom buffer that will be instanced
  15217. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15218. * @param kind defines the buffer kind
  15219. * @param stride defines the stride in floats
  15220. */
  15221. registerInstancedBuffer(kind: string, stride: number): void;
  15222. /** @hidden */
  15223. _userInstancedBuffersStorage: {
  15224. data: {
  15225. [key: string]: Float32Array;
  15226. };
  15227. sizes: {
  15228. [key: string]: number;
  15229. };
  15230. vertexBuffers: {
  15231. [key: string]: Nullable<VertexBuffer>;
  15232. };
  15233. strides: {
  15234. [key: string]: number;
  15235. };
  15236. };
  15237. }
  15238. interface AbstractMesh {
  15239. /**
  15240. * Object used to store instanced buffers defined by user
  15241. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15242. */
  15243. instancedBuffers: {
  15244. [key: string]: any;
  15245. };
  15246. }
  15247. }
  15248. declare module BABYLON {
  15249. /**
  15250. * Defines the options associated with the creation of a shader material.
  15251. */
  15252. export interface IShaderMaterialOptions {
  15253. /**
  15254. * Does the material work in alpha blend mode
  15255. */
  15256. needAlphaBlending: boolean;
  15257. /**
  15258. * Does the material work in alpha test mode
  15259. */
  15260. needAlphaTesting: boolean;
  15261. /**
  15262. * The list of attribute names used in the shader
  15263. */
  15264. attributes: string[];
  15265. /**
  15266. * The list of unifrom names used in the shader
  15267. */
  15268. uniforms: string[];
  15269. /**
  15270. * The list of UBO names used in the shader
  15271. */
  15272. uniformBuffers: string[];
  15273. /**
  15274. * The list of sampler names used in the shader
  15275. */
  15276. samplers: string[];
  15277. /**
  15278. * The list of defines used in the shader
  15279. */
  15280. defines: string[];
  15281. }
  15282. /**
  15283. * 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.
  15284. *
  15285. * This returned material effects how the mesh will look based on the code in the shaders.
  15286. *
  15287. * @see http://doc.babylonjs.com/how_to/shader_material
  15288. */
  15289. export class ShaderMaterial extends Material {
  15290. private _shaderPath;
  15291. private _options;
  15292. private _textures;
  15293. private _textureArrays;
  15294. private _floats;
  15295. private _ints;
  15296. private _floatsArrays;
  15297. private _colors3;
  15298. private _colors3Arrays;
  15299. private _colors4;
  15300. private _colors4Arrays;
  15301. private _vectors2;
  15302. private _vectors3;
  15303. private _vectors4;
  15304. private _matrices;
  15305. private _matrixArrays;
  15306. private _matrices3x3;
  15307. private _matrices2x2;
  15308. private _vectors2Arrays;
  15309. private _vectors3Arrays;
  15310. private _vectors4Arrays;
  15311. private _cachedWorldViewMatrix;
  15312. private _cachedWorldViewProjectionMatrix;
  15313. private _renderId;
  15314. private _multiview;
  15315. /**
  15316. * Instantiate a new shader material.
  15317. * 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.
  15318. * This returned material effects how the mesh will look based on the code in the shaders.
  15319. * @see http://doc.babylonjs.com/how_to/shader_material
  15320. * @param name Define the name of the material in the scene
  15321. * @param scene Define the scene the material belongs to
  15322. * @param shaderPath Defines the route to the shader code in one of three ways:
  15323. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15324. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15325. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15326. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15327. * @param options Define the options used to create the shader
  15328. */
  15329. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15330. /**
  15331. * Gets the shader path used to define the shader code
  15332. * It can be modified to trigger a new compilation
  15333. */
  15334. get shaderPath(): any;
  15335. /**
  15336. * Sets the shader path used to define the shader code
  15337. * It can be modified to trigger a new compilation
  15338. */
  15339. set shaderPath(shaderPath: any);
  15340. /**
  15341. * Gets the options used to compile the shader.
  15342. * They can be modified to trigger a new compilation
  15343. */
  15344. get options(): IShaderMaterialOptions;
  15345. /**
  15346. * Gets the current class name of the material e.g. "ShaderMaterial"
  15347. * Mainly use in serialization.
  15348. * @returns the class name
  15349. */
  15350. getClassName(): string;
  15351. /**
  15352. * Specifies if the material will require alpha blending
  15353. * @returns a boolean specifying if alpha blending is needed
  15354. */
  15355. needAlphaBlending(): boolean;
  15356. /**
  15357. * Specifies if this material should be rendered in alpha test mode
  15358. * @returns a boolean specifying if an alpha test is needed.
  15359. */
  15360. needAlphaTesting(): boolean;
  15361. private _checkUniform;
  15362. /**
  15363. * Set a texture in the shader.
  15364. * @param name Define the name of the uniform samplers as defined in the shader
  15365. * @param texture Define the texture to bind to this sampler
  15366. * @return the material itself allowing "fluent" like uniform updates
  15367. */
  15368. setTexture(name: string, texture: Texture): ShaderMaterial;
  15369. /**
  15370. * Set a texture array in the shader.
  15371. * @param name Define the name of the uniform sampler array as defined in the shader
  15372. * @param textures Define the list of textures to bind to this sampler
  15373. * @return the material itself allowing "fluent" like uniform updates
  15374. */
  15375. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15376. /**
  15377. * Set a float in the shader.
  15378. * @param name Define the name of the uniform as defined in the shader
  15379. * @param value Define the value to give to the uniform
  15380. * @return the material itself allowing "fluent" like uniform updates
  15381. */
  15382. setFloat(name: string, value: number): ShaderMaterial;
  15383. /**
  15384. * Set a int in the shader.
  15385. * @param name Define the name of the uniform as defined in the shader
  15386. * @param value Define the value to give to the uniform
  15387. * @return the material itself allowing "fluent" like uniform updates
  15388. */
  15389. setInt(name: string, value: number): ShaderMaterial;
  15390. /**
  15391. * Set an array of floats in the shader.
  15392. * @param name Define the name of the uniform as defined in the shader
  15393. * @param value Define the value to give to the uniform
  15394. * @return the material itself allowing "fluent" like uniform updates
  15395. */
  15396. setFloats(name: string, value: number[]): ShaderMaterial;
  15397. /**
  15398. * Set a vec3 in the shader from a Color3.
  15399. * @param name Define the name of the uniform as defined in the shader
  15400. * @param value Define the value to give to the uniform
  15401. * @return the material itself allowing "fluent" like uniform updates
  15402. */
  15403. setColor3(name: string, value: Color3): ShaderMaterial;
  15404. /**
  15405. * Set a vec3 array in the shader from a Color3 array.
  15406. * @param name Define the name of the uniform as defined in the shader
  15407. * @param value Define the value to give to the uniform
  15408. * @return the material itself allowing "fluent" like uniform updates
  15409. */
  15410. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15411. /**
  15412. * Set a vec4 in the shader from a Color4.
  15413. * @param name Define the name of the uniform as defined in the shader
  15414. * @param value Define the value to give to the uniform
  15415. * @return the material itself allowing "fluent" like uniform updates
  15416. */
  15417. setColor4(name: string, value: Color4): ShaderMaterial;
  15418. /**
  15419. * Set a vec4 array in the shader from a Color4 array.
  15420. * @param name Define the name of the uniform as defined in the shader
  15421. * @param value Define the value to give to the uniform
  15422. * @return the material itself allowing "fluent" like uniform updates
  15423. */
  15424. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15425. /**
  15426. * Set a vec2 in the shader from a Vector2.
  15427. * @param name Define the name of the uniform as defined in the shader
  15428. * @param value Define the value to give to the uniform
  15429. * @return the material itself allowing "fluent" like uniform updates
  15430. */
  15431. setVector2(name: string, value: Vector2): ShaderMaterial;
  15432. /**
  15433. * Set a vec3 in the shader from a Vector3.
  15434. * @param name Define the name of the uniform as defined in the shader
  15435. * @param value Define the value to give to the uniform
  15436. * @return the material itself allowing "fluent" like uniform updates
  15437. */
  15438. setVector3(name: string, value: Vector3): ShaderMaterial;
  15439. /**
  15440. * Set a vec4 in the shader from a Vector4.
  15441. * @param name Define the name of the uniform as defined in the shader
  15442. * @param value Define the value to give to the uniform
  15443. * @return the material itself allowing "fluent" like uniform updates
  15444. */
  15445. setVector4(name: string, value: Vector4): ShaderMaterial;
  15446. /**
  15447. * Set a mat4 in the shader from a Matrix.
  15448. * @param name Define the name of the uniform as defined in the shader
  15449. * @param value Define the value to give to the uniform
  15450. * @return the material itself allowing "fluent" like uniform updates
  15451. */
  15452. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15453. /**
  15454. * Set a float32Array in the shader from a matrix array.
  15455. * @param name Define the name of the uniform as defined in the shader
  15456. * @param value Define the value to give to the uniform
  15457. * @return the material itself allowing "fluent" like uniform updates
  15458. */
  15459. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15460. /**
  15461. * Set a mat3 in the shader from a Float32Array.
  15462. * @param name Define the name of the uniform as defined in the shader
  15463. * @param value Define the value to give to the uniform
  15464. * @return the material itself allowing "fluent" like uniform updates
  15465. */
  15466. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15467. /**
  15468. * Set a mat2 in the shader from a Float32Array.
  15469. * @param name Define the name of the uniform as defined in the shader
  15470. * @param value Define the value to give to the uniform
  15471. * @return the material itself allowing "fluent" like uniform updates
  15472. */
  15473. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15474. /**
  15475. * Set a vec2 array in the shader from a number array.
  15476. * @param name Define the name of the uniform as defined in the shader
  15477. * @param value Define the value to give to the uniform
  15478. * @return the material itself allowing "fluent" like uniform updates
  15479. */
  15480. setArray2(name: string, value: number[]): ShaderMaterial;
  15481. /**
  15482. * Set a vec3 array in the shader from a number array.
  15483. * @param name Define the name of the uniform as defined in the shader
  15484. * @param value Define the value to give to the uniform
  15485. * @return the material itself allowing "fluent" like uniform updates
  15486. */
  15487. setArray3(name: string, value: number[]): ShaderMaterial;
  15488. /**
  15489. * Set a vec4 array in the shader from a number array.
  15490. * @param name Define the name of the uniform as defined in the shader
  15491. * @param value Define the value to give to the uniform
  15492. * @return the material itself allowing "fluent" like uniform updates
  15493. */
  15494. setArray4(name: string, value: number[]): ShaderMaterial;
  15495. private _checkCache;
  15496. /**
  15497. * Specifies that the submesh is ready to be used
  15498. * @param mesh defines the mesh to check
  15499. * @param subMesh defines which submesh to check
  15500. * @param useInstances specifies that instances should be used
  15501. * @returns a boolean indicating that the submesh is ready or not
  15502. */
  15503. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15504. /**
  15505. * Checks if the material is ready to render the requested mesh
  15506. * @param mesh Define the mesh to render
  15507. * @param useInstances Define whether or not the material is used with instances
  15508. * @returns true if ready, otherwise false
  15509. */
  15510. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15511. /**
  15512. * Binds the world matrix to the material
  15513. * @param world defines the world transformation matrix
  15514. */
  15515. bindOnlyWorldMatrix(world: Matrix): void;
  15516. /**
  15517. * Binds the material to the mesh
  15518. * @param world defines the world transformation matrix
  15519. * @param mesh defines the mesh to bind the material to
  15520. */
  15521. bind(world: Matrix, mesh?: Mesh): void;
  15522. /**
  15523. * Gets the active textures from the material
  15524. * @returns an array of textures
  15525. */
  15526. getActiveTextures(): BaseTexture[];
  15527. /**
  15528. * Specifies if the material uses a texture
  15529. * @param texture defines the texture to check against the material
  15530. * @returns a boolean specifying if the material uses the texture
  15531. */
  15532. hasTexture(texture: BaseTexture): boolean;
  15533. /**
  15534. * Makes a duplicate of the material, and gives it a new name
  15535. * @param name defines the new name for the duplicated material
  15536. * @returns the cloned material
  15537. */
  15538. clone(name: string): ShaderMaterial;
  15539. /**
  15540. * Disposes the material
  15541. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15542. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15543. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15544. */
  15545. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15546. /**
  15547. * Serializes this material in a JSON representation
  15548. * @returns the serialized material object
  15549. */
  15550. serialize(): any;
  15551. /**
  15552. * Creates a shader material from parsed shader material data
  15553. * @param source defines the JSON represnetation of the material
  15554. * @param scene defines the hosting scene
  15555. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15556. * @returns a new material
  15557. */
  15558. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15559. }
  15560. }
  15561. declare module BABYLON {
  15562. /** @hidden */
  15563. export var colorPixelShader: {
  15564. name: string;
  15565. shader: string;
  15566. };
  15567. }
  15568. declare module BABYLON {
  15569. /** @hidden */
  15570. export var colorVertexShader: {
  15571. name: string;
  15572. shader: string;
  15573. };
  15574. }
  15575. declare module BABYLON {
  15576. /**
  15577. * Line mesh
  15578. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15579. */
  15580. export class LinesMesh extends Mesh {
  15581. /**
  15582. * If vertex color should be applied to the mesh
  15583. */
  15584. readonly useVertexColor?: boolean | undefined;
  15585. /**
  15586. * If vertex alpha should be applied to the mesh
  15587. */
  15588. readonly useVertexAlpha?: boolean | undefined;
  15589. /**
  15590. * Color of the line (Default: White)
  15591. */
  15592. color: Color3;
  15593. /**
  15594. * Alpha of the line (Default: 1)
  15595. */
  15596. alpha: number;
  15597. /**
  15598. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15599. * This margin is expressed in world space coordinates, so its value may vary.
  15600. * Default value is 0.1
  15601. */
  15602. intersectionThreshold: number;
  15603. private _colorShader;
  15604. private color4;
  15605. /**
  15606. * Creates a new LinesMesh
  15607. * @param name defines the name
  15608. * @param scene defines the hosting scene
  15609. * @param parent defines the parent mesh if any
  15610. * @param source defines the optional source LinesMesh used to clone data from
  15611. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15612. * When false, achieved by calling a clone(), also passing False.
  15613. * This will make creation of children, recursive.
  15614. * @param useVertexColor defines if this LinesMesh supports vertex color
  15615. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15616. */
  15617. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15618. /**
  15619. * If vertex color should be applied to the mesh
  15620. */
  15621. useVertexColor?: boolean | undefined,
  15622. /**
  15623. * If vertex alpha should be applied to the mesh
  15624. */
  15625. useVertexAlpha?: boolean | undefined);
  15626. private _addClipPlaneDefine;
  15627. private _removeClipPlaneDefine;
  15628. isReady(): boolean;
  15629. /**
  15630. * Returns the string "LineMesh"
  15631. */
  15632. getClassName(): string;
  15633. /**
  15634. * @hidden
  15635. */
  15636. get material(): Material;
  15637. /**
  15638. * @hidden
  15639. */
  15640. set material(value: Material);
  15641. /**
  15642. * @hidden
  15643. */
  15644. get checkCollisions(): boolean;
  15645. /** @hidden */
  15646. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15647. /** @hidden */
  15648. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15649. /**
  15650. * Disposes of the line mesh
  15651. * @param doNotRecurse If children should be disposed
  15652. */
  15653. dispose(doNotRecurse?: boolean): void;
  15654. /**
  15655. * Returns a new LineMesh object cloned from the current one.
  15656. */
  15657. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15658. /**
  15659. * Creates a new InstancedLinesMesh object from the mesh model.
  15660. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15661. * @param name defines the name of the new instance
  15662. * @returns a new InstancedLinesMesh
  15663. */
  15664. createInstance(name: string): InstancedLinesMesh;
  15665. }
  15666. /**
  15667. * Creates an instance based on a source LinesMesh
  15668. */
  15669. export class InstancedLinesMesh extends InstancedMesh {
  15670. /**
  15671. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15672. * This margin is expressed in world space coordinates, so its value may vary.
  15673. * Initilized with the intersectionThreshold value of the source LinesMesh
  15674. */
  15675. intersectionThreshold: number;
  15676. constructor(name: string, source: LinesMesh);
  15677. /**
  15678. * Returns the string "InstancedLinesMesh".
  15679. */
  15680. getClassName(): string;
  15681. }
  15682. }
  15683. declare module BABYLON {
  15684. /** @hidden */
  15685. export var linePixelShader: {
  15686. name: string;
  15687. shader: string;
  15688. };
  15689. }
  15690. declare module BABYLON {
  15691. /** @hidden */
  15692. export var lineVertexShader: {
  15693. name: string;
  15694. shader: string;
  15695. };
  15696. }
  15697. declare module BABYLON {
  15698. interface AbstractMesh {
  15699. /**
  15700. * Gets the edgesRenderer associated with the mesh
  15701. */
  15702. edgesRenderer: Nullable<EdgesRenderer>;
  15703. }
  15704. interface LinesMesh {
  15705. /**
  15706. * Enables the edge rendering mode on the mesh.
  15707. * This mode makes the mesh edges visible
  15708. * @param epsilon defines the maximal distance between two angles to detect a face
  15709. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15710. * @returns the currentAbstractMesh
  15711. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15712. */
  15713. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15714. }
  15715. interface InstancedLinesMesh {
  15716. /**
  15717. * Enables the edge rendering mode on the mesh.
  15718. * This mode makes the mesh edges visible
  15719. * @param epsilon defines the maximal distance between two angles to detect a face
  15720. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15721. * @returns the current InstancedLinesMesh
  15722. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15723. */
  15724. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15725. }
  15726. /**
  15727. * Defines the minimum contract an Edges renderer should follow.
  15728. */
  15729. export interface IEdgesRenderer extends IDisposable {
  15730. /**
  15731. * Gets or sets a boolean indicating if the edgesRenderer is active
  15732. */
  15733. isEnabled: boolean;
  15734. /**
  15735. * Renders the edges of the attached mesh,
  15736. */
  15737. render(): void;
  15738. /**
  15739. * Checks wether or not the edges renderer is ready to render.
  15740. * @return true if ready, otherwise false.
  15741. */
  15742. isReady(): boolean;
  15743. }
  15744. /**
  15745. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15746. */
  15747. export class EdgesRenderer implements IEdgesRenderer {
  15748. /**
  15749. * Define the size of the edges with an orthographic camera
  15750. */
  15751. edgesWidthScalerForOrthographic: number;
  15752. /**
  15753. * Define the size of the edges with a perspective camera
  15754. */
  15755. edgesWidthScalerForPerspective: number;
  15756. protected _source: AbstractMesh;
  15757. protected _linesPositions: number[];
  15758. protected _linesNormals: number[];
  15759. protected _linesIndices: number[];
  15760. protected _epsilon: number;
  15761. protected _indicesCount: number;
  15762. protected _lineShader: ShaderMaterial;
  15763. protected _ib: DataBuffer;
  15764. protected _buffers: {
  15765. [key: string]: Nullable<VertexBuffer>;
  15766. };
  15767. protected _checkVerticesInsteadOfIndices: boolean;
  15768. private _meshRebuildObserver;
  15769. private _meshDisposeObserver;
  15770. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15771. isEnabled: boolean;
  15772. /**
  15773. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15774. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15775. * @param source Mesh used to create edges
  15776. * @param epsilon sum of angles in adjacency to check for edge
  15777. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15778. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15779. */
  15780. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15781. protected _prepareRessources(): void;
  15782. /** @hidden */
  15783. _rebuild(): void;
  15784. /**
  15785. * Releases the required resources for the edges renderer
  15786. */
  15787. dispose(): void;
  15788. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15789. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15790. /**
  15791. * Checks if the pair of p0 and p1 is en edge
  15792. * @param faceIndex
  15793. * @param edge
  15794. * @param faceNormals
  15795. * @param p0
  15796. * @param p1
  15797. * @private
  15798. */
  15799. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15800. /**
  15801. * push line into the position, normal and index buffer
  15802. * @protected
  15803. */
  15804. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15805. /**
  15806. * Generates lines edges from adjacencjes
  15807. * @private
  15808. */
  15809. _generateEdgesLines(): void;
  15810. /**
  15811. * Checks wether or not the edges renderer is ready to render.
  15812. * @return true if ready, otherwise false.
  15813. */
  15814. isReady(): boolean;
  15815. /**
  15816. * Renders the edges of the attached mesh,
  15817. */
  15818. render(): void;
  15819. }
  15820. /**
  15821. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15822. */
  15823. export class LineEdgesRenderer extends EdgesRenderer {
  15824. /**
  15825. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15826. * @param source LineMesh used to generate edges
  15827. * @param epsilon not important (specified angle for edge detection)
  15828. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15829. */
  15830. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15831. /**
  15832. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15833. */
  15834. _generateEdgesLines(): void;
  15835. }
  15836. }
  15837. declare module BABYLON {
  15838. /**
  15839. * This represents the object necessary to create a rendering group.
  15840. * This is exclusively used and created by the rendering manager.
  15841. * To modify the behavior, you use the available helpers in your scene or meshes.
  15842. * @hidden
  15843. */
  15844. export class RenderingGroup {
  15845. index: number;
  15846. private static _zeroVector;
  15847. private _scene;
  15848. private _opaqueSubMeshes;
  15849. private _transparentSubMeshes;
  15850. private _alphaTestSubMeshes;
  15851. private _depthOnlySubMeshes;
  15852. private _particleSystems;
  15853. private _spriteManagers;
  15854. private _opaqueSortCompareFn;
  15855. private _alphaTestSortCompareFn;
  15856. private _transparentSortCompareFn;
  15857. private _renderOpaque;
  15858. private _renderAlphaTest;
  15859. private _renderTransparent;
  15860. /** @hidden */
  15861. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15862. onBeforeTransparentRendering: () => void;
  15863. /**
  15864. * Set the opaque sort comparison function.
  15865. * If null the sub meshes will be render in the order they were created
  15866. */
  15867. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15868. /**
  15869. * Set the alpha test sort comparison function.
  15870. * If null the sub meshes will be render in the order they were created
  15871. */
  15872. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15873. /**
  15874. * Set the transparent sort comparison function.
  15875. * If null the sub meshes will be render in the order they were created
  15876. */
  15877. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15878. /**
  15879. * Creates a new rendering group.
  15880. * @param index The rendering group index
  15881. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15882. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15883. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15884. */
  15885. 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>);
  15886. /**
  15887. * Render all the sub meshes contained in the group.
  15888. * @param customRenderFunction Used to override the default render behaviour of the group.
  15889. * @returns true if rendered some submeshes.
  15890. */
  15891. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15892. /**
  15893. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15894. * @param subMeshes The submeshes to render
  15895. */
  15896. private renderOpaqueSorted;
  15897. /**
  15898. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15899. * @param subMeshes The submeshes to render
  15900. */
  15901. private renderAlphaTestSorted;
  15902. /**
  15903. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15904. * @param subMeshes The submeshes to render
  15905. */
  15906. private renderTransparentSorted;
  15907. /**
  15908. * Renders the submeshes in a specified order.
  15909. * @param subMeshes The submeshes to sort before render
  15910. * @param sortCompareFn The comparison function use to sort
  15911. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15912. * @param transparent Specifies to activate blending if true
  15913. */
  15914. private static renderSorted;
  15915. /**
  15916. * Renders the submeshes in the order they were dispatched (no sort applied).
  15917. * @param subMeshes The submeshes to render
  15918. */
  15919. private static renderUnsorted;
  15920. /**
  15921. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15922. * are rendered back to front if in the same alpha index.
  15923. *
  15924. * @param a The first submesh
  15925. * @param b The second submesh
  15926. * @returns The result of the comparison
  15927. */
  15928. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15929. /**
  15930. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15931. * are rendered back to front.
  15932. *
  15933. * @param a The first submesh
  15934. * @param b The second submesh
  15935. * @returns The result of the comparison
  15936. */
  15937. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15938. /**
  15939. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15940. * are rendered front to back (prevent overdraw).
  15941. *
  15942. * @param a The first submesh
  15943. * @param b The second submesh
  15944. * @returns The result of the comparison
  15945. */
  15946. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15947. /**
  15948. * Resets the different lists of submeshes to prepare a new frame.
  15949. */
  15950. prepare(): void;
  15951. dispose(): void;
  15952. /**
  15953. * Inserts the submesh in its correct queue depending on its material.
  15954. * @param subMesh The submesh to dispatch
  15955. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15956. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15957. */
  15958. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15959. dispatchSprites(spriteManager: ISpriteManager): void;
  15960. dispatchParticles(particleSystem: IParticleSystem): void;
  15961. private _renderParticles;
  15962. private _renderSprites;
  15963. }
  15964. }
  15965. declare module BABYLON {
  15966. /**
  15967. * Interface describing the different options available in the rendering manager
  15968. * regarding Auto Clear between groups.
  15969. */
  15970. export interface IRenderingManagerAutoClearSetup {
  15971. /**
  15972. * Defines whether or not autoclear is enable.
  15973. */
  15974. autoClear: boolean;
  15975. /**
  15976. * Defines whether or not to autoclear the depth buffer.
  15977. */
  15978. depth: boolean;
  15979. /**
  15980. * Defines whether or not to autoclear the stencil buffer.
  15981. */
  15982. stencil: boolean;
  15983. }
  15984. /**
  15985. * This class is used by the onRenderingGroupObservable
  15986. */
  15987. export class RenderingGroupInfo {
  15988. /**
  15989. * The Scene that being rendered
  15990. */
  15991. scene: Scene;
  15992. /**
  15993. * The camera currently used for the rendering pass
  15994. */
  15995. camera: Nullable<Camera>;
  15996. /**
  15997. * The ID of the renderingGroup being processed
  15998. */
  15999. renderingGroupId: number;
  16000. }
  16001. /**
  16002. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16003. * It is enable to manage the different groups as well as the different necessary sort functions.
  16004. * This should not be used directly aside of the few static configurations
  16005. */
  16006. export class RenderingManager {
  16007. /**
  16008. * The max id used for rendering groups (not included)
  16009. */
  16010. static MAX_RENDERINGGROUPS: number;
  16011. /**
  16012. * The min id used for rendering groups (included)
  16013. */
  16014. static MIN_RENDERINGGROUPS: number;
  16015. /**
  16016. * Used to globally prevent autoclearing scenes.
  16017. */
  16018. static AUTOCLEAR: boolean;
  16019. /**
  16020. * @hidden
  16021. */
  16022. _useSceneAutoClearSetup: boolean;
  16023. private _scene;
  16024. private _renderingGroups;
  16025. private _depthStencilBufferAlreadyCleaned;
  16026. private _autoClearDepthStencil;
  16027. private _customOpaqueSortCompareFn;
  16028. private _customAlphaTestSortCompareFn;
  16029. private _customTransparentSortCompareFn;
  16030. private _renderingGroupInfo;
  16031. /**
  16032. * Instantiates a new rendering group for a particular scene
  16033. * @param scene Defines the scene the groups belongs to
  16034. */
  16035. constructor(scene: Scene);
  16036. private _clearDepthStencilBuffer;
  16037. /**
  16038. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16039. * @hidden
  16040. */
  16041. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16042. /**
  16043. * Resets the different information of the group to prepare a new frame
  16044. * @hidden
  16045. */
  16046. reset(): void;
  16047. /**
  16048. * Dispose and release the group and its associated resources.
  16049. * @hidden
  16050. */
  16051. dispose(): void;
  16052. /**
  16053. * Clear the info related to rendering groups preventing retention points during dispose.
  16054. */
  16055. freeRenderingGroups(): void;
  16056. private _prepareRenderingGroup;
  16057. /**
  16058. * Add a sprite manager to the rendering manager in order to render it this frame.
  16059. * @param spriteManager Define the sprite manager to render
  16060. */
  16061. dispatchSprites(spriteManager: ISpriteManager): void;
  16062. /**
  16063. * Add a particle system to the rendering manager in order to render it this frame.
  16064. * @param particleSystem Define the particle system to render
  16065. */
  16066. dispatchParticles(particleSystem: IParticleSystem): void;
  16067. /**
  16068. * Add a submesh to the manager in order to render it this frame
  16069. * @param subMesh The submesh to dispatch
  16070. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16071. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16072. */
  16073. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16074. /**
  16075. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16076. * This allowed control for front to back rendering or reversly depending of the special needs.
  16077. *
  16078. * @param renderingGroupId The rendering group id corresponding to its index
  16079. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16080. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16081. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16082. */
  16083. 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;
  16084. /**
  16085. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16086. *
  16087. * @param renderingGroupId The rendering group id corresponding to its index
  16088. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16089. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16090. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16091. */
  16092. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16093. /**
  16094. * Gets the current auto clear configuration for one rendering group of the rendering
  16095. * manager.
  16096. * @param index the rendering group index to get the information for
  16097. * @returns The auto clear setup for the requested rendering group
  16098. */
  16099. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16100. }
  16101. }
  16102. declare module BABYLON {
  16103. /**
  16104. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16105. */
  16106. export interface ICustomShaderOptions {
  16107. /**
  16108. * Gets or sets the custom shader name to use
  16109. */
  16110. shaderName: string;
  16111. /**
  16112. * The list of attribute names used in the shader
  16113. */
  16114. attributes?: string[];
  16115. /**
  16116. * The list of unifrom names used in the shader
  16117. */
  16118. uniforms?: string[];
  16119. /**
  16120. * The list of sampler names used in the shader
  16121. */
  16122. samplers?: string[];
  16123. /**
  16124. * The list of defines used in the shader
  16125. */
  16126. defines?: string[];
  16127. }
  16128. /**
  16129. * Interface to implement to create a shadow generator compatible with BJS.
  16130. */
  16131. export interface IShadowGenerator {
  16132. /**
  16133. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16134. * @returns The render target texture if present otherwise, null
  16135. */
  16136. getShadowMap(): Nullable<RenderTargetTexture>;
  16137. /**
  16138. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16139. * @param subMesh The submesh we want to render in the shadow map
  16140. * @param useInstances Defines wether will draw in the map using instances
  16141. * @returns true if ready otherwise, false
  16142. */
  16143. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16144. /**
  16145. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16146. * @param defines Defines of the material we want to update
  16147. * @param lightIndex Index of the light in the enabled light list of the material
  16148. */
  16149. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16150. /**
  16151. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16152. * defined in the generator but impacting the effect).
  16153. * It implies the unifroms available on the materials are the standard BJS ones.
  16154. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16155. * @param effect The effect we are binfing the information for
  16156. */
  16157. bindShadowLight(lightIndex: string, effect: Effect): void;
  16158. /**
  16159. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16160. * (eq to shadow prjection matrix * light transform matrix)
  16161. * @returns The transform matrix used to create the shadow map
  16162. */
  16163. getTransformMatrix(): Matrix;
  16164. /**
  16165. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16166. * Cube and 2D textures for instance.
  16167. */
  16168. recreateShadowMap(): void;
  16169. /**
  16170. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16171. * @param onCompiled Callback triggered at the and of the effects compilation
  16172. * @param options Sets of optional options forcing the compilation with different modes
  16173. */
  16174. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16175. useInstances: boolean;
  16176. }>): void;
  16177. /**
  16178. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16179. * @param options Sets of optional options forcing the compilation with different modes
  16180. * @returns A promise that resolves when the compilation completes
  16181. */
  16182. forceCompilationAsync(options?: Partial<{
  16183. useInstances: boolean;
  16184. }>): Promise<void>;
  16185. /**
  16186. * Serializes the shadow generator setup to a json object.
  16187. * @returns The serialized JSON object
  16188. */
  16189. serialize(): any;
  16190. /**
  16191. * Disposes the Shadow map and related Textures and effects.
  16192. */
  16193. dispose(): void;
  16194. }
  16195. /**
  16196. * Default implementation IShadowGenerator.
  16197. * This is the main object responsible of generating shadows in the framework.
  16198. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16199. */
  16200. export class ShadowGenerator implements IShadowGenerator {
  16201. /**
  16202. * Name of the shadow generator class
  16203. */
  16204. static CLASSNAME: string;
  16205. /**
  16206. * Shadow generator mode None: no filtering applied.
  16207. */
  16208. static readonly FILTER_NONE: number;
  16209. /**
  16210. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16211. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16212. */
  16213. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16214. /**
  16215. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16216. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16217. */
  16218. static readonly FILTER_POISSONSAMPLING: number;
  16219. /**
  16220. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16221. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16222. */
  16223. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16224. /**
  16225. * Shadow generator mode ESM: 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_CLOSEEXPONENTIALSHADOWMAP: number;
  16230. /**
  16231. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16232. * edge artifacts on steep falloff.
  16233. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16234. */
  16235. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16236. /**
  16237. * Shadow generator mode PCF: Percentage Closer Filtering
  16238. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16239. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16240. */
  16241. static readonly FILTER_PCF: number;
  16242. /**
  16243. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16244. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16245. * Contact Hardening
  16246. */
  16247. static readonly FILTER_PCSS: number;
  16248. /**
  16249. * Reserved for PCF and PCSS
  16250. * Highest Quality.
  16251. *
  16252. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16253. *
  16254. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16255. */
  16256. static readonly QUALITY_HIGH: number;
  16257. /**
  16258. * Reserved for PCF and PCSS
  16259. * Good tradeoff for quality/perf cross devices
  16260. *
  16261. * Execute PCF on a 3*3 kernel.
  16262. *
  16263. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16264. */
  16265. static readonly QUALITY_MEDIUM: number;
  16266. /**
  16267. * Reserved for PCF and PCSS
  16268. * The lowest quality but the fastest.
  16269. *
  16270. * Execute PCF on a 1*1 kernel.
  16271. *
  16272. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16273. */
  16274. static readonly QUALITY_LOW: number;
  16275. /** Gets or sets the custom shader name to use */
  16276. customShaderOptions: ICustomShaderOptions;
  16277. /**
  16278. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16279. */
  16280. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16281. /**
  16282. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16283. */
  16284. onAfterShadowMapRenderObservable: Observable<Effect>;
  16285. /**
  16286. * Observable triggered before a mesh is rendered in the shadow map.
  16287. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16288. */
  16289. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16290. /**
  16291. * Observable triggered after a mesh is rendered in the shadow map.
  16292. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16293. */
  16294. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16295. protected _bias: number;
  16296. /**
  16297. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16298. */
  16299. get bias(): number;
  16300. /**
  16301. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16302. */
  16303. set bias(bias: number);
  16304. protected _normalBias: number;
  16305. /**
  16306. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16307. */
  16308. get normalBias(): number;
  16309. /**
  16310. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16311. */
  16312. set normalBias(normalBias: number);
  16313. protected _blurBoxOffset: number;
  16314. /**
  16315. * Gets the blur box offset: offset applied during the blur pass.
  16316. * Only useful if useKernelBlur = false
  16317. */
  16318. get blurBoxOffset(): number;
  16319. /**
  16320. * Sets the blur box offset: offset applied during the blur pass.
  16321. * Only useful if useKernelBlur = false
  16322. */
  16323. set blurBoxOffset(value: number);
  16324. protected _blurScale: number;
  16325. /**
  16326. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16327. * 2 means half of the size.
  16328. */
  16329. get blurScale(): number;
  16330. /**
  16331. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16332. * 2 means half of the size.
  16333. */
  16334. set blurScale(value: number);
  16335. protected _blurKernel: number;
  16336. /**
  16337. * Gets the blur kernel: kernel size of the blur pass.
  16338. * Only useful if useKernelBlur = true
  16339. */
  16340. get blurKernel(): number;
  16341. /**
  16342. * Sets the blur kernel: kernel size of the blur pass.
  16343. * Only useful if useKernelBlur = true
  16344. */
  16345. set blurKernel(value: number);
  16346. protected _useKernelBlur: boolean;
  16347. /**
  16348. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16349. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16350. */
  16351. get useKernelBlur(): boolean;
  16352. /**
  16353. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16354. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16355. */
  16356. set useKernelBlur(value: boolean);
  16357. protected _depthScale: number;
  16358. /**
  16359. * Gets the depth scale used in ESM mode.
  16360. */
  16361. get depthScale(): number;
  16362. /**
  16363. * Sets the depth scale used in ESM mode.
  16364. * This can override the scale stored on the light.
  16365. */
  16366. set depthScale(value: number);
  16367. protected _validateFilter(filter: number): number;
  16368. protected _filter: number;
  16369. /**
  16370. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16371. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16372. */
  16373. get filter(): number;
  16374. /**
  16375. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16376. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16377. */
  16378. set filter(value: number);
  16379. /**
  16380. * Gets if the current filter is set to Poisson Sampling.
  16381. */
  16382. get usePoissonSampling(): boolean;
  16383. /**
  16384. * Sets the current filter to Poisson Sampling.
  16385. */
  16386. set usePoissonSampling(value: boolean);
  16387. /**
  16388. * Gets if the current filter is set to ESM.
  16389. */
  16390. get useExponentialShadowMap(): boolean;
  16391. /**
  16392. * Sets the current filter is to ESM.
  16393. */
  16394. set useExponentialShadowMap(value: boolean);
  16395. /**
  16396. * Gets if the current filter is set to filtered ESM.
  16397. */
  16398. get useBlurExponentialShadowMap(): boolean;
  16399. /**
  16400. * Gets if the current filter is set to filtered ESM.
  16401. */
  16402. set useBlurExponentialShadowMap(value: boolean);
  16403. /**
  16404. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16405. * exponential to prevent steep falloff artifacts).
  16406. */
  16407. get useCloseExponentialShadowMap(): boolean;
  16408. /**
  16409. * Sets the current filter to "close ESM" (using the inverse of the
  16410. * exponential to prevent steep falloff artifacts).
  16411. */
  16412. set useCloseExponentialShadowMap(value: boolean);
  16413. /**
  16414. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16415. * exponential to prevent steep falloff artifacts).
  16416. */
  16417. get useBlurCloseExponentialShadowMap(): boolean;
  16418. /**
  16419. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16420. * exponential to prevent steep falloff artifacts).
  16421. */
  16422. set useBlurCloseExponentialShadowMap(value: boolean);
  16423. /**
  16424. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16425. */
  16426. get usePercentageCloserFiltering(): boolean;
  16427. /**
  16428. * Sets the current filter to "PCF" (percentage closer filtering).
  16429. */
  16430. set usePercentageCloserFiltering(value: boolean);
  16431. protected _filteringQuality: number;
  16432. /**
  16433. * Gets the PCF or PCSS Quality.
  16434. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16435. */
  16436. get filteringQuality(): number;
  16437. /**
  16438. * Sets the PCF or PCSS Quality.
  16439. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16440. */
  16441. set filteringQuality(filteringQuality: number);
  16442. /**
  16443. * Gets if the current filter is set to "PCSS" (contact hardening).
  16444. */
  16445. get useContactHardeningShadow(): boolean;
  16446. /**
  16447. * Sets the current filter to "PCSS" (contact hardening).
  16448. */
  16449. set useContactHardeningShadow(value: boolean);
  16450. protected _contactHardeningLightSizeUVRatio: number;
  16451. /**
  16452. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16453. * Using a ratio helps keeping shape stability independently of the map size.
  16454. *
  16455. * It does not account for the light projection as it was having too much
  16456. * instability during the light setup or during light position changes.
  16457. *
  16458. * Only valid if useContactHardeningShadow is true.
  16459. */
  16460. get contactHardeningLightSizeUVRatio(): number;
  16461. /**
  16462. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16463. * Using a ratio helps keeping shape stability independently of the map size.
  16464. *
  16465. * It does not account for the light projection as it was having too much
  16466. * instability during the light setup or during light position changes.
  16467. *
  16468. * Only valid if useContactHardeningShadow is true.
  16469. */
  16470. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16471. protected _darkness: number;
  16472. /** Gets or sets the actual darkness of a shadow */
  16473. get darkness(): number;
  16474. set darkness(value: number);
  16475. /**
  16476. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16477. * 0 means strongest and 1 would means no shadow.
  16478. * @returns the darkness.
  16479. */
  16480. getDarkness(): number;
  16481. /**
  16482. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16483. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16484. * @returns the shadow generator allowing fluent coding.
  16485. */
  16486. setDarkness(darkness: number): ShadowGenerator;
  16487. protected _transparencyShadow: boolean;
  16488. /** Gets or sets the ability to have transparent shadow */
  16489. get transparencyShadow(): boolean;
  16490. set transparencyShadow(value: boolean);
  16491. /**
  16492. * Sets the ability to have transparent shadow (boolean).
  16493. * @param transparent True if transparent else False
  16494. * @returns the shadow generator allowing fluent coding
  16495. */
  16496. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16497. protected _shadowMap: Nullable<RenderTargetTexture>;
  16498. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16499. /**
  16500. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16501. * @returns The render target texture if present otherwise, null
  16502. */
  16503. getShadowMap(): Nullable<RenderTargetTexture>;
  16504. /**
  16505. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16506. * @returns The render target texture if the shadow map is present otherwise, null
  16507. */
  16508. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16509. /**
  16510. * Gets the class name of that object
  16511. * @returns "ShadowGenerator"
  16512. */
  16513. getClassName(): string;
  16514. /**
  16515. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16516. * @param mesh Mesh to add
  16517. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16518. * @returns the Shadow Generator itself
  16519. */
  16520. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16521. /**
  16522. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16523. * @param mesh Mesh to remove
  16524. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16525. * @returns the Shadow Generator itself
  16526. */
  16527. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16528. /**
  16529. * Controls the extent to which the shadows fade out at the edge of the frustum
  16530. */
  16531. frustumEdgeFalloff: number;
  16532. protected _light: IShadowLight;
  16533. /**
  16534. * Returns the associated light object.
  16535. * @returns the light generating the shadow
  16536. */
  16537. getLight(): IShadowLight;
  16538. /**
  16539. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16540. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16541. * It might on the other hand introduce peter panning.
  16542. */
  16543. forceBackFacesOnly: boolean;
  16544. protected _scene: Scene;
  16545. protected _lightDirection: Vector3;
  16546. protected _effect: Effect;
  16547. protected _viewMatrix: Matrix;
  16548. protected _projectionMatrix: Matrix;
  16549. protected _transformMatrix: Matrix;
  16550. protected _cachedPosition: Vector3;
  16551. protected _cachedDirection: Vector3;
  16552. protected _cachedDefines: string;
  16553. protected _currentRenderID: number;
  16554. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16555. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16556. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16557. protected _blurPostProcesses: PostProcess[];
  16558. protected _mapSize: number;
  16559. protected _currentFaceIndex: number;
  16560. protected _currentFaceIndexCache: number;
  16561. protected _textureType: number;
  16562. protected _defaultTextureMatrix: Matrix;
  16563. protected _storedUniqueId: Nullable<number>;
  16564. /** @hidden */
  16565. static _SceneComponentInitialization: (scene: Scene) => void;
  16566. /**
  16567. * Creates a ShadowGenerator object.
  16568. * A ShadowGenerator is the required tool to use the shadows.
  16569. * Each light casting shadows needs to use its own ShadowGenerator.
  16570. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16571. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16572. * @param light The light object generating the shadows.
  16573. * @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.
  16574. */
  16575. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16576. protected _initializeGenerator(): void;
  16577. protected _createTargetRenderTexture(): void;
  16578. protected _initializeShadowMap(): void;
  16579. protected _initializeBlurRTTAndPostProcesses(): void;
  16580. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16581. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16582. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16583. protected _applyFilterValues(): void;
  16584. /**
  16585. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16586. * @param onCompiled Callback triggered at the and of the effects compilation
  16587. * @param options Sets of optional options forcing the compilation with different modes
  16588. */
  16589. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16590. useInstances: boolean;
  16591. }>): void;
  16592. /**
  16593. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16594. * @param options Sets of optional options forcing the compilation with different modes
  16595. * @returns A promise that resolves when the compilation completes
  16596. */
  16597. forceCompilationAsync(options?: Partial<{
  16598. useInstances: boolean;
  16599. }>): Promise<void>;
  16600. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16601. /**
  16602. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16603. * @param subMesh The submesh we want to render in the shadow map
  16604. * @param useInstances Defines wether will draw in the map using instances
  16605. * @returns true if ready otherwise, false
  16606. */
  16607. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16608. /**
  16609. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16610. * @param defines Defines of the material we want to update
  16611. * @param lightIndex Index of the light in the enabled light list of the material
  16612. */
  16613. prepareDefines(defines: any, lightIndex: number): void;
  16614. /**
  16615. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16616. * defined in the generator but impacting the effect).
  16617. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16618. * @param effect The effect we are binfing the information for
  16619. */
  16620. bindShadowLight(lightIndex: string, effect: Effect): void;
  16621. /**
  16622. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16623. * (eq to shadow prjection matrix * light transform matrix)
  16624. * @returns The transform matrix used to create the shadow map
  16625. */
  16626. getTransformMatrix(): Matrix;
  16627. /**
  16628. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16629. * Cube and 2D textures for instance.
  16630. */
  16631. recreateShadowMap(): void;
  16632. protected _disposeBlurPostProcesses(): void;
  16633. protected _disposeRTTandPostProcesses(): void;
  16634. /**
  16635. * Disposes the ShadowGenerator.
  16636. * Returns nothing.
  16637. */
  16638. dispose(): void;
  16639. /**
  16640. * Serializes the shadow generator setup to a json object.
  16641. * @returns The serialized JSON object
  16642. */
  16643. serialize(): any;
  16644. /**
  16645. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16646. * @param parsedShadowGenerator The JSON object to parse
  16647. * @param scene The scene to create the shadow map for
  16648. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16649. * @returns The parsed shadow generator
  16650. */
  16651. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16652. }
  16653. }
  16654. declare module BABYLON {
  16655. /**
  16656. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16657. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16658. * 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.
  16659. */
  16660. export abstract class Light extends Node {
  16661. /**
  16662. * Falloff Default: light is falling off following the material specification:
  16663. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16664. */
  16665. static readonly FALLOFF_DEFAULT: number;
  16666. /**
  16667. * Falloff Physical: light is falling off following the inverse squared distance law.
  16668. */
  16669. static readonly FALLOFF_PHYSICAL: number;
  16670. /**
  16671. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16672. * to enhance interoperability with other engines.
  16673. */
  16674. static readonly FALLOFF_GLTF: number;
  16675. /**
  16676. * Falloff Standard: light is falling off like in the standard material
  16677. * to enhance interoperability with other materials.
  16678. */
  16679. static readonly FALLOFF_STANDARD: number;
  16680. /**
  16681. * If every light affecting the material is in this lightmapMode,
  16682. * material.lightmapTexture adds or multiplies
  16683. * (depends on material.useLightmapAsShadowmap)
  16684. * after every other light calculations.
  16685. */
  16686. static readonly LIGHTMAP_DEFAULT: number;
  16687. /**
  16688. * material.lightmapTexture as only diffuse lighting from this light
  16689. * adds only specular lighting from this light
  16690. * adds dynamic shadows
  16691. */
  16692. static readonly LIGHTMAP_SPECULAR: number;
  16693. /**
  16694. * material.lightmapTexture as only lighting
  16695. * no light calculation from this light
  16696. * only adds dynamic shadows from this light
  16697. */
  16698. static readonly LIGHTMAP_SHADOWSONLY: number;
  16699. /**
  16700. * Each light type uses the default quantity according to its type:
  16701. * point/spot lights use luminous intensity
  16702. * directional lights use illuminance
  16703. */
  16704. static readonly INTENSITYMODE_AUTOMATIC: number;
  16705. /**
  16706. * lumen (lm)
  16707. */
  16708. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16709. /**
  16710. * candela (lm/sr)
  16711. */
  16712. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16713. /**
  16714. * lux (lm/m^2)
  16715. */
  16716. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16717. /**
  16718. * nit (cd/m^2)
  16719. */
  16720. static readonly INTENSITYMODE_LUMINANCE: number;
  16721. /**
  16722. * Light type const id of the point light.
  16723. */
  16724. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16725. /**
  16726. * Light type const id of the directional light.
  16727. */
  16728. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16729. /**
  16730. * Light type const id of the spot light.
  16731. */
  16732. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16733. /**
  16734. * Light type const id of the hemispheric light.
  16735. */
  16736. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16737. /**
  16738. * Diffuse gives the basic color to an object.
  16739. */
  16740. diffuse: Color3;
  16741. /**
  16742. * Specular produces a highlight color on an object.
  16743. * Note: This is note affecting PBR materials.
  16744. */
  16745. specular: Color3;
  16746. /**
  16747. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16748. * falling off base on range or angle.
  16749. * This can be set to any values in Light.FALLOFF_x.
  16750. *
  16751. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16752. * other types of materials.
  16753. */
  16754. falloffType: number;
  16755. /**
  16756. * Strength of the light.
  16757. * Note: By default it is define in the framework own unit.
  16758. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16759. */
  16760. intensity: number;
  16761. private _range;
  16762. protected _inverseSquaredRange: number;
  16763. /**
  16764. * Defines how far from the source the light is impacting in scene units.
  16765. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16766. */
  16767. get range(): number;
  16768. /**
  16769. * Defines how far from the source the light is impacting in scene units.
  16770. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16771. */
  16772. set range(value: number);
  16773. /**
  16774. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16775. * of light.
  16776. */
  16777. private _photometricScale;
  16778. private _intensityMode;
  16779. /**
  16780. * Gets the photometric scale used to interpret the intensity.
  16781. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16782. */
  16783. get intensityMode(): number;
  16784. /**
  16785. * Sets the photometric scale used to interpret the intensity.
  16786. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16787. */
  16788. set intensityMode(value: number);
  16789. private _radius;
  16790. /**
  16791. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16792. */
  16793. get radius(): number;
  16794. /**
  16795. * sets the light radius used by PBR Materials to simulate soft area lights.
  16796. */
  16797. set radius(value: number);
  16798. private _renderPriority;
  16799. /**
  16800. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16801. * exceeding the number allowed of the materials.
  16802. */
  16803. renderPriority: number;
  16804. private _shadowEnabled;
  16805. /**
  16806. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16807. * the current shadow generator.
  16808. */
  16809. get shadowEnabled(): boolean;
  16810. /**
  16811. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16812. * the current shadow generator.
  16813. */
  16814. set shadowEnabled(value: boolean);
  16815. private _includedOnlyMeshes;
  16816. /**
  16817. * Gets the only meshes impacted by this light.
  16818. */
  16819. get includedOnlyMeshes(): AbstractMesh[];
  16820. /**
  16821. * Sets the only meshes impacted by this light.
  16822. */
  16823. set includedOnlyMeshes(value: AbstractMesh[]);
  16824. private _excludedMeshes;
  16825. /**
  16826. * Gets the meshes not impacted by this light.
  16827. */
  16828. get excludedMeshes(): AbstractMesh[];
  16829. /**
  16830. * Sets the meshes not impacted by this light.
  16831. */
  16832. set excludedMeshes(value: AbstractMesh[]);
  16833. private _excludeWithLayerMask;
  16834. /**
  16835. * Gets the layer id use to find what meshes are not impacted by the light.
  16836. * Inactive if 0
  16837. */
  16838. get excludeWithLayerMask(): number;
  16839. /**
  16840. * Sets the layer id use to find what meshes are not impacted by the light.
  16841. * Inactive if 0
  16842. */
  16843. set excludeWithLayerMask(value: number);
  16844. private _includeOnlyWithLayerMask;
  16845. /**
  16846. * Gets the layer id use to find what meshes are impacted by the light.
  16847. * Inactive if 0
  16848. */
  16849. get includeOnlyWithLayerMask(): number;
  16850. /**
  16851. * Sets the layer id use to find what meshes are impacted by the light.
  16852. * Inactive if 0
  16853. */
  16854. set includeOnlyWithLayerMask(value: number);
  16855. private _lightmapMode;
  16856. /**
  16857. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16858. */
  16859. get lightmapMode(): number;
  16860. /**
  16861. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16862. */
  16863. set lightmapMode(value: number);
  16864. /**
  16865. * Shadow generator associted to the light.
  16866. * @hidden Internal use only.
  16867. */
  16868. _shadowGenerator: Nullable<IShadowGenerator>;
  16869. /**
  16870. * @hidden Internal use only.
  16871. */
  16872. _excludedMeshesIds: string[];
  16873. /**
  16874. * @hidden Internal use only.
  16875. */
  16876. _includedOnlyMeshesIds: string[];
  16877. /**
  16878. * The current light unifom buffer.
  16879. * @hidden Internal use only.
  16880. */
  16881. _uniformBuffer: UniformBuffer;
  16882. /** @hidden */
  16883. _renderId: number;
  16884. /**
  16885. * Creates a Light object in the scene.
  16886. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16887. * @param name The firendly name of the light
  16888. * @param scene The scene the light belongs too
  16889. */
  16890. constructor(name: string, scene: Scene);
  16891. protected abstract _buildUniformLayout(): void;
  16892. /**
  16893. * Sets the passed Effect "effect" with the Light information.
  16894. * @param effect The effect to update
  16895. * @param lightIndex The index of the light in the effect to update
  16896. * @returns The light
  16897. */
  16898. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16899. /**
  16900. * Sets the passed Effect "effect" with the Light textures.
  16901. * @param effect The effect to update
  16902. * @param lightIndex The index of the light in the effect to update
  16903. * @returns The light
  16904. */
  16905. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16906. /**
  16907. * Binds the lights information from the scene to the effect for the given mesh.
  16908. * @param lightIndex Light index
  16909. * @param scene The scene where the light belongs to
  16910. * @param effect The effect we are binding the data to
  16911. * @param useSpecular Defines if specular is supported
  16912. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16913. */
  16914. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16915. /**
  16916. * Sets the passed Effect "effect" with the Light information.
  16917. * @param effect The effect to update
  16918. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16919. * @returns The light
  16920. */
  16921. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16922. /**
  16923. * Returns the string "Light".
  16924. * @returns the class name
  16925. */
  16926. getClassName(): string;
  16927. /** @hidden */
  16928. readonly _isLight: boolean;
  16929. /**
  16930. * Converts the light information to a readable string for debug purpose.
  16931. * @param fullDetails Supports for multiple levels of logging within scene loading
  16932. * @returns the human readable light info
  16933. */
  16934. toString(fullDetails?: boolean): string;
  16935. /** @hidden */
  16936. protected _syncParentEnabledState(): void;
  16937. /**
  16938. * Set the enabled state of this node.
  16939. * @param value - the new enabled state
  16940. */
  16941. setEnabled(value: boolean): void;
  16942. /**
  16943. * Returns the Light associated shadow generator if any.
  16944. * @return the associated shadow generator.
  16945. */
  16946. getShadowGenerator(): Nullable<IShadowGenerator>;
  16947. /**
  16948. * Returns a Vector3, the absolute light position in the World.
  16949. * @returns the world space position of the light
  16950. */
  16951. getAbsolutePosition(): Vector3;
  16952. /**
  16953. * Specifies if the light will affect the passed mesh.
  16954. * @param mesh The mesh to test against the light
  16955. * @return true the mesh is affected otherwise, false.
  16956. */
  16957. canAffectMesh(mesh: AbstractMesh): boolean;
  16958. /**
  16959. * Sort function to order lights for rendering.
  16960. * @param a First Light object to compare to second.
  16961. * @param b Second Light object to compare first.
  16962. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16963. */
  16964. static CompareLightsPriority(a: Light, b: Light): number;
  16965. /**
  16966. * Releases resources associated with this node.
  16967. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16968. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16969. */
  16970. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16971. /**
  16972. * Returns the light type ID (integer).
  16973. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16974. */
  16975. getTypeID(): number;
  16976. /**
  16977. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16978. * @returns the scaled intensity in intensity mode unit
  16979. */
  16980. getScaledIntensity(): number;
  16981. /**
  16982. * Returns a new Light object, named "name", from the current one.
  16983. * @param name The name of the cloned light
  16984. * @returns the new created light
  16985. */
  16986. clone(name: string): Nullable<Light>;
  16987. /**
  16988. * Serializes the current light into a Serialization object.
  16989. * @returns the serialized object.
  16990. */
  16991. serialize(): any;
  16992. /**
  16993. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16994. * This new light is named "name" and added to the passed scene.
  16995. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16996. * @param name The friendly name of the light
  16997. * @param scene The scene the new light will belong to
  16998. * @returns the constructor function
  16999. */
  17000. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17001. /**
  17002. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17003. * @param parsedLight The JSON representation of the light
  17004. * @param scene The scene to create the parsed light in
  17005. * @returns the created light after parsing
  17006. */
  17007. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17008. private _hookArrayForExcluded;
  17009. private _hookArrayForIncludedOnly;
  17010. private _resyncMeshes;
  17011. /**
  17012. * Forces the meshes to update their light related information in their rendering used effects
  17013. * @hidden Internal Use Only
  17014. */
  17015. _markMeshesAsLightDirty(): void;
  17016. /**
  17017. * Recomputes the cached photometric scale if needed.
  17018. */
  17019. private _computePhotometricScale;
  17020. /**
  17021. * Returns the Photometric Scale according to the light type and intensity mode.
  17022. */
  17023. private _getPhotometricScale;
  17024. /**
  17025. * Reorder the light in the scene according to their defined priority.
  17026. * @hidden Internal Use Only
  17027. */
  17028. _reorderLightsInScene(): void;
  17029. /**
  17030. * Prepares the list of defines specific to the light type.
  17031. * @param defines the list of defines
  17032. * @param lightIndex defines the index of the light for the effect
  17033. */
  17034. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17035. }
  17036. }
  17037. declare module BABYLON {
  17038. /**
  17039. * Interface used to define Action
  17040. */
  17041. export interface IAction {
  17042. /**
  17043. * Trigger for the action
  17044. */
  17045. trigger: number;
  17046. /** Options of the trigger */
  17047. triggerOptions: any;
  17048. /**
  17049. * Gets the trigger parameters
  17050. * @returns the trigger parameters
  17051. */
  17052. getTriggerParameter(): any;
  17053. /**
  17054. * Internal only - executes current action event
  17055. * @hidden
  17056. */
  17057. _executeCurrent(evt?: ActionEvent): void;
  17058. /**
  17059. * Serialize placeholder for child classes
  17060. * @param parent of child
  17061. * @returns the serialized object
  17062. */
  17063. serialize(parent: any): any;
  17064. /**
  17065. * Internal only
  17066. * @hidden
  17067. */
  17068. _prepare(): void;
  17069. /**
  17070. * Internal only - manager for action
  17071. * @hidden
  17072. */
  17073. _actionManager: AbstractActionManager;
  17074. /**
  17075. * Adds action to chain of actions, may be a DoNothingAction
  17076. * @param action defines the next action to execute
  17077. * @returns The action passed in
  17078. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17079. */
  17080. then(action: IAction): IAction;
  17081. }
  17082. /**
  17083. * The action to be carried out following a trigger
  17084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17085. */
  17086. export class Action implements IAction {
  17087. /** the trigger, with or without parameters, for the action */
  17088. triggerOptions: any;
  17089. /**
  17090. * Trigger for the action
  17091. */
  17092. trigger: number;
  17093. /**
  17094. * Internal only - manager for action
  17095. * @hidden
  17096. */
  17097. _actionManager: ActionManager;
  17098. private _nextActiveAction;
  17099. private _child;
  17100. private _condition?;
  17101. private _triggerParameter;
  17102. /**
  17103. * An event triggered prior to action being executed.
  17104. */
  17105. onBeforeExecuteObservable: Observable<Action>;
  17106. /**
  17107. * Creates a new Action
  17108. * @param triggerOptions the trigger, with or without parameters, for the action
  17109. * @param condition an optional determinant of action
  17110. */
  17111. constructor(
  17112. /** the trigger, with or without parameters, for the action */
  17113. triggerOptions: any, condition?: Condition);
  17114. /**
  17115. * Internal only
  17116. * @hidden
  17117. */
  17118. _prepare(): void;
  17119. /**
  17120. * Gets the trigger parameters
  17121. * @returns the trigger parameters
  17122. */
  17123. getTriggerParameter(): any;
  17124. /**
  17125. * Internal only - executes current action event
  17126. * @hidden
  17127. */
  17128. _executeCurrent(evt?: ActionEvent): void;
  17129. /**
  17130. * Execute placeholder for child classes
  17131. * @param evt optional action event
  17132. */
  17133. execute(evt?: ActionEvent): void;
  17134. /**
  17135. * Skips to next active action
  17136. */
  17137. skipToNextActiveAction(): void;
  17138. /**
  17139. * Adds action to chain of actions, may be a DoNothingAction
  17140. * @param action defines the next action to execute
  17141. * @returns The action passed in
  17142. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17143. */
  17144. then(action: Action): Action;
  17145. /**
  17146. * Internal only
  17147. * @hidden
  17148. */
  17149. _getProperty(propertyPath: string): string;
  17150. /**
  17151. * Internal only
  17152. * @hidden
  17153. */
  17154. _getEffectiveTarget(target: any, propertyPath: string): any;
  17155. /**
  17156. * Serialize placeholder for child classes
  17157. * @param parent of child
  17158. * @returns the serialized object
  17159. */
  17160. serialize(parent: any): any;
  17161. /**
  17162. * Internal only called by serialize
  17163. * @hidden
  17164. */
  17165. protected _serialize(serializedAction: any, parent?: any): any;
  17166. /**
  17167. * Internal only
  17168. * @hidden
  17169. */
  17170. static _SerializeValueAsString: (value: any) => string;
  17171. /**
  17172. * Internal only
  17173. * @hidden
  17174. */
  17175. static _GetTargetProperty: (target: Node | Scene) => {
  17176. name: string;
  17177. targetType: string;
  17178. value: string;
  17179. };
  17180. }
  17181. }
  17182. declare module BABYLON {
  17183. /**
  17184. * A Condition applied to an Action
  17185. */
  17186. export class Condition {
  17187. /**
  17188. * Internal only - manager for action
  17189. * @hidden
  17190. */
  17191. _actionManager: ActionManager;
  17192. /**
  17193. * Internal only
  17194. * @hidden
  17195. */
  17196. _evaluationId: number;
  17197. /**
  17198. * Internal only
  17199. * @hidden
  17200. */
  17201. _currentResult: boolean;
  17202. /**
  17203. * Creates a new Condition
  17204. * @param actionManager the manager of the action the condition is applied to
  17205. */
  17206. constructor(actionManager: ActionManager);
  17207. /**
  17208. * Check if the current condition is valid
  17209. * @returns a boolean
  17210. */
  17211. isValid(): boolean;
  17212. /**
  17213. * Internal only
  17214. * @hidden
  17215. */
  17216. _getProperty(propertyPath: string): string;
  17217. /**
  17218. * Internal only
  17219. * @hidden
  17220. */
  17221. _getEffectiveTarget(target: any, propertyPath: string): any;
  17222. /**
  17223. * Serialize placeholder for child classes
  17224. * @returns the serialized object
  17225. */
  17226. serialize(): any;
  17227. /**
  17228. * Internal only
  17229. * @hidden
  17230. */
  17231. protected _serialize(serializedCondition: any): any;
  17232. }
  17233. /**
  17234. * Defines specific conditional operators as extensions of Condition
  17235. */
  17236. export class ValueCondition extends Condition {
  17237. /** path to specify the property of the target the conditional operator uses */
  17238. propertyPath: string;
  17239. /** the value compared by the conditional operator against the current value of the property */
  17240. value: any;
  17241. /** the conditional operator, default ValueCondition.IsEqual */
  17242. operator: number;
  17243. /**
  17244. * Internal only
  17245. * @hidden
  17246. */
  17247. private static _IsEqual;
  17248. /**
  17249. * Internal only
  17250. * @hidden
  17251. */
  17252. private static _IsDifferent;
  17253. /**
  17254. * Internal only
  17255. * @hidden
  17256. */
  17257. private static _IsGreater;
  17258. /**
  17259. * Internal only
  17260. * @hidden
  17261. */
  17262. private static _IsLesser;
  17263. /**
  17264. * returns the number for IsEqual
  17265. */
  17266. static get IsEqual(): number;
  17267. /**
  17268. * Returns the number for IsDifferent
  17269. */
  17270. static get IsDifferent(): number;
  17271. /**
  17272. * Returns the number for IsGreater
  17273. */
  17274. static get IsGreater(): number;
  17275. /**
  17276. * Returns the number for IsLesser
  17277. */
  17278. static get IsLesser(): number;
  17279. /**
  17280. * Internal only The action manager for the condition
  17281. * @hidden
  17282. */
  17283. _actionManager: ActionManager;
  17284. /**
  17285. * Internal only
  17286. * @hidden
  17287. */
  17288. private _target;
  17289. /**
  17290. * Internal only
  17291. * @hidden
  17292. */
  17293. private _effectiveTarget;
  17294. /**
  17295. * Internal only
  17296. * @hidden
  17297. */
  17298. private _property;
  17299. /**
  17300. * Creates a new ValueCondition
  17301. * @param actionManager manager for the action the condition applies to
  17302. * @param target for the action
  17303. * @param propertyPath path to specify the property of the target the conditional operator uses
  17304. * @param value the value compared by the conditional operator against the current value of the property
  17305. * @param operator the conditional operator, default ValueCondition.IsEqual
  17306. */
  17307. constructor(actionManager: ActionManager, target: any,
  17308. /** path to specify the property of the target the conditional operator uses */
  17309. propertyPath: string,
  17310. /** the value compared by the conditional operator against the current value of the property */
  17311. value: any,
  17312. /** the conditional operator, default ValueCondition.IsEqual */
  17313. operator?: number);
  17314. /**
  17315. * Compares the given value with the property value for the specified conditional operator
  17316. * @returns the result of the comparison
  17317. */
  17318. isValid(): boolean;
  17319. /**
  17320. * Serialize the ValueCondition into a JSON compatible object
  17321. * @returns serialization object
  17322. */
  17323. serialize(): any;
  17324. /**
  17325. * Gets the name of the conditional operator for the ValueCondition
  17326. * @param operator the conditional operator
  17327. * @returns the name
  17328. */
  17329. static GetOperatorName(operator: number): string;
  17330. }
  17331. /**
  17332. * Defines a predicate condition as an extension of Condition
  17333. */
  17334. export class PredicateCondition extends Condition {
  17335. /** defines the predicate function used to validate the condition */
  17336. predicate: () => boolean;
  17337. /**
  17338. * Internal only - manager for action
  17339. * @hidden
  17340. */
  17341. _actionManager: ActionManager;
  17342. /**
  17343. * Creates a new PredicateCondition
  17344. * @param actionManager manager for the action the condition applies to
  17345. * @param predicate defines the predicate function used to validate the condition
  17346. */
  17347. constructor(actionManager: ActionManager,
  17348. /** defines the predicate function used to validate the condition */
  17349. predicate: () => boolean);
  17350. /**
  17351. * @returns the validity of the predicate condition
  17352. */
  17353. isValid(): boolean;
  17354. }
  17355. /**
  17356. * Defines a state condition as an extension of Condition
  17357. */
  17358. export class StateCondition extends Condition {
  17359. /** Value to compare with target state */
  17360. value: string;
  17361. /**
  17362. * Internal only - manager for action
  17363. * @hidden
  17364. */
  17365. _actionManager: ActionManager;
  17366. /**
  17367. * Internal only
  17368. * @hidden
  17369. */
  17370. private _target;
  17371. /**
  17372. * Creates a new StateCondition
  17373. * @param actionManager manager for the action the condition applies to
  17374. * @param target of the condition
  17375. * @param value to compare with target state
  17376. */
  17377. constructor(actionManager: ActionManager, target: any,
  17378. /** Value to compare with target state */
  17379. value: string);
  17380. /**
  17381. * Gets a boolean indicating if the current condition is met
  17382. * @returns the validity of the state
  17383. */
  17384. isValid(): boolean;
  17385. /**
  17386. * Serialize the StateCondition into a JSON compatible object
  17387. * @returns serialization object
  17388. */
  17389. serialize(): any;
  17390. }
  17391. }
  17392. declare module BABYLON {
  17393. /**
  17394. * This defines an action responsible to toggle a boolean once triggered.
  17395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17396. */
  17397. export class SwitchBooleanAction extends Action {
  17398. /**
  17399. * The path to the boolean property in the target object
  17400. */
  17401. propertyPath: string;
  17402. private _target;
  17403. private _effectiveTarget;
  17404. private _property;
  17405. /**
  17406. * Instantiate the action
  17407. * @param triggerOptions defines the trigger options
  17408. * @param target defines the object containing the boolean
  17409. * @param propertyPath defines the path to the boolean property in the target object
  17410. * @param condition defines the trigger related conditions
  17411. */
  17412. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17413. /** @hidden */
  17414. _prepare(): void;
  17415. /**
  17416. * Execute the action toggle the boolean value.
  17417. */
  17418. execute(): void;
  17419. /**
  17420. * Serializes the actions and its related information.
  17421. * @param parent defines the object to serialize in
  17422. * @returns the serialized object
  17423. */
  17424. serialize(parent: any): any;
  17425. }
  17426. /**
  17427. * This defines an action responsible to set a the state field of the target
  17428. * to a desired value once triggered.
  17429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17430. */
  17431. export class SetStateAction extends Action {
  17432. /**
  17433. * The value to store in the state field.
  17434. */
  17435. value: string;
  17436. private _target;
  17437. /**
  17438. * Instantiate the action
  17439. * @param triggerOptions defines the trigger options
  17440. * @param target defines the object containing the state property
  17441. * @param value defines the value to store in the state field
  17442. * @param condition defines the trigger related conditions
  17443. */
  17444. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17445. /**
  17446. * Execute the action and store the value on the target state property.
  17447. */
  17448. execute(): void;
  17449. /**
  17450. * Serializes the actions and its related information.
  17451. * @param parent defines the object to serialize in
  17452. * @returns the serialized object
  17453. */
  17454. serialize(parent: any): any;
  17455. }
  17456. /**
  17457. * This defines an action responsible to set a property of the target
  17458. * to a desired value once triggered.
  17459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17460. */
  17461. export class SetValueAction extends Action {
  17462. /**
  17463. * The path of the property to set in the target.
  17464. */
  17465. propertyPath: string;
  17466. /**
  17467. * The value to set in the property
  17468. */
  17469. value: any;
  17470. private _target;
  17471. private _effectiveTarget;
  17472. private _property;
  17473. /**
  17474. * Instantiate the action
  17475. * @param triggerOptions defines the trigger options
  17476. * @param target defines the object containing the property
  17477. * @param propertyPath defines the path of the property to set in the target
  17478. * @param value defines the value to set in the property
  17479. * @param condition defines the trigger related conditions
  17480. */
  17481. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17482. /** @hidden */
  17483. _prepare(): void;
  17484. /**
  17485. * Execute the action and set the targetted property to the desired value.
  17486. */
  17487. execute(): void;
  17488. /**
  17489. * Serializes the actions and its related information.
  17490. * @param parent defines the object to serialize in
  17491. * @returns the serialized object
  17492. */
  17493. serialize(parent: any): any;
  17494. }
  17495. /**
  17496. * This defines an action responsible to increment the target value
  17497. * to a desired value once triggered.
  17498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17499. */
  17500. export class IncrementValueAction extends Action {
  17501. /**
  17502. * The path of the property to increment in the target.
  17503. */
  17504. propertyPath: string;
  17505. /**
  17506. * The value we should increment the property by.
  17507. */
  17508. value: any;
  17509. private _target;
  17510. private _effectiveTarget;
  17511. private _property;
  17512. /**
  17513. * Instantiate the action
  17514. * @param triggerOptions defines the trigger options
  17515. * @param target defines the object containing the property
  17516. * @param propertyPath defines the path of the property to increment in the target
  17517. * @param value defines the value value we should increment the property by
  17518. * @param condition defines the trigger related conditions
  17519. */
  17520. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17521. /** @hidden */
  17522. _prepare(): void;
  17523. /**
  17524. * Execute the action and increment the target of the value amount.
  17525. */
  17526. execute(): void;
  17527. /**
  17528. * Serializes the actions and its related information.
  17529. * @param parent defines the object to serialize in
  17530. * @returns the serialized object
  17531. */
  17532. serialize(parent: any): any;
  17533. }
  17534. /**
  17535. * This defines an action responsible to start an animation once triggered.
  17536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17537. */
  17538. export class PlayAnimationAction extends Action {
  17539. /**
  17540. * Where the animation should start (animation frame)
  17541. */
  17542. from: number;
  17543. /**
  17544. * Where the animation should stop (animation frame)
  17545. */
  17546. to: number;
  17547. /**
  17548. * Define if the animation should loop or stop after the first play.
  17549. */
  17550. loop?: boolean;
  17551. private _target;
  17552. /**
  17553. * Instantiate the action
  17554. * @param triggerOptions defines the trigger options
  17555. * @param target defines the target animation or animation name
  17556. * @param from defines from where the animation should start (animation frame)
  17557. * @param end defines where the animation should stop (animation frame)
  17558. * @param loop defines if the animation should loop or stop after the first play
  17559. * @param condition defines the trigger related conditions
  17560. */
  17561. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17562. /** @hidden */
  17563. _prepare(): void;
  17564. /**
  17565. * Execute the action and play the animation.
  17566. */
  17567. execute(): void;
  17568. /**
  17569. * Serializes the actions and its related information.
  17570. * @param parent defines the object to serialize in
  17571. * @returns the serialized object
  17572. */
  17573. serialize(parent: any): any;
  17574. }
  17575. /**
  17576. * This defines an action responsible to stop an animation once triggered.
  17577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17578. */
  17579. export class StopAnimationAction extends Action {
  17580. private _target;
  17581. /**
  17582. * Instantiate the action
  17583. * @param triggerOptions defines the trigger options
  17584. * @param target defines the target animation or animation name
  17585. * @param condition defines the trigger related conditions
  17586. */
  17587. constructor(triggerOptions: any, target: any, condition?: Condition);
  17588. /** @hidden */
  17589. _prepare(): void;
  17590. /**
  17591. * Execute the action and stop the animation.
  17592. */
  17593. execute(): void;
  17594. /**
  17595. * Serializes the actions and its related information.
  17596. * @param parent defines the object to serialize in
  17597. * @returns the serialized object
  17598. */
  17599. serialize(parent: any): any;
  17600. }
  17601. /**
  17602. * This defines an action responsible that does nothing once triggered.
  17603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17604. */
  17605. export class DoNothingAction extends Action {
  17606. /**
  17607. * Instantiate the action
  17608. * @param triggerOptions defines the trigger options
  17609. * @param condition defines the trigger related conditions
  17610. */
  17611. constructor(triggerOptions?: any, condition?: Condition);
  17612. /**
  17613. * Execute the action and do nothing.
  17614. */
  17615. execute(): void;
  17616. /**
  17617. * Serializes the actions and its related information.
  17618. * @param parent defines the object to serialize in
  17619. * @returns the serialized object
  17620. */
  17621. serialize(parent: any): any;
  17622. }
  17623. /**
  17624. * This defines an action responsible to trigger several actions once triggered.
  17625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17626. */
  17627. export class CombineAction extends Action {
  17628. /**
  17629. * The list of aggregated animations to run.
  17630. */
  17631. children: Action[];
  17632. /**
  17633. * Instantiate the action
  17634. * @param triggerOptions defines the trigger options
  17635. * @param children defines the list of aggregated animations to run
  17636. * @param condition defines the trigger related conditions
  17637. */
  17638. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17639. /** @hidden */
  17640. _prepare(): void;
  17641. /**
  17642. * Execute the action and executes all the aggregated actions.
  17643. */
  17644. execute(evt: ActionEvent): void;
  17645. /**
  17646. * Serializes the actions and its related information.
  17647. * @param parent defines the object to serialize in
  17648. * @returns the serialized object
  17649. */
  17650. serialize(parent: any): any;
  17651. }
  17652. /**
  17653. * This defines an action responsible to run code (external event) once triggered.
  17654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17655. */
  17656. export class ExecuteCodeAction extends Action {
  17657. /**
  17658. * The callback function to run.
  17659. */
  17660. func: (evt: ActionEvent) => void;
  17661. /**
  17662. * Instantiate the action
  17663. * @param triggerOptions defines the trigger options
  17664. * @param func defines the callback function to run
  17665. * @param condition defines the trigger related conditions
  17666. */
  17667. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17668. /**
  17669. * Execute the action and run the attached code.
  17670. */
  17671. execute(evt: ActionEvent): void;
  17672. }
  17673. /**
  17674. * This defines an action responsible to set the parent property of the target once triggered.
  17675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17676. */
  17677. export class SetParentAction extends Action {
  17678. private _parent;
  17679. private _target;
  17680. /**
  17681. * Instantiate the action
  17682. * @param triggerOptions defines the trigger options
  17683. * @param target defines the target containing the parent property
  17684. * @param parent defines from where the animation should start (animation frame)
  17685. * @param condition defines the trigger related conditions
  17686. */
  17687. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17688. /** @hidden */
  17689. _prepare(): void;
  17690. /**
  17691. * Execute the action and set the parent property.
  17692. */
  17693. execute(): void;
  17694. /**
  17695. * Serializes the actions and its related information.
  17696. * @param parent defines the object to serialize in
  17697. * @returns the serialized object
  17698. */
  17699. serialize(parent: any): any;
  17700. }
  17701. }
  17702. declare module BABYLON {
  17703. /**
  17704. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17705. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17707. */
  17708. export class ActionManager extends AbstractActionManager {
  17709. /**
  17710. * Nothing
  17711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17712. */
  17713. static readonly NothingTrigger: number;
  17714. /**
  17715. * On pick
  17716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17717. */
  17718. static readonly OnPickTrigger: number;
  17719. /**
  17720. * On left pick
  17721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17722. */
  17723. static readonly OnLeftPickTrigger: number;
  17724. /**
  17725. * On right pick
  17726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17727. */
  17728. static readonly OnRightPickTrigger: number;
  17729. /**
  17730. * On center pick
  17731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17732. */
  17733. static readonly OnCenterPickTrigger: number;
  17734. /**
  17735. * On pick down
  17736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17737. */
  17738. static readonly OnPickDownTrigger: number;
  17739. /**
  17740. * On double pick
  17741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17742. */
  17743. static readonly OnDoublePickTrigger: number;
  17744. /**
  17745. * On pick up
  17746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17747. */
  17748. static readonly OnPickUpTrigger: number;
  17749. /**
  17750. * On pick out.
  17751. * This trigger will only be raised if you also declared a OnPickDown
  17752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17753. */
  17754. static readonly OnPickOutTrigger: number;
  17755. /**
  17756. * On long press
  17757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17758. */
  17759. static readonly OnLongPressTrigger: number;
  17760. /**
  17761. * On pointer over
  17762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17763. */
  17764. static readonly OnPointerOverTrigger: number;
  17765. /**
  17766. * On pointer out
  17767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17768. */
  17769. static readonly OnPointerOutTrigger: number;
  17770. /**
  17771. * On every frame
  17772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17773. */
  17774. static readonly OnEveryFrameTrigger: number;
  17775. /**
  17776. * On intersection enter
  17777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17778. */
  17779. static readonly OnIntersectionEnterTrigger: number;
  17780. /**
  17781. * On intersection exit
  17782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17783. */
  17784. static readonly OnIntersectionExitTrigger: number;
  17785. /**
  17786. * On key down
  17787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17788. */
  17789. static readonly OnKeyDownTrigger: number;
  17790. /**
  17791. * On key up
  17792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17793. */
  17794. static readonly OnKeyUpTrigger: number;
  17795. private _scene;
  17796. /**
  17797. * Creates a new action manager
  17798. * @param scene defines the hosting scene
  17799. */
  17800. constructor(scene: Scene);
  17801. /**
  17802. * Releases all associated resources
  17803. */
  17804. dispose(): void;
  17805. /**
  17806. * Gets hosting scene
  17807. * @returns the hosting scene
  17808. */
  17809. getScene(): Scene;
  17810. /**
  17811. * Does this action manager handles actions of any of the given triggers
  17812. * @param triggers defines the triggers to be tested
  17813. * @return a boolean indicating whether one (or more) of the triggers is handled
  17814. */
  17815. hasSpecificTriggers(triggers: number[]): boolean;
  17816. /**
  17817. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17818. * speed.
  17819. * @param triggerA defines the trigger to be tested
  17820. * @param triggerB defines the trigger to be tested
  17821. * @return a boolean indicating whether one (or more) of the triggers is handled
  17822. */
  17823. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17824. /**
  17825. * Does this action manager handles actions of a given trigger
  17826. * @param trigger defines the trigger to be tested
  17827. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17828. * @return whether the trigger is handled
  17829. */
  17830. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17831. /**
  17832. * Does this action manager has pointer triggers
  17833. */
  17834. get hasPointerTriggers(): boolean;
  17835. /**
  17836. * Does this action manager has pick triggers
  17837. */
  17838. get hasPickTriggers(): boolean;
  17839. /**
  17840. * Registers an action to this action manager
  17841. * @param action defines the action to be registered
  17842. * @return the action amended (prepared) after registration
  17843. */
  17844. registerAction(action: IAction): Nullable<IAction>;
  17845. /**
  17846. * Unregisters an action to this action manager
  17847. * @param action defines the action to be unregistered
  17848. * @return a boolean indicating whether the action has been unregistered
  17849. */
  17850. unregisterAction(action: IAction): Boolean;
  17851. /**
  17852. * Process a specific trigger
  17853. * @param trigger defines the trigger to process
  17854. * @param evt defines the event details to be processed
  17855. */
  17856. processTrigger(trigger: number, evt?: IActionEvent): void;
  17857. /** @hidden */
  17858. _getEffectiveTarget(target: any, propertyPath: string): any;
  17859. /** @hidden */
  17860. _getProperty(propertyPath: string): string;
  17861. /**
  17862. * Serialize this manager to a JSON object
  17863. * @param name defines the property name to store this manager
  17864. * @returns a JSON representation of this manager
  17865. */
  17866. serialize(name: string): any;
  17867. /**
  17868. * Creates a new ActionManager from a JSON data
  17869. * @param parsedActions defines the JSON data to read from
  17870. * @param object defines the hosting mesh
  17871. * @param scene defines the hosting scene
  17872. */
  17873. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17874. /**
  17875. * Get a trigger name by index
  17876. * @param trigger defines the trigger index
  17877. * @returns a trigger name
  17878. */
  17879. static GetTriggerName(trigger: number): string;
  17880. }
  17881. }
  17882. declare module BABYLON {
  17883. /**
  17884. * Class used to represent a sprite
  17885. * @see http://doc.babylonjs.com/babylon101/sprites
  17886. */
  17887. export class Sprite {
  17888. /** defines the name */
  17889. name: string;
  17890. /** Gets or sets the current world position */
  17891. position: Vector3;
  17892. /** Gets or sets the main color */
  17893. color: Color4;
  17894. /** Gets or sets the width */
  17895. width: number;
  17896. /** Gets or sets the height */
  17897. height: number;
  17898. /** Gets or sets rotation angle */
  17899. angle: number;
  17900. /** Gets or sets the cell index in the sprite sheet */
  17901. cellIndex: number;
  17902. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17903. cellRef: string;
  17904. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17905. invertU: number;
  17906. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17907. invertV: number;
  17908. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17909. disposeWhenFinishedAnimating: boolean;
  17910. /** Gets the list of attached animations */
  17911. animations: Animation[];
  17912. /** Gets or sets a boolean indicating if the sprite can be picked */
  17913. isPickable: boolean;
  17914. /**
  17915. * Gets or sets the associated action manager
  17916. */
  17917. actionManager: Nullable<ActionManager>;
  17918. private _animationStarted;
  17919. private _loopAnimation;
  17920. private _fromIndex;
  17921. private _toIndex;
  17922. private _delay;
  17923. private _direction;
  17924. private _manager;
  17925. private _time;
  17926. private _onAnimationEnd;
  17927. /**
  17928. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17929. */
  17930. isVisible: boolean;
  17931. /**
  17932. * Gets or sets the sprite size
  17933. */
  17934. get size(): number;
  17935. set size(value: number);
  17936. /**
  17937. * Creates a new Sprite
  17938. * @param name defines the name
  17939. * @param manager defines the manager
  17940. */
  17941. constructor(
  17942. /** defines the name */
  17943. name: string, manager: ISpriteManager);
  17944. /**
  17945. * Starts an animation
  17946. * @param from defines the initial key
  17947. * @param to defines the end key
  17948. * @param loop defines if the animation must loop
  17949. * @param delay defines the start delay (in ms)
  17950. * @param onAnimationEnd defines a callback to call when animation ends
  17951. */
  17952. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17953. /** Stops current animation (if any) */
  17954. stopAnimation(): void;
  17955. /** @hidden */
  17956. _animate(deltaTime: number): void;
  17957. /** Release associated resources */
  17958. dispose(): void;
  17959. }
  17960. }
  17961. declare module BABYLON {
  17962. /**
  17963. * Information about the result of picking within a scene
  17964. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  17965. */
  17966. export class PickingInfo {
  17967. /** @hidden */
  17968. _pickingUnavailable: boolean;
  17969. /**
  17970. * If the pick collided with an object
  17971. */
  17972. hit: boolean;
  17973. /**
  17974. * Distance away where the pick collided
  17975. */
  17976. distance: number;
  17977. /**
  17978. * The location of pick collision
  17979. */
  17980. pickedPoint: Nullable<Vector3>;
  17981. /**
  17982. * The mesh corresponding the the pick collision
  17983. */
  17984. pickedMesh: Nullable<AbstractMesh>;
  17985. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  17986. bu: number;
  17987. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  17988. bv: number;
  17989. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  17990. faceId: number;
  17991. /** Id of the the submesh that was picked */
  17992. subMeshId: number;
  17993. /** If a sprite was picked, this will be the sprite the pick collided with */
  17994. pickedSprite: Nullable<Sprite>;
  17995. /**
  17996. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  17997. */
  17998. originMesh: Nullable<AbstractMesh>;
  17999. /**
  18000. * The ray that was used to perform the picking.
  18001. */
  18002. ray: Nullable<Ray>;
  18003. /**
  18004. * Gets the normal correspodning to the face the pick collided with
  18005. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18006. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18007. * @returns The normal correspodning to the face the pick collided with
  18008. */
  18009. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18010. /**
  18011. * Gets the texture coordinates of where the pick occured
  18012. * @returns the vector containing the coordnates of the texture
  18013. */
  18014. getTextureCoordinates(): Nullable<Vector2>;
  18015. }
  18016. }
  18017. declare module BABYLON {
  18018. /**
  18019. * Gather the list of pointer event types as constants.
  18020. */
  18021. export class PointerEventTypes {
  18022. /**
  18023. * 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.
  18024. */
  18025. static readonly POINTERDOWN: number;
  18026. /**
  18027. * The pointerup event is fired when a pointer is no longer active.
  18028. */
  18029. static readonly POINTERUP: number;
  18030. /**
  18031. * The pointermove event is fired when a pointer changes coordinates.
  18032. */
  18033. static readonly POINTERMOVE: number;
  18034. /**
  18035. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18036. */
  18037. static readonly POINTERWHEEL: number;
  18038. /**
  18039. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18040. */
  18041. static readonly POINTERPICK: number;
  18042. /**
  18043. * The pointertap event is fired when a the object has been touched and released without drag.
  18044. */
  18045. static readonly POINTERTAP: number;
  18046. /**
  18047. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18048. */
  18049. static readonly POINTERDOUBLETAP: number;
  18050. }
  18051. /**
  18052. * Base class of pointer info types.
  18053. */
  18054. export class PointerInfoBase {
  18055. /**
  18056. * Defines the type of event (PointerEventTypes)
  18057. */
  18058. type: number;
  18059. /**
  18060. * Defines the related dom event
  18061. */
  18062. event: PointerEvent | MouseWheelEvent;
  18063. /**
  18064. * Instantiates the base class of pointers info.
  18065. * @param type Defines the type of event (PointerEventTypes)
  18066. * @param event Defines the related dom event
  18067. */
  18068. constructor(
  18069. /**
  18070. * Defines the type of event (PointerEventTypes)
  18071. */
  18072. type: number,
  18073. /**
  18074. * Defines the related dom event
  18075. */
  18076. event: PointerEvent | MouseWheelEvent);
  18077. }
  18078. /**
  18079. * This class is used to store pointer related info for the onPrePointerObservable event.
  18080. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18081. */
  18082. export class PointerInfoPre extends PointerInfoBase {
  18083. /**
  18084. * Ray from a pointer if availible (eg. 6dof controller)
  18085. */
  18086. ray: Nullable<Ray>;
  18087. /**
  18088. * Defines the local position of the pointer on the canvas.
  18089. */
  18090. localPosition: Vector2;
  18091. /**
  18092. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18093. */
  18094. skipOnPointerObservable: boolean;
  18095. /**
  18096. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18097. * @param type Defines the type of event (PointerEventTypes)
  18098. * @param event Defines the related dom event
  18099. * @param localX Defines the local x coordinates of the pointer when the event occured
  18100. * @param localY Defines the local y coordinates of the pointer when the event occured
  18101. */
  18102. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18103. }
  18104. /**
  18105. * This type contains all the data related to a pointer event in Babylon.js.
  18106. * 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.
  18107. */
  18108. export class PointerInfo extends PointerInfoBase {
  18109. /**
  18110. * Defines the picking info associated to the info (if any)\
  18111. */
  18112. pickInfo: Nullable<PickingInfo>;
  18113. /**
  18114. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18115. * @param type Defines the type of event (PointerEventTypes)
  18116. * @param event Defines the related dom event
  18117. * @param pickInfo Defines the picking info associated to the info (if any)\
  18118. */
  18119. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18120. /**
  18121. * Defines the picking info associated to the info (if any)\
  18122. */
  18123. pickInfo: Nullable<PickingInfo>);
  18124. }
  18125. /**
  18126. * Data relating to a touch event on the screen.
  18127. */
  18128. export interface PointerTouch {
  18129. /**
  18130. * X coordinate of touch.
  18131. */
  18132. x: number;
  18133. /**
  18134. * Y coordinate of touch.
  18135. */
  18136. y: number;
  18137. /**
  18138. * Id of touch. Unique for each finger.
  18139. */
  18140. pointerId: number;
  18141. /**
  18142. * Event type passed from DOM.
  18143. */
  18144. type: any;
  18145. }
  18146. }
  18147. declare module BABYLON {
  18148. /**
  18149. * Manage the mouse inputs to control the movement of a free camera.
  18150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18151. */
  18152. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18153. /**
  18154. * Define if touch is enabled in the mouse input
  18155. */
  18156. touchEnabled: boolean;
  18157. /**
  18158. * Defines the camera the input is attached to.
  18159. */
  18160. camera: FreeCamera;
  18161. /**
  18162. * Defines the buttons associated with the input to handle camera move.
  18163. */
  18164. buttons: number[];
  18165. /**
  18166. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18167. */
  18168. angularSensibility: number;
  18169. private _pointerInput;
  18170. private _onMouseMove;
  18171. private _observer;
  18172. private previousPosition;
  18173. /**
  18174. * Observable for when a pointer move event occurs containing the move offset
  18175. */
  18176. onPointerMovedObservable: Observable<{
  18177. offsetX: number;
  18178. offsetY: number;
  18179. }>;
  18180. /**
  18181. * @hidden
  18182. * If the camera should be rotated automatically based on pointer movement
  18183. */
  18184. _allowCameraRotation: boolean;
  18185. /**
  18186. * Manage the mouse inputs to control the movement of a free camera.
  18187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18188. * @param touchEnabled Defines if touch is enabled or not
  18189. */
  18190. constructor(
  18191. /**
  18192. * Define if touch is enabled in the mouse input
  18193. */
  18194. touchEnabled?: boolean);
  18195. /**
  18196. * Attach the input controls to a specific dom element to get the input from.
  18197. * @param element Defines the element the controls should be listened from
  18198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18199. */
  18200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18201. /**
  18202. * Called on JS contextmenu event.
  18203. * Override this method to provide functionality.
  18204. */
  18205. protected onContextMenu(evt: PointerEvent): void;
  18206. /**
  18207. * Detach the current controls from the specified dom element.
  18208. * @param element Defines the element to stop listening the inputs from
  18209. */
  18210. detachControl(element: Nullable<HTMLElement>): void;
  18211. /**
  18212. * Gets the class name of the current intput.
  18213. * @returns the class name
  18214. */
  18215. getClassName(): string;
  18216. /**
  18217. * Get the friendly name associated with the input class.
  18218. * @returns the input friendly name
  18219. */
  18220. getSimpleName(): string;
  18221. }
  18222. }
  18223. declare module BABYLON {
  18224. /**
  18225. * Manage the touch inputs to control the movement of a free camera.
  18226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18227. */
  18228. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18229. /**
  18230. * Defines the camera the input is attached to.
  18231. */
  18232. camera: FreeCamera;
  18233. /**
  18234. * Defines the touch sensibility for rotation.
  18235. * The higher the faster.
  18236. */
  18237. touchAngularSensibility: number;
  18238. /**
  18239. * Defines the touch sensibility for move.
  18240. * The higher the faster.
  18241. */
  18242. touchMoveSensibility: number;
  18243. private _offsetX;
  18244. private _offsetY;
  18245. private _pointerPressed;
  18246. private _pointerInput;
  18247. private _observer;
  18248. private _onLostFocus;
  18249. /**
  18250. * Attach the input controls to a specific dom element to get the input from.
  18251. * @param element Defines the element the controls should be listened from
  18252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18253. */
  18254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18255. /**
  18256. * Detach the current controls from the specified dom element.
  18257. * @param element Defines the element to stop listening the inputs from
  18258. */
  18259. detachControl(element: Nullable<HTMLElement>): void;
  18260. /**
  18261. * Update the current camera state depending on the inputs that have been used this frame.
  18262. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18263. */
  18264. checkInputs(): void;
  18265. /**
  18266. * Gets the class name of the current intput.
  18267. * @returns the class name
  18268. */
  18269. getClassName(): string;
  18270. /**
  18271. * Get the friendly name associated with the input class.
  18272. * @returns the input friendly name
  18273. */
  18274. getSimpleName(): string;
  18275. }
  18276. }
  18277. declare module BABYLON {
  18278. /**
  18279. * Default Inputs manager for the FreeCamera.
  18280. * It groups all the default supported inputs for ease of use.
  18281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18282. */
  18283. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18284. /**
  18285. * @hidden
  18286. */
  18287. _mouseInput: Nullable<FreeCameraMouseInput>;
  18288. /**
  18289. * Instantiates a new FreeCameraInputsManager.
  18290. * @param camera Defines the camera the inputs belong to
  18291. */
  18292. constructor(camera: FreeCamera);
  18293. /**
  18294. * Add keyboard input support to the input manager.
  18295. * @returns the current input manager
  18296. */
  18297. addKeyboard(): FreeCameraInputsManager;
  18298. /**
  18299. * Add mouse input support to the input manager.
  18300. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18301. * @returns the current input manager
  18302. */
  18303. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18304. /**
  18305. * Removes the mouse input support from the manager
  18306. * @returns the current input manager
  18307. */
  18308. removeMouse(): FreeCameraInputsManager;
  18309. /**
  18310. * Add touch input support to the input manager.
  18311. * @returns the current input manager
  18312. */
  18313. addTouch(): FreeCameraInputsManager;
  18314. /**
  18315. * Remove all attached input methods from a camera
  18316. */
  18317. clear(): void;
  18318. }
  18319. }
  18320. declare module BABYLON {
  18321. /**
  18322. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18323. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18324. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18325. */
  18326. export class FreeCamera extends TargetCamera {
  18327. /**
  18328. * Define the collision ellipsoid of the camera.
  18329. * This is helpful to simulate a camera body like the player body around the camera
  18330. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18331. */
  18332. ellipsoid: Vector3;
  18333. /**
  18334. * Define an offset for the position of the ellipsoid around the camera.
  18335. * This can be helpful to determine the center of the body near the gravity center of the body
  18336. * instead of its head.
  18337. */
  18338. ellipsoidOffset: Vector3;
  18339. /**
  18340. * Enable or disable collisions of the camera with the rest of the scene objects.
  18341. */
  18342. checkCollisions: boolean;
  18343. /**
  18344. * Enable or disable gravity on the camera.
  18345. */
  18346. applyGravity: boolean;
  18347. /**
  18348. * Define the input manager associated to the camera.
  18349. */
  18350. inputs: FreeCameraInputsManager;
  18351. /**
  18352. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18353. * Higher values reduce sensitivity.
  18354. */
  18355. get angularSensibility(): number;
  18356. /**
  18357. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18358. * Higher values reduce sensitivity.
  18359. */
  18360. set angularSensibility(value: number);
  18361. /**
  18362. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18363. */
  18364. get keysUp(): number[];
  18365. set keysUp(value: number[]);
  18366. /**
  18367. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18368. */
  18369. get keysDown(): number[];
  18370. set keysDown(value: number[]);
  18371. /**
  18372. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18373. */
  18374. get keysLeft(): number[];
  18375. set keysLeft(value: number[]);
  18376. /**
  18377. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18378. */
  18379. get keysRight(): number[];
  18380. set keysRight(value: number[]);
  18381. /**
  18382. * Event raised when the camera collide with a mesh in the scene.
  18383. */
  18384. onCollide: (collidedMesh: AbstractMesh) => void;
  18385. private _collider;
  18386. private _needMoveForGravity;
  18387. private _oldPosition;
  18388. private _diffPosition;
  18389. private _newPosition;
  18390. /** @hidden */
  18391. _localDirection: Vector3;
  18392. /** @hidden */
  18393. _transformedDirection: Vector3;
  18394. /**
  18395. * Instantiates a Free Camera.
  18396. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18397. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18398. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18399. * @param name Define the name of the camera in the scene
  18400. * @param position Define the start position of the camera in the scene
  18401. * @param scene Define the scene the camera belongs to
  18402. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18403. */
  18404. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18405. /**
  18406. * Attached controls to the current camera.
  18407. * @param element Defines the element the controls should be listened from
  18408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18409. */
  18410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18411. /**
  18412. * Detach the current controls from the camera.
  18413. * The camera will stop reacting to inputs.
  18414. * @param element Defines the element to stop listening the inputs from
  18415. */
  18416. detachControl(element: HTMLElement): void;
  18417. private _collisionMask;
  18418. /**
  18419. * Define a collision mask to limit the list of object the camera can collide with
  18420. */
  18421. get collisionMask(): number;
  18422. set collisionMask(mask: number);
  18423. /** @hidden */
  18424. _collideWithWorld(displacement: Vector3): void;
  18425. private _onCollisionPositionChange;
  18426. /** @hidden */
  18427. _checkInputs(): void;
  18428. /** @hidden */
  18429. _decideIfNeedsToMove(): boolean;
  18430. /** @hidden */
  18431. _updatePosition(): void;
  18432. /**
  18433. * Destroy the camera and release the current resources hold by it.
  18434. */
  18435. dispose(): void;
  18436. /**
  18437. * Gets the current object class name.
  18438. * @return the class name
  18439. */
  18440. getClassName(): string;
  18441. }
  18442. }
  18443. declare module BABYLON {
  18444. /**
  18445. * Represents a gamepad control stick position
  18446. */
  18447. export class StickValues {
  18448. /**
  18449. * The x component of the control stick
  18450. */
  18451. x: number;
  18452. /**
  18453. * The y component of the control stick
  18454. */
  18455. y: number;
  18456. /**
  18457. * Initializes the gamepad x and y control stick values
  18458. * @param x The x component of the gamepad control stick value
  18459. * @param y The y component of the gamepad control stick value
  18460. */
  18461. constructor(
  18462. /**
  18463. * The x component of the control stick
  18464. */
  18465. x: number,
  18466. /**
  18467. * The y component of the control stick
  18468. */
  18469. y: number);
  18470. }
  18471. /**
  18472. * An interface which manages callbacks for gamepad button changes
  18473. */
  18474. export interface GamepadButtonChanges {
  18475. /**
  18476. * Called when a gamepad has been changed
  18477. */
  18478. changed: boolean;
  18479. /**
  18480. * Called when a gamepad press event has been triggered
  18481. */
  18482. pressChanged: boolean;
  18483. /**
  18484. * Called when a touch event has been triggered
  18485. */
  18486. touchChanged: boolean;
  18487. /**
  18488. * Called when a value has changed
  18489. */
  18490. valueChanged: boolean;
  18491. }
  18492. /**
  18493. * Represents a gamepad
  18494. */
  18495. export class Gamepad {
  18496. /**
  18497. * The id of the gamepad
  18498. */
  18499. id: string;
  18500. /**
  18501. * The index of the gamepad
  18502. */
  18503. index: number;
  18504. /**
  18505. * The browser gamepad
  18506. */
  18507. browserGamepad: any;
  18508. /**
  18509. * Specifies what type of gamepad this represents
  18510. */
  18511. type: number;
  18512. private _leftStick;
  18513. private _rightStick;
  18514. /** @hidden */
  18515. _isConnected: boolean;
  18516. private _leftStickAxisX;
  18517. private _leftStickAxisY;
  18518. private _rightStickAxisX;
  18519. private _rightStickAxisY;
  18520. /**
  18521. * Triggered when the left control stick has been changed
  18522. */
  18523. private _onleftstickchanged;
  18524. /**
  18525. * Triggered when the right control stick has been changed
  18526. */
  18527. private _onrightstickchanged;
  18528. /**
  18529. * Represents a gamepad controller
  18530. */
  18531. static GAMEPAD: number;
  18532. /**
  18533. * Represents a generic controller
  18534. */
  18535. static GENERIC: number;
  18536. /**
  18537. * Represents an XBox controller
  18538. */
  18539. static XBOX: number;
  18540. /**
  18541. * Represents a pose-enabled controller
  18542. */
  18543. static POSE_ENABLED: number;
  18544. /**
  18545. * Represents an Dual Shock controller
  18546. */
  18547. static DUALSHOCK: number;
  18548. /**
  18549. * Specifies whether the left control stick should be Y-inverted
  18550. */
  18551. protected _invertLeftStickY: boolean;
  18552. /**
  18553. * Specifies if the gamepad has been connected
  18554. */
  18555. get isConnected(): boolean;
  18556. /**
  18557. * Initializes the gamepad
  18558. * @param id The id of the gamepad
  18559. * @param index The index of the gamepad
  18560. * @param browserGamepad The browser gamepad
  18561. * @param leftStickX The x component of the left joystick
  18562. * @param leftStickY The y component of the left joystick
  18563. * @param rightStickX The x component of the right joystick
  18564. * @param rightStickY The y component of the right joystick
  18565. */
  18566. constructor(
  18567. /**
  18568. * The id of the gamepad
  18569. */
  18570. id: string,
  18571. /**
  18572. * The index of the gamepad
  18573. */
  18574. index: number,
  18575. /**
  18576. * The browser gamepad
  18577. */
  18578. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18579. /**
  18580. * Callback triggered when the left joystick has changed
  18581. * @param callback
  18582. */
  18583. onleftstickchanged(callback: (values: StickValues) => void): void;
  18584. /**
  18585. * Callback triggered when the right joystick has changed
  18586. * @param callback
  18587. */
  18588. onrightstickchanged(callback: (values: StickValues) => void): void;
  18589. /**
  18590. * Gets the left joystick
  18591. */
  18592. get leftStick(): StickValues;
  18593. /**
  18594. * Sets the left joystick values
  18595. */
  18596. set leftStick(newValues: StickValues);
  18597. /**
  18598. * Gets the right joystick
  18599. */
  18600. get rightStick(): StickValues;
  18601. /**
  18602. * Sets the right joystick value
  18603. */
  18604. set rightStick(newValues: StickValues);
  18605. /**
  18606. * Updates the gamepad joystick positions
  18607. */
  18608. update(): void;
  18609. /**
  18610. * Disposes the gamepad
  18611. */
  18612. dispose(): void;
  18613. }
  18614. /**
  18615. * Represents a generic gamepad
  18616. */
  18617. export class GenericPad extends Gamepad {
  18618. private _buttons;
  18619. private _onbuttondown;
  18620. private _onbuttonup;
  18621. /**
  18622. * Observable triggered when a button has been pressed
  18623. */
  18624. onButtonDownObservable: Observable<number>;
  18625. /**
  18626. * Observable triggered when a button has been released
  18627. */
  18628. onButtonUpObservable: Observable<number>;
  18629. /**
  18630. * Callback triggered when a button has been pressed
  18631. * @param callback Called when a button has been pressed
  18632. */
  18633. onbuttondown(callback: (buttonPressed: number) => void): void;
  18634. /**
  18635. * Callback triggered when a button has been released
  18636. * @param callback Called when a button has been released
  18637. */
  18638. onbuttonup(callback: (buttonReleased: number) => void): void;
  18639. /**
  18640. * Initializes the generic gamepad
  18641. * @param id The id of the generic gamepad
  18642. * @param index The index of the generic gamepad
  18643. * @param browserGamepad The browser gamepad
  18644. */
  18645. constructor(id: string, index: number, browserGamepad: any);
  18646. private _setButtonValue;
  18647. /**
  18648. * Updates the generic gamepad
  18649. */
  18650. update(): void;
  18651. /**
  18652. * Disposes the generic gamepad
  18653. */
  18654. dispose(): void;
  18655. }
  18656. }
  18657. declare module BABYLON {
  18658. /**
  18659. * Defines the types of pose enabled controllers that are supported
  18660. */
  18661. export enum PoseEnabledControllerType {
  18662. /**
  18663. * HTC Vive
  18664. */
  18665. VIVE = 0,
  18666. /**
  18667. * Oculus Rift
  18668. */
  18669. OCULUS = 1,
  18670. /**
  18671. * Windows mixed reality
  18672. */
  18673. WINDOWS = 2,
  18674. /**
  18675. * Samsung gear VR
  18676. */
  18677. GEAR_VR = 3,
  18678. /**
  18679. * Google Daydream
  18680. */
  18681. DAYDREAM = 4,
  18682. /**
  18683. * Generic
  18684. */
  18685. GENERIC = 5
  18686. }
  18687. /**
  18688. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18689. */
  18690. export interface MutableGamepadButton {
  18691. /**
  18692. * Value of the button/trigger
  18693. */
  18694. value: number;
  18695. /**
  18696. * If the button/trigger is currently touched
  18697. */
  18698. touched: boolean;
  18699. /**
  18700. * If the button/trigger is currently pressed
  18701. */
  18702. pressed: boolean;
  18703. }
  18704. /**
  18705. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18706. * @hidden
  18707. */
  18708. export interface ExtendedGamepadButton extends GamepadButton {
  18709. /**
  18710. * If the button/trigger is currently pressed
  18711. */
  18712. readonly pressed: boolean;
  18713. /**
  18714. * If the button/trigger is currently touched
  18715. */
  18716. readonly touched: boolean;
  18717. /**
  18718. * Value of the button/trigger
  18719. */
  18720. readonly value: number;
  18721. }
  18722. /** @hidden */
  18723. export interface _GamePadFactory {
  18724. /**
  18725. * Returns whether or not the current gamepad can be created for this type of controller.
  18726. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18727. * @returns true if it can be created, otherwise false
  18728. */
  18729. canCreate(gamepadInfo: any): boolean;
  18730. /**
  18731. * Creates a new instance of the Gamepad.
  18732. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18733. * @returns the new gamepad instance
  18734. */
  18735. create(gamepadInfo: any): Gamepad;
  18736. }
  18737. /**
  18738. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18739. */
  18740. export class PoseEnabledControllerHelper {
  18741. /** @hidden */
  18742. static _ControllerFactories: _GamePadFactory[];
  18743. /** @hidden */
  18744. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18745. /**
  18746. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18747. * @param vrGamepad the gamepad to initialized
  18748. * @returns a vr controller of the type the gamepad identified as
  18749. */
  18750. static InitiateController(vrGamepad: any): Gamepad;
  18751. }
  18752. /**
  18753. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18754. */
  18755. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18756. /**
  18757. * If the controller is used in a webXR session
  18758. */
  18759. isXR: boolean;
  18760. private _deviceRoomPosition;
  18761. private _deviceRoomRotationQuaternion;
  18762. /**
  18763. * The device position in babylon space
  18764. */
  18765. devicePosition: Vector3;
  18766. /**
  18767. * The device rotation in babylon space
  18768. */
  18769. deviceRotationQuaternion: Quaternion;
  18770. /**
  18771. * The scale factor of the device in babylon space
  18772. */
  18773. deviceScaleFactor: number;
  18774. /**
  18775. * (Likely devicePosition should be used instead) The device position in its room space
  18776. */
  18777. position: Vector3;
  18778. /**
  18779. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18780. */
  18781. rotationQuaternion: Quaternion;
  18782. /**
  18783. * The type of controller (Eg. Windows mixed reality)
  18784. */
  18785. controllerType: PoseEnabledControllerType;
  18786. protected _calculatedPosition: Vector3;
  18787. private _calculatedRotation;
  18788. /**
  18789. * The raw pose from the device
  18790. */
  18791. rawPose: DevicePose;
  18792. private _trackPosition;
  18793. private _maxRotationDistFromHeadset;
  18794. private _draggedRoomRotation;
  18795. /**
  18796. * @hidden
  18797. */
  18798. _disableTrackPosition(fixedPosition: Vector3): void;
  18799. /**
  18800. * Internal, the mesh attached to the controller
  18801. * @hidden
  18802. */
  18803. _mesh: Nullable<AbstractMesh>;
  18804. private _poseControlledCamera;
  18805. private _leftHandSystemQuaternion;
  18806. /**
  18807. * Internal, matrix used to convert room space to babylon space
  18808. * @hidden
  18809. */
  18810. _deviceToWorld: Matrix;
  18811. /**
  18812. * Node to be used when casting a ray from the controller
  18813. * @hidden
  18814. */
  18815. _pointingPoseNode: Nullable<TransformNode>;
  18816. /**
  18817. * Name of the child mesh that can be used to cast a ray from the controller
  18818. */
  18819. static readonly POINTING_POSE: string;
  18820. /**
  18821. * Creates a new PoseEnabledController from a gamepad
  18822. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18823. */
  18824. constructor(browserGamepad: any);
  18825. private _workingMatrix;
  18826. /**
  18827. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18828. */
  18829. update(): void;
  18830. /**
  18831. * Updates only the pose device and mesh without doing any button event checking
  18832. */
  18833. protected _updatePoseAndMesh(): void;
  18834. /**
  18835. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18836. * @param poseData raw pose fromthe device
  18837. */
  18838. updateFromDevice(poseData: DevicePose): void;
  18839. /**
  18840. * @hidden
  18841. */
  18842. _meshAttachedObservable: Observable<AbstractMesh>;
  18843. /**
  18844. * Attaches a mesh to the controller
  18845. * @param mesh the mesh to be attached
  18846. */
  18847. attachToMesh(mesh: AbstractMesh): void;
  18848. /**
  18849. * Attaches the controllers mesh to a camera
  18850. * @param camera the camera the mesh should be attached to
  18851. */
  18852. attachToPoseControlledCamera(camera: TargetCamera): void;
  18853. /**
  18854. * Disposes of the controller
  18855. */
  18856. dispose(): void;
  18857. /**
  18858. * The mesh that is attached to the controller
  18859. */
  18860. get mesh(): Nullable<AbstractMesh>;
  18861. /**
  18862. * Gets the ray of the controller in the direction the controller is pointing
  18863. * @param length the length the resulting ray should be
  18864. * @returns a ray in the direction the controller is pointing
  18865. */
  18866. getForwardRay(length?: number): Ray;
  18867. }
  18868. }
  18869. declare module BABYLON {
  18870. /**
  18871. * Defines the WebVRController object that represents controllers tracked in 3D space
  18872. */
  18873. export abstract class WebVRController extends PoseEnabledController {
  18874. /**
  18875. * Internal, the default controller model for the controller
  18876. */
  18877. protected _defaultModel: Nullable<AbstractMesh>;
  18878. /**
  18879. * Fired when the trigger state has changed
  18880. */
  18881. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18882. /**
  18883. * Fired when the main button state has changed
  18884. */
  18885. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18886. /**
  18887. * Fired when the secondary button state has changed
  18888. */
  18889. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18890. /**
  18891. * Fired when the pad state has changed
  18892. */
  18893. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18894. /**
  18895. * Fired when controllers stick values have changed
  18896. */
  18897. onPadValuesChangedObservable: Observable<StickValues>;
  18898. /**
  18899. * Array of button availible on the controller
  18900. */
  18901. protected _buttons: Array<MutableGamepadButton>;
  18902. private _onButtonStateChange;
  18903. /**
  18904. * Fired when a controller button's state has changed
  18905. * @param callback the callback containing the button that was modified
  18906. */
  18907. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18908. /**
  18909. * X and Y axis corresponding to the controllers joystick
  18910. */
  18911. pad: StickValues;
  18912. /**
  18913. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18914. */
  18915. hand: string;
  18916. /**
  18917. * The default controller model for the controller
  18918. */
  18919. get defaultModel(): Nullable<AbstractMesh>;
  18920. /**
  18921. * Creates a new WebVRController from a gamepad
  18922. * @param vrGamepad the gamepad that the WebVRController should be created from
  18923. */
  18924. constructor(vrGamepad: any);
  18925. /**
  18926. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18927. */
  18928. update(): void;
  18929. /**
  18930. * Function to be called when a button is modified
  18931. */
  18932. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18933. /**
  18934. * Loads a mesh and attaches it to the controller
  18935. * @param scene the scene the mesh should be added to
  18936. * @param meshLoaded callback for when the mesh has been loaded
  18937. */
  18938. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18939. private _setButtonValue;
  18940. private _changes;
  18941. private _checkChanges;
  18942. /**
  18943. * Disposes of th webVRCOntroller
  18944. */
  18945. dispose(): void;
  18946. }
  18947. }
  18948. declare module BABYLON {
  18949. /**
  18950. * The HemisphericLight simulates the ambient environment light,
  18951. * so the passed direction is the light reflection direction, not the incoming direction.
  18952. */
  18953. export class HemisphericLight extends Light {
  18954. /**
  18955. * The groundColor is the light in the opposite direction to the one specified during creation.
  18956. * 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.
  18957. */
  18958. groundColor: Color3;
  18959. /**
  18960. * The light reflection direction, not the incoming direction.
  18961. */
  18962. direction: Vector3;
  18963. /**
  18964. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  18965. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  18966. * The HemisphericLight can't cast shadows.
  18967. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18968. * @param name The friendly name of the light
  18969. * @param direction The direction of the light reflection
  18970. * @param scene The scene the light belongs to
  18971. */
  18972. constructor(name: string, direction: Vector3, scene: Scene);
  18973. protected _buildUniformLayout(): void;
  18974. /**
  18975. * Returns the string "HemisphericLight".
  18976. * @return The class name
  18977. */
  18978. getClassName(): string;
  18979. /**
  18980. * Sets the HemisphericLight direction towards the passed target (Vector3).
  18981. * Returns the updated direction.
  18982. * @param target The target the direction should point to
  18983. * @return The computed direction
  18984. */
  18985. setDirectionToTarget(target: Vector3): Vector3;
  18986. /**
  18987. * Returns the shadow generator associated to the light.
  18988. * @returns Always null for hemispheric lights because it does not support shadows.
  18989. */
  18990. getShadowGenerator(): Nullable<IShadowGenerator>;
  18991. /**
  18992. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  18993. * @param effect The effect to update
  18994. * @param lightIndex The index of the light in the effect to update
  18995. * @returns The hemispheric light
  18996. */
  18997. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  18998. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  18999. /**
  19000. * Computes the world matrix of the node
  19001. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19002. * @param useWasUpdatedFlag defines a reserved property
  19003. * @returns the world matrix
  19004. */
  19005. computeWorldMatrix(): Matrix;
  19006. /**
  19007. * Returns the integer 3.
  19008. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19009. */
  19010. getTypeID(): number;
  19011. /**
  19012. * Prepares the list of defines specific to the light type.
  19013. * @param defines the list of defines
  19014. * @param lightIndex defines the index of the light for the effect
  19015. */
  19016. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19017. }
  19018. }
  19019. declare module BABYLON {
  19020. /** @hidden */
  19021. export var vrMultiviewToSingleviewPixelShader: {
  19022. name: string;
  19023. shader: string;
  19024. };
  19025. }
  19026. declare module BABYLON {
  19027. /**
  19028. * Renders to multiple views with a single draw call
  19029. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19030. */
  19031. export class MultiviewRenderTarget extends RenderTargetTexture {
  19032. /**
  19033. * Creates a multiview render target
  19034. * @param scene scene used with the render target
  19035. * @param size the size of the render target (used for each view)
  19036. */
  19037. constructor(scene: Scene, size?: number | {
  19038. width: number;
  19039. height: number;
  19040. } | {
  19041. ratio: number;
  19042. });
  19043. /**
  19044. * @hidden
  19045. * @param faceIndex the face index, if its a cube texture
  19046. */
  19047. _bindFrameBuffer(faceIndex?: number): void;
  19048. /**
  19049. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19050. * @returns the view count
  19051. */
  19052. getViewCount(): number;
  19053. }
  19054. }
  19055. declare module BABYLON {
  19056. /**
  19057. * Represents a camera frustum
  19058. */
  19059. export class Frustum {
  19060. /**
  19061. * Gets the planes representing the frustum
  19062. * @param transform matrix to be applied to the returned planes
  19063. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19064. */
  19065. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19066. /**
  19067. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19072. /**
  19073. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19078. /**
  19079. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19084. /**
  19085. * Gets the right 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 GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19090. /**
  19091. * Gets the top 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 GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19096. /**
  19097. * Gets the bottom frustum plane transformed by the transform matrix
  19098. * @param transform transformation matrix to be applied to the resulting frustum plane
  19099. * @param frustumPlane the resuling frustum plane
  19100. */
  19101. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19102. /**
  19103. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19104. * @param transform transformation matrix to be applied to the resulting frustum planes
  19105. * @param frustumPlanes the resuling frustum planes
  19106. */
  19107. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19108. }
  19109. }
  19110. declare module BABYLON {
  19111. interface Engine {
  19112. /**
  19113. * Creates a new multiview render target
  19114. * @param width defines the width of the texture
  19115. * @param height defines the height of the texture
  19116. * @returns the created multiview texture
  19117. */
  19118. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19119. /**
  19120. * Binds a multiview framebuffer to be drawn to
  19121. * @param multiviewTexture texture to bind
  19122. */
  19123. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19124. }
  19125. interface Camera {
  19126. /**
  19127. * @hidden
  19128. * 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)
  19129. */
  19130. _useMultiviewToSingleView: boolean;
  19131. /**
  19132. * @hidden
  19133. * 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)
  19134. */
  19135. _multiviewTexture: Nullable<RenderTargetTexture>;
  19136. /**
  19137. * @hidden
  19138. * ensures the multiview texture of the camera exists and has the specified width/height
  19139. * @param width height to set on the multiview texture
  19140. * @param height width to set on the multiview texture
  19141. */
  19142. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19143. }
  19144. interface Scene {
  19145. /** @hidden */
  19146. _transformMatrixR: Matrix;
  19147. /** @hidden */
  19148. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19149. /** @hidden */
  19150. _createMultiviewUbo(): void;
  19151. /** @hidden */
  19152. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19153. /** @hidden */
  19154. _renderMultiviewToSingleView(camera: Camera): void;
  19155. }
  19156. }
  19157. declare module BABYLON {
  19158. /**
  19159. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19160. * This will not be used for webXR as it supports displaying texture arrays directly
  19161. */
  19162. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19163. /**
  19164. * Initializes a VRMultiviewToSingleview
  19165. * @param name name of the post process
  19166. * @param camera camera to be applied to
  19167. * @param scaleFactor scaling factor to the size of the output texture
  19168. */
  19169. constructor(name: string, camera: Camera, scaleFactor: number);
  19170. }
  19171. }
  19172. declare module BABYLON {
  19173. /**
  19174. * Interface used to define additional presentation attributes
  19175. */
  19176. export interface IVRPresentationAttributes {
  19177. /**
  19178. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19179. */
  19180. highRefreshRate: boolean;
  19181. /**
  19182. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19183. */
  19184. foveationLevel: number;
  19185. }
  19186. interface Engine {
  19187. /** @hidden */
  19188. _vrDisplay: any;
  19189. /** @hidden */
  19190. _vrSupported: boolean;
  19191. /** @hidden */
  19192. _oldSize: Size;
  19193. /** @hidden */
  19194. _oldHardwareScaleFactor: number;
  19195. /** @hidden */
  19196. _vrExclusivePointerMode: boolean;
  19197. /** @hidden */
  19198. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19199. /** @hidden */
  19200. _onVRDisplayPointerRestricted: () => void;
  19201. /** @hidden */
  19202. _onVRDisplayPointerUnrestricted: () => void;
  19203. /** @hidden */
  19204. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19205. /** @hidden */
  19206. _onVrDisplayDisconnect: Nullable<() => void>;
  19207. /** @hidden */
  19208. _onVrDisplayPresentChange: Nullable<() => void>;
  19209. /**
  19210. * Observable signaled when VR display mode changes
  19211. */
  19212. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19213. /**
  19214. * Observable signaled when VR request present is complete
  19215. */
  19216. onVRRequestPresentComplete: Observable<boolean>;
  19217. /**
  19218. * Observable signaled when VR request present starts
  19219. */
  19220. onVRRequestPresentStart: Observable<Engine>;
  19221. /**
  19222. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19223. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19224. */
  19225. isInVRExclusivePointerMode: boolean;
  19226. /**
  19227. * Gets a boolean indicating if a webVR device was detected
  19228. * @returns true if a webVR device was detected
  19229. */
  19230. isVRDevicePresent(): boolean;
  19231. /**
  19232. * Gets the current webVR device
  19233. * @returns the current webVR device (or null)
  19234. */
  19235. getVRDevice(): any;
  19236. /**
  19237. * Initializes a webVR display and starts listening to display change events
  19238. * The onVRDisplayChangedObservable will be notified upon these changes
  19239. * @returns A promise containing a VRDisplay and if vr is supported
  19240. */
  19241. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19242. /** @hidden */
  19243. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19244. /**
  19245. * Gets or sets the presentation attributes used to configure VR rendering
  19246. */
  19247. vrPresentationAttributes?: IVRPresentationAttributes;
  19248. /**
  19249. * Call this function to switch to webVR mode
  19250. * Will do nothing if webVR is not supported or if there is no webVR device
  19251. * @param options the webvr options provided to the camera. mainly used for multiview
  19252. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19253. */
  19254. enableVR(options: WebVROptions): void;
  19255. /** @hidden */
  19256. _onVRFullScreenTriggered(): void;
  19257. }
  19258. }
  19259. declare module BABYLON {
  19260. /**
  19261. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19262. * IMPORTANT!! The data is right-hand data.
  19263. * @export
  19264. * @interface DevicePose
  19265. */
  19266. export interface DevicePose {
  19267. /**
  19268. * The position of the device, values in array are [x,y,z].
  19269. */
  19270. readonly position: Nullable<Float32Array>;
  19271. /**
  19272. * The linearVelocity of the device, values in array are [x,y,z].
  19273. */
  19274. readonly linearVelocity: Nullable<Float32Array>;
  19275. /**
  19276. * The linearAcceleration of the device, values in array are [x,y,z].
  19277. */
  19278. readonly linearAcceleration: Nullable<Float32Array>;
  19279. /**
  19280. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19281. */
  19282. readonly orientation: Nullable<Float32Array>;
  19283. /**
  19284. * The angularVelocity of the device, values in array are [x,y,z].
  19285. */
  19286. readonly angularVelocity: Nullable<Float32Array>;
  19287. /**
  19288. * The angularAcceleration of the device, values in array are [x,y,z].
  19289. */
  19290. readonly angularAcceleration: Nullable<Float32Array>;
  19291. }
  19292. /**
  19293. * Interface representing a pose controlled object in Babylon.
  19294. * A pose controlled object has both regular pose values as well as pose values
  19295. * from an external device such as a VR head mounted display
  19296. */
  19297. export interface PoseControlled {
  19298. /**
  19299. * The position of the object in babylon space.
  19300. */
  19301. position: Vector3;
  19302. /**
  19303. * The rotation quaternion of the object in babylon space.
  19304. */
  19305. rotationQuaternion: Quaternion;
  19306. /**
  19307. * The position of the device in babylon space.
  19308. */
  19309. devicePosition?: Vector3;
  19310. /**
  19311. * The rotation quaternion of the device in babylon space.
  19312. */
  19313. deviceRotationQuaternion: Quaternion;
  19314. /**
  19315. * The raw pose coming from the device.
  19316. */
  19317. rawPose: Nullable<DevicePose>;
  19318. /**
  19319. * The scale of the device to be used when translating from device space to babylon space.
  19320. */
  19321. deviceScaleFactor: number;
  19322. /**
  19323. * Updates the poseControlled values based on the input device pose.
  19324. * @param poseData the pose data to update the object with
  19325. */
  19326. updateFromDevice(poseData: DevicePose): void;
  19327. }
  19328. /**
  19329. * Set of options to customize the webVRCamera
  19330. */
  19331. export interface WebVROptions {
  19332. /**
  19333. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19334. */
  19335. trackPosition?: boolean;
  19336. /**
  19337. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19338. */
  19339. positionScale?: number;
  19340. /**
  19341. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19342. */
  19343. displayName?: string;
  19344. /**
  19345. * Should the native controller meshes be initialized. (default: true)
  19346. */
  19347. controllerMeshes?: boolean;
  19348. /**
  19349. * Creating a default HemiLight only on controllers. (default: true)
  19350. */
  19351. defaultLightingOnControllers?: boolean;
  19352. /**
  19353. * If you don't want to use the default VR button of the helper. (default: false)
  19354. */
  19355. useCustomVRButton?: boolean;
  19356. /**
  19357. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19358. */
  19359. customVRButton?: HTMLButtonElement;
  19360. /**
  19361. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19362. */
  19363. rayLength?: number;
  19364. /**
  19365. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19366. */
  19367. defaultHeight?: number;
  19368. /**
  19369. * If multiview should be used if availible (default: false)
  19370. */
  19371. useMultiview?: boolean;
  19372. }
  19373. /**
  19374. * This represents a WebVR camera.
  19375. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19376. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19377. */
  19378. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19379. private webVROptions;
  19380. /**
  19381. * @hidden
  19382. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19383. */
  19384. _vrDevice: any;
  19385. /**
  19386. * The rawPose of the vrDevice.
  19387. */
  19388. rawPose: Nullable<DevicePose>;
  19389. private _onVREnabled;
  19390. private _specsVersion;
  19391. private _attached;
  19392. private _frameData;
  19393. protected _descendants: Array<Node>;
  19394. private _deviceRoomPosition;
  19395. /** @hidden */
  19396. _deviceRoomRotationQuaternion: Quaternion;
  19397. private _standingMatrix;
  19398. /**
  19399. * Represents device position in babylon space.
  19400. */
  19401. devicePosition: Vector3;
  19402. /**
  19403. * Represents device rotation in babylon space.
  19404. */
  19405. deviceRotationQuaternion: Quaternion;
  19406. /**
  19407. * The scale of the device to be used when translating from device space to babylon space.
  19408. */
  19409. deviceScaleFactor: number;
  19410. private _deviceToWorld;
  19411. private _worldToDevice;
  19412. /**
  19413. * References to the webVR controllers for the vrDevice.
  19414. */
  19415. controllers: Array<WebVRController>;
  19416. /**
  19417. * Emits an event when a controller is attached.
  19418. */
  19419. onControllersAttachedObservable: Observable<WebVRController[]>;
  19420. /**
  19421. * Emits an event when a controller's mesh has been loaded;
  19422. */
  19423. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19424. /**
  19425. * Emits an event when the HMD's pose has been updated.
  19426. */
  19427. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19428. private _poseSet;
  19429. /**
  19430. * If the rig cameras be used as parent instead of this camera.
  19431. */
  19432. rigParenting: boolean;
  19433. private _lightOnControllers;
  19434. private _defaultHeight?;
  19435. /**
  19436. * Instantiates a WebVRFreeCamera.
  19437. * @param name The name of the WebVRFreeCamera
  19438. * @param position The starting anchor position for the camera
  19439. * @param scene The scene the camera belongs to
  19440. * @param webVROptions a set of customizable options for the webVRCamera
  19441. */
  19442. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19443. /**
  19444. * Gets the device distance from the ground in meters.
  19445. * @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.
  19446. */
  19447. deviceDistanceToRoomGround(): number;
  19448. /**
  19449. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19450. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19451. */
  19452. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19453. /**
  19454. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19455. * @returns A promise with a boolean set to if the standing matrix is supported.
  19456. */
  19457. useStandingMatrixAsync(): Promise<boolean>;
  19458. /**
  19459. * Disposes the camera
  19460. */
  19461. dispose(): void;
  19462. /**
  19463. * Gets a vrController by name.
  19464. * @param name The name of the controller to retreive
  19465. * @returns the controller matching the name specified or null if not found
  19466. */
  19467. getControllerByName(name: string): Nullable<WebVRController>;
  19468. private _leftController;
  19469. /**
  19470. * The controller corresponding to the users left hand.
  19471. */
  19472. get leftController(): Nullable<WebVRController>;
  19473. private _rightController;
  19474. /**
  19475. * The controller corresponding to the users right hand.
  19476. */
  19477. get rightController(): Nullable<WebVRController>;
  19478. /**
  19479. * Casts a ray forward from the vrCamera's gaze.
  19480. * @param length Length of the ray (default: 100)
  19481. * @returns the ray corresponding to the gaze
  19482. */
  19483. getForwardRay(length?: number): Ray;
  19484. /**
  19485. * @hidden
  19486. * Updates the camera based on device's frame data
  19487. */
  19488. _checkInputs(): void;
  19489. /**
  19490. * Updates the poseControlled values based on the input device pose.
  19491. * @param poseData Pose coming from the device
  19492. */
  19493. updateFromDevice(poseData: DevicePose): void;
  19494. private _htmlElementAttached;
  19495. private _detachIfAttached;
  19496. /**
  19497. * WebVR's attach control will start broadcasting frames to the device.
  19498. * Note that in certain browsers (chrome for example) this function must be called
  19499. * within a user-interaction callback. Example:
  19500. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19501. *
  19502. * @param element html element to attach the vrDevice to
  19503. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19504. */
  19505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19506. /**
  19507. * Detaches the camera from the html element and disables VR
  19508. *
  19509. * @param element html element to detach from
  19510. */
  19511. detachControl(element: HTMLElement): void;
  19512. /**
  19513. * @returns the name of this class
  19514. */
  19515. getClassName(): string;
  19516. /**
  19517. * Calls resetPose on the vrDisplay
  19518. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19519. */
  19520. resetToCurrentRotation(): void;
  19521. /**
  19522. * @hidden
  19523. * Updates the rig cameras (left and right eye)
  19524. */
  19525. _updateRigCameras(): void;
  19526. private _workingVector;
  19527. private _oneVector;
  19528. private _workingMatrix;
  19529. private updateCacheCalled;
  19530. private _correctPositionIfNotTrackPosition;
  19531. /**
  19532. * @hidden
  19533. * Updates the cached values of the camera
  19534. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19535. */
  19536. _updateCache(ignoreParentClass?: boolean): void;
  19537. /**
  19538. * @hidden
  19539. * Get current device position in babylon world
  19540. */
  19541. _computeDevicePosition(): void;
  19542. /**
  19543. * Updates the current device position and rotation in the babylon world
  19544. */
  19545. update(): void;
  19546. /**
  19547. * @hidden
  19548. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19549. * @returns an identity matrix
  19550. */
  19551. _getViewMatrix(): Matrix;
  19552. private _tmpMatrix;
  19553. /**
  19554. * This function is called by the two RIG cameras.
  19555. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19556. * @hidden
  19557. */
  19558. _getWebVRViewMatrix(): Matrix;
  19559. /** @hidden */
  19560. _getWebVRProjectionMatrix(): Matrix;
  19561. private _onGamepadConnectedObserver;
  19562. private _onGamepadDisconnectedObserver;
  19563. private _updateCacheWhenTrackingDisabledObserver;
  19564. /**
  19565. * Initializes the controllers and their meshes
  19566. */
  19567. initControllers(): void;
  19568. }
  19569. }
  19570. declare module BABYLON {
  19571. /**
  19572. * Size options for a post process
  19573. */
  19574. export type PostProcessOptions = {
  19575. width: number;
  19576. height: number;
  19577. };
  19578. /**
  19579. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19580. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19581. */
  19582. export class PostProcess {
  19583. /** Name of the PostProcess. */
  19584. name: string;
  19585. /**
  19586. * Gets or sets the unique id of the post process
  19587. */
  19588. uniqueId: number;
  19589. /**
  19590. * Width of the texture to apply the post process on
  19591. */
  19592. width: number;
  19593. /**
  19594. * Height of the texture to apply the post process on
  19595. */
  19596. height: number;
  19597. /**
  19598. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19599. * @hidden
  19600. */
  19601. _outputTexture: Nullable<InternalTexture>;
  19602. /**
  19603. * Sampling mode used by the shader
  19604. * See https://doc.babylonjs.com/classes/3.1/texture
  19605. */
  19606. renderTargetSamplingMode: number;
  19607. /**
  19608. * Clear color to use when screen clearing
  19609. */
  19610. clearColor: Color4;
  19611. /**
  19612. * If the buffer needs to be cleared before applying the post process. (default: true)
  19613. * Should be set to false if shader will overwrite all previous pixels.
  19614. */
  19615. autoClear: boolean;
  19616. /**
  19617. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19618. */
  19619. alphaMode: number;
  19620. /**
  19621. * Sets the setAlphaBlendConstants of the babylon engine
  19622. */
  19623. alphaConstants: Color4;
  19624. /**
  19625. * Animations to be used for the post processing
  19626. */
  19627. animations: Animation[];
  19628. /**
  19629. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19630. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19631. */
  19632. enablePixelPerfectMode: boolean;
  19633. /**
  19634. * Force the postprocess to be applied without taking in account viewport
  19635. */
  19636. forceFullscreenViewport: boolean;
  19637. /**
  19638. * List of inspectable custom properties (used by the Inspector)
  19639. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19640. */
  19641. inspectableCustomProperties: IInspectable[];
  19642. /**
  19643. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19644. *
  19645. * | Value | Type | Description |
  19646. * | ----- | ----------------------------------- | ----------- |
  19647. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19648. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19649. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19650. *
  19651. */
  19652. scaleMode: number;
  19653. /**
  19654. * Force textures to be a power of two (default: false)
  19655. */
  19656. alwaysForcePOT: boolean;
  19657. private _samples;
  19658. /**
  19659. * Number of sample textures (default: 1)
  19660. */
  19661. get samples(): number;
  19662. set samples(n: number);
  19663. /**
  19664. * Modify the scale of the post process to be the same as the viewport (default: false)
  19665. */
  19666. adaptScaleToCurrentViewport: boolean;
  19667. private _camera;
  19668. private _scene;
  19669. private _engine;
  19670. private _options;
  19671. private _reusable;
  19672. private _textureType;
  19673. private _textureFormat;
  19674. /**
  19675. * Smart array of input and output textures for the post process.
  19676. * @hidden
  19677. */
  19678. _textures: SmartArray<InternalTexture>;
  19679. /**
  19680. * The index in _textures that corresponds to the output texture.
  19681. * @hidden
  19682. */
  19683. _currentRenderTextureInd: number;
  19684. private _effect;
  19685. private _samplers;
  19686. private _fragmentUrl;
  19687. private _vertexUrl;
  19688. private _parameters;
  19689. private _scaleRatio;
  19690. protected _indexParameters: any;
  19691. private _shareOutputWithPostProcess;
  19692. private _texelSize;
  19693. private _forcedOutputTexture;
  19694. /**
  19695. * Returns the fragment url or shader name used in the post process.
  19696. * @returns the fragment url or name in the shader store.
  19697. */
  19698. getEffectName(): string;
  19699. /**
  19700. * An event triggered when the postprocess is activated.
  19701. */
  19702. onActivateObservable: Observable<Camera>;
  19703. private _onActivateObserver;
  19704. /**
  19705. * A function that is added to the onActivateObservable
  19706. */
  19707. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19708. /**
  19709. * An event triggered when the postprocess changes its size.
  19710. */
  19711. onSizeChangedObservable: Observable<PostProcess>;
  19712. private _onSizeChangedObserver;
  19713. /**
  19714. * A function that is added to the onSizeChangedObservable
  19715. */
  19716. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19717. /**
  19718. * An event triggered when the postprocess applies its effect.
  19719. */
  19720. onApplyObservable: Observable<Effect>;
  19721. private _onApplyObserver;
  19722. /**
  19723. * A function that is added to the onApplyObservable
  19724. */
  19725. set onApply(callback: (effect: Effect) => void);
  19726. /**
  19727. * An event triggered before rendering the postprocess
  19728. */
  19729. onBeforeRenderObservable: Observable<Effect>;
  19730. private _onBeforeRenderObserver;
  19731. /**
  19732. * A function that is added to the onBeforeRenderObservable
  19733. */
  19734. set onBeforeRender(callback: (effect: Effect) => void);
  19735. /**
  19736. * An event triggered after rendering the postprocess
  19737. */
  19738. onAfterRenderObservable: Observable<Effect>;
  19739. private _onAfterRenderObserver;
  19740. /**
  19741. * A function that is added to the onAfterRenderObservable
  19742. */
  19743. set onAfterRender(callback: (efect: Effect) => void);
  19744. /**
  19745. * 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
  19746. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19747. */
  19748. get inputTexture(): InternalTexture;
  19749. set inputTexture(value: InternalTexture);
  19750. /**
  19751. * Gets the camera which post process is applied to.
  19752. * @returns The camera the post process is applied to.
  19753. */
  19754. getCamera(): Camera;
  19755. /**
  19756. * Gets the texel size of the postprocess.
  19757. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19758. */
  19759. get texelSize(): Vector2;
  19760. /**
  19761. * Creates a new instance PostProcess
  19762. * @param name The name of the PostProcess.
  19763. * @param fragmentUrl The url of the fragment shader to be used.
  19764. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19765. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19766. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19767. * @param camera The camera to apply the render pass to.
  19768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19769. * @param engine The engine which the post process will be applied. (default: current engine)
  19770. * @param reusable If the post process can be reused on the same frame. (default: false)
  19771. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19772. * @param textureType Type of textures used when performing the post process. (default: 0)
  19773. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19774. * @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
  19775. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19776. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19777. */
  19778. constructor(
  19779. /** Name of the PostProcess. */
  19780. 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);
  19781. /**
  19782. * Gets a string idenfifying the name of the class
  19783. * @returns "PostProcess" string
  19784. */
  19785. getClassName(): string;
  19786. /**
  19787. * Gets the engine which this post process belongs to.
  19788. * @returns The engine the post process was enabled with.
  19789. */
  19790. getEngine(): Engine;
  19791. /**
  19792. * The effect that is created when initializing the post process.
  19793. * @returns The created effect corresponding the the postprocess.
  19794. */
  19795. getEffect(): Effect;
  19796. /**
  19797. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19798. * @param postProcess The post process to share the output with.
  19799. * @returns This post process.
  19800. */
  19801. shareOutputWith(postProcess: PostProcess): PostProcess;
  19802. /**
  19803. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19804. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19805. */
  19806. useOwnOutput(): void;
  19807. /**
  19808. * Updates the effect with the current post process compile time values and recompiles the shader.
  19809. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19810. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19811. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19812. * @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
  19813. * @param onCompiled Called when the shader has been compiled.
  19814. * @param onError Called if there is an error when compiling a shader.
  19815. */
  19816. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19817. /**
  19818. * The post process is reusable if it can be used multiple times within one frame.
  19819. * @returns If the post process is reusable
  19820. */
  19821. isReusable(): boolean;
  19822. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19823. markTextureDirty(): void;
  19824. /**
  19825. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19826. * 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.
  19827. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19828. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19829. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19830. * @returns The target texture that was bound to be written to.
  19831. */
  19832. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19833. /**
  19834. * If the post process is supported.
  19835. */
  19836. get isSupported(): boolean;
  19837. /**
  19838. * The aspect ratio of the output texture.
  19839. */
  19840. get aspectRatio(): number;
  19841. /**
  19842. * Get a value indicating if the post-process is ready to be used
  19843. * @returns true if the post-process is ready (shader is compiled)
  19844. */
  19845. isReady(): boolean;
  19846. /**
  19847. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19848. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19849. */
  19850. apply(): Nullable<Effect>;
  19851. private _disposeTextures;
  19852. /**
  19853. * Disposes the post process.
  19854. * @param camera The camera to dispose the post process on.
  19855. */
  19856. dispose(camera?: Camera): void;
  19857. }
  19858. }
  19859. declare module BABYLON {
  19860. /** @hidden */
  19861. export var kernelBlurVaryingDeclaration: {
  19862. name: string;
  19863. shader: string;
  19864. };
  19865. }
  19866. declare module BABYLON {
  19867. /** @hidden */
  19868. export var kernelBlurFragment: {
  19869. name: string;
  19870. shader: string;
  19871. };
  19872. }
  19873. declare module BABYLON {
  19874. /** @hidden */
  19875. export var kernelBlurFragment2: {
  19876. name: string;
  19877. shader: string;
  19878. };
  19879. }
  19880. declare module BABYLON {
  19881. /** @hidden */
  19882. export var kernelBlurPixelShader: {
  19883. name: string;
  19884. shader: string;
  19885. };
  19886. }
  19887. declare module BABYLON {
  19888. /** @hidden */
  19889. export var kernelBlurVertex: {
  19890. name: string;
  19891. shader: string;
  19892. };
  19893. }
  19894. declare module BABYLON {
  19895. /** @hidden */
  19896. export var kernelBlurVertexShader: {
  19897. name: string;
  19898. shader: string;
  19899. };
  19900. }
  19901. declare module BABYLON {
  19902. /**
  19903. * The Blur Post Process which blurs an image based on a kernel and direction.
  19904. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19905. */
  19906. export class BlurPostProcess extends PostProcess {
  19907. /** The direction in which to blur the image. */
  19908. direction: Vector2;
  19909. private blockCompilation;
  19910. protected _kernel: number;
  19911. protected _idealKernel: number;
  19912. protected _packedFloat: boolean;
  19913. private _staticDefines;
  19914. /**
  19915. * Sets the length in pixels of the blur sample region
  19916. */
  19917. set kernel(v: number);
  19918. /**
  19919. * Gets the length in pixels of the blur sample region
  19920. */
  19921. get kernel(): number;
  19922. /**
  19923. * Sets wether or not the blur needs to unpack/repack floats
  19924. */
  19925. set packedFloat(v: boolean);
  19926. /**
  19927. * Gets wether or not the blur is unpacking/repacking floats
  19928. */
  19929. get packedFloat(): boolean;
  19930. /**
  19931. * Creates a new instance BlurPostProcess
  19932. * @param name The name of the effect.
  19933. * @param direction The direction in which to blur the image.
  19934. * @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.
  19935. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19936. * @param camera The camera to apply the render pass to.
  19937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19938. * @param engine The engine which the post process will be applied. (default: current engine)
  19939. * @param reusable If the post process can be reused on the same frame. (default: false)
  19940. * @param textureType Type of textures used when performing the post process. (default: 0)
  19941. * @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)
  19942. */
  19943. constructor(name: string,
  19944. /** The direction in which to blur the image. */
  19945. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19946. /**
  19947. * Updates the effect with the current post process compile time values and recompiles the shader.
  19948. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19949. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19950. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19951. * @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
  19952. * @param onCompiled Called when the shader has been compiled.
  19953. * @param onError Called if there is an error when compiling a shader.
  19954. */
  19955. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19956. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19957. /**
  19958. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19959. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19960. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19961. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19962. * The gaps between physical kernels are compensated for in the weighting of the samples
  19963. * @param idealKernel Ideal blur kernel.
  19964. * @return Nearest best kernel.
  19965. */
  19966. protected _nearestBestKernel(idealKernel: number): number;
  19967. /**
  19968. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19969. * @param x The point on the Gaussian distribution to sample.
  19970. * @return the value of the Gaussian function at x.
  19971. */
  19972. protected _gaussianWeight(x: number): number;
  19973. /**
  19974. * Generates a string that can be used as a floating point number in GLSL.
  19975. * @param x Value to print.
  19976. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19977. * @return GLSL float string.
  19978. */
  19979. protected _glslFloat(x: number, decimalFigures?: number): string;
  19980. }
  19981. }
  19982. declare module BABYLON {
  19983. /**
  19984. * Mirror texture can be used to simulate the view from a mirror in a scene.
  19985. * It will dynamically be rendered every frame to adapt to the camera point of view.
  19986. * You can then easily use it as a reflectionTexture on a flat surface.
  19987. * In case the surface is not a plane, please consider relying on reflection probes.
  19988. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19989. */
  19990. export class MirrorTexture extends RenderTargetTexture {
  19991. private scene;
  19992. /**
  19993. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  19994. * 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.
  19995. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19996. */
  19997. mirrorPlane: Plane;
  19998. /**
  19999. * Define the blur ratio used to blur the reflection if needed.
  20000. */
  20001. set blurRatio(value: number);
  20002. get blurRatio(): number;
  20003. /**
  20004. * Define the adaptive blur kernel used to blur the reflection if needed.
  20005. * This will autocompute the closest best match for the `blurKernel`
  20006. */
  20007. set adaptiveBlurKernel(value: number);
  20008. /**
  20009. * Define the blur kernel used to blur the reflection if needed.
  20010. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20011. */
  20012. set blurKernel(value: number);
  20013. /**
  20014. * Define the blur kernel on the X 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 blurKernelX(value: number);
  20018. get blurKernelX(): number;
  20019. /**
  20020. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20021. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20022. */
  20023. set blurKernelY(value: number);
  20024. get blurKernelY(): number;
  20025. private _autoComputeBlurKernel;
  20026. protected _onRatioRescale(): void;
  20027. private _updateGammaSpace;
  20028. private _imageProcessingConfigChangeObserver;
  20029. private _transformMatrix;
  20030. private _mirrorMatrix;
  20031. private _savedViewMatrix;
  20032. private _blurX;
  20033. private _blurY;
  20034. private _adaptiveBlurKernel;
  20035. private _blurKernelX;
  20036. private _blurKernelY;
  20037. private _blurRatio;
  20038. /**
  20039. * Instantiates a Mirror Texture.
  20040. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20041. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20042. * You can then easily use it as a reflectionTexture on a flat surface.
  20043. * In case the surface is not a plane, please consider relying on reflection probes.
  20044. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20045. * @param name
  20046. * @param size
  20047. * @param scene
  20048. * @param generateMipMaps
  20049. * @param type
  20050. * @param samplingMode
  20051. * @param generateDepthBuffer
  20052. */
  20053. constructor(name: string, size: number | {
  20054. width: number;
  20055. height: number;
  20056. } | {
  20057. ratio: number;
  20058. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20059. private _preparePostProcesses;
  20060. /**
  20061. * Clone the mirror texture.
  20062. * @returns the cloned texture
  20063. */
  20064. clone(): MirrorTexture;
  20065. /**
  20066. * Serialize the texture to a JSON representation you could use in Parse later on
  20067. * @returns the serialized JSON representation
  20068. */
  20069. serialize(): any;
  20070. /**
  20071. * Dispose the texture and release its associated resources.
  20072. */
  20073. dispose(): void;
  20074. }
  20075. }
  20076. declare module BABYLON {
  20077. /**
  20078. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20079. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20080. */
  20081. export class Texture extends BaseTexture {
  20082. /**
  20083. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20084. */
  20085. static SerializeBuffers: boolean;
  20086. /** @hidden */
  20087. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20088. /** @hidden */
  20089. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20090. /** @hidden */
  20091. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20092. /** nearest is mag = nearest and min = nearest and mip = linear */
  20093. static readonly NEAREST_SAMPLINGMODE: number;
  20094. /** nearest is mag = nearest and min = nearest and mip = linear */
  20095. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20096. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20097. static readonly BILINEAR_SAMPLINGMODE: number;
  20098. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20099. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20100. /** Trilinear is mag = linear and min = linear and mip = linear */
  20101. static readonly TRILINEAR_SAMPLINGMODE: number;
  20102. /** Trilinear is mag = linear and min = linear and mip = linear */
  20103. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20104. /** mag = nearest and min = nearest and mip = nearest */
  20105. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20106. /** mag = nearest and min = linear and mip = nearest */
  20107. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20108. /** mag = nearest and min = linear and mip = linear */
  20109. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20110. /** mag = nearest and min = linear and mip = none */
  20111. static readonly NEAREST_LINEAR: number;
  20112. /** mag = nearest and min = nearest and mip = none */
  20113. static readonly NEAREST_NEAREST: number;
  20114. /** mag = linear and min = nearest and mip = nearest */
  20115. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20116. /** mag = linear and min = nearest and mip = linear */
  20117. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20118. /** mag = linear and min = linear and mip = none */
  20119. static readonly LINEAR_LINEAR: number;
  20120. /** mag = linear and min = nearest and mip = none */
  20121. static readonly LINEAR_NEAREST: number;
  20122. /** Explicit coordinates mode */
  20123. static readonly EXPLICIT_MODE: number;
  20124. /** Spherical coordinates mode */
  20125. static readonly SPHERICAL_MODE: number;
  20126. /** Planar coordinates mode */
  20127. static readonly PLANAR_MODE: number;
  20128. /** Cubic coordinates mode */
  20129. static readonly CUBIC_MODE: number;
  20130. /** Projection coordinates mode */
  20131. static readonly PROJECTION_MODE: number;
  20132. /** Inverse Cubic coordinates mode */
  20133. static readonly SKYBOX_MODE: number;
  20134. /** Inverse Cubic coordinates mode */
  20135. static readonly INVCUBIC_MODE: number;
  20136. /** Equirectangular coordinates mode */
  20137. static readonly EQUIRECTANGULAR_MODE: number;
  20138. /** Equirectangular Fixed coordinates mode */
  20139. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20140. /** Equirectangular Fixed Mirrored coordinates mode */
  20141. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20142. /** Texture is not repeating outside of 0..1 UVs */
  20143. static readonly CLAMP_ADDRESSMODE: number;
  20144. /** Texture is repeating outside of 0..1 UVs */
  20145. static readonly WRAP_ADDRESSMODE: number;
  20146. /** Texture is repeating and mirrored */
  20147. static readonly MIRROR_ADDRESSMODE: number;
  20148. /**
  20149. * 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
  20150. */
  20151. static UseSerializedUrlIfAny: boolean;
  20152. /**
  20153. * Define the url of the texture.
  20154. */
  20155. url: Nullable<string>;
  20156. /**
  20157. * Define an offset on the texture to offset the u coordinates of the UVs
  20158. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20159. */
  20160. uOffset: number;
  20161. /**
  20162. * Define an offset on the texture to offset the v coordinates of the UVs
  20163. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20164. */
  20165. vOffset: number;
  20166. /**
  20167. * Define an offset on the texture to scale the u coordinates of the UVs
  20168. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20169. */
  20170. uScale: number;
  20171. /**
  20172. * Define an offset on the texture to scale the v coordinates of the UVs
  20173. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20174. */
  20175. vScale: number;
  20176. /**
  20177. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20178. * @see http://doc.babylonjs.com/how_to/more_materials
  20179. */
  20180. uAng: number;
  20181. /**
  20182. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20183. * @see http://doc.babylonjs.com/how_to/more_materials
  20184. */
  20185. vAng: number;
  20186. /**
  20187. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20188. * @see http://doc.babylonjs.com/how_to/more_materials
  20189. */
  20190. wAng: number;
  20191. /**
  20192. * Defines the center of rotation (U)
  20193. */
  20194. uRotationCenter: number;
  20195. /**
  20196. * Defines the center of rotation (V)
  20197. */
  20198. vRotationCenter: number;
  20199. /**
  20200. * Defines the center of rotation (W)
  20201. */
  20202. wRotationCenter: number;
  20203. /**
  20204. * Are mip maps generated for this texture or not.
  20205. */
  20206. get noMipmap(): boolean;
  20207. /**
  20208. * List of inspectable custom properties (used by the Inspector)
  20209. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20210. */
  20211. inspectableCustomProperties: Nullable<IInspectable[]>;
  20212. private _noMipmap;
  20213. /** @hidden */
  20214. _invertY: boolean;
  20215. private _rowGenerationMatrix;
  20216. private _cachedTextureMatrix;
  20217. private _projectionModeMatrix;
  20218. private _t0;
  20219. private _t1;
  20220. private _t2;
  20221. private _cachedUOffset;
  20222. private _cachedVOffset;
  20223. private _cachedUScale;
  20224. private _cachedVScale;
  20225. private _cachedUAng;
  20226. private _cachedVAng;
  20227. private _cachedWAng;
  20228. private _cachedProjectionMatrixId;
  20229. private _cachedCoordinatesMode;
  20230. /** @hidden */
  20231. protected _initialSamplingMode: number;
  20232. /** @hidden */
  20233. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20234. private _deleteBuffer;
  20235. protected _format: Nullable<number>;
  20236. private _delayedOnLoad;
  20237. private _delayedOnError;
  20238. private _mimeType?;
  20239. /**
  20240. * Observable triggered once the texture has been loaded.
  20241. */
  20242. onLoadObservable: Observable<Texture>;
  20243. protected _isBlocking: boolean;
  20244. /**
  20245. * Is the texture preventing material to render while loading.
  20246. * If false, a default texture will be used instead of the loading one during the preparation step.
  20247. */
  20248. set isBlocking(value: boolean);
  20249. get isBlocking(): boolean;
  20250. /**
  20251. * Get the current sampling mode associated with the texture.
  20252. */
  20253. get samplingMode(): number;
  20254. /**
  20255. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20256. */
  20257. get invertY(): boolean;
  20258. /**
  20259. * Instantiates a new texture.
  20260. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20261. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20262. * @param url defines the url of the picture to load as a texture
  20263. * @param scene defines the scene or engine the texture will belong to
  20264. * @param noMipmap defines if the texture will require mip maps or not
  20265. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20266. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20267. * @param onLoad defines a callback triggered when the texture has been loaded
  20268. * @param onError defines a callback triggered when an error occurred during the loading session
  20269. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20270. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20271. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20272. * @param mimeType defines an optional mime type information
  20273. */
  20274. 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);
  20275. /**
  20276. * Update the url (and optional buffer) of this texture if url was null during construction.
  20277. * @param url the url of the texture
  20278. * @param buffer the buffer of the texture (defaults to null)
  20279. * @param onLoad callback called when the texture is loaded (defaults to null)
  20280. */
  20281. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20282. /**
  20283. * Finish the loading sequence of a texture flagged as delayed load.
  20284. * @hidden
  20285. */
  20286. delayLoad(): void;
  20287. private _prepareRowForTextureGeneration;
  20288. /**
  20289. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20290. * @returns the transform matrix of the texture.
  20291. */
  20292. getTextureMatrix(uBase?: number): Matrix;
  20293. /**
  20294. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20295. * @returns The reflection texture transform
  20296. */
  20297. getReflectionTextureMatrix(): Matrix;
  20298. /**
  20299. * Clones the texture.
  20300. * @returns the cloned texture
  20301. */
  20302. clone(): Texture;
  20303. /**
  20304. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20305. * @returns The JSON representation of the texture
  20306. */
  20307. serialize(): any;
  20308. /**
  20309. * Get the current class name of the texture useful for serialization or dynamic coding.
  20310. * @returns "Texture"
  20311. */
  20312. getClassName(): string;
  20313. /**
  20314. * Dispose the texture and release its associated resources.
  20315. */
  20316. dispose(): void;
  20317. /**
  20318. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20319. * @param parsedTexture Define the JSON representation of the texture
  20320. * @param scene Define the scene the parsed texture should be instantiated in
  20321. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20322. * @returns The parsed texture if successful
  20323. */
  20324. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20325. /**
  20326. * Creates a texture from its base 64 representation.
  20327. * @param data Define the base64 payload without the data: prefix
  20328. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20329. * @param scene Define the scene the texture should belong to
  20330. * @param noMipmap Forces the texture to not create mip map information if true
  20331. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20332. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20333. * @param onLoad define a callback triggered when the texture has been loaded
  20334. * @param onError define a callback triggered when an error occurred during the loading session
  20335. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20336. * @returns the created texture
  20337. */
  20338. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20339. /**
  20340. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20341. * @param data Define the base64 payload without the data: prefix
  20342. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20343. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20344. * @param scene Define the scene the texture should belong to
  20345. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20346. * @param noMipmap Forces the texture to not create mip map information if true
  20347. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20348. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20349. * @param onLoad define a callback triggered when the texture has been loaded
  20350. * @param onError define a callback triggered when an error occurred during the loading session
  20351. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20352. * @returns the created texture
  20353. */
  20354. 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;
  20355. }
  20356. }
  20357. declare module BABYLON {
  20358. /**
  20359. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20360. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20361. */
  20362. export class PostProcessManager {
  20363. private _scene;
  20364. private _indexBuffer;
  20365. private _vertexBuffers;
  20366. /**
  20367. * Creates a new instance PostProcess
  20368. * @param scene The scene that the post process is associated with.
  20369. */
  20370. constructor(scene: Scene);
  20371. private _prepareBuffers;
  20372. private _buildIndexBuffer;
  20373. /**
  20374. * Rebuilds the vertex buffers of the manager.
  20375. * @hidden
  20376. */
  20377. _rebuild(): void;
  20378. /**
  20379. * Prepares a frame to be run through a post process.
  20380. * @param sourceTexture The input texture to the post procesess. (default: null)
  20381. * @param postProcesses An array of post processes to be run. (default: null)
  20382. * @returns True if the post processes were able to be run.
  20383. * @hidden
  20384. */
  20385. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20386. /**
  20387. * Manually render a set of post processes to a texture.
  20388. * @param postProcesses An array of post processes to be run.
  20389. * @param targetTexture The target texture to render to.
  20390. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20391. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20392. * @param lodLevel defines which lod of the texture to render to
  20393. */
  20394. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20395. /**
  20396. * Finalize the result of the output of the postprocesses.
  20397. * @param doNotPresent If true the result will not be displayed to the screen.
  20398. * @param targetTexture The target texture to render to.
  20399. * @param faceIndex The index of the face to bind the target texture to.
  20400. * @param postProcesses The array of post processes to render.
  20401. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20402. * @hidden
  20403. */
  20404. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20405. /**
  20406. * Disposes of the post process manager.
  20407. */
  20408. dispose(): void;
  20409. }
  20410. }
  20411. declare module BABYLON {
  20412. /**
  20413. * This Helps creating a texture that will be created from a camera in your scene.
  20414. * It is basically a dynamic texture that could be used to create special effects for instance.
  20415. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20416. */
  20417. export class RenderTargetTexture extends Texture {
  20418. isCube: boolean;
  20419. /**
  20420. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20421. */
  20422. static readonly REFRESHRATE_RENDER_ONCE: number;
  20423. /**
  20424. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20425. */
  20426. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20427. /**
  20428. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20429. * the central point of your effect and can save a lot of performances.
  20430. */
  20431. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20432. /**
  20433. * Use this predicate to dynamically define the list of mesh you want to render.
  20434. * If set, the renderList property will be overwritten.
  20435. */
  20436. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20437. private _renderList;
  20438. /**
  20439. * Use this list to define the list of mesh you want to render.
  20440. */
  20441. get renderList(): Nullable<Array<AbstractMesh>>;
  20442. set renderList(value: Nullable<Array<AbstractMesh>>);
  20443. /**
  20444. * Use this function to overload the renderList array at rendering time.
  20445. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20446. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20447. * the cube (if the RTT is a cube, else layerOrFace=0).
  20448. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20449. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20450. * hold dummy elements!
  20451. */
  20452. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20453. private _hookArray;
  20454. /**
  20455. * Define if particles should be rendered in your texture.
  20456. */
  20457. renderParticles: boolean;
  20458. /**
  20459. * Define if sprites should be rendered in your texture.
  20460. */
  20461. renderSprites: boolean;
  20462. /**
  20463. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20464. */
  20465. coordinatesMode: number;
  20466. /**
  20467. * Define the camera used to render the texture.
  20468. */
  20469. activeCamera: Nullable<Camera>;
  20470. /**
  20471. * Override the render function of the texture with your own one.
  20472. */
  20473. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20474. /**
  20475. * Define if camera post processes should be use while rendering the texture.
  20476. */
  20477. useCameraPostProcesses: boolean;
  20478. /**
  20479. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20480. */
  20481. ignoreCameraViewport: boolean;
  20482. private _postProcessManager;
  20483. private _postProcesses;
  20484. private _resizeObserver;
  20485. /**
  20486. * An event triggered when the texture is unbind.
  20487. */
  20488. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20489. /**
  20490. * An event triggered when the texture is unbind.
  20491. */
  20492. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20493. private _onAfterUnbindObserver;
  20494. /**
  20495. * Set a after unbind callback in the texture.
  20496. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20497. */
  20498. set onAfterUnbind(callback: () => void);
  20499. /**
  20500. * An event triggered before rendering the texture
  20501. */
  20502. onBeforeRenderObservable: Observable<number>;
  20503. private _onBeforeRenderObserver;
  20504. /**
  20505. * Set a before render callback in the texture.
  20506. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20507. */
  20508. set onBeforeRender(callback: (faceIndex: number) => void);
  20509. /**
  20510. * An event triggered after rendering the texture
  20511. */
  20512. onAfterRenderObservable: Observable<number>;
  20513. private _onAfterRenderObserver;
  20514. /**
  20515. * Set a after render callback in the texture.
  20516. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20517. */
  20518. set onAfterRender(callback: (faceIndex: number) => void);
  20519. /**
  20520. * An event triggered after the texture clear
  20521. */
  20522. onClearObservable: Observable<Engine>;
  20523. private _onClearObserver;
  20524. /**
  20525. * Set a clear callback in the texture.
  20526. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20527. */
  20528. set onClear(callback: (Engine: Engine) => void);
  20529. /**
  20530. * An event triggered when the texture is resized.
  20531. */
  20532. onResizeObservable: Observable<RenderTargetTexture>;
  20533. /**
  20534. * Define the clear color of the Render Target if it should be different from the scene.
  20535. */
  20536. clearColor: Color4;
  20537. protected _size: number | {
  20538. width: number;
  20539. height: number;
  20540. layers?: number;
  20541. };
  20542. protected _initialSizeParameter: number | {
  20543. width: number;
  20544. height: number;
  20545. } | {
  20546. ratio: number;
  20547. };
  20548. protected _sizeRatio: Nullable<number>;
  20549. /** @hidden */
  20550. _generateMipMaps: boolean;
  20551. protected _renderingManager: RenderingManager;
  20552. /** @hidden */
  20553. _waitingRenderList: string[];
  20554. protected _doNotChangeAspectRatio: boolean;
  20555. protected _currentRefreshId: number;
  20556. protected _refreshRate: number;
  20557. protected _textureMatrix: Matrix;
  20558. protected _samples: number;
  20559. protected _renderTargetOptions: RenderTargetCreationOptions;
  20560. /**
  20561. * Gets render target creation options that were used.
  20562. */
  20563. get renderTargetOptions(): RenderTargetCreationOptions;
  20564. protected _engine: Engine;
  20565. protected _onRatioRescale(): void;
  20566. /**
  20567. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20568. * It must define where the camera used to render the texture is set
  20569. */
  20570. boundingBoxPosition: Vector3;
  20571. private _boundingBoxSize;
  20572. /**
  20573. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20574. * When defined, the cubemap will switch to local mode
  20575. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20576. * @example https://www.babylonjs-playground.com/#RNASML
  20577. */
  20578. set boundingBoxSize(value: Vector3);
  20579. get boundingBoxSize(): Vector3;
  20580. /**
  20581. * In case the RTT has been created with a depth texture, get the associated
  20582. * depth texture.
  20583. * Otherwise, return null.
  20584. */
  20585. get depthStencilTexture(): Nullable<InternalTexture>;
  20586. /**
  20587. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20588. * or used a shadow, depth texture...
  20589. * @param name The friendly name of the texture
  20590. * @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)
  20591. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20592. * @param generateMipMaps True if mip maps need to be generated after render.
  20593. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20594. * @param type The type of the buffer in the RTT (int, half float, float...)
  20595. * @param isCube True if a cube texture needs to be created
  20596. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20597. * @param generateDepthBuffer True to generate a depth buffer
  20598. * @param generateStencilBuffer True to generate a stencil buffer
  20599. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20600. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20601. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20602. */
  20603. constructor(name: string, size: number | {
  20604. width: number;
  20605. height: number;
  20606. layers?: number;
  20607. } | {
  20608. ratio: number;
  20609. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20610. /**
  20611. * Creates a depth stencil texture.
  20612. * This is only available in WebGL 2 or with the depth texture extension available.
  20613. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20614. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20615. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20616. */
  20617. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20618. private _processSizeParameter;
  20619. /**
  20620. * Define the number of samples to use in case of MSAA.
  20621. * It defaults to one meaning no MSAA has been enabled.
  20622. */
  20623. get samples(): number;
  20624. set samples(value: number);
  20625. /**
  20626. * Resets the refresh counter of the texture and start bak from scratch.
  20627. * Could be useful to regenerate the texture if it is setup to render only once.
  20628. */
  20629. resetRefreshCounter(): void;
  20630. /**
  20631. * Define the refresh rate of the texture or the rendering frequency.
  20632. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20633. */
  20634. get refreshRate(): number;
  20635. set refreshRate(value: number);
  20636. /**
  20637. * Adds a post process to the render target rendering passes.
  20638. * @param postProcess define the post process to add
  20639. */
  20640. addPostProcess(postProcess: PostProcess): void;
  20641. /**
  20642. * Clear all the post processes attached to the render target
  20643. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20644. */
  20645. clearPostProcesses(dispose?: boolean): void;
  20646. /**
  20647. * Remove one of the post process from the list of attached post processes to the texture
  20648. * @param postProcess define the post process to remove from the list
  20649. */
  20650. removePostProcess(postProcess: PostProcess): void;
  20651. /** @hidden */
  20652. _shouldRender(): boolean;
  20653. /**
  20654. * Gets the actual render size of the texture.
  20655. * @returns the width of the render size
  20656. */
  20657. getRenderSize(): number;
  20658. /**
  20659. * Gets the actual render width of the texture.
  20660. * @returns the width of the render size
  20661. */
  20662. getRenderWidth(): number;
  20663. /**
  20664. * Gets the actual render height of the texture.
  20665. * @returns the height of the render size
  20666. */
  20667. getRenderHeight(): number;
  20668. /**
  20669. * Gets the actual number of layers of the texture.
  20670. * @returns the number of layers
  20671. */
  20672. getRenderLayers(): number;
  20673. /**
  20674. * Get if the texture can be rescaled or not.
  20675. */
  20676. get canRescale(): boolean;
  20677. /**
  20678. * Resize the texture using a ratio.
  20679. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20680. */
  20681. scale(ratio: number): void;
  20682. /**
  20683. * Get the texture reflection matrix used to rotate/transform the reflection.
  20684. * @returns the reflection matrix
  20685. */
  20686. getReflectionTextureMatrix(): Matrix;
  20687. /**
  20688. * Resize the texture to a new desired size.
  20689. * Be carrefull as it will recreate all the data in the new texture.
  20690. * @param size Define the new size. It can be:
  20691. * - a number for squared texture,
  20692. * - an object containing { width: number, height: number }
  20693. * - or an object containing a ratio { ratio: number }
  20694. */
  20695. resize(size: number | {
  20696. width: number;
  20697. height: number;
  20698. } | {
  20699. ratio: number;
  20700. }): void;
  20701. private _defaultRenderListPrepared;
  20702. /**
  20703. * Renders all the objects from the render list into the texture.
  20704. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20705. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20706. */
  20707. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20708. private _bestReflectionRenderTargetDimension;
  20709. private _prepareRenderingManager;
  20710. /**
  20711. * @hidden
  20712. * @param faceIndex face index to bind to if this is a cubetexture
  20713. * @param layer defines the index of the texture to bind in the array
  20714. */
  20715. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20716. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20717. private renderToTarget;
  20718. /**
  20719. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20720. * This allowed control for front to back rendering or reversly depending of the special needs.
  20721. *
  20722. * @param renderingGroupId The rendering group id corresponding to its index
  20723. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20724. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20725. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20726. */
  20727. 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;
  20728. /**
  20729. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20730. *
  20731. * @param renderingGroupId The rendering group id corresponding to its index
  20732. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20733. */
  20734. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20735. /**
  20736. * Clones the texture.
  20737. * @returns the cloned texture
  20738. */
  20739. clone(): RenderTargetTexture;
  20740. /**
  20741. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20742. * @returns The JSON representation of the texture
  20743. */
  20744. serialize(): any;
  20745. /**
  20746. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20747. */
  20748. disposeFramebufferObjects(): void;
  20749. /**
  20750. * Dispose the texture and release its associated resources.
  20751. */
  20752. dispose(): void;
  20753. /** @hidden */
  20754. _rebuild(): void;
  20755. /**
  20756. * Clear the info related to rendering groups preventing retention point in material dispose.
  20757. */
  20758. freeRenderingGroups(): void;
  20759. /**
  20760. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20761. * @returns the view count
  20762. */
  20763. getViewCount(): number;
  20764. }
  20765. }
  20766. declare module BABYLON {
  20767. /**
  20768. * Options for compiling materials.
  20769. */
  20770. export interface IMaterialCompilationOptions {
  20771. /**
  20772. * Defines whether clip planes are enabled.
  20773. */
  20774. clipPlane: boolean;
  20775. /**
  20776. * Defines whether instances are enabled.
  20777. */
  20778. useInstances: boolean;
  20779. }
  20780. /**
  20781. * Base class for the main features of a material in Babylon.js
  20782. */
  20783. export class Material implements IAnimatable {
  20784. /**
  20785. * Returns the triangle fill mode
  20786. */
  20787. static readonly TriangleFillMode: number;
  20788. /**
  20789. * Returns the wireframe mode
  20790. */
  20791. static readonly WireFrameFillMode: number;
  20792. /**
  20793. * Returns the point fill mode
  20794. */
  20795. static readonly PointFillMode: number;
  20796. /**
  20797. * Returns the point list draw mode
  20798. */
  20799. static readonly PointListDrawMode: number;
  20800. /**
  20801. * Returns the line list draw mode
  20802. */
  20803. static readonly LineListDrawMode: number;
  20804. /**
  20805. * Returns the line loop draw mode
  20806. */
  20807. static readonly LineLoopDrawMode: number;
  20808. /**
  20809. * Returns the line strip draw mode
  20810. */
  20811. static readonly LineStripDrawMode: number;
  20812. /**
  20813. * Returns the triangle strip draw mode
  20814. */
  20815. static readonly TriangleStripDrawMode: number;
  20816. /**
  20817. * Returns the triangle fan draw mode
  20818. */
  20819. static readonly TriangleFanDrawMode: number;
  20820. /**
  20821. * Stores the clock-wise side orientation
  20822. */
  20823. static readonly ClockWiseSideOrientation: number;
  20824. /**
  20825. * Stores the counter clock-wise side orientation
  20826. */
  20827. static readonly CounterClockWiseSideOrientation: number;
  20828. /**
  20829. * The dirty texture flag value
  20830. */
  20831. static readonly TextureDirtyFlag: number;
  20832. /**
  20833. * The dirty light flag value
  20834. */
  20835. static readonly LightDirtyFlag: number;
  20836. /**
  20837. * The dirty fresnel flag value
  20838. */
  20839. static readonly FresnelDirtyFlag: number;
  20840. /**
  20841. * The dirty attribute flag value
  20842. */
  20843. static readonly AttributesDirtyFlag: number;
  20844. /**
  20845. * The dirty misc flag value
  20846. */
  20847. static readonly MiscDirtyFlag: number;
  20848. /**
  20849. * The all dirty flag value
  20850. */
  20851. static readonly AllDirtyFlag: number;
  20852. /**
  20853. * The ID of the material
  20854. */
  20855. id: string;
  20856. /**
  20857. * Gets or sets the unique id of the material
  20858. */
  20859. uniqueId: number;
  20860. /**
  20861. * The name of the material
  20862. */
  20863. name: string;
  20864. /**
  20865. * Gets or sets user defined metadata
  20866. */
  20867. metadata: any;
  20868. /**
  20869. * For internal use only. Please do not use.
  20870. */
  20871. reservedDataStore: any;
  20872. /**
  20873. * Specifies if the ready state should be checked on each call
  20874. */
  20875. checkReadyOnEveryCall: boolean;
  20876. /**
  20877. * Specifies if the ready state should be checked once
  20878. */
  20879. checkReadyOnlyOnce: boolean;
  20880. /**
  20881. * The state of the material
  20882. */
  20883. state: string;
  20884. /**
  20885. * The alpha value of the material
  20886. */
  20887. protected _alpha: number;
  20888. /**
  20889. * List of inspectable custom properties (used by the Inspector)
  20890. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20891. */
  20892. inspectableCustomProperties: IInspectable[];
  20893. /**
  20894. * Sets the alpha value of the material
  20895. */
  20896. set alpha(value: number);
  20897. /**
  20898. * Gets the alpha value of the material
  20899. */
  20900. get alpha(): number;
  20901. /**
  20902. * Specifies if back face culling is enabled
  20903. */
  20904. protected _backFaceCulling: boolean;
  20905. /**
  20906. * Sets the back-face culling state
  20907. */
  20908. set backFaceCulling(value: boolean);
  20909. /**
  20910. * Gets the back-face culling state
  20911. */
  20912. get backFaceCulling(): boolean;
  20913. /**
  20914. * Stores the value for side orientation
  20915. */
  20916. sideOrientation: number;
  20917. /**
  20918. * Callback triggered when the material is compiled
  20919. */
  20920. onCompiled: Nullable<(effect: Effect) => void>;
  20921. /**
  20922. * Callback triggered when an error occurs
  20923. */
  20924. onError: Nullable<(effect: Effect, errors: string) => void>;
  20925. /**
  20926. * Callback triggered to get the render target textures
  20927. */
  20928. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20929. /**
  20930. * Gets a boolean indicating that current material needs to register RTT
  20931. */
  20932. get hasRenderTargetTextures(): boolean;
  20933. /**
  20934. * Specifies if the material should be serialized
  20935. */
  20936. doNotSerialize: boolean;
  20937. /**
  20938. * @hidden
  20939. */
  20940. _storeEffectOnSubMeshes: boolean;
  20941. /**
  20942. * Stores the animations for the material
  20943. */
  20944. animations: Nullable<Array<Animation>>;
  20945. /**
  20946. * An event triggered when the material is disposed
  20947. */
  20948. onDisposeObservable: Observable<Material>;
  20949. /**
  20950. * An observer which watches for dispose events
  20951. */
  20952. private _onDisposeObserver;
  20953. private _onUnBindObservable;
  20954. /**
  20955. * Called during a dispose event
  20956. */
  20957. set onDispose(callback: () => void);
  20958. private _onBindObservable;
  20959. /**
  20960. * An event triggered when the material is bound
  20961. */
  20962. get onBindObservable(): Observable<AbstractMesh>;
  20963. /**
  20964. * An observer which watches for bind events
  20965. */
  20966. private _onBindObserver;
  20967. /**
  20968. * Called during a bind event
  20969. */
  20970. set onBind(callback: (Mesh: AbstractMesh) => void);
  20971. /**
  20972. * An event triggered when the material is unbound
  20973. */
  20974. get onUnBindObservable(): Observable<Material>;
  20975. /**
  20976. * Stores the value of the alpha mode
  20977. */
  20978. private _alphaMode;
  20979. /**
  20980. * Sets the value of the alpha mode.
  20981. *
  20982. * | Value | Type | Description |
  20983. * | --- | --- | --- |
  20984. * | 0 | ALPHA_DISABLE | |
  20985. * | 1 | ALPHA_ADD | |
  20986. * | 2 | ALPHA_COMBINE | |
  20987. * | 3 | ALPHA_SUBTRACT | |
  20988. * | 4 | ALPHA_MULTIPLY | |
  20989. * | 5 | ALPHA_MAXIMIZED | |
  20990. * | 6 | ALPHA_ONEONE | |
  20991. * | 7 | ALPHA_PREMULTIPLIED | |
  20992. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20993. * | 9 | ALPHA_INTERPOLATE | |
  20994. * | 10 | ALPHA_SCREENMODE | |
  20995. *
  20996. */
  20997. set alphaMode(value: number);
  20998. /**
  20999. * Gets the value of the alpha mode
  21000. */
  21001. get alphaMode(): number;
  21002. /**
  21003. * Stores the state of the need depth pre-pass value
  21004. */
  21005. private _needDepthPrePass;
  21006. /**
  21007. * Sets the need depth pre-pass value
  21008. */
  21009. set needDepthPrePass(value: boolean);
  21010. /**
  21011. * Gets the depth pre-pass value
  21012. */
  21013. get needDepthPrePass(): boolean;
  21014. /**
  21015. * Specifies if depth writing should be disabled
  21016. */
  21017. disableDepthWrite: boolean;
  21018. /**
  21019. * Specifies if depth writing should be forced
  21020. */
  21021. forceDepthWrite: boolean;
  21022. /**
  21023. * Specifies the depth function that should be used. 0 means the default engine function
  21024. */
  21025. depthFunction: number;
  21026. /**
  21027. * Specifies if there should be a separate pass for culling
  21028. */
  21029. separateCullingPass: boolean;
  21030. /**
  21031. * Stores the state specifing if fog should be enabled
  21032. */
  21033. private _fogEnabled;
  21034. /**
  21035. * Sets the state for enabling fog
  21036. */
  21037. set fogEnabled(value: boolean);
  21038. /**
  21039. * Gets the value of the fog enabled state
  21040. */
  21041. get fogEnabled(): boolean;
  21042. /**
  21043. * Stores the size of points
  21044. */
  21045. pointSize: number;
  21046. /**
  21047. * Stores the z offset value
  21048. */
  21049. zOffset: number;
  21050. /**
  21051. * Gets a value specifying if wireframe mode is enabled
  21052. */
  21053. get wireframe(): boolean;
  21054. /**
  21055. * Sets the state of wireframe mode
  21056. */
  21057. set wireframe(value: boolean);
  21058. /**
  21059. * Gets the value specifying if point clouds are enabled
  21060. */
  21061. get pointsCloud(): boolean;
  21062. /**
  21063. * Sets the state of point cloud mode
  21064. */
  21065. set pointsCloud(value: boolean);
  21066. /**
  21067. * Gets the material fill mode
  21068. */
  21069. get fillMode(): number;
  21070. /**
  21071. * Sets the material fill mode
  21072. */
  21073. set fillMode(value: number);
  21074. /**
  21075. * @hidden
  21076. * Stores the effects for the material
  21077. */
  21078. _effect: Nullable<Effect>;
  21079. /**
  21080. * Specifies if uniform buffers should be used
  21081. */
  21082. private _useUBO;
  21083. /**
  21084. * Stores a reference to the scene
  21085. */
  21086. private _scene;
  21087. /**
  21088. * Stores the fill mode state
  21089. */
  21090. private _fillMode;
  21091. /**
  21092. * Specifies if the depth write state should be cached
  21093. */
  21094. private _cachedDepthWriteState;
  21095. /**
  21096. * Specifies if the depth function state should be cached
  21097. */
  21098. private _cachedDepthFunctionState;
  21099. /**
  21100. * Stores the uniform buffer
  21101. */
  21102. protected _uniformBuffer: UniformBuffer;
  21103. /** @hidden */
  21104. _indexInSceneMaterialArray: number;
  21105. /** @hidden */
  21106. meshMap: Nullable<{
  21107. [id: string]: AbstractMesh | undefined;
  21108. }>;
  21109. /**
  21110. * Creates a material instance
  21111. * @param name defines the name of the material
  21112. * @param scene defines the scene to reference
  21113. * @param doNotAdd specifies if the material should be added to the scene
  21114. */
  21115. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21116. /**
  21117. * Returns a string representation of the current material
  21118. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21119. * @returns a string with material information
  21120. */
  21121. toString(fullDetails?: boolean): string;
  21122. /**
  21123. * Gets the class name of the material
  21124. * @returns a string with the class name of the material
  21125. */
  21126. getClassName(): string;
  21127. /**
  21128. * Specifies if updates for the material been locked
  21129. */
  21130. get isFrozen(): boolean;
  21131. /**
  21132. * Locks updates for the material
  21133. */
  21134. freeze(): void;
  21135. /**
  21136. * Unlocks updates for the material
  21137. */
  21138. unfreeze(): void;
  21139. /**
  21140. * Specifies if the material is ready to be used
  21141. * @param mesh defines the mesh to check
  21142. * @param useInstances specifies if instances should be used
  21143. * @returns a boolean indicating if the material is ready to be used
  21144. */
  21145. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21146. /**
  21147. * Specifies that the submesh is ready to be used
  21148. * @param mesh defines the mesh to check
  21149. * @param subMesh defines which submesh to check
  21150. * @param useInstances specifies that instances should be used
  21151. * @returns a boolean indicating that the submesh is ready or not
  21152. */
  21153. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21154. /**
  21155. * Returns the material effect
  21156. * @returns the effect associated with the material
  21157. */
  21158. getEffect(): Nullable<Effect>;
  21159. /**
  21160. * Returns the current scene
  21161. * @returns a Scene
  21162. */
  21163. getScene(): Scene;
  21164. /**
  21165. * Specifies if the material will require alpha blending
  21166. * @returns a boolean specifying if alpha blending is needed
  21167. */
  21168. needAlphaBlending(): boolean;
  21169. /**
  21170. * Specifies if the mesh will require alpha blending
  21171. * @param mesh defines the mesh to check
  21172. * @returns a boolean specifying if alpha blending is needed for the mesh
  21173. */
  21174. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21175. /**
  21176. * Specifies if this material should be rendered in alpha test mode
  21177. * @returns a boolean specifying if an alpha test is needed.
  21178. */
  21179. needAlphaTesting(): boolean;
  21180. /**
  21181. * Gets the texture used for the alpha test
  21182. * @returns the texture to use for alpha testing
  21183. */
  21184. getAlphaTestTexture(): Nullable<BaseTexture>;
  21185. /**
  21186. * Marks the material to indicate that it needs to be re-calculated
  21187. */
  21188. markDirty(): void;
  21189. /** @hidden */
  21190. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21191. /**
  21192. * Binds the material to the mesh
  21193. * @param world defines the world transformation matrix
  21194. * @param mesh defines the mesh to bind the material to
  21195. */
  21196. bind(world: Matrix, mesh?: Mesh): void;
  21197. /**
  21198. * Binds the submesh to the material
  21199. * @param world defines the world transformation matrix
  21200. * @param mesh defines the mesh containing the submesh
  21201. * @param subMesh defines the submesh to bind the material to
  21202. */
  21203. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21204. /**
  21205. * Binds the world matrix to the material
  21206. * @param world defines the world transformation matrix
  21207. */
  21208. bindOnlyWorldMatrix(world: Matrix): void;
  21209. /**
  21210. * Binds the scene's uniform buffer to the effect.
  21211. * @param effect defines the effect to bind to the scene uniform buffer
  21212. * @param sceneUbo defines the uniform buffer storing scene data
  21213. */
  21214. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21215. /**
  21216. * Binds the view matrix to the effect
  21217. * @param effect defines the effect to bind the view matrix to
  21218. */
  21219. bindView(effect: Effect): void;
  21220. /**
  21221. * Binds the view projection matrix to the effect
  21222. * @param effect defines the effect to bind the view projection matrix to
  21223. */
  21224. bindViewProjection(effect: Effect): void;
  21225. /**
  21226. * Specifies if material alpha testing should be turned on for the mesh
  21227. * @param mesh defines the mesh to check
  21228. */
  21229. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21230. /**
  21231. * Processes to execute after binding the material to a mesh
  21232. * @param mesh defines the rendered mesh
  21233. */
  21234. protected _afterBind(mesh?: Mesh): void;
  21235. /**
  21236. * Unbinds the material from the mesh
  21237. */
  21238. unbind(): void;
  21239. /**
  21240. * Gets the active textures from the material
  21241. * @returns an array of textures
  21242. */
  21243. getActiveTextures(): BaseTexture[];
  21244. /**
  21245. * Specifies if the material uses a texture
  21246. * @param texture defines the texture to check against the material
  21247. * @returns a boolean specifying if the material uses the texture
  21248. */
  21249. hasTexture(texture: BaseTexture): boolean;
  21250. /**
  21251. * Makes a duplicate of the material, and gives it a new name
  21252. * @param name defines the new name for the duplicated material
  21253. * @returns the cloned material
  21254. */
  21255. clone(name: string): Nullable<Material>;
  21256. /**
  21257. * Gets the meshes bound to the material
  21258. * @returns an array of meshes bound to the material
  21259. */
  21260. getBindedMeshes(): AbstractMesh[];
  21261. /**
  21262. * Force shader compilation
  21263. * @param mesh defines the mesh associated with this material
  21264. * @param onCompiled defines a function to execute once the material is compiled
  21265. * @param options defines the options to configure the compilation
  21266. * @param onError defines a function to execute if the material fails compiling
  21267. */
  21268. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21269. /**
  21270. * Force shader compilation
  21271. * @param mesh defines the mesh that will use this material
  21272. * @param options defines additional options for compiling the shaders
  21273. * @returns a promise that resolves when the compilation completes
  21274. */
  21275. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21276. private static readonly _AllDirtyCallBack;
  21277. private static readonly _ImageProcessingDirtyCallBack;
  21278. private static readonly _TextureDirtyCallBack;
  21279. private static readonly _FresnelDirtyCallBack;
  21280. private static readonly _MiscDirtyCallBack;
  21281. private static readonly _LightsDirtyCallBack;
  21282. private static readonly _AttributeDirtyCallBack;
  21283. private static _FresnelAndMiscDirtyCallBack;
  21284. private static _TextureAndMiscDirtyCallBack;
  21285. private static readonly _DirtyCallbackArray;
  21286. private static readonly _RunDirtyCallBacks;
  21287. /**
  21288. * Marks a define in the material to indicate that it needs to be re-computed
  21289. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21290. */
  21291. markAsDirty(flag: number): void;
  21292. /**
  21293. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21294. * @param func defines a function which checks material defines against the submeshes
  21295. */
  21296. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21297. /**
  21298. * Indicates that we need to re-calculated for all submeshes
  21299. */
  21300. protected _markAllSubMeshesAsAllDirty(): void;
  21301. /**
  21302. * Indicates that image processing needs to be re-calculated for all submeshes
  21303. */
  21304. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21305. /**
  21306. * Indicates that textures need to be re-calculated for all submeshes
  21307. */
  21308. protected _markAllSubMeshesAsTexturesDirty(): void;
  21309. /**
  21310. * Indicates that fresnel needs to be re-calculated for all submeshes
  21311. */
  21312. protected _markAllSubMeshesAsFresnelDirty(): void;
  21313. /**
  21314. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21315. */
  21316. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21317. /**
  21318. * Indicates that lights need to be re-calculated for all submeshes
  21319. */
  21320. protected _markAllSubMeshesAsLightsDirty(): void;
  21321. /**
  21322. * Indicates that attributes need to be re-calculated for all submeshes
  21323. */
  21324. protected _markAllSubMeshesAsAttributesDirty(): void;
  21325. /**
  21326. * Indicates that misc needs to be re-calculated for all submeshes
  21327. */
  21328. protected _markAllSubMeshesAsMiscDirty(): void;
  21329. /**
  21330. * Indicates that textures and misc need to be re-calculated for all submeshes
  21331. */
  21332. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21333. /**
  21334. * Disposes the material
  21335. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21336. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21337. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21338. */
  21339. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21340. /** @hidden */
  21341. private releaseVertexArrayObject;
  21342. /**
  21343. * Serializes this material
  21344. * @returns the serialized material object
  21345. */
  21346. serialize(): any;
  21347. /**
  21348. * Creates a material from parsed material data
  21349. * @param parsedMaterial defines parsed material data
  21350. * @param scene defines the hosting scene
  21351. * @param rootUrl defines the root URL to use to load textures
  21352. * @returns a new material
  21353. */
  21354. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21355. }
  21356. }
  21357. declare module BABYLON {
  21358. /**
  21359. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21360. * separate meshes. This can be use to improve performances.
  21361. * @see http://doc.babylonjs.com/how_to/multi_materials
  21362. */
  21363. export class MultiMaterial extends Material {
  21364. private _subMaterials;
  21365. /**
  21366. * Gets or Sets the list of Materials used within the multi material.
  21367. * They need to be ordered according to the submeshes order in the associated mesh
  21368. */
  21369. get subMaterials(): Nullable<Material>[];
  21370. set subMaterials(value: Nullable<Material>[]);
  21371. /**
  21372. * Function used to align with Node.getChildren()
  21373. * @returns the list of Materials used within the multi material
  21374. */
  21375. getChildren(): Nullable<Material>[];
  21376. /**
  21377. * Instantiates a new Multi Material
  21378. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21379. * separate meshes. This can be use to improve performances.
  21380. * @see http://doc.babylonjs.com/how_to/multi_materials
  21381. * @param name Define the name in the scene
  21382. * @param scene Define the scene the material belongs to
  21383. */
  21384. constructor(name: string, scene: Scene);
  21385. private _hookArray;
  21386. /**
  21387. * Get one of the submaterial by its index in the submaterials array
  21388. * @param index The index to look the sub material at
  21389. * @returns The Material if the index has been defined
  21390. */
  21391. getSubMaterial(index: number): Nullable<Material>;
  21392. /**
  21393. * Get the list of active textures for the whole sub materials list.
  21394. * @returns All the textures that will be used during the rendering
  21395. */
  21396. getActiveTextures(): BaseTexture[];
  21397. /**
  21398. * Gets the current class name of the material e.g. "MultiMaterial"
  21399. * Mainly use in serialization.
  21400. * @returns the class name
  21401. */
  21402. getClassName(): string;
  21403. /**
  21404. * Checks if the material is ready to render the requested sub mesh
  21405. * @param mesh Define the mesh the submesh belongs to
  21406. * @param subMesh Define the sub mesh to look readyness for
  21407. * @param useInstances Define whether or not the material is used with instances
  21408. * @returns true if ready, otherwise false
  21409. */
  21410. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21411. /**
  21412. * Clones the current material and its related sub materials
  21413. * @param name Define the name of the newly cloned material
  21414. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21415. * @returns the cloned material
  21416. */
  21417. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21418. /**
  21419. * Serializes the materials into a JSON representation.
  21420. * @returns the JSON representation
  21421. */
  21422. serialize(): any;
  21423. /**
  21424. * Dispose the material and release its associated resources
  21425. * @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)
  21426. * @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)
  21427. * @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)
  21428. */
  21429. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21430. /**
  21431. * Creates a MultiMaterial from parsed MultiMaterial data.
  21432. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21433. * @param scene defines the hosting scene
  21434. * @returns a new MultiMaterial
  21435. */
  21436. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21437. }
  21438. }
  21439. declare module BABYLON {
  21440. /**
  21441. * Base class for submeshes
  21442. */
  21443. export class BaseSubMesh {
  21444. /** @hidden */
  21445. _materialDefines: Nullable<MaterialDefines>;
  21446. /** @hidden */
  21447. _materialEffect: Nullable<Effect>;
  21448. /**
  21449. * Gets material defines used by the effect associated to the sub mesh
  21450. */
  21451. get materialDefines(): Nullable<MaterialDefines>;
  21452. /**
  21453. * Sets material defines used by the effect associated to the sub mesh
  21454. */
  21455. set materialDefines(defines: Nullable<MaterialDefines>);
  21456. /**
  21457. * Gets associated effect
  21458. */
  21459. get effect(): Nullable<Effect>;
  21460. /**
  21461. * Sets associated effect (effect used to render this submesh)
  21462. * @param effect defines the effect to associate with
  21463. * @param defines defines the set of defines used to compile this effect
  21464. */
  21465. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21466. }
  21467. /**
  21468. * Defines a subdivision inside a mesh
  21469. */
  21470. export class SubMesh extends BaseSubMesh implements ICullable {
  21471. /** the material index to use */
  21472. materialIndex: number;
  21473. /** vertex index start */
  21474. verticesStart: number;
  21475. /** vertices count */
  21476. verticesCount: number;
  21477. /** index start */
  21478. indexStart: number;
  21479. /** indices count */
  21480. indexCount: number;
  21481. /** @hidden */
  21482. _linesIndexCount: number;
  21483. private _mesh;
  21484. private _renderingMesh;
  21485. private _boundingInfo;
  21486. private _linesIndexBuffer;
  21487. /** @hidden */
  21488. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21489. /** @hidden */
  21490. _trianglePlanes: Plane[];
  21491. /** @hidden */
  21492. _lastColliderTransformMatrix: Nullable<Matrix>;
  21493. /** @hidden */
  21494. _renderId: number;
  21495. /** @hidden */
  21496. _alphaIndex: number;
  21497. /** @hidden */
  21498. _distanceToCamera: number;
  21499. /** @hidden */
  21500. _id: number;
  21501. private _currentMaterial;
  21502. /**
  21503. * Add a new submesh to a mesh
  21504. * @param materialIndex defines the material index to use
  21505. * @param verticesStart defines vertex index start
  21506. * @param verticesCount defines vertices count
  21507. * @param indexStart defines index start
  21508. * @param indexCount defines indices count
  21509. * @param mesh defines the parent mesh
  21510. * @param renderingMesh defines an optional rendering mesh
  21511. * @param createBoundingBox defines if bounding box should be created for this submesh
  21512. * @returns the new submesh
  21513. */
  21514. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21515. /**
  21516. * Creates a new submesh
  21517. * @param materialIndex defines the material index to use
  21518. * @param verticesStart defines vertex index start
  21519. * @param verticesCount defines vertices count
  21520. * @param indexStart defines index start
  21521. * @param indexCount defines indices count
  21522. * @param mesh defines the parent mesh
  21523. * @param renderingMesh defines an optional rendering mesh
  21524. * @param createBoundingBox defines if bounding box should be created for this submesh
  21525. */
  21526. constructor(
  21527. /** the material index to use */
  21528. materialIndex: number,
  21529. /** vertex index start */
  21530. verticesStart: number,
  21531. /** vertices count */
  21532. verticesCount: number,
  21533. /** index start */
  21534. indexStart: number,
  21535. /** indices count */
  21536. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21537. /**
  21538. * Returns true if this submesh covers the entire parent mesh
  21539. * @ignorenaming
  21540. */
  21541. get IsGlobal(): boolean;
  21542. /**
  21543. * Returns the submesh BoudingInfo object
  21544. * @returns current bounding info (or mesh's one if the submesh is global)
  21545. */
  21546. getBoundingInfo(): BoundingInfo;
  21547. /**
  21548. * Sets the submesh BoundingInfo
  21549. * @param boundingInfo defines the new bounding info to use
  21550. * @returns the SubMesh
  21551. */
  21552. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21553. /**
  21554. * Returns the mesh of the current submesh
  21555. * @return the parent mesh
  21556. */
  21557. getMesh(): AbstractMesh;
  21558. /**
  21559. * Returns the rendering mesh of the submesh
  21560. * @returns the rendering mesh (could be different from parent mesh)
  21561. */
  21562. getRenderingMesh(): Mesh;
  21563. /**
  21564. * Returns the submesh material
  21565. * @returns null or the current material
  21566. */
  21567. getMaterial(): Nullable<Material>;
  21568. /**
  21569. * Sets a new updated BoundingInfo object to the submesh
  21570. * @param data defines an optional position array to use to determine the bounding info
  21571. * @returns the SubMesh
  21572. */
  21573. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21574. /** @hidden */
  21575. _checkCollision(collider: Collider): boolean;
  21576. /**
  21577. * Updates the submesh BoundingInfo
  21578. * @param world defines the world matrix to use to update the bounding info
  21579. * @returns the submesh
  21580. */
  21581. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21582. /**
  21583. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21584. * @param frustumPlanes defines the frustum planes
  21585. * @returns true if the submesh is intersecting with the frustum
  21586. */
  21587. isInFrustum(frustumPlanes: Plane[]): boolean;
  21588. /**
  21589. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21590. * @param frustumPlanes defines the frustum planes
  21591. * @returns true if the submesh is inside the frustum
  21592. */
  21593. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21594. /**
  21595. * Renders the submesh
  21596. * @param enableAlphaMode defines if alpha needs to be used
  21597. * @returns the submesh
  21598. */
  21599. render(enableAlphaMode: boolean): SubMesh;
  21600. /**
  21601. * @hidden
  21602. */
  21603. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21604. /**
  21605. * Checks if the submesh intersects with a ray
  21606. * @param ray defines the ray to test
  21607. * @returns true is the passed ray intersects the submesh bounding box
  21608. */
  21609. canIntersects(ray: Ray): boolean;
  21610. /**
  21611. * Intersects current submesh with a ray
  21612. * @param ray defines the ray to test
  21613. * @param positions defines mesh's positions array
  21614. * @param indices defines mesh's indices array
  21615. * @param fastCheck defines if only bounding info should be used
  21616. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21617. * @returns intersection info or null if no intersection
  21618. */
  21619. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21620. /** @hidden */
  21621. private _intersectLines;
  21622. /** @hidden */
  21623. private _intersectUnIndexedLines;
  21624. /** @hidden */
  21625. private _intersectTriangles;
  21626. /** @hidden */
  21627. private _intersectUnIndexedTriangles;
  21628. /** @hidden */
  21629. _rebuild(): void;
  21630. /**
  21631. * Creates a new submesh from the passed mesh
  21632. * @param newMesh defines the new hosting mesh
  21633. * @param newRenderingMesh defines an optional rendering mesh
  21634. * @returns the new submesh
  21635. */
  21636. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21637. /**
  21638. * Release associated resources
  21639. */
  21640. dispose(): void;
  21641. /**
  21642. * Gets the class name
  21643. * @returns the string "SubMesh".
  21644. */
  21645. getClassName(): string;
  21646. /**
  21647. * Creates a new submesh from indices data
  21648. * @param materialIndex the index of the main mesh material
  21649. * @param startIndex the index where to start the copy in the mesh indices array
  21650. * @param indexCount the number of indices to copy then from the startIndex
  21651. * @param mesh the main mesh to create the submesh from
  21652. * @param renderingMesh the optional rendering mesh
  21653. * @returns a new submesh
  21654. */
  21655. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21656. }
  21657. }
  21658. declare module BABYLON {
  21659. /**
  21660. * Class used to represent data loading progression
  21661. */
  21662. export class SceneLoaderFlags {
  21663. private static _ForceFullSceneLoadingForIncremental;
  21664. private static _ShowLoadingScreen;
  21665. private static _CleanBoneMatrixWeights;
  21666. private static _loggingLevel;
  21667. /**
  21668. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21669. */
  21670. static get ForceFullSceneLoadingForIncremental(): boolean;
  21671. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21672. /**
  21673. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21674. */
  21675. static get ShowLoadingScreen(): boolean;
  21676. static set ShowLoadingScreen(value: boolean);
  21677. /**
  21678. * Defines the current logging level (while loading the scene)
  21679. * @ignorenaming
  21680. */
  21681. static get loggingLevel(): number;
  21682. static set loggingLevel(value: number);
  21683. /**
  21684. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21685. */
  21686. static get CleanBoneMatrixWeights(): boolean;
  21687. static set CleanBoneMatrixWeights(value: boolean);
  21688. }
  21689. }
  21690. declare module BABYLON {
  21691. /**
  21692. * Class used to store geometry data (vertex buffers + index buffer)
  21693. */
  21694. export class Geometry implements IGetSetVerticesData {
  21695. /**
  21696. * Gets or sets the ID of the geometry
  21697. */
  21698. id: string;
  21699. /**
  21700. * Gets or sets the unique ID of the geometry
  21701. */
  21702. uniqueId: number;
  21703. /**
  21704. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21705. */
  21706. delayLoadState: number;
  21707. /**
  21708. * Gets the file containing the data to load when running in delay load state
  21709. */
  21710. delayLoadingFile: Nullable<string>;
  21711. /**
  21712. * Callback called when the geometry is updated
  21713. */
  21714. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21715. private _scene;
  21716. private _engine;
  21717. private _meshes;
  21718. private _totalVertices;
  21719. /** @hidden */
  21720. _indices: IndicesArray;
  21721. /** @hidden */
  21722. _vertexBuffers: {
  21723. [key: string]: VertexBuffer;
  21724. };
  21725. private _isDisposed;
  21726. private _extend;
  21727. private _boundingBias;
  21728. /** @hidden */
  21729. _delayInfo: Array<string>;
  21730. private _indexBuffer;
  21731. private _indexBufferIsUpdatable;
  21732. /** @hidden */
  21733. _boundingInfo: Nullable<BoundingInfo>;
  21734. /** @hidden */
  21735. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21736. /** @hidden */
  21737. _softwareSkinningFrameId: number;
  21738. private _vertexArrayObjects;
  21739. private _updatable;
  21740. /** @hidden */
  21741. _positions: Nullable<Vector3[]>;
  21742. /**
  21743. * 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
  21744. */
  21745. get boundingBias(): Vector2;
  21746. /**
  21747. * 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
  21748. */
  21749. set boundingBias(value: Vector2);
  21750. /**
  21751. * Static function used to attach a new empty geometry to a mesh
  21752. * @param mesh defines the mesh to attach the geometry to
  21753. * @returns the new Geometry
  21754. */
  21755. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21756. /**
  21757. * Creates a new geometry
  21758. * @param id defines the unique ID
  21759. * @param scene defines the hosting scene
  21760. * @param vertexData defines the VertexData used to get geometry data
  21761. * @param updatable defines if geometry must be updatable (false by default)
  21762. * @param mesh defines the mesh that will be associated with the geometry
  21763. */
  21764. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21765. /**
  21766. * Gets the current extend of the geometry
  21767. */
  21768. get extend(): {
  21769. minimum: Vector3;
  21770. maximum: Vector3;
  21771. };
  21772. /**
  21773. * Gets the hosting scene
  21774. * @returns the hosting Scene
  21775. */
  21776. getScene(): Scene;
  21777. /**
  21778. * Gets the hosting engine
  21779. * @returns the hosting Engine
  21780. */
  21781. getEngine(): Engine;
  21782. /**
  21783. * Defines if the geometry is ready to use
  21784. * @returns true if the geometry is ready to be used
  21785. */
  21786. isReady(): boolean;
  21787. /**
  21788. * Gets a value indicating that the geometry should not be serialized
  21789. */
  21790. get doNotSerialize(): boolean;
  21791. /** @hidden */
  21792. _rebuild(): void;
  21793. /**
  21794. * Affects all geometry data in one call
  21795. * @param vertexData defines the geometry data
  21796. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21797. */
  21798. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21799. /**
  21800. * Set specific vertex data
  21801. * @param kind defines the data kind (Position, normal, etc...)
  21802. * @param data defines the vertex data to use
  21803. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21804. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21805. */
  21806. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21807. /**
  21808. * Removes a specific vertex data
  21809. * @param kind defines the data kind (Position, normal, etc...)
  21810. */
  21811. removeVerticesData(kind: string): void;
  21812. /**
  21813. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21814. * @param buffer defines the vertex buffer to use
  21815. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21816. */
  21817. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21818. /**
  21819. * Update a specific vertex buffer
  21820. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21821. * It will do nothing if the buffer is not updatable
  21822. * @param kind defines the data kind (Position, normal, etc...)
  21823. * @param data defines the data to use
  21824. * @param offset defines the offset in the target buffer where to store the data
  21825. * @param useBytes set to true if the offset is in bytes
  21826. */
  21827. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21828. /**
  21829. * Update a specific vertex buffer
  21830. * This function will create a new buffer if the current one is not updatable
  21831. * @param kind defines the data kind (Position, normal, etc...)
  21832. * @param data defines the data to use
  21833. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21834. */
  21835. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21836. private _updateBoundingInfo;
  21837. /** @hidden */
  21838. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21839. /**
  21840. * Gets total number of vertices
  21841. * @returns the total number of vertices
  21842. */
  21843. getTotalVertices(): number;
  21844. /**
  21845. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21846. * @param kind defines the data kind (Position, normal, etc...)
  21847. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21848. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21849. * @returns a float array containing vertex data
  21850. */
  21851. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21852. /**
  21853. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21854. * @param kind defines the data kind (Position, normal, etc...)
  21855. * @returns true if the vertex buffer with the specified kind is updatable
  21856. */
  21857. isVertexBufferUpdatable(kind: string): boolean;
  21858. /**
  21859. * Gets a specific vertex buffer
  21860. * @param kind defines the data kind (Position, normal, etc...)
  21861. * @returns a VertexBuffer
  21862. */
  21863. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21864. /**
  21865. * Returns all vertex buffers
  21866. * @return an object holding all vertex buffers indexed by kind
  21867. */
  21868. getVertexBuffers(): Nullable<{
  21869. [key: string]: VertexBuffer;
  21870. }>;
  21871. /**
  21872. * Gets a boolean indicating if specific vertex buffer is present
  21873. * @param kind defines the data kind (Position, normal, etc...)
  21874. * @returns true if data is present
  21875. */
  21876. isVerticesDataPresent(kind: string): boolean;
  21877. /**
  21878. * Gets a list of all attached data kinds (Position, normal, etc...)
  21879. * @returns a list of string containing all kinds
  21880. */
  21881. getVerticesDataKinds(): string[];
  21882. /**
  21883. * Update index buffer
  21884. * @param indices defines the indices to store in the index buffer
  21885. * @param offset defines the offset in the target buffer where to store the data
  21886. * @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)
  21887. */
  21888. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21889. /**
  21890. * Creates a new index buffer
  21891. * @param indices defines the indices to store in the index buffer
  21892. * @param totalVertices defines the total number of vertices (could be null)
  21893. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21894. */
  21895. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21896. /**
  21897. * Return the total number of indices
  21898. * @returns the total number of indices
  21899. */
  21900. getTotalIndices(): number;
  21901. /**
  21902. * Gets the index buffer array
  21903. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21904. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21905. * @returns the index buffer array
  21906. */
  21907. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21908. /**
  21909. * Gets the index buffer
  21910. * @return the index buffer
  21911. */
  21912. getIndexBuffer(): Nullable<DataBuffer>;
  21913. /** @hidden */
  21914. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21915. /**
  21916. * Release the associated resources for a specific mesh
  21917. * @param mesh defines the source mesh
  21918. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21919. */
  21920. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21921. /**
  21922. * Apply current geometry to a given mesh
  21923. * @param mesh defines the mesh to apply geometry to
  21924. */
  21925. applyToMesh(mesh: Mesh): void;
  21926. private _updateExtend;
  21927. private _applyToMesh;
  21928. private notifyUpdate;
  21929. /**
  21930. * Load the geometry if it was flagged as delay loaded
  21931. * @param scene defines the hosting scene
  21932. * @param onLoaded defines a callback called when the geometry is loaded
  21933. */
  21934. load(scene: Scene, onLoaded?: () => void): void;
  21935. private _queueLoad;
  21936. /**
  21937. * Invert the geometry to move from a right handed system to a left handed one.
  21938. */
  21939. toLeftHanded(): void;
  21940. /** @hidden */
  21941. _resetPointsArrayCache(): void;
  21942. /** @hidden */
  21943. _generatePointsArray(): boolean;
  21944. /**
  21945. * Gets a value indicating if the geometry is disposed
  21946. * @returns true if the geometry was disposed
  21947. */
  21948. isDisposed(): boolean;
  21949. private _disposeVertexArrayObjects;
  21950. /**
  21951. * Free all associated resources
  21952. */
  21953. dispose(): void;
  21954. /**
  21955. * Clone the current geometry into a new geometry
  21956. * @param id defines the unique ID of the new geometry
  21957. * @returns a new geometry object
  21958. */
  21959. copy(id: string): Geometry;
  21960. /**
  21961. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21962. * @return a JSON representation of the current geometry data (without the vertices data)
  21963. */
  21964. serialize(): any;
  21965. private toNumberArray;
  21966. /**
  21967. * Serialize all vertices data into a JSON oject
  21968. * @returns a JSON representation of the current geometry data
  21969. */
  21970. serializeVerticeData(): any;
  21971. /**
  21972. * Extracts a clone of a mesh geometry
  21973. * @param mesh defines the source mesh
  21974. * @param id defines the unique ID of the new geometry object
  21975. * @returns the new geometry object
  21976. */
  21977. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21978. /**
  21979. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21980. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21981. * Be aware Math.random() could cause collisions, but:
  21982. * "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"
  21983. * @returns a string containing a new GUID
  21984. */
  21985. static RandomId(): string;
  21986. /** @hidden */
  21987. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21988. private static _CleanMatricesWeights;
  21989. /**
  21990. * Create a new geometry from persisted data (Using .babylon file format)
  21991. * @param parsedVertexData defines the persisted data
  21992. * @param scene defines the hosting scene
  21993. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21994. * @returns the new geometry object
  21995. */
  21996. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21997. }
  21998. }
  21999. declare module BABYLON {
  22000. /**
  22001. * Define an interface for all classes that will get and set the data on vertices
  22002. */
  22003. export interface IGetSetVerticesData {
  22004. /**
  22005. * Gets a boolean indicating if specific vertex data is present
  22006. * @param kind defines the vertex data kind to use
  22007. * @returns true is data kind is present
  22008. */
  22009. isVerticesDataPresent(kind: string): boolean;
  22010. /**
  22011. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22012. * @param kind defines the data kind (Position, normal, etc...)
  22013. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22014. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22015. * @returns a float array containing vertex data
  22016. */
  22017. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22018. /**
  22019. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22020. * @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.
  22021. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22022. * @returns the indices array or an empty array if the mesh has no geometry
  22023. */
  22024. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22025. /**
  22026. * Set specific vertex data
  22027. * @param kind defines the data kind (Position, normal, etc...)
  22028. * @param data defines the vertex data to use
  22029. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22030. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22031. */
  22032. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22033. /**
  22034. * Update a specific associated vertex buffer
  22035. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22036. * - VertexBuffer.PositionKind
  22037. * - VertexBuffer.UVKind
  22038. * - VertexBuffer.UV2Kind
  22039. * - VertexBuffer.UV3Kind
  22040. * - VertexBuffer.UV4Kind
  22041. * - VertexBuffer.UV5Kind
  22042. * - VertexBuffer.UV6Kind
  22043. * - VertexBuffer.ColorKind
  22044. * - VertexBuffer.MatricesIndicesKind
  22045. * - VertexBuffer.MatricesIndicesExtraKind
  22046. * - VertexBuffer.MatricesWeightsKind
  22047. * - VertexBuffer.MatricesWeightsExtraKind
  22048. * @param data defines the data source
  22049. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22050. * @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)
  22051. */
  22052. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22053. /**
  22054. * Creates a new index buffer
  22055. * @param indices defines the indices to store in the index buffer
  22056. * @param totalVertices defines the total number of vertices (could be null)
  22057. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22058. */
  22059. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22060. }
  22061. /**
  22062. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22063. */
  22064. export class VertexData {
  22065. /**
  22066. * Mesh side orientation : usually the external or front surface
  22067. */
  22068. static readonly FRONTSIDE: number;
  22069. /**
  22070. * Mesh side orientation : usually the internal or back surface
  22071. */
  22072. static readonly BACKSIDE: number;
  22073. /**
  22074. * Mesh side orientation : both internal and external or front and back surfaces
  22075. */
  22076. static readonly DOUBLESIDE: number;
  22077. /**
  22078. * Mesh side orientation : by default, `FRONTSIDE`
  22079. */
  22080. static readonly DEFAULTSIDE: number;
  22081. /**
  22082. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22083. */
  22084. positions: Nullable<FloatArray>;
  22085. /**
  22086. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22087. */
  22088. normals: Nullable<FloatArray>;
  22089. /**
  22090. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22091. */
  22092. tangents: Nullable<FloatArray>;
  22093. /**
  22094. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22095. */
  22096. uvs: Nullable<FloatArray>;
  22097. /**
  22098. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22099. */
  22100. uvs2: Nullable<FloatArray>;
  22101. /**
  22102. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22103. */
  22104. uvs3: Nullable<FloatArray>;
  22105. /**
  22106. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22107. */
  22108. uvs4: Nullable<FloatArray>;
  22109. /**
  22110. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22111. */
  22112. uvs5: Nullable<FloatArray>;
  22113. /**
  22114. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22115. */
  22116. uvs6: Nullable<FloatArray>;
  22117. /**
  22118. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22119. */
  22120. colors: Nullable<FloatArray>;
  22121. /**
  22122. * 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).
  22123. */
  22124. matricesIndices: Nullable<FloatArray>;
  22125. /**
  22126. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22127. */
  22128. matricesWeights: Nullable<FloatArray>;
  22129. /**
  22130. * An array extending the number of possible indices
  22131. */
  22132. matricesIndicesExtra: Nullable<FloatArray>;
  22133. /**
  22134. * An array extending the number of possible weights when the number of indices is extended
  22135. */
  22136. matricesWeightsExtra: Nullable<FloatArray>;
  22137. /**
  22138. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22139. */
  22140. indices: Nullable<IndicesArray>;
  22141. /**
  22142. * Uses the passed data array to set the set the values for the specified kind of data
  22143. * @param data a linear array of floating numbers
  22144. * @param kind the type of data that is being set, eg positions, colors etc
  22145. */
  22146. set(data: FloatArray, kind: string): void;
  22147. /**
  22148. * Associates the vertexData to the passed Mesh.
  22149. * Sets it as updatable or not (default `false`)
  22150. * @param mesh the mesh the vertexData is applied to
  22151. * @param updatable when used and having the value true allows new data to update the vertexData
  22152. * @returns the VertexData
  22153. */
  22154. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22155. /**
  22156. * Associates the vertexData to the passed Geometry.
  22157. * Sets it as updatable or not (default `false`)
  22158. * @param geometry the geometry the vertexData is applied to
  22159. * @param updatable when used and having the value true allows new data to update the vertexData
  22160. * @returns VertexData
  22161. */
  22162. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22163. /**
  22164. * Updates the associated mesh
  22165. * @param mesh the mesh to be updated
  22166. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22167. * @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
  22168. * @returns VertexData
  22169. */
  22170. updateMesh(mesh: Mesh): VertexData;
  22171. /**
  22172. * Updates the associated geometry
  22173. * @param geometry the geometry to be updated
  22174. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22175. * @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
  22176. * @returns VertexData.
  22177. */
  22178. updateGeometry(geometry: Geometry): VertexData;
  22179. private _applyTo;
  22180. private _update;
  22181. /**
  22182. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22183. * @param matrix the transforming matrix
  22184. * @returns the VertexData
  22185. */
  22186. transform(matrix: Matrix): VertexData;
  22187. /**
  22188. * Merges the passed VertexData into the current one
  22189. * @param other the VertexData to be merged into the current one
  22190. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22191. * @returns the modified VertexData
  22192. */
  22193. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22194. private _mergeElement;
  22195. private _validate;
  22196. /**
  22197. * Serializes the VertexData
  22198. * @returns a serialized object
  22199. */
  22200. serialize(): any;
  22201. /**
  22202. * Extracts the vertexData from a mesh
  22203. * @param mesh the mesh from which to extract the VertexData
  22204. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22205. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22206. * @returns the object VertexData associated to the passed mesh
  22207. */
  22208. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22209. /**
  22210. * Extracts the vertexData from the geometry
  22211. * @param geometry the geometry from which to extract the VertexData
  22212. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22213. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22214. * @returns the object VertexData associated to the passed mesh
  22215. */
  22216. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22217. private static _ExtractFrom;
  22218. /**
  22219. * Creates the VertexData for a Ribbon
  22220. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22221. * * pathArray array of paths, each of which an array of successive Vector3
  22222. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22223. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22224. * * 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
  22225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22226. * * 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)
  22227. * * 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)
  22228. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22229. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22230. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22231. * @returns the VertexData of the ribbon
  22232. */
  22233. static CreateRibbon(options: {
  22234. pathArray: Vector3[][];
  22235. closeArray?: boolean;
  22236. closePath?: boolean;
  22237. offset?: number;
  22238. sideOrientation?: number;
  22239. frontUVs?: Vector4;
  22240. backUVs?: Vector4;
  22241. invertUV?: boolean;
  22242. uvs?: Vector2[];
  22243. colors?: Color4[];
  22244. }): VertexData;
  22245. /**
  22246. * Creates the VertexData for a box
  22247. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22248. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22249. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22250. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22251. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22252. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22253. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22255. * * 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)
  22256. * * 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)
  22257. * @returns the VertexData of the box
  22258. */
  22259. static CreateBox(options: {
  22260. size?: number;
  22261. width?: number;
  22262. height?: number;
  22263. depth?: number;
  22264. faceUV?: Vector4[];
  22265. faceColors?: Color4[];
  22266. sideOrientation?: number;
  22267. frontUVs?: Vector4;
  22268. backUVs?: Vector4;
  22269. }): VertexData;
  22270. /**
  22271. * Creates the VertexData for a tiled box
  22272. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22273. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22274. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22275. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22277. * @returns the VertexData of the box
  22278. */
  22279. static CreateTiledBox(options: {
  22280. pattern?: number;
  22281. width?: number;
  22282. height?: number;
  22283. depth?: number;
  22284. tileSize?: number;
  22285. tileWidth?: number;
  22286. tileHeight?: number;
  22287. alignHorizontal?: number;
  22288. alignVertical?: number;
  22289. faceUV?: Vector4[];
  22290. faceColors?: Color4[];
  22291. sideOrientation?: number;
  22292. }): VertexData;
  22293. /**
  22294. * Creates the VertexData for a tiled plane
  22295. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22296. * * pattern a limited pattern arrangement depending on the number
  22297. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22298. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22299. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22301. * * 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)
  22302. * * 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)
  22303. * @returns the VertexData of the tiled plane
  22304. */
  22305. static CreateTiledPlane(options: {
  22306. pattern?: number;
  22307. tileSize?: number;
  22308. tileWidth?: number;
  22309. tileHeight?: number;
  22310. size?: number;
  22311. width?: number;
  22312. height?: number;
  22313. alignHorizontal?: number;
  22314. alignVertical?: number;
  22315. sideOrientation?: number;
  22316. frontUVs?: Vector4;
  22317. backUVs?: Vector4;
  22318. }): VertexData;
  22319. /**
  22320. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22321. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22322. * * segments sets the number of horizontal strips optional, default 32
  22323. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22324. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22325. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22326. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22327. * * 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
  22328. * * 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
  22329. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22330. * * 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)
  22331. * * 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)
  22332. * @returns the VertexData of the ellipsoid
  22333. */
  22334. static CreateSphere(options: {
  22335. segments?: number;
  22336. diameter?: number;
  22337. diameterX?: number;
  22338. diameterY?: number;
  22339. diameterZ?: number;
  22340. arc?: number;
  22341. slice?: number;
  22342. sideOrientation?: number;
  22343. frontUVs?: Vector4;
  22344. backUVs?: Vector4;
  22345. }): VertexData;
  22346. /**
  22347. * Creates the VertexData for a cylinder, cone or prism
  22348. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22349. * * height sets the height (y direction) of the cylinder, optional, default 2
  22350. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22351. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22352. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22353. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22354. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22355. * * 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
  22356. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22357. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22358. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22359. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22360. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22361. * * 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)
  22362. * * 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)
  22363. * @returns the VertexData of the cylinder, cone or prism
  22364. */
  22365. static CreateCylinder(options: {
  22366. height?: number;
  22367. diameterTop?: number;
  22368. diameterBottom?: number;
  22369. diameter?: number;
  22370. tessellation?: number;
  22371. subdivisions?: number;
  22372. arc?: number;
  22373. faceColors?: Color4[];
  22374. faceUV?: Vector4[];
  22375. hasRings?: boolean;
  22376. enclose?: boolean;
  22377. sideOrientation?: number;
  22378. frontUVs?: Vector4;
  22379. backUVs?: Vector4;
  22380. }): VertexData;
  22381. /**
  22382. * Creates the VertexData for a torus
  22383. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22384. * * diameter the diameter of the torus, optional default 1
  22385. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22386. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22387. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22388. * * 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)
  22389. * * 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)
  22390. * @returns the VertexData of the torus
  22391. */
  22392. static CreateTorus(options: {
  22393. diameter?: number;
  22394. thickness?: number;
  22395. tessellation?: number;
  22396. sideOrientation?: number;
  22397. frontUVs?: Vector4;
  22398. backUVs?: Vector4;
  22399. }): VertexData;
  22400. /**
  22401. * Creates the VertexData of the LineSystem
  22402. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22403. * - lines an array of lines, each line being an array of successive Vector3
  22404. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22405. * @returns the VertexData of the LineSystem
  22406. */
  22407. static CreateLineSystem(options: {
  22408. lines: Vector3[][];
  22409. colors?: Nullable<Color4[][]>;
  22410. }): VertexData;
  22411. /**
  22412. * Create the VertexData for a DashedLines
  22413. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22414. * - points an array successive Vector3
  22415. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22416. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22417. * - dashNb the intended total number of dashes, optional, default 200
  22418. * @returns the VertexData for the DashedLines
  22419. */
  22420. static CreateDashedLines(options: {
  22421. points: Vector3[];
  22422. dashSize?: number;
  22423. gapSize?: number;
  22424. dashNb?: number;
  22425. }): VertexData;
  22426. /**
  22427. * Creates the VertexData for a Ground
  22428. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22429. * - width the width (x direction) of the ground, optional, default 1
  22430. * - height the height (z direction) of the ground, optional, default 1
  22431. * - subdivisions the number of subdivisions per side, optional, default 1
  22432. * @returns the VertexData of the Ground
  22433. */
  22434. static CreateGround(options: {
  22435. width?: number;
  22436. height?: number;
  22437. subdivisions?: number;
  22438. subdivisionsX?: number;
  22439. subdivisionsY?: number;
  22440. }): VertexData;
  22441. /**
  22442. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22443. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22444. * * xmin the ground minimum X coordinate, optional, default -1
  22445. * * zmin the ground minimum Z coordinate, optional, default -1
  22446. * * xmax the ground maximum X coordinate, optional, default 1
  22447. * * zmax the ground maximum Z coordinate, optional, default 1
  22448. * * 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}
  22449. * * 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}
  22450. * @returns the VertexData of the TiledGround
  22451. */
  22452. static CreateTiledGround(options: {
  22453. xmin: number;
  22454. zmin: number;
  22455. xmax: number;
  22456. zmax: number;
  22457. subdivisions?: {
  22458. w: number;
  22459. h: number;
  22460. };
  22461. precision?: {
  22462. w: number;
  22463. h: number;
  22464. };
  22465. }): VertexData;
  22466. /**
  22467. * Creates the VertexData of the Ground designed from a heightmap
  22468. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22469. * * width the width (x direction) of the ground
  22470. * * height the height (z direction) of the ground
  22471. * * subdivisions the number of subdivisions per side
  22472. * * minHeight the minimum altitude on the ground, optional, default 0
  22473. * * maxHeight the maximum altitude on the ground, optional default 1
  22474. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22475. * * buffer the array holding the image color data
  22476. * * bufferWidth the width of image
  22477. * * bufferHeight the height of image
  22478. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22479. * @returns the VertexData of the Ground designed from a heightmap
  22480. */
  22481. static CreateGroundFromHeightMap(options: {
  22482. width: number;
  22483. height: number;
  22484. subdivisions: number;
  22485. minHeight: number;
  22486. maxHeight: number;
  22487. colorFilter: Color3;
  22488. buffer: Uint8Array;
  22489. bufferWidth: number;
  22490. bufferHeight: number;
  22491. alphaFilter: number;
  22492. }): VertexData;
  22493. /**
  22494. * Creates the VertexData for a Plane
  22495. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22496. * * size sets the width and height of the plane to the value of size, optional default 1
  22497. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22498. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22499. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22500. * * 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)
  22501. * * 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)
  22502. * @returns the VertexData of the box
  22503. */
  22504. static CreatePlane(options: {
  22505. size?: number;
  22506. width?: number;
  22507. height?: number;
  22508. sideOrientation?: number;
  22509. frontUVs?: Vector4;
  22510. backUVs?: Vector4;
  22511. }): VertexData;
  22512. /**
  22513. * Creates the VertexData of the Disc or regular Polygon
  22514. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22515. * * radius the radius of the disc, optional default 0.5
  22516. * * tessellation the number of polygon sides, optional, default 64
  22517. * * 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
  22518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22519. * * 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)
  22520. * * 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)
  22521. * @returns the VertexData of the box
  22522. */
  22523. static CreateDisc(options: {
  22524. radius?: number;
  22525. tessellation?: number;
  22526. arc?: number;
  22527. sideOrientation?: number;
  22528. frontUVs?: Vector4;
  22529. backUVs?: Vector4;
  22530. }): VertexData;
  22531. /**
  22532. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22533. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22534. * @param polygon a mesh built from polygonTriangulation.build()
  22535. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22536. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22537. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22538. * @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)
  22539. * @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)
  22540. * @returns the VertexData of the Polygon
  22541. */
  22542. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22543. /**
  22544. * Creates the VertexData of the IcoSphere
  22545. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22546. * * radius the radius of the IcoSphere, optional default 1
  22547. * * radiusX allows stretching in the x direction, optional, default radius
  22548. * * radiusY allows stretching in the y direction, optional, default radius
  22549. * * radiusZ allows stretching in the z direction, optional, default radius
  22550. * * flat when true creates a flat shaded mesh, optional, default true
  22551. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22553. * * 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)
  22554. * * 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)
  22555. * @returns the VertexData of the IcoSphere
  22556. */
  22557. static CreateIcoSphere(options: {
  22558. radius?: number;
  22559. radiusX?: number;
  22560. radiusY?: number;
  22561. radiusZ?: number;
  22562. flat?: boolean;
  22563. subdivisions?: number;
  22564. sideOrientation?: number;
  22565. frontUVs?: Vector4;
  22566. backUVs?: Vector4;
  22567. }): VertexData;
  22568. /**
  22569. * Creates the VertexData for a Polyhedron
  22570. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22571. * * type provided types are:
  22572. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22573. * * 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)
  22574. * * size the size of the IcoSphere, optional default 1
  22575. * * sizeX allows stretching in the x direction, optional, default size
  22576. * * sizeY allows stretching in the y direction, optional, default size
  22577. * * sizeZ allows stretching in the z direction, optional, default size
  22578. * * 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
  22579. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22580. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22581. * * flat when true creates a flat shaded mesh, optional, default true
  22582. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22583. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22584. * * 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)
  22585. * * 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)
  22586. * @returns the VertexData of the Polyhedron
  22587. */
  22588. static CreatePolyhedron(options: {
  22589. type?: number;
  22590. size?: number;
  22591. sizeX?: number;
  22592. sizeY?: number;
  22593. sizeZ?: number;
  22594. custom?: any;
  22595. faceUV?: Vector4[];
  22596. faceColors?: Color4[];
  22597. flat?: boolean;
  22598. sideOrientation?: number;
  22599. frontUVs?: Vector4;
  22600. backUVs?: Vector4;
  22601. }): VertexData;
  22602. /**
  22603. * Creates the VertexData for a TorusKnot
  22604. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22605. * * radius the radius of the torus knot, optional, default 2
  22606. * * tube the thickness of the tube, optional, default 0.5
  22607. * * radialSegments the number of sides on each tube segments, optional, default 32
  22608. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22609. * * p the number of windings around the z axis, optional, default 2
  22610. * * q the number of windings around the x axis, optional, default 3
  22611. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22612. * * 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)
  22613. * * 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)
  22614. * @returns the VertexData of the Torus Knot
  22615. */
  22616. static CreateTorusKnot(options: {
  22617. radius?: number;
  22618. tube?: number;
  22619. radialSegments?: number;
  22620. tubularSegments?: number;
  22621. p?: number;
  22622. q?: number;
  22623. sideOrientation?: number;
  22624. frontUVs?: Vector4;
  22625. backUVs?: Vector4;
  22626. }): VertexData;
  22627. /**
  22628. * Compute normals for given positions and indices
  22629. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22630. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22631. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22632. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22633. * * facetNormals : optional array of facet normals (vector3)
  22634. * * facetPositions : optional array of facet positions (vector3)
  22635. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22636. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22637. * * bInfo : optional bounding info, required for facetPartitioning computation
  22638. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22639. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22640. * * useRightHandedSystem: optional boolean to for right handed system computation
  22641. * * depthSort : optional boolean to enable the facet depth sort computation
  22642. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22643. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22644. */
  22645. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22646. facetNormals?: any;
  22647. facetPositions?: any;
  22648. facetPartitioning?: any;
  22649. ratio?: number;
  22650. bInfo?: any;
  22651. bbSize?: Vector3;
  22652. subDiv?: any;
  22653. useRightHandedSystem?: boolean;
  22654. depthSort?: boolean;
  22655. distanceTo?: Vector3;
  22656. depthSortedFacets?: any;
  22657. }): void;
  22658. /** @hidden */
  22659. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22660. /**
  22661. * Applies VertexData created from the imported parameters to the geometry
  22662. * @param parsedVertexData the parsed data from an imported file
  22663. * @param geometry the geometry to apply the VertexData to
  22664. */
  22665. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22666. }
  22667. }
  22668. declare module BABYLON {
  22669. /**
  22670. * Defines a target to use with MorphTargetManager
  22671. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22672. */
  22673. export class MorphTarget implements IAnimatable {
  22674. /** defines the name of the target */
  22675. name: string;
  22676. /**
  22677. * Gets or sets the list of animations
  22678. */
  22679. animations: Animation[];
  22680. private _scene;
  22681. private _positions;
  22682. private _normals;
  22683. private _tangents;
  22684. private _uvs;
  22685. private _influence;
  22686. private _uniqueId;
  22687. /**
  22688. * Observable raised when the influence changes
  22689. */
  22690. onInfluenceChanged: Observable<boolean>;
  22691. /** @hidden */
  22692. _onDataLayoutChanged: Observable<void>;
  22693. /**
  22694. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22695. */
  22696. get influence(): number;
  22697. set influence(influence: number);
  22698. /**
  22699. * Gets or sets the id of the morph Target
  22700. */
  22701. id: string;
  22702. private _animationPropertiesOverride;
  22703. /**
  22704. * Gets or sets the animation properties override
  22705. */
  22706. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22707. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22708. /**
  22709. * Creates a new MorphTarget
  22710. * @param name defines the name of the target
  22711. * @param influence defines the influence to use
  22712. * @param scene defines the scene the morphtarget belongs to
  22713. */
  22714. constructor(
  22715. /** defines the name of the target */
  22716. name: string, influence?: number, scene?: Nullable<Scene>);
  22717. /**
  22718. * Gets the unique ID of this manager
  22719. */
  22720. get uniqueId(): number;
  22721. /**
  22722. * Gets a boolean defining if the target contains position data
  22723. */
  22724. get hasPositions(): boolean;
  22725. /**
  22726. * Gets a boolean defining if the target contains normal data
  22727. */
  22728. get hasNormals(): boolean;
  22729. /**
  22730. * Gets a boolean defining if the target contains tangent data
  22731. */
  22732. get hasTangents(): boolean;
  22733. /**
  22734. * Gets a boolean defining if the target contains texture coordinates data
  22735. */
  22736. get hasUVs(): boolean;
  22737. /**
  22738. * Affects position data to this target
  22739. * @param data defines the position data to use
  22740. */
  22741. setPositions(data: Nullable<FloatArray>): void;
  22742. /**
  22743. * Gets the position data stored in this target
  22744. * @returns a FloatArray containing the position data (or null if not present)
  22745. */
  22746. getPositions(): Nullable<FloatArray>;
  22747. /**
  22748. * Affects normal data to this target
  22749. * @param data defines the normal data to use
  22750. */
  22751. setNormals(data: Nullable<FloatArray>): void;
  22752. /**
  22753. * Gets the normal data stored in this target
  22754. * @returns a FloatArray containing the normal data (or null if not present)
  22755. */
  22756. getNormals(): Nullable<FloatArray>;
  22757. /**
  22758. * Affects tangent data to this target
  22759. * @param data defines the tangent data to use
  22760. */
  22761. setTangents(data: Nullable<FloatArray>): void;
  22762. /**
  22763. * Gets the tangent data stored in this target
  22764. * @returns a FloatArray containing the tangent data (or null if not present)
  22765. */
  22766. getTangents(): Nullable<FloatArray>;
  22767. /**
  22768. * Affects texture coordinates data to this target
  22769. * @param data defines the texture coordinates data to use
  22770. */
  22771. setUVs(data: Nullable<FloatArray>): void;
  22772. /**
  22773. * Gets the texture coordinates data stored in this target
  22774. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22775. */
  22776. getUVs(): Nullable<FloatArray>;
  22777. /**
  22778. * Clone the current target
  22779. * @returns a new MorphTarget
  22780. */
  22781. clone(): MorphTarget;
  22782. /**
  22783. * Serializes the current target into a Serialization object
  22784. * @returns the serialized object
  22785. */
  22786. serialize(): any;
  22787. /**
  22788. * Returns the string "MorphTarget"
  22789. * @returns "MorphTarget"
  22790. */
  22791. getClassName(): string;
  22792. /**
  22793. * Creates a new target from serialized data
  22794. * @param serializationObject defines the serialized data to use
  22795. * @returns a new MorphTarget
  22796. */
  22797. static Parse(serializationObject: any): MorphTarget;
  22798. /**
  22799. * Creates a MorphTarget from mesh data
  22800. * @param mesh defines the source mesh
  22801. * @param name defines the name to use for the new target
  22802. * @param influence defines the influence to attach to the target
  22803. * @returns a new MorphTarget
  22804. */
  22805. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22806. }
  22807. }
  22808. declare module BABYLON {
  22809. /**
  22810. * This class is used to deform meshes using morphing between different targets
  22811. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22812. */
  22813. export class MorphTargetManager {
  22814. private _targets;
  22815. private _targetInfluenceChangedObservers;
  22816. private _targetDataLayoutChangedObservers;
  22817. private _activeTargets;
  22818. private _scene;
  22819. private _influences;
  22820. private _supportsNormals;
  22821. private _supportsTangents;
  22822. private _supportsUVs;
  22823. private _vertexCount;
  22824. private _uniqueId;
  22825. private _tempInfluences;
  22826. /**
  22827. * Gets or sets a boolean indicating if normals must be morphed
  22828. */
  22829. enableNormalMorphing: boolean;
  22830. /**
  22831. * Gets or sets a boolean indicating if tangents must be morphed
  22832. */
  22833. enableTangentMorphing: boolean;
  22834. /**
  22835. * Gets or sets a boolean indicating if UV must be morphed
  22836. */
  22837. enableUVMorphing: boolean;
  22838. /**
  22839. * Creates a new MorphTargetManager
  22840. * @param scene defines the current scene
  22841. */
  22842. constructor(scene?: Nullable<Scene>);
  22843. /**
  22844. * Gets the unique ID of this manager
  22845. */
  22846. get uniqueId(): number;
  22847. /**
  22848. * Gets the number of vertices handled by this manager
  22849. */
  22850. get vertexCount(): number;
  22851. /**
  22852. * Gets a boolean indicating if this manager supports morphing of normals
  22853. */
  22854. get supportsNormals(): boolean;
  22855. /**
  22856. * Gets a boolean indicating if this manager supports morphing of tangents
  22857. */
  22858. get supportsTangents(): boolean;
  22859. /**
  22860. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22861. */
  22862. get supportsUVs(): boolean;
  22863. /**
  22864. * Gets the number of targets stored in this manager
  22865. */
  22866. get numTargets(): number;
  22867. /**
  22868. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22869. */
  22870. get numInfluencers(): number;
  22871. /**
  22872. * Gets the list of influences (one per target)
  22873. */
  22874. get influences(): Float32Array;
  22875. /**
  22876. * Gets the active target at specified index. An active target is a target with an influence > 0
  22877. * @param index defines the index to check
  22878. * @returns the requested target
  22879. */
  22880. getActiveTarget(index: number): MorphTarget;
  22881. /**
  22882. * Gets the target at specified index
  22883. * @param index defines the index to check
  22884. * @returns the requested target
  22885. */
  22886. getTarget(index: number): MorphTarget;
  22887. /**
  22888. * Add a new target to this manager
  22889. * @param target defines the target to add
  22890. */
  22891. addTarget(target: MorphTarget): void;
  22892. /**
  22893. * Removes a target from the manager
  22894. * @param target defines the target to remove
  22895. */
  22896. removeTarget(target: MorphTarget): void;
  22897. /**
  22898. * Clone the current manager
  22899. * @returns a new MorphTargetManager
  22900. */
  22901. clone(): MorphTargetManager;
  22902. /**
  22903. * Serializes the current manager into a Serialization object
  22904. * @returns the serialized object
  22905. */
  22906. serialize(): any;
  22907. private _syncActiveTargets;
  22908. /**
  22909. * Syncrhonize the targets with all the meshes using this morph target manager
  22910. */
  22911. synchronize(): void;
  22912. /**
  22913. * Creates a new MorphTargetManager from serialized data
  22914. * @param serializationObject defines the serialized data
  22915. * @param scene defines the hosting scene
  22916. * @returns the new MorphTargetManager
  22917. */
  22918. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22919. }
  22920. }
  22921. declare module BABYLON {
  22922. /**
  22923. * Class used to represent a specific level of detail of a mesh
  22924. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22925. */
  22926. export class MeshLODLevel {
  22927. /** Defines the distance where this level should start being displayed */
  22928. distance: number;
  22929. /** Defines the mesh to use to render this level */
  22930. mesh: Nullable<Mesh>;
  22931. /**
  22932. * Creates a new LOD level
  22933. * @param distance defines the distance where this level should star being displayed
  22934. * @param mesh defines the mesh to use to render this level
  22935. */
  22936. constructor(
  22937. /** Defines the distance where this level should start being displayed */
  22938. distance: number,
  22939. /** Defines the mesh to use to render this level */
  22940. mesh: Nullable<Mesh>);
  22941. }
  22942. }
  22943. declare module BABYLON {
  22944. /**
  22945. * Mesh representing the gorund
  22946. */
  22947. export class GroundMesh extends Mesh {
  22948. /** If octree should be generated */
  22949. generateOctree: boolean;
  22950. private _heightQuads;
  22951. /** @hidden */
  22952. _subdivisionsX: number;
  22953. /** @hidden */
  22954. _subdivisionsY: number;
  22955. /** @hidden */
  22956. _width: number;
  22957. /** @hidden */
  22958. _height: number;
  22959. /** @hidden */
  22960. _minX: number;
  22961. /** @hidden */
  22962. _maxX: number;
  22963. /** @hidden */
  22964. _minZ: number;
  22965. /** @hidden */
  22966. _maxZ: number;
  22967. constructor(name: string, scene: Scene);
  22968. /**
  22969. * "GroundMesh"
  22970. * @returns "GroundMesh"
  22971. */
  22972. getClassName(): string;
  22973. /**
  22974. * The minimum of x and y subdivisions
  22975. */
  22976. get subdivisions(): number;
  22977. /**
  22978. * X subdivisions
  22979. */
  22980. get subdivisionsX(): number;
  22981. /**
  22982. * Y subdivisions
  22983. */
  22984. get subdivisionsY(): number;
  22985. /**
  22986. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22987. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22988. * @param chunksCount the number of subdivisions for x and y
  22989. * @param octreeBlocksSize (Default: 32)
  22990. */
  22991. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22992. /**
  22993. * Returns a height (y) value in the Worl system :
  22994. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22995. * @param x x coordinate
  22996. * @param z z coordinate
  22997. * @returns the ground y position if (x, z) are outside the ground surface.
  22998. */
  22999. getHeightAtCoordinates(x: number, z: number): number;
  23000. /**
  23001. * Returns a normalized vector (Vector3) orthogonal to the ground
  23002. * at the ground coordinates (x, z) expressed in the World system.
  23003. * @param x x coordinate
  23004. * @param z z coordinate
  23005. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23006. */
  23007. getNormalAtCoordinates(x: number, z: number): Vector3;
  23008. /**
  23009. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23010. * at the ground coordinates (x, z) expressed in the World system.
  23011. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23012. * @param x x coordinate
  23013. * @param z z coordinate
  23014. * @param ref vector to store the result
  23015. * @returns the GroundMesh.
  23016. */
  23017. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23018. /**
  23019. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23020. * if the ground has been updated.
  23021. * This can be used in the render loop.
  23022. * @returns the GroundMesh.
  23023. */
  23024. updateCoordinateHeights(): GroundMesh;
  23025. private _getFacetAt;
  23026. private _initHeightQuads;
  23027. private _computeHeightQuads;
  23028. /**
  23029. * Serializes this ground mesh
  23030. * @param serializationObject object to write serialization to
  23031. */
  23032. serialize(serializationObject: any): void;
  23033. /**
  23034. * Parses a serialized ground mesh
  23035. * @param parsedMesh the serialized mesh
  23036. * @param scene the scene to create the ground mesh in
  23037. * @returns the created ground mesh
  23038. */
  23039. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23040. }
  23041. }
  23042. declare module BABYLON {
  23043. /**
  23044. * Interface for Physics-Joint data
  23045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23046. */
  23047. export interface PhysicsJointData {
  23048. /**
  23049. * The main pivot of the joint
  23050. */
  23051. mainPivot?: Vector3;
  23052. /**
  23053. * The connected pivot of the joint
  23054. */
  23055. connectedPivot?: Vector3;
  23056. /**
  23057. * The main axis of the joint
  23058. */
  23059. mainAxis?: Vector3;
  23060. /**
  23061. * The connected axis of the joint
  23062. */
  23063. connectedAxis?: Vector3;
  23064. /**
  23065. * The collision of the joint
  23066. */
  23067. collision?: boolean;
  23068. /**
  23069. * Native Oimo/Cannon/Energy data
  23070. */
  23071. nativeParams?: any;
  23072. }
  23073. /**
  23074. * This is a holder class for the physics joint created by the physics plugin
  23075. * It holds a set of functions to control the underlying joint
  23076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23077. */
  23078. export class PhysicsJoint {
  23079. /**
  23080. * The type of the physics joint
  23081. */
  23082. type: number;
  23083. /**
  23084. * The data for the physics joint
  23085. */
  23086. jointData: PhysicsJointData;
  23087. private _physicsJoint;
  23088. protected _physicsPlugin: IPhysicsEnginePlugin;
  23089. /**
  23090. * Initializes the physics joint
  23091. * @param type The type of the physics joint
  23092. * @param jointData The data for the physics joint
  23093. */
  23094. constructor(
  23095. /**
  23096. * The type of the physics joint
  23097. */
  23098. type: number,
  23099. /**
  23100. * The data for the physics joint
  23101. */
  23102. jointData: PhysicsJointData);
  23103. /**
  23104. * Gets the physics joint
  23105. */
  23106. get physicsJoint(): any;
  23107. /**
  23108. * Sets the physics joint
  23109. */
  23110. set physicsJoint(newJoint: any);
  23111. /**
  23112. * Sets the physics plugin
  23113. */
  23114. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23115. /**
  23116. * Execute a function that is physics-plugin specific.
  23117. * @param {Function} func the function that will be executed.
  23118. * It accepts two parameters: the physics world and the physics joint
  23119. */
  23120. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23121. /**
  23122. * Distance-Joint type
  23123. */
  23124. static DistanceJoint: number;
  23125. /**
  23126. * Hinge-Joint type
  23127. */
  23128. static HingeJoint: number;
  23129. /**
  23130. * Ball-and-Socket joint type
  23131. */
  23132. static BallAndSocketJoint: number;
  23133. /**
  23134. * Wheel-Joint type
  23135. */
  23136. static WheelJoint: number;
  23137. /**
  23138. * Slider-Joint type
  23139. */
  23140. static SliderJoint: number;
  23141. /**
  23142. * Prismatic-Joint type
  23143. */
  23144. static PrismaticJoint: number;
  23145. /**
  23146. * Universal-Joint type
  23147. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23148. */
  23149. static UniversalJoint: number;
  23150. /**
  23151. * Hinge-Joint 2 type
  23152. */
  23153. static Hinge2Joint: number;
  23154. /**
  23155. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23156. */
  23157. static PointToPointJoint: number;
  23158. /**
  23159. * Spring-Joint type
  23160. */
  23161. static SpringJoint: number;
  23162. /**
  23163. * Lock-Joint type
  23164. */
  23165. static LockJoint: number;
  23166. }
  23167. /**
  23168. * A class representing a physics distance joint
  23169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23170. */
  23171. export class DistanceJoint extends PhysicsJoint {
  23172. /**
  23173. *
  23174. * @param jointData The data for the Distance-Joint
  23175. */
  23176. constructor(jointData: DistanceJointData);
  23177. /**
  23178. * Update the predefined distance.
  23179. * @param maxDistance The maximum preferred distance
  23180. * @param minDistance The minimum preferred distance
  23181. */
  23182. updateDistance(maxDistance: number, minDistance?: number): void;
  23183. }
  23184. /**
  23185. * Represents a Motor-Enabled Joint
  23186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23187. */
  23188. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23189. /**
  23190. * Initializes the Motor-Enabled Joint
  23191. * @param type The type of the joint
  23192. * @param jointData The physica joint data for the joint
  23193. */
  23194. constructor(type: number, jointData: PhysicsJointData);
  23195. /**
  23196. * Set the motor values.
  23197. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23198. * @param force the force to apply
  23199. * @param maxForce max force for this motor.
  23200. */
  23201. setMotor(force?: number, maxForce?: number): void;
  23202. /**
  23203. * Set the motor's limits.
  23204. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23205. * @param upperLimit The upper limit of the motor
  23206. * @param lowerLimit The lower limit of the motor
  23207. */
  23208. setLimit(upperLimit: number, lowerLimit?: number): void;
  23209. }
  23210. /**
  23211. * This class represents a single physics Hinge-Joint
  23212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23213. */
  23214. export class HingeJoint extends MotorEnabledJoint {
  23215. /**
  23216. * Initializes the Hinge-Joint
  23217. * @param jointData The joint data for the Hinge-Joint
  23218. */
  23219. constructor(jointData: PhysicsJointData);
  23220. /**
  23221. * Set the motor values.
  23222. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23223. * @param {number} force the force to apply
  23224. * @param {number} maxForce max force for this motor.
  23225. */
  23226. setMotor(force?: number, maxForce?: number): void;
  23227. /**
  23228. * Set the motor's limits.
  23229. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23230. * @param upperLimit The upper limit of the motor
  23231. * @param lowerLimit The lower limit of the motor
  23232. */
  23233. setLimit(upperLimit: number, lowerLimit?: number): void;
  23234. }
  23235. /**
  23236. * This class represents a dual hinge physics joint (same as wheel joint)
  23237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23238. */
  23239. export class Hinge2Joint extends MotorEnabledJoint {
  23240. /**
  23241. * Initializes the Hinge2-Joint
  23242. * @param jointData The joint data for the Hinge2-Joint
  23243. */
  23244. constructor(jointData: PhysicsJointData);
  23245. /**
  23246. * Set the motor values.
  23247. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23248. * @param {number} targetSpeed the speed the motor is to reach
  23249. * @param {number} maxForce max force for this motor.
  23250. * @param {motorIndex} the motor's index, 0 or 1.
  23251. */
  23252. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23253. /**
  23254. * Set the motor limits.
  23255. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23256. * @param {number} upperLimit the upper limit
  23257. * @param {number} lowerLimit lower limit
  23258. * @param {motorIndex} the motor's index, 0 or 1.
  23259. */
  23260. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23261. }
  23262. /**
  23263. * Interface for a motor enabled joint
  23264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23265. */
  23266. export interface IMotorEnabledJoint {
  23267. /**
  23268. * Physics joint
  23269. */
  23270. physicsJoint: any;
  23271. /**
  23272. * Sets the motor of the motor-enabled joint
  23273. * @param force The force of the motor
  23274. * @param maxForce The maximum force of the motor
  23275. * @param motorIndex The index of the motor
  23276. */
  23277. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23278. /**
  23279. * Sets the limit of the motor
  23280. * @param upperLimit The upper limit of the motor
  23281. * @param lowerLimit The lower limit of the motor
  23282. * @param motorIndex The index of the motor
  23283. */
  23284. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23285. }
  23286. /**
  23287. * Joint data for a Distance-Joint
  23288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23289. */
  23290. export interface DistanceJointData extends PhysicsJointData {
  23291. /**
  23292. * Max distance the 2 joint objects can be apart
  23293. */
  23294. maxDistance: number;
  23295. }
  23296. /**
  23297. * Joint data from a spring joint
  23298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23299. */
  23300. export interface SpringJointData extends PhysicsJointData {
  23301. /**
  23302. * Length of the spring
  23303. */
  23304. length: number;
  23305. /**
  23306. * Stiffness of the spring
  23307. */
  23308. stiffness: number;
  23309. /**
  23310. * Damping of the spring
  23311. */
  23312. damping: number;
  23313. /** this callback will be called when applying the force to the impostors. */
  23314. forceApplicationCallback: () => void;
  23315. }
  23316. }
  23317. declare module BABYLON {
  23318. /**
  23319. * Holds the data for the raycast result
  23320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23321. */
  23322. export class PhysicsRaycastResult {
  23323. private _hasHit;
  23324. private _hitDistance;
  23325. private _hitNormalWorld;
  23326. private _hitPointWorld;
  23327. private _rayFromWorld;
  23328. private _rayToWorld;
  23329. /**
  23330. * Gets if there was a hit
  23331. */
  23332. get hasHit(): boolean;
  23333. /**
  23334. * Gets the distance from the hit
  23335. */
  23336. get hitDistance(): number;
  23337. /**
  23338. * Gets the hit normal/direction in the world
  23339. */
  23340. get hitNormalWorld(): Vector3;
  23341. /**
  23342. * Gets the hit point in the world
  23343. */
  23344. get hitPointWorld(): Vector3;
  23345. /**
  23346. * Gets the ray "start point" of the ray in the world
  23347. */
  23348. get rayFromWorld(): Vector3;
  23349. /**
  23350. * Gets the ray "end point" of the ray in the world
  23351. */
  23352. get rayToWorld(): Vector3;
  23353. /**
  23354. * Sets the hit data (normal & point in world space)
  23355. * @param hitNormalWorld defines the normal in world space
  23356. * @param hitPointWorld defines the point in world space
  23357. */
  23358. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23359. /**
  23360. * Sets the distance from the start point to the hit point
  23361. * @param distance
  23362. */
  23363. setHitDistance(distance: number): void;
  23364. /**
  23365. * Calculates the distance manually
  23366. */
  23367. calculateHitDistance(): void;
  23368. /**
  23369. * Resets all the values to default
  23370. * @param from The from point on world space
  23371. * @param to The to point on world space
  23372. */
  23373. reset(from?: Vector3, to?: Vector3): void;
  23374. }
  23375. /**
  23376. * Interface for the size containing width and height
  23377. */
  23378. interface IXYZ {
  23379. /**
  23380. * X
  23381. */
  23382. x: number;
  23383. /**
  23384. * Y
  23385. */
  23386. y: number;
  23387. /**
  23388. * Z
  23389. */
  23390. z: number;
  23391. }
  23392. }
  23393. declare module BABYLON {
  23394. /**
  23395. * Interface used to describe a physics joint
  23396. */
  23397. export interface PhysicsImpostorJoint {
  23398. /** Defines the main impostor to which the joint is linked */
  23399. mainImpostor: PhysicsImpostor;
  23400. /** Defines the impostor that is connected to the main impostor using this joint */
  23401. connectedImpostor: PhysicsImpostor;
  23402. /** Defines the joint itself */
  23403. joint: PhysicsJoint;
  23404. }
  23405. /** @hidden */
  23406. export interface IPhysicsEnginePlugin {
  23407. world: any;
  23408. name: string;
  23409. setGravity(gravity: Vector3): void;
  23410. setTimeStep(timeStep: number): void;
  23411. getTimeStep(): number;
  23412. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23413. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23414. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23415. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23416. removePhysicsBody(impostor: PhysicsImpostor): void;
  23417. generateJoint(joint: PhysicsImpostorJoint): void;
  23418. removeJoint(joint: PhysicsImpostorJoint): void;
  23419. isSupported(): boolean;
  23420. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23421. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23422. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23423. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23424. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23425. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23426. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23427. getBodyMass(impostor: PhysicsImpostor): number;
  23428. getBodyFriction(impostor: PhysicsImpostor): number;
  23429. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23430. getBodyRestitution(impostor: PhysicsImpostor): number;
  23431. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23432. getBodyPressure?(impostor: PhysicsImpostor): number;
  23433. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23434. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23435. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23436. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23437. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23438. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23439. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23440. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23441. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23442. sleepBody(impostor: PhysicsImpostor): void;
  23443. wakeUpBody(impostor: PhysicsImpostor): void;
  23444. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23445. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23446. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23447. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23448. getRadius(impostor: PhysicsImpostor): number;
  23449. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23450. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23451. dispose(): void;
  23452. }
  23453. /**
  23454. * Interface used to define a physics engine
  23455. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23456. */
  23457. export interface IPhysicsEngine {
  23458. /**
  23459. * Gets the gravity vector used by the simulation
  23460. */
  23461. gravity: Vector3;
  23462. /**
  23463. * Sets the gravity vector used by the simulation
  23464. * @param gravity defines the gravity vector to use
  23465. */
  23466. setGravity(gravity: Vector3): void;
  23467. /**
  23468. * Set the time step of the physics engine.
  23469. * Default is 1/60.
  23470. * To slow it down, enter 1/600 for example.
  23471. * To speed it up, 1/30
  23472. * @param newTimeStep the new timestep to apply to this world.
  23473. */
  23474. setTimeStep(newTimeStep: number): void;
  23475. /**
  23476. * Get the time step of the physics engine.
  23477. * @returns the current time step
  23478. */
  23479. getTimeStep(): number;
  23480. /**
  23481. * Set the sub time step of the physics engine.
  23482. * Default is 0 meaning there is no sub steps
  23483. * To increase physics resolution precision, set a small value (like 1 ms)
  23484. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23485. */
  23486. setSubTimeStep(subTimeStep: number): void;
  23487. /**
  23488. * Get the sub time step of the physics engine.
  23489. * @returns the current sub time step
  23490. */
  23491. getSubTimeStep(): number;
  23492. /**
  23493. * Release all resources
  23494. */
  23495. dispose(): void;
  23496. /**
  23497. * Gets the name of the current physics plugin
  23498. * @returns the name of the plugin
  23499. */
  23500. getPhysicsPluginName(): string;
  23501. /**
  23502. * Adding a new impostor for the impostor tracking.
  23503. * This will be done by the impostor itself.
  23504. * @param impostor the impostor to add
  23505. */
  23506. addImpostor(impostor: PhysicsImpostor): void;
  23507. /**
  23508. * Remove an impostor from the engine.
  23509. * This impostor and its mesh will not longer be updated by the physics engine.
  23510. * @param impostor the impostor to remove
  23511. */
  23512. removeImpostor(impostor: PhysicsImpostor): void;
  23513. /**
  23514. * Add a joint to the physics engine
  23515. * @param mainImpostor defines the main impostor to which the joint is added.
  23516. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23517. * @param joint defines the joint that will connect both impostors.
  23518. */
  23519. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23520. /**
  23521. * Removes a joint from the simulation
  23522. * @param mainImpostor defines the impostor used with the joint
  23523. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23524. * @param joint defines the joint to remove
  23525. */
  23526. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23527. /**
  23528. * Gets the current plugin used to run the simulation
  23529. * @returns current plugin
  23530. */
  23531. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23532. /**
  23533. * Gets the list of physic impostors
  23534. * @returns an array of PhysicsImpostor
  23535. */
  23536. getImpostors(): Array<PhysicsImpostor>;
  23537. /**
  23538. * Gets the impostor for a physics enabled object
  23539. * @param object defines the object impersonated by the impostor
  23540. * @returns the PhysicsImpostor or null if not found
  23541. */
  23542. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23543. /**
  23544. * Gets the impostor for a physics body object
  23545. * @param body defines physics body used by the impostor
  23546. * @returns the PhysicsImpostor or null if not found
  23547. */
  23548. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23549. /**
  23550. * Does a raycast in the physics world
  23551. * @param from when should the ray start?
  23552. * @param to when should the ray end?
  23553. * @returns PhysicsRaycastResult
  23554. */
  23555. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23556. /**
  23557. * Called by the scene. No need to call it.
  23558. * @param delta defines the timespam between frames
  23559. */
  23560. _step(delta: number): void;
  23561. }
  23562. }
  23563. declare module BABYLON {
  23564. /**
  23565. * The interface for the physics imposter parameters
  23566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23567. */
  23568. export interface PhysicsImpostorParameters {
  23569. /**
  23570. * The mass of the physics imposter
  23571. */
  23572. mass: number;
  23573. /**
  23574. * The friction of the physics imposter
  23575. */
  23576. friction?: number;
  23577. /**
  23578. * The coefficient of restitution of the physics imposter
  23579. */
  23580. restitution?: number;
  23581. /**
  23582. * The native options of the physics imposter
  23583. */
  23584. nativeOptions?: any;
  23585. /**
  23586. * Specifies if the parent should be ignored
  23587. */
  23588. ignoreParent?: boolean;
  23589. /**
  23590. * Specifies if bi-directional transformations should be disabled
  23591. */
  23592. disableBidirectionalTransformation?: boolean;
  23593. /**
  23594. * The pressure inside the physics imposter, soft object only
  23595. */
  23596. pressure?: number;
  23597. /**
  23598. * The stiffness the physics imposter, soft object only
  23599. */
  23600. stiffness?: number;
  23601. /**
  23602. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23603. */
  23604. velocityIterations?: number;
  23605. /**
  23606. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23607. */
  23608. positionIterations?: number;
  23609. /**
  23610. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23611. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23612. * Add to fix multiple points
  23613. */
  23614. fixedPoints?: number;
  23615. /**
  23616. * The collision margin around a soft object
  23617. */
  23618. margin?: number;
  23619. /**
  23620. * The collision margin around a soft object
  23621. */
  23622. damping?: number;
  23623. /**
  23624. * The path for a rope based on an extrusion
  23625. */
  23626. path?: any;
  23627. /**
  23628. * The shape of an extrusion used for a rope based on an extrusion
  23629. */
  23630. shape?: any;
  23631. }
  23632. /**
  23633. * Interface for a physics-enabled object
  23634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23635. */
  23636. export interface IPhysicsEnabledObject {
  23637. /**
  23638. * The position of the physics-enabled object
  23639. */
  23640. position: Vector3;
  23641. /**
  23642. * The rotation of the physics-enabled object
  23643. */
  23644. rotationQuaternion: Nullable<Quaternion>;
  23645. /**
  23646. * The scale of the physics-enabled object
  23647. */
  23648. scaling: Vector3;
  23649. /**
  23650. * The rotation of the physics-enabled object
  23651. */
  23652. rotation?: Vector3;
  23653. /**
  23654. * The parent of the physics-enabled object
  23655. */
  23656. parent?: any;
  23657. /**
  23658. * The bounding info of the physics-enabled object
  23659. * @returns The bounding info of the physics-enabled object
  23660. */
  23661. getBoundingInfo(): BoundingInfo;
  23662. /**
  23663. * Computes the world matrix
  23664. * @param force Specifies if the world matrix should be computed by force
  23665. * @returns A world matrix
  23666. */
  23667. computeWorldMatrix(force: boolean): Matrix;
  23668. /**
  23669. * Gets the world matrix
  23670. * @returns A world matrix
  23671. */
  23672. getWorldMatrix?(): Matrix;
  23673. /**
  23674. * Gets the child meshes
  23675. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23676. * @returns An array of abstract meshes
  23677. */
  23678. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23679. /**
  23680. * Gets the vertex data
  23681. * @param kind The type of vertex data
  23682. * @returns A nullable array of numbers, or a float32 array
  23683. */
  23684. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23685. /**
  23686. * Gets the indices from the mesh
  23687. * @returns A nullable array of index arrays
  23688. */
  23689. getIndices?(): Nullable<IndicesArray>;
  23690. /**
  23691. * Gets the scene from the mesh
  23692. * @returns the indices array or null
  23693. */
  23694. getScene?(): Scene;
  23695. /**
  23696. * Gets the absolute position from the mesh
  23697. * @returns the absolute position
  23698. */
  23699. getAbsolutePosition(): Vector3;
  23700. /**
  23701. * Gets the absolute pivot point from the mesh
  23702. * @returns the absolute pivot point
  23703. */
  23704. getAbsolutePivotPoint(): Vector3;
  23705. /**
  23706. * Rotates the mesh
  23707. * @param axis The axis of rotation
  23708. * @param amount The amount of rotation
  23709. * @param space The space of the rotation
  23710. * @returns The rotation transform node
  23711. */
  23712. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23713. /**
  23714. * Translates the mesh
  23715. * @param axis The axis of translation
  23716. * @param distance The distance of translation
  23717. * @param space The space of the translation
  23718. * @returns The transform node
  23719. */
  23720. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23721. /**
  23722. * Sets the absolute position of the mesh
  23723. * @param absolutePosition The absolute position of the mesh
  23724. * @returns The transform node
  23725. */
  23726. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23727. /**
  23728. * Gets the class name of the mesh
  23729. * @returns The class name
  23730. */
  23731. getClassName(): string;
  23732. }
  23733. /**
  23734. * Represents a physics imposter
  23735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23736. */
  23737. export class PhysicsImpostor {
  23738. /**
  23739. * The physics-enabled object used as the physics imposter
  23740. */
  23741. object: IPhysicsEnabledObject;
  23742. /**
  23743. * The type of the physics imposter
  23744. */
  23745. type: number;
  23746. private _options;
  23747. private _scene?;
  23748. /**
  23749. * The default object size of the imposter
  23750. */
  23751. static DEFAULT_OBJECT_SIZE: Vector3;
  23752. /**
  23753. * The identity quaternion of the imposter
  23754. */
  23755. static IDENTITY_QUATERNION: Quaternion;
  23756. /** @hidden */
  23757. _pluginData: any;
  23758. private _physicsEngine;
  23759. private _physicsBody;
  23760. private _bodyUpdateRequired;
  23761. private _onBeforePhysicsStepCallbacks;
  23762. private _onAfterPhysicsStepCallbacks;
  23763. /** @hidden */
  23764. _onPhysicsCollideCallbacks: Array<{
  23765. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23766. otherImpostors: Array<PhysicsImpostor>;
  23767. }>;
  23768. private _deltaPosition;
  23769. private _deltaRotation;
  23770. private _deltaRotationConjugated;
  23771. /** @hidden */
  23772. _isFromLine: boolean;
  23773. private _parent;
  23774. private _isDisposed;
  23775. private static _tmpVecs;
  23776. private static _tmpQuat;
  23777. /**
  23778. * Specifies if the physics imposter is disposed
  23779. */
  23780. get isDisposed(): boolean;
  23781. /**
  23782. * Gets the mass of the physics imposter
  23783. */
  23784. get mass(): number;
  23785. set mass(value: number);
  23786. /**
  23787. * Gets the coefficient of friction
  23788. */
  23789. get friction(): number;
  23790. /**
  23791. * Sets the coefficient of friction
  23792. */
  23793. set friction(value: number);
  23794. /**
  23795. * Gets the coefficient of restitution
  23796. */
  23797. get restitution(): number;
  23798. /**
  23799. * Sets the coefficient of restitution
  23800. */
  23801. set restitution(value: number);
  23802. /**
  23803. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23804. */
  23805. get pressure(): number;
  23806. /**
  23807. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23808. */
  23809. set pressure(value: number);
  23810. /**
  23811. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23812. */
  23813. get stiffness(): number;
  23814. /**
  23815. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23816. */
  23817. set stiffness(value: number);
  23818. /**
  23819. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23820. */
  23821. get velocityIterations(): number;
  23822. /**
  23823. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23824. */
  23825. set velocityIterations(value: number);
  23826. /**
  23827. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23828. */
  23829. get positionIterations(): number;
  23830. /**
  23831. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23832. */
  23833. set positionIterations(value: number);
  23834. /**
  23835. * The unique id of the physics imposter
  23836. * set by the physics engine when adding this impostor to the array
  23837. */
  23838. uniqueId: number;
  23839. /**
  23840. * @hidden
  23841. */
  23842. soft: boolean;
  23843. /**
  23844. * @hidden
  23845. */
  23846. segments: number;
  23847. private _joints;
  23848. /**
  23849. * Initializes the physics imposter
  23850. * @param object The physics-enabled object used as the physics imposter
  23851. * @param type The type of the physics imposter
  23852. * @param _options The options for the physics imposter
  23853. * @param _scene The Babylon scene
  23854. */
  23855. constructor(
  23856. /**
  23857. * The physics-enabled object used as the physics imposter
  23858. */
  23859. object: IPhysicsEnabledObject,
  23860. /**
  23861. * The type of the physics imposter
  23862. */
  23863. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23864. /**
  23865. * This function will completly initialize this impostor.
  23866. * It will create a new body - but only if this mesh has no parent.
  23867. * If it has, this impostor will not be used other than to define the impostor
  23868. * of the child mesh.
  23869. * @hidden
  23870. */
  23871. _init(): void;
  23872. private _getPhysicsParent;
  23873. /**
  23874. * Should a new body be generated.
  23875. * @returns boolean specifying if body initialization is required
  23876. */
  23877. isBodyInitRequired(): boolean;
  23878. /**
  23879. * Sets the updated scaling
  23880. * @param updated Specifies if the scaling is updated
  23881. */
  23882. setScalingUpdated(): void;
  23883. /**
  23884. * Force a regeneration of this or the parent's impostor's body.
  23885. * Use under cautious - This will remove all joints already implemented.
  23886. */
  23887. forceUpdate(): void;
  23888. /**
  23889. * Gets the body that holds this impostor. Either its own, or its parent.
  23890. */
  23891. get physicsBody(): any;
  23892. /**
  23893. * Get the parent of the physics imposter
  23894. * @returns Physics imposter or null
  23895. */
  23896. get parent(): Nullable<PhysicsImpostor>;
  23897. /**
  23898. * Sets the parent of the physics imposter
  23899. */
  23900. set parent(value: Nullable<PhysicsImpostor>);
  23901. /**
  23902. * Set the physics body. Used mainly by the physics engine/plugin
  23903. */
  23904. set physicsBody(physicsBody: any);
  23905. /**
  23906. * Resets the update flags
  23907. */
  23908. resetUpdateFlags(): void;
  23909. /**
  23910. * Gets the object extend size
  23911. * @returns the object extend size
  23912. */
  23913. getObjectExtendSize(): Vector3;
  23914. /**
  23915. * Gets the object center
  23916. * @returns The object center
  23917. */
  23918. getObjectCenter(): Vector3;
  23919. /**
  23920. * Get a specific parameter from the options parameters
  23921. * @param paramName The object parameter name
  23922. * @returns The object parameter
  23923. */
  23924. getParam(paramName: string): any;
  23925. /**
  23926. * Sets a specific parameter in the options given to the physics plugin
  23927. * @param paramName The parameter name
  23928. * @param value The value of the parameter
  23929. */
  23930. setParam(paramName: string, value: number): void;
  23931. /**
  23932. * Specifically change the body's mass option. Won't recreate the physics body object
  23933. * @param mass The mass of the physics imposter
  23934. */
  23935. setMass(mass: number): void;
  23936. /**
  23937. * Gets the linear velocity
  23938. * @returns linear velocity or null
  23939. */
  23940. getLinearVelocity(): Nullable<Vector3>;
  23941. /**
  23942. * Sets the linear velocity
  23943. * @param velocity linear velocity or null
  23944. */
  23945. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23946. /**
  23947. * Gets the angular velocity
  23948. * @returns angular velocity or null
  23949. */
  23950. getAngularVelocity(): Nullable<Vector3>;
  23951. /**
  23952. * Sets the angular velocity
  23953. * @param velocity The velocity or null
  23954. */
  23955. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23956. /**
  23957. * Execute a function with the physics plugin native code
  23958. * Provide a function the will have two variables - the world object and the physics body object
  23959. * @param func The function to execute with the physics plugin native code
  23960. */
  23961. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23962. /**
  23963. * Register a function that will be executed before the physics world is stepping forward
  23964. * @param func The function to execute before the physics world is stepped forward
  23965. */
  23966. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23967. /**
  23968. * Unregister a function that will be executed before the physics world is stepping forward
  23969. * @param func The function to execute before the physics world is stepped forward
  23970. */
  23971. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23972. /**
  23973. * Register a function that will be executed after the physics step
  23974. * @param func The function to execute after physics step
  23975. */
  23976. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23977. /**
  23978. * Unregisters a function that will be executed after the physics step
  23979. * @param func The function to execute after physics step
  23980. */
  23981. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23982. /**
  23983. * register a function that will be executed when this impostor collides against a different body
  23984. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23985. * @param func Callback that is executed on collision
  23986. */
  23987. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23988. /**
  23989. * Unregisters the physics imposter on contact
  23990. * @param collideAgainst The physics object to collide against
  23991. * @param func Callback to execute on collision
  23992. */
  23993. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23994. private _tmpQuat;
  23995. private _tmpQuat2;
  23996. /**
  23997. * Get the parent rotation
  23998. * @returns The parent rotation
  23999. */
  24000. getParentsRotation(): Quaternion;
  24001. /**
  24002. * this function is executed by the physics engine.
  24003. */
  24004. beforeStep: () => void;
  24005. /**
  24006. * this function is executed by the physics engine
  24007. */
  24008. afterStep: () => void;
  24009. /**
  24010. * Legacy collision detection event support
  24011. */
  24012. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24013. /**
  24014. * event and body object due to cannon's event-based architecture.
  24015. */
  24016. onCollide: (e: {
  24017. body: any;
  24018. }) => void;
  24019. /**
  24020. * Apply a force
  24021. * @param force The force to apply
  24022. * @param contactPoint The contact point for the force
  24023. * @returns The physics imposter
  24024. */
  24025. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24026. /**
  24027. * Apply an impulse
  24028. * @param force The impulse force
  24029. * @param contactPoint The contact point for the impulse force
  24030. * @returns The physics imposter
  24031. */
  24032. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24033. /**
  24034. * A help function to create a joint
  24035. * @param otherImpostor A physics imposter used to create a joint
  24036. * @param jointType The type of joint
  24037. * @param jointData The data for the joint
  24038. * @returns The physics imposter
  24039. */
  24040. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24041. /**
  24042. * Add a joint to this impostor with a different impostor
  24043. * @param otherImpostor A physics imposter used to add a joint
  24044. * @param joint The joint to add
  24045. * @returns The physics imposter
  24046. */
  24047. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24048. /**
  24049. * Add an anchor to a cloth impostor
  24050. * @param otherImpostor rigid impostor to anchor to
  24051. * @param width ratio across width from 0 to 1
  24052. * @param height ratio up height from 0 to 1
  24053. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24054. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24055. * @returns impostor the soft imposter
  24056. */
  24057. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24058. /**
  24059. * Add a hook to a rope impostor
  24060. * @param otherImpostor rigid impostor to anchor to
  24061. * @param length ratio across rope from 0 to 1
  24062. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24063. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24064. * @returns impostor the rope imposter
  24065. */
  24066. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24067. /**
  24068. * Will keep this body still, in a sleep mode.
  24069. * @returns the physics imposter
  24070. */
  24071. sleep(): PhysicsImpostor;
  24072. /**
  24073. * Wake the body up.
  24074. * @returns The physics imposter
  24075. */
  24076. wakeUp(): PhysicsImpostor;
  24077. /**
  24078. * Clones the physics imposter
  24079. * @param newObject The physics imposter clones to this physics-enabled object
  24080. * @returns A nullable physics imposter
  24081. */
  24082. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24083. /**
  24084. * Disposes the physics imposter
  24085. */
  24086. dispose(): void;
  24087. /**
  24088. * Sets the delta position
  24089. * @param position The delta position amount
  24090. */
  24091. setDeltaPosition(position: Vector3): void;
  24092. /**
  24093. * Sets the delta rotation
  24094. * @param rotation The delta rotation amount
  24095. */
  24096. setDeltaRotation(rotation: Quaternion): void;
  24097. /**
  24098. * Gets the box size of the physics imposter and stores the result in the input parameter
  24099. * @param result Stores the box size
  24100. * @returns The physics imposter
  24101. */
  24102. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24103. /**
  24104. * Gets the radius of the physics imposter
  24105. * @returns Radius of the physics imposter
  24106. */
  24107. getRadius(): number;
  24108. /**
  24109. * Sync a bone with this impostor
  24110. * @param bone The bone to sync to the impostor.
  24111. * @param boneMesh The mesh that the bone is influencing.
  24112. * @param jointPivot The pivot of the joint / bone in local space.
  24113. * @param distToJoint Optional distance from the impostor to the joint.
  24114. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24115. */
  24116. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24117. /**
  24118. * Sync impostor to a bone
  24119. * @param bone The bone that the impostor will be synced to.
  24120. * @param boneMesh The mesh that the bone is influencing.
  24121. * @param jointPivot The pivot of the joint / bone in local space.
  24122. * @param distToJoint Optional distance from the impostor to the joint.
  24123. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24124. * @param boneAxis Optional vector3 axis the bone is aligned with
  24125. */
  24126. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24127. /**
  24128. * No-Imposter type
  24129. */
  24130. static NoImpostor: number;
  24131. /**
  24132. * Sphere-Imposter type
  24133. */
  24134. static SphereImpostor: number;
  24135. /**
  24136. * Box-Imposter type
  24137. */
  24138. static BoxImpostor: number;
  24139. /**
  24140. * Plane-Imposter type
  24141. */
  24142. static PlaneImpostor: number;
  24143. /**
  24144. * Mesh-imposter type
  24145. */
  24146. static MeshImpostor: number;
  24147. /**
  24148. * Capsule-Impostor type (Ammo.js plugin only)
  24149. */
  24150. static CapsuleImpostor: number;
  24151. /**
  24152. * Cylinder-Imposter type
  24153. */
  24154. static CylinderImpostor: number;
  24155. /**
  24156. * Particle-Imposter type
  24157. */
  24158. static ParticleImpostor: number;
  24159. /**
  24160. * Heightmap-Imposter type
  24161. */
  24162. static HeightmapImpostor: number;
  24163. /**
  24164. * ConvexHull-Impostor type (Ammo.js plugin only)
  24165. */
  24166. static ConvexHullImpostor: number;
  24167. /**
  24168. * Custom-Imposter type (Ammo.js plugin only)
  24169. */
  24170. static CustomImpostor: number;
  24171. /**
  24172. * Rope-Imposter type
  24173. */
  24174. static RopeImpostor: number;
  24175. /**
  24176. * Cloth-Imposter type
  24177. */
  24178. static ClothImpostor: number;
  24179. /**
  24180. * Softbody-Imposter type
  24181. */
  24182. static SoftbodyImpostor: number;
  24183. }
  24184. }
  24185. declare module BABYLON {
  24186. /**
  24187. * @hidden
  24188. **/
  24189. export class _CreationDataStorage {
  24190. closePath?: boolean;
  24191. closeArray?: boolean;
  24192. idx: number[];
  24193. dashSize: number;
  24194. gapSize: number;
  24195. path3D: Path3D;
  24196. pathArray: Vector3[][];
  24197. arc: number;
  24198. radius: number;
  24199. cap: number;
  24200. tessellation: number;
  24201. }
  24202. /**
  24203. * @hidden
  24204. **/
  24205. class _InstanceDataStorage {
  24206. visibleInstances: any;
  24207. batchCache: _InstancesBatch;
  24208. instancesBufferSize: number;
  24209. instancesBuffer: Nullable<Buffer>;
  24210. instancesData: Float32Array;
  24211. overridenInstanceCount: number;
  24212. isFrozen: boolean;
  24213. previousBatch: Nullable<_InstancesBatch>;
  24214. hardwareInstancedRendering: boolean;
  24215. sideOrientation: number;
  24216. manualUpdate: boolean;
  24217. }
  24218. /**
  24219. * @hidden
  24220. **/
  24221. export class _InstancesBatch {
  24222. mustReturn: boolean;
  24223. visibleInstances: Nullable<InstancedMesh[]>[];
  24224. renderSelf: boolean[];
  24225. hardwareInstancedRendering: boolean[];
  24226. }
  24227. /**
  24228. * Class used to represent renderable models
  24229. */
  24230. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24231. /**
  24232. * Mesh side orientation : usually the external or front surface
  24233. */
  24234. static readonly FRONTSIDE: number;
  24235. /**
  24236. * Mesh side orientation : usually the internal or back surface
  24237. */
  24238. static readonly BACKSIDE: number;
  24239. /**
  24240. * Mesh side orientation : both internal and external or front and back surfaces
  24241. */
  24242. static readonly DOUBLESIDE: number;
  24243. /**
  24244. * Mesh side orientation : by default, `FRONTSIDE`
  24245. */
  24246. static readonly DEFAULTSIDE: number;
  24247. /**
  24248. * Mesh cap setting : no cap
  24249. */
  24250. static readonly NO_CAP: number;
  24251. /**
  24252. * Mesh cap setting : one cap at the beginning of the mesh
  24253. */
  24254. static readonly CAP_START: number;
  24255. /**
  24256. * Mesh cap setting : one cap at the end of the mesh
  24257. */
  24258. static readonly CAP_END: number;
  24259. /**
  24260. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24261. */
  24262. static readonly CAP_ALL: number;
  24263. /**
  24264. * Mesh pattern setting : no flip or rotate
  24265. */
  24266. static readonly NO_FLIP: number;
  24267. /**
  24268. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24269. */
  24270. static readonly FLIP_TILE: number;
  24271. /**
  24272. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24273. */
  24274. static readonly ROTATE_TILE: number;
  24275. /**
  24276. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24277. */
  24278. static readonly FLIP_ROW: number;
  24279. /**
  24280. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24281. */
  24282. static readonly ROTATE_ROW: number;
  24283. /**
  24284. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24285. */
  24286. static readonly FLIP_N_ROTATE_TILE: number;
  24287. /**
  24288. * Mesh pattern setting : rotate pattern and rotate
  24289. */
  24290. static readonly FLIP_N_ROTATE_ROW: number;
  24291. /**
  24292. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24293. */
  24294. static readonly CENTER: number;
  24295. /**
  24296. * Mesh tile positioning : part tiles on left
  24297. */
  24298. static readonly LEFT: number;
  24299. /**
  24300. * Mesh tile positioning : part tiles on right
  24301. */
  24302. static readonly RIGHT: number;
  24303. /**
  24304. * Mesh tile positioning : part tiles on top
  24305. */
  24306. static readonly TOP: number;
  24307. /**
  24308. * Mesh tile positioning : part tiles on bottom
  24309. */
  24310. static readonly BOTTOM: number;
  24311. /**
  24312. * Gets the default side orientation.
  24313. * @param orientation the orientation to value to attempt to get
  24314. * @returns the default orientation
  24315. * @hidden
  24316. */
  24317. static _GetDefaultSideOrientation(orientation?: number): number;
  24318. private _internalMeshDataInfo;
  24319. /**
  24320. * An event triggered before rendering the mesh
  24321. */
  24322. get onBeforeRenderObservable(): Observable<Mesh>;
  24323. /**
  24324. * An event triggered before binding the mesh
  24325. */
  24326. get onBeforeBindObservable(): Observable<Mesh>;
  24327. /**
  24328. * An event triggered after rendering the mesh
  24329. */
  24330. get onAfterRenderObservable(): Observable<Mesh>;
  24331. /**
  24332. * An event triggered before drawing the mesh
  24333. */
  24334. get onBeforeDrawObservable(): Observable<Mesh>;
  24335. private _onBeforeDrawObserver;
  24336. /**
  24337. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24338. */
  24339. set onBeforeDraw(callback: () => void);
  24340. get hasInstances(): boolean;
  24341. /**
  24342. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24343. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24344. */
  24345. delayLoadState: number;
  24346. /**
  24347. * Gets the list of instances created from this mesh
  24348. * it is not supposed to be modified manually.
  24349. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24350. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24351. */
  24352. instances: InstancedMesh[];
  24353. /**
  24354. * Gets the file containing delay loading data for this mesh
  24355. */
  24356. delayLoadingFile: string;
  24357. /** @hidden */
  24358. _binaryInfo: any;
  24359. /**
  24360. * User defined function used to change how LOD level selection is done
  24361. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24362. */
  24363. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24364. /**
  24365. * Gets or sets the morph target manager
  24366. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24367. */
  24368. get morphTargetManager(): Nullable<MorphTargetManager>;
  24369. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24370. /** @hidden */
  24371. _creationDataStorage: Nullable<_CreationDataStorage>;
  24372. /** @hidden */
  24373. _geometry: Nullable<Geometry>;
  24374. /** @hidden */
  24375. _delayInfo: Array<string>;
  24376. /** @hidden */
  24377. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24378. /** @hidden */
  24379. _instanceDataStorage: _InstanceDataStorage;
  24380. private _effectiveMaterial;
  24381. /** @hidden */
  24382. _shouldGenerateFlatShading: boolean;
  24383. /** @hidden */
  24384. _originalBuilderSideOrientation: number;
  24385. /**
  24386. * Use this property to change the original side orientation defined at construction time
  24387. */
  24388. overrideMaterialSideOrientation: Nullable<number>;
  24389. /**
  24390. * Gets the source mesh (the one used to clone this one from)
  24391. */
  24392. get source(): Nullable<Mesh>;
  24393. /**
  24394. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24395. */
  24396. get isUnIndexed(): boolean;
  24397. set isUnIndexed(value: boolean);
  24398. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24399. get worldMatrixInstancedBuffer(): Float32Array;
  24400. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24401. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24402. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24403. /**
  24404. * @constructor
  24405. * @param name The value used by scene.getMeshByName() to do a lookup.
  24406. * @param scene The scene to add this mesh to.
  24407. * @param parent The parent of this mesh, if it has one
  24408. * @param source An optional Mesh from which geometry is shared, cloned.
  24409. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24410. * When false, achieved by calling a clone(), also passing False.
  24411. * This will make creation of children, recursive.
  24412. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24413. */
  24414. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24415. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24416. doNotInstantiate: boolean;
  24417. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24418. /**
  24419. * Gets the class name
  24420. * @returns the string "Mesh".
  24421. */
  24422. getClassName(): string;
  24423. /** @hidden */
  24424. get _isMesh(): boolean;
  24425. /**
  24426. * Returns a description of this mesh
  24427. * @param fullDetails define if full details about this mesh must be used
  24428. * @returns a descriptive string representing this mesh
  24429. */
  24430. toString(fullDetails?: boolean): string;
  24431. /** @hidden */
  24432. _unBindEffect(): void;
  24433. /**
  24434. * Gets a boolean indicating if this mesh has LOD
  24435. */
  24436. get hasLODLevels(): boolean;
  24437. /**
  24438. * Gets the list of MeshLODLevel associated with the current mesh
  24439. * @returns an array of MeshLODLevel
  24440. */
  24441. getLODLevels(): MeshLODLevel[];
  24442. private _sortLODLevels;
  24443. /**
  24444. * Add a mesh as LOD level triggered at the given distance.
  24445. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24446. * @param distance The distance from the center of the object to show this level
  24447. * @param mesh The mesh to be added as LOD level (can be null)
  24448. * @return This mesh (for chaining)
  24449. */
  24450. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24451. /**
  24452. * Returns the LOD level mesh at the passed distance or null if not found.
  24453. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24454. * @param distance The distance from the center of the object to show this level
  24455. * @returns a Mesh or `null`
  24456. */
  24457. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24458. /**
  24459. * Remove a mesh from the LOD array
  24460. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24461. * @param mesh defines the mesh to be removed
  24462. * @return This mesh (for chaining)
  24463. */
  24464. removeLODLevel(mesh: Mesh): Mesh;
  24465. /**
  24466. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24467. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24468. * @param camera defines the camera to use to compute distance
  24469. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24470. * @return This mesh (for chaining)
  24471. */
  24472. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24473. /**
  24474. * Gets the mesh internal Geometry object
  24475. */
  24476. get geometry(): Nullable<Geometry>;
  24477. /**
  24478. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24479. * @returns the total number of vertices
  24480. */
  24481. getTotalVertices(): number;
  24482. /**
  24483. * Returns the content of an associated vertex buffer
  24484. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24485. * - VertexBuffer.PositionKind
  24486. * - VertexBuffer.UVKind
  24487. * - VertexBuffer.UV2Kind
  24488. * - VertexBuffer.UV3Kind
  24489. * - VertexBuffer.UV4Kind
  24490. * - VertexBuffer.UV5Kind
  24491. * - VertexBuffer.UV6Kind
  24492. * - VertexBuffer.ColorKind
  24493. * - VertexBuffer.MatricesIndicesKind
  24494. * - VertexBuffer.MatricesIndicesExtraKind
  24495. * - VertexBuffer.MatricesWeightsKind
  24496. * - VertexBuffer.MatricesWeightsExtraKind
  24497. * @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
  24498. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24499. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24500. */
  24501. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24502. /**
  24503. * Returns the mesh VertexBuffer object from the requested `kind`
  24504. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24505. * - VertexBuffer.PositionKind
  24506. * - VertexBuffer.NormalKind
  24507. * - VertexBuffer.UVKind
  24508. * - VertexBuffer.UV2Kind
  24509. * - VertexBuffer.UV3Kind
  24510. * - VertexBuffer.UV4Kind
  24511. * - VertexBuffer.UV5Kind
  24512. * - VertexBuffer.UV6Kind
  24513. * - VertexBuffer.ColorKind
  24514. * - VertexBuffer.MatricesIndicesKind
  24515. * - VertexBuffer.MatricesIndicesExtraKind
  24516. * - VertexBuffer.MatricesWeightsKind
  24517. * - VertexBuffer.MatricesWeightsExtraKind
  24518. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24519. */
  24520. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24521. /**
  24522. * Tests if a specific vertex buffer is associated with this mesh
  24523. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24524. * - VertexBuffer.PositionKind
  24525. * - VertexBuffer.NormalKind
  24526. * - VertexBuffer.UVKind
  24527. * - VertexBuffer.UV2Kind
  24528. * - VertexBuffer.UV3Kind
  24529. * - VertexBuffer.UV4Kind
  24530. * - VertexBuffer.UV5Kind
  24531. * - VertexBuffer.UV6Kind
  24532. * - VertexBuffer.ColorKind
  24533. * - VertexBuffer.MatricesIndicesKind
  24534. * - VertexBuffer.MatricesIndicesExtraKind
  24535. * - VertexBuffer.MatricesWeightsKind
  24536. * - VertexBuffer.MatricesWeightsExtraKind
  24537. * @returns a boolean
  24538. */
  24539. isVerticesDataPresent(kind: string): boolean;
  24540. /**
  24541. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24542. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24543. * - VertexBuffer.PositionKind
  24544. * - VertexBuffer.UVKind
  24545. * - VertexBuffer.UV2Kind
  24546. * - VertexBuffer.UV3Kind
  24547. * - VertexBuffer.UV4Kind
  24548. * - VertexBuffer.UV5Kind
  24549. * - VertexBuffer.UV6Kind
  24550. * - VertexBuffer.ColorKind
  24551. * - VertexBuffer.MatricesIndicesKind
  24552. * - VertexBuffer.MatricesIndicesExtraKind
  24553. * - VertexBuffer.MatricesWeightsKind
  24554. * - VertexBuffer.MatricesWeightsExtraKind
  24555. * @returns a boolean
  24556. */
  24557. isVertexBufferUpdatable(kind: string): boolean;
  24558. /**
  24559. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24560. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24561. * - VertexBuffer.PositionKind
  24562. * - VertexBuffer.NormalKind
  24563. * - VertexBuffer.UVKind
  24564. * - VertexBuffer.UV2Kind
  24565. * - VertexBuffer.UV3Kind
  24566. * - VertexBuffer.UV4Kind
  24567. * - VertexBuffer.UV5Kind
  24568. * - VertexBuffer.UV6Kind
  24569. * - VertexBuffer.ColorKind
  24570. * - VertexBuffer.MatricesIndicesKind
  24571. * - VertexBuffer.MatricesIndicesExtraKind
  24572. * - VertexBuffer.MatricesWeightsKind
  24573. * - VertexBuffer.MatricesWeightsExtraKind
  24574. * @returns an array of strings
  24575. */
  24576. getVerticesDataKinds(): string[];
  24577. /**
  24578. * Returns a positive integer : the total number of indices in this mesh geometry.
  24579. * @returns the numner of indices or zero if the mesh has no geometry.
  24580. */
  24581. getTotalIndices(): number;
  24582. /**
  24583. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24584. * @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.
  24585. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24586. * @returns the indices array or an empty array if the mesh has no geometry
  24587. */
  24588. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24589. get isBlocked(): boolean;
  24590. /**
  24591. * Determine if the current mesh is ready to be rendered
  24592. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24593. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24594. * @returns true if all associated assets are ready (material, textures, shaders)
  24595. */
  24596. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24597. /**
  24598. * 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.
  24599. */
  24600. get areNormalsFrozen(): boolean;
  24601. /**
  24602. * 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.
  24603. * @returns the current mesh
  24604. */
  24605. freezeNormals(): Mesh;
  24606. /**
  24607. * 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
  24608. * @returns the current mesh
  24609. */
  24610. unfreezeNormals(): Mesh;
  24611. /**
  24612. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24613. */
  24614. set overridenInstanceCount(count: number);
  24615. /** @hidden */
  24616. _preActivate(): Mesh;
  24617. /** @hidden */
  24618. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24619. /** @hidden */
  24620. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24621. /**
  24622. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24623. * This means the mesh underlying bounding box and sphere are recomputed.
  24624. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24625. * @returns the current mesh
  24626. */
  24627. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24628. /** @hidden */
  24629. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24630. /**
  24631. * This function will subdivide the mesh into multiple submeshes
  24632. * @param count defines the expected number of submeshes
  24633. */
  24634. subdivide(count: number): void;
  24635. /**
  24636. * Copy a FloatArray into a specific associated vertex buffer
  24637. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24638. * - VertexBuffer.PositionKind
  24639. * - VertexBuffer.UVKind
  24640. * - VertexBuffer.UV2Kind
  24641. * - VertexBuffer.UV3Kind
  24642. * - VertexBuffer.UV4Kind
  24643. * - VertexBuffer.UV5Kind
  24644. * - VertexBuffer.UV6Kind
  24645. * - VertexBuffer.ColorKind
  24646. * - VertexBuffer.MatricesIndicesKind
  24647. * - VertexBuffer.MatricesIndicesExtraKind
  24648. * - VertexBuffer.MatricesWeightsKind
  24649. * - VertexBuffer.MatricesWeightsExtraKind
  24650. * @param data defines the data source
  24651. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24652. * @param stride defines the data stride size (can be null)
  24653. * @returns the current mesh
  24654. */
  24655. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24656. /**
  24657. * Delete a vertex buffer associated with this mesh
  24658. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24659. * - VertexBuffer.PositionKind
  24660. * - VertexBuffer.UVKind
  24661. * - VertexBuffer.UV2Kind
  24662. * - VertexBuffer.UV3Kind
  24663. * - VertexBuffer.UV4Kind
  24664. * - VertexBuffer.UV5Kind
  24665. * - VertexBuffer.UV6Kind
  24666. * - VertexBuffer.ColorKind
  24667. * - VertexBuffer.MatricesIndicesKind
  24668. * - VertexBuffer.MatricesIndicesExtraKind
  24669. * - VertexBuffer.MatricesWeightsKind
  24670. * - VertexBuffer.MatricesWeightsExtraKind
  24671. */
  24672. removeVerticesData(kind: string): void;
  24673. /**
  24674. * Flags an associated vertex buffer as updatable
  24675. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24676. * - VertexBuffer.PositionKind
  24677. * - VertexBuffer.UVKind
  24678. * - VertexBuffer.UV2Kind
  24679. * - VertexBuffer.UV3Kind
  24680. * - VertexBuffer.UV4Kind
  24681. * - VertexBuffer.UV5Kind
  24682. * - VertexBuffer.UV6Kind
  24683. * - VertexBuffer.ColorKind
  24684. * - VertexBuffer.MatricesIndicesKind
  24685. * - VertexBuffer.MatricesIndicesExtraKind
  24686. * - VertexBuffer.MatricesWeightsKind
  24687. * - VertexBuffer.MatricesWeightsExtraKind
  24688. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24689. */
  24690. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24691. /**
  24692. * Sets the mesh global Vertex Buffer
  24693. * @param buffer defines the buffer to use
  24694. * @returns the current mesh
  24695. */
  24696. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24697. /**
  24698. * Update a specific associated vertex buffer
  24699. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24700. * - VertexBuffer.PositionKind
  24701. * - VertexBuffer.UVKind
  24702. * - VertexBuffer.UV2Kind
  24703. * - VertexBuffer.UV3Kind
  24704. * - VertexBuffer.UV4Kind
  24705. * - VertexBuffer.UV5Kind
  24706. * - VertexBuffer.UV6Kind
  24707. * - VertexBuffer.ColorKind
  24708. * - VertexBuffer.MatricesIndicesKind
  24709. * - VertexBuffer.MatricesIndicesExtraKind
  24710. * - VertexBuffer.MatricesWeightsKind
  24711. * - VertexBuffer.MatricesWeightsExtraKind
  24712. * @param data defines the data source
  24713. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24714. * @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)
  24715. * @returns the current mesh
  24716. */
  24717. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24718. /**
  24719. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24720. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24721. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24722. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24723. * @returns the current mesh
  24724. */
  24725. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24726. /**
  24727. * Creates a un-shared specific occurence of the geometry for the mesh.
  24728. * @returns the current mesh
  24729. */
  24730. makeGeometryUnique(): Mesh;
  24731. /**
  24732. * Set the index buffer of this mesh
  24733. * @param indices defines the source data
  24734. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24735. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24736. * @returns the current mesh
  24737. */
  24738. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24739. /**
  24740. * Update the current index buffer
  24741. * @param indices defines the source data
  24742. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24743. * @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)
  24744. * @returns the current mesh
  24745. */
  24746. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24747. /**
  24748. * Invert the geometry to move from a right handed system to a left handed one.
  24749. * @returns the current mesh
  24750. */
  24751. toLeftHanded(): Mesh;
  24752. /** @hidden */
  24753. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24754. /** @hidden */
  24755. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24756. /**
  24757. * Registers for this mesh a javascript function called just before the rendering process
  24758. * @param func defines the function to call before rendering this mesh
  24759. * @returns the current mesh
  24760. */
  24761. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24762. /**
  24763. * Disposes a previously registered javascript function called before the rendering
  24764. * @param func defines the function to remove
  24765. * @returns the current mesh
  24766. */
  24767. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24768. /**
  24769. * Registers for this mesh a javascript function called just after the rendering is complete
  24770. * @param func defines the function to call after rendering this mesh
  24771. * @returns the current mesh
  24772. */
  24773. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24774. /**
  24775. * Disposes a previously registered javascript function called after the rendering.
  24776. * @param func defines the function to remove
  24777. * @returns the current mesh
  24778. */
  24779. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24780. /** @hidden */
  24781. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24782. /** @hidden */
  24783. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24784. /** @hidden */
  24785. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24786. /** @hidden */
  24787. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24788. /** @hidden */
  24789. _rebuild(): void;
  24790. /** @hidden */
  24791. _freeze(): void;
  24792. /** @hidden */
  24793. _unFreeze(): void;
  24794. /**
  24795. * 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
  24796. * @param subMesh defines the subMesh to render
  24797. * @param enableAlphaMode defines if alpha mode can be changed
  24798. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24799. * @returns the current mesh
  24800. */
  24801. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24802. private _onBeforeDraw;
  24803. /**
  24804. * Renormalize the mesh and patch it up if there are no weights
  24805. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24806. * However in the case of zero weights then we set just a single influence to 1.
  24807. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24808. */
  24809. cleanMatrixWeights(): void;
  24810. private normalizeSkinFourWeights;
  24811. private normalizeSkinWeightsAndExtra;
  24812. /**
  24813. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24814. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24815. * the user know there was an issue with importing the mesh
  24816. * @returns a validation object with skinned, valid and report string
  24817. */
  24818. validateSkinning(): {
  24819. skinned: boolean;
  24820. valid: boolean;
  24821. report: string;
  24822. };
  24823. /** @hidden */
  24824. _checkDelayState(): Mesh;
  24825. private _queueLoad;
  24826. /**
  24827. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24828. * A mesh is in the frustum if its bounding box intersects the frustum
  24829. * @param frustumPlanes defines the frustum to test
  24830. * @returns true if the mesh is in the frustum planes
  24831. */
  24832. isInFrustum(frustumPlanes: Plane[]): boolean;
  24833. /**
  24834. * Sets the mesh material by the material or multiMaterial `id` property
  24835. * @param id is a string identifying the material or the multiMaterial
  24836. * @returns the current mesh
  24837. */
  24838. setMaterialByID(id: string): Mesh;
  24839. /**
  24840. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24841. * @returns an array of IAnimatable
  24842. */
  24843. getAnimatables(): IAnimatable[];
  24844. /**
  24845. * Modifies the mesh geometry according to the passed transformation matrix.
  24846. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24847. * The mesh normals are modified using the same transformation.
  24848. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24849. * @param transform defines the transform matrix to use
  24850. * @see http://doc.babylonjs.com/resources/baking_transformations
  24851. * @returns the current mesh
  24852. */
  24853. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24854. /**
  24855. * Modifies the mesh geometry according to its own current World Matrix.
  24856. * The mesh World Matrix is then reset.
  24857. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24858. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24859. * @see http://doc.babylonjs.com/resources/baking_transformations
  24860. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24861. * @returns the current mesh
  24862. */
  24863. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24864. /** @hidden */
  24865. get _positions(): Nullable<Vector3[]>;
  24866. /** @hidden */
  24867. _resetPointsArrayCache(): Mesh;
  24868. /** @hidden */
  24869. _generatePointsArray(): boolean;
  24870. /**
  24871. * Returns a new Mesh object generated from the current mesh properties.
  24872. * This method must not get confused with createInstance()
  24873. * @param name is a string, the name given to the new mesh
  24874. * @param newParent can be any Node object (default `null`)
  24875. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24876. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24877. * @returns a new mesh
  24878. */
  24879. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24880. /**
  24881. * Releases resources associated with this mesh.
  24882. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24883. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24884. */
  24885. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24886. /** @hidden */
  24887. _disposeInstanceSpecificData(): void;
  24888. /**
  24889. * Modifies the mesh geometry according to a displacement map.
  24890. * 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.
  24891. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24892. * @param url is a string, the URL from the image file is to be downloaded.
  24893. * @param minHeight is the lower limit of the displacement.
  24894. * @param maxHeight is the upper limit of the displacement.
  24895. * @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.
  24896. * @param uvOffset is an optional vector2 used to offset UV.
  24897. * @param uvScale is an optional vector2 used to scale UV.
  24898. * @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.
  24899. * @returns the Mesh.
  24900. */
  24901. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24902. /**
  24903. * Modifies the mesh geometry according to a displacementMap buffer.
  24904. * 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.
  24905. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24906. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24907. * @param heightMapWidth is the width of the buffer image.
  24908. * @param heightMapHeight is the height of the buffer image.
  24909. * @param minHeight is the lower limit of the displacement.
  24910. * @param maxHeight is the upper limit of the displacement.
  24911. * @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.
  24912. * @param uvOffset is an optional vector2 used to offset UV.
  24913. * @param uvScale is an optional vector2 used to scale UV.
  24914. * @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.
  24915. * @returns the Mesh.
  24916. */
  24917. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24918. /**
  24919. * Modify the mesh to get a flat shading rendering.
  24920. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24921. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24922. * @returns current mesh
  24923. */
  24924. convertToFlatShadedMesh(): Mesh;
  24925. /**
  24926. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24927. * In other words, more vertices, no more indices and a single bigger VBO.
  24928. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24929. * @returns current mesh
  24930. */
  24931. convertToUnIndexedMesh(): Mesh;
  24932. /**
  24933. * Inverses facet orientations.
  24934. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24935. * @param flipNormals will also inverts the normals
  24936. * @returns current mesh
  24937. */
  24938. flipFaces(flipNormals?: boolean): Mesh;
  24939. /**
  24940. * Increase the number of facets and hence vertices in a mesh
  24941. * Vertex normals are interpolated from existing vertex normals
  24942. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24943. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24944. */
  24945. increaseVertices(numberPerEdge: number): void;
  24946. /**
  24947. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24948. * This will undo any application of covertToFlatShadedMesh
  24949. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24950. */
  24951. forceSharedVertices(): void;
  24952. /** @hidden */
  24953. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24954. /** @hidden */
  24955. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24956. /**
  24957. * Creates a new InstancedMesh object from the mesh model.
  24958. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24959. * @param name defines the name of the new instance
  24960. * @returns a new InstancedMesh
  24961. */
  24962. createInstance(name: string): InstancedMesh;
  24963. /**
  24964. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24965. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24966. * @returns the current mesh
  24967. */
  24968. synchronizeInstances(): Mesh;
  24969. /**
  24970. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24971. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24972. * This should be used together with the simplification to avoid disappearing triangles.
  24973. * @param successCallback an optional success callback to be called after the optimization finished.
  24974. * @returns the current mesh
  24975. */
  24976. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24977. /**
  24978. * Serialize current mesh
  24979. * @param serializationObject defines the object which will receive the serialization data
  24980. */
  24981. serialize(serializationObject: any): void;
  24982. /** @hidden */
  24983. _syncGeometryWithMorphTargetManager(): void;
  24984. /** @hidden */
  24985. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24986. /**
  24987. * Returns a new Mesh object parsed from the source provided.
  24988. * @param parsedMesh is the source
  24989. * @param scene defines the hosting scene
  24990. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24991. * @returns a new Mesh
  24992. */
  24993. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24994. /**
  24995. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24996. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24997. * @param name defines the name of the mesh to create
  24998. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24999. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25000. * @param closePath creates a seam between the first and the last points of each path of the path array
  25001. * @param offset is taken in account only if the `pathArray` is containing a single path
  25002. * @param scene defines the hosting scene
  25003. * @param updatable defines if the mesh must be flagged as updatable
  25004. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25005. * @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)
  25006. * @returns a new Mesh
  25007. */
  25008. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25009. /**
  25010. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25011. * @param name defines the name of the mesh to create
  25012. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25013. * @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
  25014. * @param scene defines the hosting scene
  25015. * @param updatable defines if the mesh must be flagged as updatable
  25016. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25017. * @returns a new Mesh
  25018. */
  25019. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25020. /**
  25021. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25022. * @param name defines the name of the mesh to create
  25023. * @param size sets the size (float) of each box side (default 1)
  25024. * @param scene defines the hosting scene
  25025. * @param updatable defines if the mesh must be flagged as updatable
  25026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25027. * @returns a new Mesh
  25028. */
  25029. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25030. /**
  25031. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25032. * @param name defines the name of the mesh to create
  25033. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25034. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25035. * @param scene defines the hosting scene
  25036. * @param updatable defines if the mesh must be flagged as updatable
  25037. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25038. * @returns a new Mesh
  25039. */
  25040. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25041. /**
  25042. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25043. * @param name defines the name of the mesh to create
  25044. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25045. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25046. * @param scene defines the hosting scene
  25047. * @returns a new Mesh
  25048. */
  25049. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25050. /**
  25051. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25052. * @param name defines the name of the mesh to create
  25053. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25054. * @param diameterTop set the top cap diameter (floats, default 1)
  25055. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25056. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25057. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25058. * @param scene defines the hosting scene
  25059. * @param updatable defines if the mesh must be flagged as updatable
  25060. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25061. * @returns a new Mesh
  25062. */
  25063. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25064. /**
  25065. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25066. * @param name defines the name of the mesh to create
  25067. * @param diameter sets the diameter size (float) of the torus (default 1)
  25068. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25069. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25070. * @param scene defines the hosting scene
  25071. * @param updatable defines if the mesh must be flagged as updatable
  25072. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25073. * @returns a new Mesh
  25074. */
  25075. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25076. /**
  25077. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25078. * @param name defines the name of the mesh to create
  25079. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25080. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25081. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25082. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25083. * @param p the number of windings on X axis (positive integers, default 2)
  25084. * @param q the number of windings on Y axis (positive integers, default 3)
  25085. * @param scene defines the hosting scene
  25086. * @param updatable defines if the mesh must be flagged as updatable
  25087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25088. * @returns a new Mesh
  25089. */
  25090. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25091. /**
  25092. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25093. * @param name defines the name of the mesh to create
  25094. * @param points is an array successive Vector3
  25095. * @param scene defines the hosting scene
  25096. * @param updatable defines if the mesh must be flagged as updatable
  25097. * @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).
  25098. * @returns a new Mesh
  25099. */
  25100. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25101. /**
  25102. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25103. * @param name defines the name of the mesh to create
  25104. * @param points is an array successive Vector3
  25105. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25106. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25107. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25108. * @param scene defines the hosting scene
  25109. * @param updatable defines if the mesh must be flagged as updatable
  25110. * @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)
  25111. * @returns a new Mesh
  25112. */
  25113. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25114. /**
  25115. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25116. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25117. * 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.
  25118. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25119. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25120. * Remember you can only change the shape positions, not their number when updating a polygon.
  25121. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25122. * @param name defines the name of the mesh to create
  25123. * @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
  25124. * @param scene defines the hosting scene
  25125. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25126. * @param updatable defines if the mesh must be flagged as updatable
  25127. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25128. * @param earcutInjection can be used to inject your own earcut reference
  25129. * @returns a new Mesh
  25130. */
  25131. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25132. /**
  25133. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25134. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25135. * @param name defines the name of the mesh to create
  25136. * @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
  25137. * @param depth defines the height of extrusion
  25138. * @param scene defines the hosting scene
  25139. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25140. * @param updatable defines if the mesh must be flagged as updatable
  25141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25142. * @param earcutInjection can be used to inject your own earcut reference
  25143. * @returns a new Mesh
  25144. */
  25145. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25146. /**
  25147. * Creates an extruded shape mesh.
  25148. * 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
  25149. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25150. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25151. * @param name defines the name of the mesh to create
  25152. * @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
  25153. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25154. * @param scale is the value to scale the shape
  25155. * @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
  25156. * @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
  25157. * @param scene defines the hosting scene
  25158. * @param updatable defines if the mesh must be flagged as updatable
  25159. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25160. * @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)
  25161. * @returns a new Mesh
  25162. */
  25163. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25164. /**
  25165. * Creates an custom extruded shape mesh.
  25166. * The custom extrusion is a parametric shape.
  25167. * It has no predefined shape. Its final shape will depend on the input parameters.
  25168. * Please consider using the same method from the MeshBuilder class instead
  25169. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25170. * @param name defines the name of the mesh to create
  25171. * @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
  25172. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25173. * @param scaleFunction is a custom Javascript function called on each path point
  25174. * @param rotationFunction is a custom Javascript function called on each path point
  25175. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25176. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25177. * @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
  25178. * @param scene defines the hosting scene
  25179. * @param updatable defines if the mesh must be flagged as updatable
  25180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25181. * @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)
  25182. * @returns a new Mesh
  25183. */
  25184. 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;
  25185. /**
  25186. * Creates lathe mesh.
  25187. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25188. * Please consider using the same method from the MeshBuilder class instead
  25189. * @param name defines the name of the mesh to create
  25190. * @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
  25191. * @param radius is the radius value of the lathe
  25192. * @param tessellation is the side number of the lathe.
  25193. * @param scene defines the hosting scene
  25194. * @param updatable defines if the mesh must be flagged as updatable
  25195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25196. * @returns a new Mesh
  25197. */
  25198. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25199. /**
  25200. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25201. * @param name defines the name of the mesh to create
  25202. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25203. * @param scene defines the hosting scene
  25204. * @param updatable defines if the mesh must be flagged as updatable
  25205. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25206. * @returns a new Mesh
  25207. */
  25208. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25209. /**
  25210. * Creates a ground mesh.
  25211. * Please consider using the same method from the MeshBuilder class instead
  25212. * @param name defines the name of the mesh to create
  25213. * @param width set the width of the ground
  25214. * @param height set the height of the ground
  25215. * @param subdivisions sets the number of subdivisions per side
  25216. * @param scene defines the hosting scene
  25217. * @param updatable defines if the mesh must be flagged as updatable
  25218. * @returns a new Mesh
  25219. */
  25220. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25221. /**
  25222. * Creates a tiled ground mesh.
  25223. * Please consider using the same method from the MeshBuilder class instead
  25224. * @param name defines the name of the mesh to create
  25225. * @param xmin set the ground minimum X coordinate
  25226. * @param zmin set the ground minimum Y coordinate
  25227. * @param xmax set the ground maximum X coordinate
  25228. * @param zmax set the ground maximum Z coordinate
  25229. * @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
  25230. * @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
  25231. * @param scene defines the hosting scene
  25232. * @param updatable defines if the mesh must be flagged as updatable
  25233. * @returns a new Mesh
  25234. */
  25235. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25236. w: number;
  25237. h: number;
  25238. }, precision: {
  25239. w: number;
  25240. h: number;
  25241. }, scene: Scene, updatable?: boolean): Mesh;
  25242. /**
  25243. * Creates a ground mesh from a height map.
  25244. * Please consider using the same method from the MeshBuilder class instead
  25245. * @see http://doc.babylonjs.com/babylon101/height_map
  25246. * @param name defines the name of the mesh to create
  25247. * @param url sets the URL of the height map image resource
  25248. * @param width set the ground width size
  25249. * @param height set the ground height size
  25250. * @param subdivisions sets the number of subdivision per side
  25251. * @param minHeight is the minimum altitude on the ground
  25252. * @param maxHeight is the maximum altitude on the ground
  25253. * @param scene defines the hosting scene
  25254. * @param updatable defines if the mesh must be flagged as updatable
  25255. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25256. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25257. * @returns a new Mesh
  25258. */
  25259. 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;
  25260. /**
  25261. * Creates a tube mesh.
  25262. * The tube is a parametric shape.
  25263. * It has no predefined shape. Its final shape will depend on the input parameters.
  25264. * Please consider using the same method from the MeshBuilder class instead
  25265. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25266. * @param name defines the name of the mesh to create
  25267. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25268. * @param radius sets the tube radius size
  25269. * @param tessellation is the number of sides on the tubular surface
  25270. * @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
  25271. * @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
  25272. * @param scene defines the hosting scene
  25273. * @param updatable defines if the mesh must be flagged as updatable
  25274. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25275. * @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)
  25276. * @returns a new Mesh
  25277. */
  25278. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25279. (i: number, distance: number): number;
  25280. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25281. /**
  25282. * Creates a polyhedron mesh.
  25283. * Please consider using the same method from the MeshBuilder class instead.
  25284. * * 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
  25285. * * The parameter `size` (positive float, default 1) sets the polygon size
  25286. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25287. * * 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`
  25288. * * 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
  25289. * * 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)`)
  25290. * * 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
  25291. * * 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
  25292. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25293. * * 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
  25294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25295. * @param name defines the name of the mesh to create
  25296. * @param options defines the options used to create the mesh
  25297. * @param scene defines the hosting scene
  25298. * @returns a new Mesh
  25299. */
  25300. static CreatePolyhedron(name: string, options: {
  25301. type?: number;
  25302. size?: number;
  25303. sizeX?: number;
  25304. sizeY?: number;
  25305. sizeZ?: number;
  25306. custom?: any;
  25307. faceUV?: Vector4[];
  25308. faceColors?: Color4[];
  25309. updatable?: boolean;
  25310. sideOrientation?: number;
  25311. }, scene: Scene): Mesh;
  25312. /**
  25313. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25314. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25315. * * 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`)
  25316. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25317. * * 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
  25318. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25319. * * 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
  25320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25321. * @param name defines the name of the mesh
  25322. * @param options defines the options used to create the mesh
  25323. * @param scene defines the hosting scene
  25324. * @returns a new Mesh
  25325. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25326. */
  25327. static CreateIcoSphere(name: string, options: {
  25328. radius?: number;
  25329. flat?: boolean;
  25330. subdivisions?: number;
  25331. sideOrientation?: number;
  25332. updatable?: boolean;
  25333. }, scene: Scene): Mesh;
  25334. /**
  25335. * Creates a decal mesh.
  25336. * Please consider using the same method from the MeshBuilder class instead.
  25337. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25338. * @param name defines the name of the mesh
  25339. * @param sourceMesh defines the mesh receiving the decal
  25340. * @param position sets the position of the decal in world coordinates
  25341. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25342. * @param size sets the decal scaling
  25343. * @param angle sets the angle to rotate the decal
  25344. * @returns a new Mesh
  25345. */
  25346. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25347. /**
  25348. * Prepare internal position array for software CPU skinning
  25349. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25350. */
  25351. setPositionsForCPUSkinning(): Float32Array;
  25352. /**
  25353. * Prepare internal normal array for software CPU skinning
  25354. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25355. */
  25356. setNormalsForCPUSkinning(): Float32Array;
  25357. /**
  25358. * Updates the vertex buffer by applying transformation from the bones
  25359. * @param skeleton defines the skeleton to apply to current mesh
  25360. * @returns the current mesh
  25361. */
  25362. applySkeleton(skeleton: Skeleton): Mesh;
  25363. /**
  25364. * 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
  25365. * @param meshes defines the list of meshes to scan
  25366. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25367. */
  25368. static MinMax(meshes: AbstractMesh[]): {
  25369. min: Vector3;
  25370. max: Vector3;
  25371. };
  25372. /**
  25373. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25374. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25375. * @returns a vector3
  25376. */
  25377. static Center(meshesOrMinMaxVector: {
  25378. min: Vector3;
  25379. max: Vector3;
  25380. } | AbstractMesh[]): Vector3;
  25381. /**
  25382. * Merge the array of meshes into a single mesh for performance reasons.
  25383. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25384. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25385. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25386. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25387. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25388. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25389. * @returns a new mesh
  25390. */
  25391. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25392. /** @hidden */
  25393. addInstance(instance: InstancedMesh): void;
  25394. /** @hidden */
  25395. removeInstance(instance: InstancedMesh): void;
  25396. }
  25397. }
  25398. declare module BABYLON {
  25399. /**
  25400. * This is the base class of all the camera used in the application.
  25401. * @see http://doc.babylonjs.com/features/cameras
  25402. */
  25403. export class Camera extends Node {
  25404. /** @hidden */
  25405. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25406. /**
  25407. * This is the default projection mode used by the cameras.
  25408. * It helps recreating a feeling of perspective and better appreciate depth.
  25409. * This is the best way to simulate real life cameras.
  25410. */
  25411. static readonly PERSPECTIVE_CAMERA: number;
  25412. /**
  25413. * This helps creating camera with an orthographic mode.
  25414. * 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.
  25415. */
  25416. static readonly ORTHOGRAPHIC_CAMERA: number;
  25417. /**
  25418. * This is the default FOV mode for perspective cameras.
  25419. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25420. */
  25421. static readonly FOVMODE_VERTICAL_FIXED: number;
  25422. /**
  25423. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25424. */
  25425. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25426. /**
  25427. * This specifies ther is no need for a camera rig.
  25428. * Basically only one eye is rendered corresponding to the camera.
  25429. */
  25430. static readonly RIG_MODE_NONE: number;
  25431. /**
  25432. * Simulates a camera Rig with one blue eye and one red eye.
  25433. * This can be use with 3d blue and red glasses.
  25434. */
  25435. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25436. /**
  25437. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25438. */
  25439. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25440. /**
  25441. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25442. */
  25443. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25444. /**
  25445. * Defines that both eyes of the camera will be rendered over under each other.
  25446. */
  25447. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25448. /**
  25449. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25450. */
  25451. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25452. /**
  25453. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25454. */
  25455. static readonly RIG_MODE_VR: number;
  25456. /**
  25457. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25458. */
  25459. static readonly RIG_MODE_WEBVR: number;
  25460. /**
  25461. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25462. */
  25463. static readonly RIG_MODE_CUSTOM: number;
  25464. /**
  25465. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25466. */
  25467. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25468. /**
  25469. * Define the input manager associated with the camera.
  25470. */
  25471. inputs: CameraInputsManager<Camera>;
  25472. /** @hidden */
  25473. _position: Vector3;
  25474. /**
  25475. * Define the current local position of the camera in the scene
  25476. */
  25477. get position(): Vector3;
  25478. set position(newPosition: Vector3);
  25479. /**
  25480. * The vector the camera should consider as up.
  25481. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25482. */
  25483. upVector: Vector3;
  25484. /**
  25485. * Define the current limit on the left side for an orthographic camera
  25486. * In scene unit
  25487. */
  25488. orthoLeft: Nullable<number>;
  25489. /**
  25490. * Define the current limit on the right side for an orthographic camera
  25491. * In scene unit
  25492. */
  25493. orthoRight: Nullable<number>;
  25494. /**
  25495. * Define the current limit on the bottom side for an orthographic camera
  25496. * In scene unit
  25497. */
  25498. orthoBottom: Nullable<number>;
  25499. /**
  25500. * Define the current limit on the top side for an orthographic camera
  25501. * In scene unit
  25502. */
  25503. orthoTop: Nullable<number>;
  25504. /**
  25505. * Field Of View is set in Radians. (default is 0.8)
  25506. */
  25507. fov: number;
  25508. /**
  25509. * Define the minimum distance the camera can see from.
  25510. * This is important to note that the depth buffer are not infinite and the closer it starts
  25511. * the more your scene might encounter depth fighting issue.
  25512. */
  25513. minZ: number;
  25514. /**
  25515. * Define the maximum distance the camera can see to.
  25516. * This is important to note that the depth buffer are not infinite and the further it end
  25517. * the more your scene might encounter depth fighting issue.
  25518. */
  25519. maxZ: number;
  25520. /**
  25521. * Define the default inertia of the camera.
  25522. * This helps giving a smooth feeling to the camera movement.
  25523. */
  25524. inertia: number;
  25525. /**
  25526. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25527. */
  25528. mode: number;
  25529. /**
  25530. * Define whether the camera is intermediate.
  25531. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25532. */
  25533. isIntermediate: boolean;
  25534. /**
  25535. * Define the viewport of the camera.
  25536. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25537. */
  25538. viewport: Viewport;
  25539. /**
  25540. * Restricts the camera to viewing objects with the same layerMask.
  25541. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25542. */
  25543. layerMask: number;
  25544. /**
  25545. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25546. */
  25547. fovMode: number;
  25548. /**
  25549. * Rig mode of the camera.
  25550. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25551. * This is normally controlled byt the camera themselves as internal use.
  25552. */
  25553. cameraRigMode: number;
  25554. /**
  25555. * Defines the distance between both "eyes" in case of a RIG
  25556. */
  25557. interaxialDistance: number;
  25558. /**
  25559. * Defines if stereoscopic rendering is done side by side or over under.
  25560. */
  25561. isStereoscopicSideBySide: boolean;
  25562. /**
  25563. * 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
  25564. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25565. * else in the scene. (Eg. security camera)
  25566. *
  25567. * 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)
  25568. */
  25569. customRenderTargets: RenderTargetTexture[];
  25570. /**
  25571. * When set, the camera will render to this render target instead of the default canvas
  25572. *
  25573. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25574. */
  25575. outputRenderTarget: Nullable<RenderTargetTexture>;
  25576. /**
  25577. * Observable triggered when the camera view matrix has changed.
  25578. */
  25579. onViewMatrixChangedObservable: Observable<Camera>;
  25580. /**
  25581. * Observable triggered when the camera Projection matrix has changed.
  25582. */
  25583. onProjectionMatrixChangedObservable: Observable<Camera>;
  25584. /**
  25585. * Observable triggered when the inputs have been processed.
  25586. */
  25587. onAfterCheckInputsObservable: Observable<Camera>;
  25588. /**
  25589. * Observable triggered when reset has been called and applied to the camera.
  25590. */
  25591. onRestoreStateObservable: Observable<Camera>;
  25592. /**
  25593. * Is this camera a part of a rig system?
  25594. */
  25595. isRigCamera: boolean;
  25596. /**
  25597. * If isRigCamera set to true this will be set with the parent camera.
  25598. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25599. */
  25600. rigParent?: Camera;
  25601. /** @hidden */
  25602. _cameraRigParams: any;
  25603. /** @hidden */
  25604. _rigCameras: Camera[];
  25605. /** @hidden */
  25606. _rigPostProcess: Nullable<PostProcess>;
  25607. protected _webvrViewMatrix: Matrix;
  25608. /** @hidden */
  25609. _skipRendering: boolean;
  25610. /** @hidden */
  25611. _projectionMatrix: Matrix;
  25612. /** @hidden */
  25613. _postProcesses: Nullable<PostProcess>[];
  25614. /** @hidden */
  25615. _activeMeshes: SmartArray<AbstractMesh>;
  25616. protected _globalPosition: Vector3;
  25617. /** @hidden */
  25618. _computedViewMatrix: Matrix;
  25619. private _doNotComputeProjectionMatrix;
  25620. private _transformMatrix;
  25621. private _frustumPlanes;
  25622. private _refreshFrustumPlanes;
  25623. private _storedFov;
  25624. private _stateStored;
  25625. /**
  25626. * Instantiates a new camera object.
  25627. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25628. * @see http://doc.babylonjs.com/features/cameras
  25629. * @param name Defines the name of the camera in the scene
  25630. * @param position Defines the position of the camera
  25631. * @param scene Defines the scene the camera belongs too
  25632. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25633. */
  25634. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25635. /**
  25636. * Store current camera state (fov, position, etc..)
  25637. * @returns the camera
  25638. */
  25639. storeState(): Camera;
  25640. /**
  25641. * Restores the camera state values if it has been stored. You must call storeState() first
  25642. */
  25643. protected _restoreStateValues(): boolean;
  25644. /**
  25645. * Restored camera state. You must call storeState() first.
  25646. * @returns true if restored and false otherwise
  25647. */
  25648. restoreState(): boolean;
  25649. /**
  25650. * Gets the class name of the camera.
  25651. * @returns the class name
  25652. */
  25653. getClassName(): string;
  25654. /** @hidden */
  25655. readonly _isCamera: boolean;
  25656. /**
  25657. * Gets a string representation of the camera useful for debug purpose.
  25658. * @param fullDetails Defines that a more verboe level of logging is required
  25659. * @returns the string representation
  25660. */
  25661. toString(fullDetails?: boolean): string;
  25662. /**
  25663. * Gets the current world space position of the camera.
  25664. */
  25665. get globalPosition(): Vector3;
  25666. /**
  25667. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25668. * @returns the active meshe list
  25669. */
  25670. getActiveMeshes(): SmartArray<AbstractMesh>;
  25671. /**
  25672. * Check whether a mesh is part of the current active mesh list of the camera
  25673. * @param mesh Defines the mesh to check
  25674. * @returns true if active, false otherwise
  25675. */
  25676. isActiveMesh(mesh: Mesh): boolean;
  25677. /**
  25678. * Is this camera ready to be used/rendered
  25679. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25680. * @return true if the camera is ready
  25681. */
  25682. isReady(completeCheck?: boolean): boolean;
  25683. /** @hidden */
  25684. _initCache(): void;
  25685. /** @hidden */
  25686. _updateCache(ignoreParentClass?: boolean): void;
  25687. /** @hidden */
  25688. _isSynchronized(): boolean;
  25689. /** @hidden */
  25690. _isSynchronizedViewMatrix(): boolean;
  25691. /** @hidden */
  25692. _isSynchronizedProjectionMatrix(): boolean;
  25693. /**
  25694. * Attach the input controls to a specific dom element to get the input from.
  25695. * @param element Defines the element the controls should be listened from
  25696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25697. */
  25698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25699. /**
  25700. * Detach the current controls from the specified dom element.
  25701. * @param element Defines the element to stop listening the inputs from
  25702. */
  25703. detachControl(element: HTMLElement): void;
  25704. /**
  25705. * Update the camera state according to the different inputs gathered during the frame.
  25706. */
  25707. update(): void;
  25708. /** @hidden */
  25709. _checkInputs(): void;
  25710. /** @hidden */
  25711. get rigCameras(): Camera[];
  25712. /**
  25713. * Gets the post process used by the rig cameras
  25714. */
  25715. get rigPostProcess(): Nullable<PostProcess>;
  25716. /**
  25717. * Internal, gets the first post proces.
  25718. * @returns the first post process to be run on this camera.
  25719. */
  25720. _getFirstPostProcess(): Nullable<PostProcess>;
  25721. private _cascadePostProcessesToRigCams;
  25722. /**
  25723. * Attach a post process to the camera.
  25724. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25725. * @param postProcess The post process to attach to the camera
  25726. * @param insertAt The position of the post process in case several of them are in use in the scene
  25727. * @returns the position the post process has been inserted at
  25728. */
  25729. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25730. /**
  25731. * Detach a post process to the camera.
  25732. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25733. * @param postProcess The post process to detach from the camera
  25734. */
  25735. detachPostProcess(postProcess: PostProcess): void;
  25736. /**
  25737. * Gets the current world matrix of the camera
  25738. */
  25739. getWorldMatrix(): Matrix;
  25740. /** @hidden */
  25741. _getViewMatrix(): Matrix;
  25742. /**
  25743. * Gets the current view matrix of the camera.
  25744. * @param force forces the camera to recompute the matrix without looking at the cached state
  25745. * @returns the view matrix
  25746. */
  25747. getViewMatrix(force?: boolean): Matrix;
  25748. /**
  25749. * Freeze the projection matrix.
  25750. * It will prevent the cache check of the camera projection compute and can speed up perf
  25751. * if no parameter of the camera are meant to change
  25752. * @param projection Defines manually a projection if necessary
  25753. */
  25754. freezeProjectionMatrix(projection?: Matrix): void;
  25755. /**
  25756. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25757. */
  25758. unfreezeProjectionMatrix(): void;
  25759. /**
  25760. * Gets the current projection matrix of the camera.
  25761. * @param force forces the camera to recompute the matrix without looking at the cached state
  25762. * @returns the projection matrix
  25763. */
  25764. getProjectionMatrix(force?: boolean): Matrix;
  25765. /**
  25766. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25767. * @returns a Matrix
  25768. */
  25769. getTransformationMatrix(): Matrix;
  25770. private _updateFrustumPlanes;
  25771. /**
  25772. * Checks if a cullable object (mesh...) is in the camera frustum
  25773. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25774. * @param target The object to check
  25775. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25776. * @returns true if the object is in frustum otherwise false
  25777. */
  25778. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25779. /**
  25780. * Checks if a cullable object (mesh...) is in the camera frustum
  25781. * Unlike isInFrustum this cheks the full bounding box
  25782. * @param target The object to check
  25783. * @returns true if the object is in frustum otherwise false
  25784. */
  25785. isCompletelyInFrustum(target: ICullable): boolean;
  25786. /**
  25787. * Gets a ray in the forward direction from the camera.
  25788. * @param length Defines the length of the ray to create
  25789. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25790. * @param origin Defines the start point of the ray which defaults to the camera position
  25791. * @returns the forward ray
  25792. */
  25793. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25794. /**
  25795. * Releases resources associated with this node.
  25796. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25797. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25798. */
  25799. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25800. /** @hidden */
  25801. _isLeftCamera: boolean;
  25802. /**
  25803. * Gets the left camera of a rig setup in case of Rigged Camera
  25804. */
  25805. get isLeftCamera(): boolean;
  25806. /** @hidden */
  25807. _isRightCamera: boolean;
  25808. /**
  25809. * Gets the right camera of a rig setup in case of Rigged Camera
  25810. */
  25811. get isRightCamera(): boolean;
  25812. /**
  25813. * Gets the left camera of a rig setup in case of Rigged Camera
  25814. */
  25815. get leftCamera(): Nullable<FreeCamera>;
  25816. /**
  25817. * Gets the right camera of a rig setup in case of Rigged Camera
  25818. */
  25819. get rightCamera(): Nullable<FreeCamera>;
  25820. /**
  25821. * Gets the left camera target of a rig setup in case of Rigged Camera
  25822. * @returns the target position
  25823. */
  25824. getLeftTarget(): Nullable<Vector3>;
  25825. /**
  25826. * Gets the right camera target of a rig setup in case of Rigged Camera
  25827. * @returns the target position
  25828. */
  25829. getRightTarget(): Nullable<Vector3>;
  25830. /**
  25831. * @hidden
  25832. */
  25833. setCameraRigMode(mode: number, rigParams: any): void;
  25834. /** @hidden */
  25835. static _setStereoscopicRigMode(camera: Camera): void;
  25836. /** @hidden */
  25837. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25838. /** @hidden */
  25839. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25840. /** @hidden */
  25841. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25842. /** @hidden */
  25843. _getVRProjectionMatrix(): Matrix;
  25844. protected _updateCameraRotationMatrix(): void;
  25845. protected _updateWebVRCameraRotationMatrix(): void;
  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. _getWebVRProjectionMatrix(): Matrix;
  25852. /**
  25853. * This function MUST be overwritten by the different WebVR cameras available.
  25854. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25855. * @hidden
  25856. */
  25857. _getWebVRViewMatrix(): Matrix;
  25858. /** @hidden */
  25859. setCameraRigParameter(name: string, value: any): void;
  25860. /**
  25861. * needs to be overridden by children so sub has required properties to be copied
  25862. * @hidden
  25863. */
  25864. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25865. /**
  25866. * May need to be overridden by children
  25867. * @hidden
  25868. */
  25869. _updateRigCameras(): void;
  25870. /** @hidden */
  25871. _setupInputs(): void;
  25872. /**
  25873. * Serialiaze the camera setup to a json represention
  25874. * @returns the JSON representation
  25875. */
  25876. serialize(): any;
  25877. /**
  25878. * Clones the current camera.
  25879. * @param name The cloned camera name
  25880. * @returns the cloned camera
  25881. */
  25882. clone(name: string): Camera;
  25883. /**
  25884. * Gets the direction of the camera relative to a given local axis.
  25885. * @param localAxis Defines the reference axis to provide a relative direction.
  25886. * @return the direction
  25887. */
  25888. getDirection(localAxis: Vector3): Vector3;
  25889. /**
  25890. * Returns the current camera absolute rotation
  25891. */
  25892. get absoluteRotation(): Quaternion;
  25893. /**
  25894. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25895. * @param localAxis Defines the reference axis to provide a relative direction.
  25896. * @param result Defines the vector to store the result in
  25897. */
  25898. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25899. /**
  25900. * Gets a camera constructor for a given camera type
  25901. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25902. * @param name The name of the camera the result will be able to instantiate
  25903. * @param scene The scene the result will construct the camera in
  25904. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25905. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25906. * @returns a factory method to construc the camera
  25907. */
  25908. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25909. /**
  25910. * Compute the world matrix of the camera.
  25911. * @returns the camera world matrix
  25912. */
  25913. computeWorldMatrix(): Matrix;
  25914. /**
  25915. * Parse a JSON and creates the camera from the parsed information
  25916. * @param parsedCamera The JSON to parse
  25917. * @param scene The scene to instantiate the camera in
  25918. * @returns the newly constructed camera
  25919. */
  25920. static Parse(parsedCamera: any, scene: Scene): Camera;
  25921. }
  25922. }
  25923. declare module BABYLON {
  25924. /**
  25925. * Class containing static functions to help procedurally build meshes
  25926. */
  25927. export class DiscBuilder {
  25928. /**
  25929. * Creates a plane polygonal mesh. By default, this is a disc
  25930. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25931. * * 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
  25932. * * 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
  25933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25934. * * 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
  25935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25936. * @param name defines the name of the mesh
  25937. * @param options defines the options used to create the mesh
  25938. * @param scene defines the hosting scene
  25939. * @returns the plane polygonal mesh
  25940. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25941. */
  25942. static CreateDisc(name: string, options: {
  25943. radius?: number;
  25944. tessellation?: number;
  25945. arc?: number;
  25946. updatable?: boolean;
  25947. sideOrientation?: number;
  25948. frontUVs?: Vector4;
  25949. backUVs?: Vector4;
  25950. }, scene?: Nullable<Scene>): Mesh;
  25951. }
  25952. }
  25953. declare module BABYLON {
  25954. /**
  25955. * This represents all the required information to add a fresnel effect on a material:
  25956. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25957. */
  25958. export class FresnelParameters {
  25959. private _isEnabled;
  25960. /**
  25961. * Define if the fresnel effect is enable or not.
  25962. */
  25963. get isEnabled(): boolean;
  25964. set isEnabled(value: boolean);
  25965. /**
  25966. * Define the color used on edges (grazing angle)
  25967. */
  25968. leftColor: Color3;
  25969. /**
  25970. * Define the color used on center
  25971. */
  25972. rightColor: Color3;
  25973. /**
  25974. * Define bias applied to computed fresnel term
  25975. */
  25976. bias: number;
  25977. /**
  25978. * Defined the power exponent applied to fresnel term
  25979. */
  25980. power: number;
  25981. /**
  25982. * Clones the current fresnel and its valuues
  25983. * @returns a clone fresnel configuration
  25984. */
  25985. clone(): FresnelParameters;
  25986. /**
  25987. * Serializes the current fresnel parameters to a JSON representation.
  25988. * @return the JSON serialization
  25989. */
  25990. serialize(): any;
  25991. /**
  25992. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25993. * @param parsedFresnelParameters Define the JSON representation
  25994. * @returns the parsed parameters
  25995. */
  25996. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25997. }
  25998. }
  25999. declare module BABYLON {
  26000. /**
  26001. * Base class of materials working in push mode in babylon JS
  26002. * @hidden
  26003. */
  26004. export class PushMaterial extends Material {
  26005. protected _activeEffect: Effect;
  26006. protected _normalMatrix: Matrix;
  26007. /**
  26008. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26009. * This means that the material can keep using a previous shader while a new one is being compiled.
  26010. * This is mostly used when shader parallel compilation is supported (true by default)
  26011. */
  26012. allowShaderHotSwapping: boolean;
  26013. constructor(name: string, scene: Scene);
  26014. getEffect(): Effect;
  26015. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26016. /**
  26017. * Binds the given world matrix to the active effect
  26018. *
  26019. * @param world the matrix to bind
  26020. */
  26021. bindOnlyWorldMatrix(world: Matrix): void;
  26022. /**
  26023. * Binds the given normal matrix to the active effect
  26024. *
  26025. * @param normalMatrix the matrix to bind
  26026. */
  26027. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26028. bind(world: Matrix, mesh?: Mesh): void;
  26029. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26030. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26031. }
  26032. }
  26033. declare module BABYLON {
  26034. /**
  26035. * This groups all the flags used to control the materials channel.
  26036. */
  26037. export class MaterialFlags {
  26038. private static _DiffuseTextureEnabled;
  26039. /**
  26040. * Are diffuse textures enabled in the application.
  26041. */
  26042. static get DiffuseTextureEnabled(): boolean;
  26043. static set DiffuseTextureEnabled(value: boolean);
  26044. private static _AmbientTextureEnabled;
  26045. /**
  26046. * Are ambient textures enabled in the application.
  26047. */
  26048. static get AmbientTextureEnabled(): boolean;
  26049. static set AmbientTextureEnabled(value: boolean);
  26050. private static _OpacityTextureEnabled;
  26051. /**
  26052. * Are opacity textures enabled in the application.
  26053. */
  26054. static get OpacityTextureEnabled(): boolean;
  26055. static set OpacityTextureEnabled(value: boolean);
  26056. private static _ReflectionTextureEnabled;
  26057. /**
  26058. * Are reflection textures enabled in the application.
  26059. */
  26060. static get ReflectionTextureEnabled(): boolean;
  26061. static set ReflectionTextureEnabled(value: boolean);
  26062. private static _EmissiveTextureEnabled;
  26063. /**
  26064. * Are emissive textures enabled in the application.
  26065. */
  26066. static get EmissiveTextureEnabled(): boolean;
  26067. static set EmissiveTextureEnabled(value: boolean);
  26068. private static _SpecularTextureEnabled;
  26069. /**
  26070. * Are specular textures enabled in the application.
  26071. */
  26072. static get SpecularTextureEnabled(): boolean;
  26073. static set SpecularTextureEnabled(value: boolean);
  26074. private static _BumpTextureEnabled;
  26075. /**
  26076. * Are bump textures enabled in the application.
  26077. */
  26078. static get BumpTextureEnabled(): boolean;
  26079. static set BumpTextureEnabled(value: boolean);
  26080. private static _LightmapTextureEnabled;
  26081. /**
  26082. * Are lightmap textures enabled in the application.
  26083. */
  26084. static get LightmapTextureEnabled(): boolean;
  26085. static set LightmapTextureEnabled(value: boolean);
  26086. private static _RefractionTextureEnabled;
  26087. /**
  26088. * Are refraction textures enabled in the application.
  26089. */
  26090. static get RefractionTextureEnabled(): boolean;
  26091. static set RefractionTextureEnabled(value: boolean);
  26092. private static _ColorGradingTextureEnabled;
  26093. /**
  26094. * Are color grading textures enabled in the application.
  26095. */
  26096. static get ColorGradingTextureEnabled(): boolean;
  26097. static set ColorGradingTextureEnabled(value: boolean);
  26098. private static _FresnelEnabled;
  26099. /**
  26100. * Are fresnels enabled in the application.
  26101. */
  26102. static get FresnelEnabled(): boolean;
  26103. static set FresnelEnabled(value: boolean);
  26104. private static _ClearCoatTextureEnabled;
  26105. /**
  26106. * Are clear coat textures enabled in the application.
  26107. */
  26108. static get ClearCoatTextureEnabled(): boolean;
  26109. static set ClearCoatTextureEnabled(value: boolean);
  26110. private static _ClearCoatBumpTextureEnabled;
  26111. /**
  26112. * Are clear coat bump textures enabled in the application.
  26113. */
  26114. static get ClearCoatBumpTextureEnabled(): boolean;
  26115. static set ClearCoatBumpTextureEnabled(value: boolean);
  26116. private static _ClearCoatTintTextureEnabled;
  26117. /**
  26118. * Are clear coat tint textures enabled in the application.
  26119. */
  26120. static get ClearCoatTintTextureEnabled(): boolean;
  26121. static set ClearCoatTintTextureEnabled(value: boolean);
  26122. private static _SheenTextureEnabled;
  26123. /**
  26124. * Are sheen textures enabled in the application.
  26125. */
  26126. static get SheenTextureEnabled(): boolean;
  26127. static set SheenTextureEnabled(value: boolean);
  26128. private static _AnisotropicTextureEnabled;
  26129. /**
  26130. * Are anisotropic textures enabled in the application.
  26131. */
  26132. static get AnisotropicTextureEnabled(): boolean;
  26133. static set AnisotropicTextureEnabled(value: boolean);
  26134. private static _ThicknessTextureEnabled;
  26135. /**
  26136. * Are thickness textures enabled in the application.
  26137. */
  26138. static get ThicknessTextureEnabled(): boolean;
  26139. static set ThicknessTextureEnabled(value: boolean);
  26140. }
  26141. }
  26142. declare module BABYLON {
  26143. /** @hidden */
  26144. export var defaultFragmentDeclaration: {
  26145. name: string;
  26146. shader: string;
  26147. };
  26148. }
  26149. declare module BABYLON {
  26150. /** @hidden */
  26151. export var defaultUboDeclaration: {
  26152. name: string;
  26153. shader: string;
  26154. };
  26155. }
  26156. declare module BABYLON {
  26157. /** @hidden */
  26158. export var lightFragmentDeclaration: {
  26159. name: string;
  26160. shader: string;
  26161. };
  26162. }
  26163. declare module BABYLON {
  26164. /** @hidden */
  26165. export var lightUboDeclaration: {
  26166. name: string;
  26167. shader: string;
  26168. };
  26169. }
  26170. declare module BABYLON {
  26171. /** @hidden */
  26172. export var lightsFragmentFunctions: {
  26173. name: string;
  26174. shader: string;
  26175. };
  26176. }
  26177. declare module BABYLON {
  26178. /** @hidden */
  26179. export var shadowsFragmentFunctions: {
  26180. name: string;
  26181. shader: string;
  26182. };
  26183. }
  26184. declare module BABYLON {
  26185. /** @hidden */
  26186. export var fresnelFunction: {
  26187. name: string;
  26188. shader: string;
  26189. };
  26190. }
  26191. declare module BABYLON {
  26192. /** @hidden */
  26193. export var reflectionFunction: {
  26194. name: string;
  26195. shader: string;
  26196. };
  26197. }
  26198. declare module BABYLON {
  26199. /** @hidden */
  26200. export var bumpFragmentFunctions: {
  26201. name: string;
  26202. shader: string;
  26203. };
  26204. }
  26205. declare module BABYLON {
  26206. /** @hidden */
  26207. export var logDepthDeclaration: {
  26208. name: string;
  26209. shader: string;
  26210. };
  26211. }
  26212. declare module BABYLON {
  26213. /** @hidden */
  26214. export var bumpFragment: {
  26215. name: string;
  26216. shader: string;
  26217. };
  26218. }
  26219. declare module BABYLON {
  26220. /** @hidden */
  26221. export var depthPrePass: {
  26222. name: string;
  26223. shader: string;
  26224. };
  26225. }
  26226. declare module BABYLON {
  26227. /** @hidden */
  26228. export var lightFragment: {
  26229. name: string;
  26230. shader: string;
  26231. };
  26232. }
  26233. declare module BABYLON {
  26234. /** @hidden */
  26235. export var logDepthFragment: {
  26236. name: string;
  26237. shader: string;
  26238. };
  26239. }
  26240. declare module BABYLON {
  26241. /** @hidden */
  26242. export var defaultPixelShader: {
  26243. name: string;
  26244. shader: string;
  26245. };
  26246. }
  26247. declare module BABYLON {
  26248. /** @hidden */
  26249. export var defaultVertexDeclaration: {
  26250. name: string;
  26251. shader: string;
  26252. };
  26253. }
  26254. declare module BABYLON {
  26255. /** @hidden */
  26256. export var bumpVertexDeclaration: {
  26257. name: string;
  26258. shader: string;
  26259. };
  26260. }
  26261. declare module BABYLON {
  26262. /** @hidden */
  26263. export var bumpVertex: {
  26264. name: string;
  26265. shader: string;
  26266. };
  26267. }
  26268. declare module BABYLON {
  26269. /** @hidden */
  26270. export var fogVertex: {
  26271. name: string;
  26272. shader: string;
  26273. };
  26274. }
  26275. declare module BABYLON {
  26276. /** @hidden */
  26277. export var shadowsVertex: {
  26278. name: string;
  26279. shader: string;
  26280. };
  26281. }
  26282. declare module BABYLON {
  26283. /** @hidden */
  26284. export var pointCloudVertex: {
  26285. name: string;
  26286. shader: string;
  26287. };
  26288. }
  26289. declare module BABYLON {
  26290. /** @hidden */
  26291. export var logDepthVertex: {
  26292. name: string;
  26293. shader: string;
  26294. };
  26295. }
  26296. declare module BABYLON {
  26297. /** @hidden */
  26298. export var defaultVertexShader: {
  26299. name: string;
  26300. shader: string;
  26301. };
  26302. }
  26303. declare module BABYLON {
  26304. /** @hidden */
  26305. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26306. MAINUV1: boolean;
  26307. MAINUV2: boolean;
  26308. DIFFUSE: boolean;
  26309. DIFFUSEDIRECTUV: number;
  26310. AMBIENT: boolean;
  26311. AMBIENTDIRECTUV: number;
  26312. OPACITY: boolean;
  26313. OPACITYDIRECTUV: number;
  26314. OPACITYRGB: boolean;
  26315. REFLECTION: boolean;
  26316. EMISSIVE: boolean;
  26317. EMISSIVEDIRECTUV: number;
  26318. SPECULAR: boolean;
  26319. SPECULARDIRECTUV: number;
  26320. BUMP: boolean;
  26321. BUMPDIRECTUV: number;
  26322. PARALLAX: boolean;
  26323. PARALLAXOCCLUSION: boolean;
  26324. SPECULAROVERALPHA: boolean;
  26325. CLIPPLANE: boolean;
  26326. CLIPPLANE2: boolean;
  26327. CLIPPLANE3: boolean;
  26328. CLIPPLANE4: boolean;
  26329. CLIPPLANE5: boolean;
  26330. CLIPPLANE6: boolean;
  26331. ALPHATEST: boolean;
  26332. DEPTHPREPASS: boolean;
  26333. ALPHAFROMDIFFUSE: boolean;
  26334. POINTSIZE: boolean;
  26335. FOG: boolean;
  26336. SPECULARTERM: boolean;
  26337. DIFFUSEFRESNEL: boolean;
  26338. OPACITYFRESNEL: boolean;
  26339. REFLECTIONFRESNEL: boolean;
  26340. REFRACTIONFRESNEL: boolean;
  26341. EMISSIVEFRESNEL: boolean;
  26342. FRESNEL: boolean;
  26343. NORMAL: boolean;
  26344. UV1: boolean;
  26345. UV2: boolean;
  26346. VERTEXCOLOR: boolean;
  26347. VERTEXALPHA: boolean;
  26348. NUM_BONE_INFLUENCERS: number;
  26349. BonesPerMesh: number;
  26350. BONETEXTURE: boolean;
  26351. INSTANCES: boolean;
  26352. GLOSSINESS: boolean;
  26353. ROUGHNESS: boolean;
  26354. EMISSIVEASILLUMINATION: boolean;
  26355. LINKEMISSIVEWITHDIFFUSE: boolean;
  26356. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26357. LIGHTMAP: boolean;
  26358. LIGHTMAPDIRECTUV: number;
  26359. OBJECTSPACE_NORMALMAP: boolean;
  26360. USELIGHTMAPASSHADOWMAP: boolean;
  26361. REFLECTIONMAP_3D: boolean;
  26362. REFLECTIONMAP_SPHERICAL: boolean;
  26363. REFLECTIONMAP_PLANAR: boolean;
  26364. REFLECTIONMAP_CUBIC: boolean;
  26365. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26366. REFLECTIONMAP_PROJECTION: boolean;
  26367. REFLECTIONMAP_SKYBOX: boolean;
  26368. REFLECTIONMAP_EXPLICIT: boolean;
  26369. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26370. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26371. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26372. INVERTCUBICMAP: boolean;
  26373. LOGARITHMICDEPTH: boolean;
  26374. REFRACTION: boolean;
  26375. REFRACTIONMAP_3D: boolean;
  26376. REFLECTIONOVERALPHA: boolean;
  26377. TWOSIDEDLIGHTING: boolean;
  26378. SHADOWFLOAT: boolean;
  26379. MORPHTARGETS: boolean;
  26380. MORPHTARGETS_NORMAL: boolean;
  26381. MORPHTARGETS_TANGENT: boolean;
  26382. MORPHTARGETS_UV: boolean;
  26383. NUM_MORPH_INFLUENCERS: number;
  26384. NONUNIFORMSCALING: boolean;
  26385. PREMULTIPLYALPHA: boolean;
  26386. IMAGEPROCESSING: boolean;
  26387. VIGNETTE: boolean;
  26388. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26389. VIGNETTEBLENDMODEOPAQUE: boolean;
  26390. TONEMAPPING: boolean;
  26391. TONEMAPPING_ACES: boolean;
  26392. CONTRAST: boolean;
  26393. COLORCURVES: boolean;
  26394. COLORGRADING: boolean;
  26395. COLORGRADING3D: boolean;
  26396. SAMPLER3DGREENDEPTH: boolean;
  26397. SAMPLER3DBGRMAP: boolean;
  26398. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26399. MULTIVIEW: boolean;
  26400. /**
  26401. * If the reflection texture on this material is in linear color space
  26402. * @hidden
  26403. */
  26404. IS_REFLECTION_LINEAR: boolean;
  26405. /**
  26406. * If the refraction texture on this material is in linear color space
  26407. * @hidden
  26408. */
  26409. IS_REFRACTION_LINEAR: boolean;
  26410. EXPOSURE: boolean;
  26411. constructor();
  26412. setReflectionMode(modeToEnable: string): void;
  26413. }
  26414. /**
  26415. * This is the default material used in Babylon. It is the best trade off between quality
  26416. * and performances.
  26417. * @see http://doc.babylonjs.com/babylon101/materials
  26418. */
  26419. export class StandardMaterial extends PushMaterial {
  26420. private _diffuseTexture;
  26421. /**
  26422. * The basic texture of the material as viewed under a light.
  26423. */
  26424. diffuseTexture: Nullable<BaseTexture>;
  26425. private _ambientTexture;
  26426. /**
  26427. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26428. */
  26429. ambientTexture: Nullable<BaseTexture>;
  26430. private _opacityTexture;
  26431. /**
  26432. * Define the transparency of the material from a texture.
  26433. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26434. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26435. */
  26436. opacityTexture: Nullable<BaseTexture>;
  26437. private _reflectionTexture;
  26438. /**
  26439. * Define the texture used to display the reflection.
  26440. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26441. */
  26442. reflectionTexture: Nullable<BaseTexture>;
  26443. private _emissiveTexture;
  26444. /**
  26445. * Define texture of the material as if self lit.
  26446. * This will be mixed in the final result even in the absence of light.
  26447. */
  26448. emissiveTexture: Nullable<BaseTexture>;
  26449. private _specularTexture;
  26450. /**
  26451. * Define how the color and intensity of the highlight given by the light in the material.
  26452. */
  26453. specularTexture: Nullable<BaseTexture>;
  26454. private _bumpTexture;
  26455. /**
  26456. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26457. * 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.
  26458. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26459. */
  26460. bumpTexture: Nullable<BaseTexture>;
  26461. private _lightmapTexture;
  26462. /**
  26463. * Complex lighting can be computationally expensive to compute at runtime.
  26464. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26465. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26466. */
  26467. lightmapTexture: Nullable<BaseTexture>;
  26468. private _refractionTexture;
  26469. /**
  26470. * Define the texture used to display the refraction.
  26471. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26472. */
  26473. refractionTexture: Nullable<BaseTexture>;
  26474. /**
  26475. * The color of the material lit by the environmental background lighting.
  26476. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26477. */
  26478. ambientColor: Color3;
  26479. /**
  26480. * The basic color of the material as viewed under a light.
  26481. */
  26482. diffuseColor: Color3;
  26483. /**
  26484. * Define how the color and intensity of the highlight given by the light in the material.
  26485. */
  26486. specularColor: Color3;
  26487. /**
  26488. * Define the color of the material as if self lit.
  26489. * This will be mixed in the final result even in the absence of light.
  26490. */
  26491. emissiveColor: Color3;
  26492. /**
  26493. * Defines how sharp are the highlights in the material.
  26494. * The bigger the value the sharper giving a more glossy feeling to the result.
  26495. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26496. */
  26497. specularPower: number;
  26498. private _useAlphaFromDiffuseTexture;
  26499. /**
  26500. * Does the transparency come from the diffuse texture alpha channel.
  26501. */
  26502. useAlphaFromDiffuseTexture: boolean;
  26503. private _useEmissiveAsIllumination;
  26504. /**
  26505. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26506. */
  26507. useEmissiveAsIllumination: boolean;
  26508. private _linkEmissiveWithDiffuse;
  26509. /**
  26510. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26511. * the emissive level when the final color is close to one.
  26512. */
  26513. linkEmissiveWithDiffuse: boolean;
  26514. private _useSpecularOverAlpha;
  26515. /**
  26516. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26517. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26518. */
  26519. useSpecularOverAlpha: boolean;
  26520. private _useReflectionOverAlpha;
  26521. /**
  26522. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26523. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26524. */
  26525. useReflectionOverAlpha: boolean;
  26526. private _disableLighting;
  26527. /**
  26528. * Does lights from the scene impacts this material.
  26529. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26530. */
  26531. disableLighting: boolean;
  26532. private _useObjectSpaceNormalMap;
  26533. /**
  26534. * Allows using an object space normal map (instead of tangent space).
  26535. */
  26536. useObjectSpaceNormalMap: boolean;
  26537. private _useParallax;
  26538. /**
  26539. * Is parallax enabled or not.
  26540. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26541. */
  26542. useParallax: boolean;
  26543. private _useParallaxOcclusion;
  26544. /**
  26545. * Is parallax occlusion enabled or not.
  26546. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26547. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26548. */
  26549. useParallaxOcclusion: boolean;
  26550. /**
  26551. * 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.
  26552. */
  26553. parallaxScaleBias: number;
  26554. private _roughness;
  26555. /**
  26556. * Helps to define how blurry the reflections should appears in the material.
  26557. */
  26558. roughness: number;
  26559. /**
  26560. * In case of refraction, define the value of the index of refraction.
  26561. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26562. */
  26563. indexOfRefraction: number;
  26564. /**
  26565. * Invert the refraction texture alongside the y axis.
  26566. * It can be useful with procedural textures or probe for instance.
  26567. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26568. */
  26569. invertRefractionY: boolean;
  26570. /**
  26571. * Defines the alpha limits in alpha test mode.
  26572. */
  26573. alphaCutOff: number;
  26574. private _useLightmapAsShadowmap;
  26575. /**
  26576. * In case of light mapping, define whether the map contains light or shadow informations.
  26577. */
  26578. useLightmapAsShadowmap: boolean;
  26579. private _diffuseFresnelParameters;
  26580. /**
  26581. * Define the diffuse fresnel parameters of the material.
  26582. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26583. */
  26584. diffuseFresnelParameters: FresnelParameters;
  26585. private _opacityFresnelParameters;
  26586. /**
  26587. * Define the opacity fresnel parameters of the material.
  26588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26589. */
  26590. opacityFresnelParameters: FresnelParameters;
  26591. private _reflectionFresnelParameters;
  26592. /**
  26593. * Define the reflection fresnel parameters of the material.
  26594. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26595. */
  26596. reflectionFresnelParameters: FresnelParameters;
  26597. private _refractionFresnelParameters;
  26598. /**
  26599. * Define the refraction fresnel parameters of the material.
  26600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26601. */
  26602. refractionFresnelParameters: FresnelParameters;
  26603. private _emissiveFresnelParameters;
  26604. /**
  26605. * Define the emissive fresnel parameters of the material.
  26606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26607. */
  26608. emissiveFresnelParameters: FresnelParameters;
  26609. private _useReflectionFresnelFromSpecular;
  26610. /**
  26611. * If true automatically deducts the fresnels values from the material specularity.
  26612. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26613. */
  26614. useReflectionFresnelFromSpecular: boolean;
  26615. private _useGlossinessFromSpecularMapAlpha;
  26616. /**
  26617. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26618. */
  26619. useGlossinessFromSpecularMapAlpha: boolean;
  26620. private _maxSimultaneousLights;
  26621. /**
  26622. * Defines the maximum number of lights that can be used in the material
  26623. */
  26624. maxSimultaneousLights: number;
  26625. private _invertNormalMapX;
  26626. /**
  26627. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26628. */
  26629. invertNormalMapX: boolean;
  26630. private _invertNormalMapY;
  26631. /**
  26632. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26633. */
  26634. invertNormalMapY: boolean;
  26635. private _twoSidedLighting;
  26636. /**
  26637. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26638. */
  26639. twoSidedLighting: boolean;
  26640. /**
  26641. * Default configuration related to image processing available in the standard Material.
  26642. */
  26643. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26644. /**
  26645. * Gets the image processing configuration used either in this material.
  26646. */
  26647. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26648. /**
  26649. * Sets the Default image processing configuration used either in the this material.
  26650. *
  26651. * If sets to null, the scene one is in use.
  26652. */
  26653. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26654. /**
  26655. * Keep track of the image processing observer to allow dispose and replace.
  26656. */
  26657. private _imageProcessingObserver;
  26658. /**
  26659. * Attaches a new image processing configuration to the Standard Material.
  26660. * @param configuration
  26661. */
  26662. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26663. /**
  26664. * Gets wether the color curves effect is enabled.
  26665. */
  26666. get cameraColorCurvesEnabled(): boolean;
  26667. /**
  26668. * Sets wether the color curves effect is enabled.
  26669. */
  26670. set cameraColorCurvesEnabled(value: boolean);
  26671. /**
  26672. * Gets wether the color grading effect is enabled.
  26673. */
  26674. get cameraColorGradingEnabled(): boolean;
  26675. /**
  26676. * Gets wether the color grading effect is enabled.
  26677. */
  26678. set cameraColorGradingEnabled(value: boolean);
  26679. /**
  26680. * Gets wether tonemapping is enabled or not.
  26681. */
  26682. get cameraToneMappingEnabled(): boolean;
  26683. /**
  26684. * Sets wether tonemapping is enabled or not
  26685. */
  26686. set cameraToneMappingEnabled(value: boolean);
  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. get cameraExposure(): number;
  26693. /**
  26694. * The camera exposure used on this material.
  26695. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26696. * This corresponds to a photographic exposure.
  26697. */
  26698. set cameraExposure(value: number);
  26699. /**
  26700. * Gets The camera contrast used on this material.
  26701. */
  26702. get cameraContrast(): number;
  26703. /**
  26704. * Sets The camera contrast used on this material.
  26705. */
  26706. set cameraContrast(value: number);
  26707. /**
  26708. * Gets the Color Grading 2D Lookup Texture.
  26709. */
  26710. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26711. /**
  26712. * Sets the Color Grading 2D Lookup Texture.
  26713. */
  26714. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26715. /**
  26716. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26717. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26718. * 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;
  26719. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26720. */
  26721. get cameraColorCurves(): Nullable<ColorCurves>;
  26722. /**
  26723. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26724. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26725. * 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;
  26726. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26727. */
  26728. set cameraColorCurves(value: Nullable<ColorCurves>);
  26729. /**
  26730. * Custom callback helping to override the default shader used in the material.
  26731. */
  26732. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26733. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26734. protected _worldViewProjectionMatrix: Matrix;
  26735. protected _globalAmbientColor: Color3;
  26736. protected _useLogarithmicDepth: boolean;
  26737. protected _rebuildInParallel: boolean;
  26738. /**
  26739. * Instantiates a new standard material.
  26740. * This is the default material used in Babylon. It is the best trade off between quality
  26741. * and performances.
  26742. * @see http://doc.babylonjs.com/babylon101/materials
  26743. * @param name Define the name of the material in the scene
  26744. * @param scene Define the scene the material belong to
  26745. */
  26746. constructor(name: string, scene: Scene);
  26747. /**
  26748. * Gets a boolean indicating that current material needs to register RTT
  26749. */
  26750. get hasRenderTargetTextures(): boolean;
  26751. /**
  26752. * Gets the current class name of the material e.g. "StandardMaterial"
  26753. * Mainly use in serialization.
  26754. * @returns the class name
  26755. */
  26756. getClassName(): string;
  26757. /**
  26758. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26759. * You can try switching to logarithmic depth.
  26760. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26761. */
  26762. get useLogarithmicDepth(): boolean;
  26763. set useLogarithmicDepth(value: boolean);
  26764. /**
  26765. * Specifies if the material will require alpha blending
  26766. * @returns a boolean specifying if alpha blending is needed
  26767. */
  26768. needAlphaBlending(): boolean;
  26769. /**
  26770. * Specifies if this material should be rendered in alpha test mode
  26771. * @returns a boolean specifying if an alpha test is needed.
  26772. */
  26773. needAlphaTesting(): boolean;
  26774. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26775. /**
  26776. * Get the texture used for alpha test purpose.
  26777. * @returns the diffuse texture in case of the standard material.
  26778. */
  26779. getAlphaTestTexture(): Nullable<BaseTexture>;
  26780. /**
  26781. * Get if the submesh is ready to be used and all its information available.
  26782. * Child classes can use it to update shaders
  26783. * @param mesh defines the mesh to check
  26784. * @param subMesh defines which submesh to check
  26785. * @param useInstances specifies that instances should be used
  26786. * @returns a boolean indicating that the submesh is ready or not
  26787. */
  26788. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26789. /**
  26790. * Builds the material UBO layouts.
  26791. * Used internally during the effect preparation.
  26792. */
  26793. buildUniformLayout(): void;
  26794. /**
  26795. * Unbinds the material from the mesh
  26796. */
  26797. unbind(): void;
  26798. /**
  26799. * Binds the submesh to this material by preparing the effect and shader to draw
  26800. * @param world defines the world transformation matrix
  26801. * @param mesh defines the mesh containing the submesh
  26802. * @param subMesh defines the submesh to bind the material to
  26803. */
  26804. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26805. /**
  26806. * Get the list of animatables in the material.
  26807. * @returns the list of animatables object used in the material
  26808. */
  26809. getAnimatables(): IAnimatable[];
  26810. /**
  26811. * Gets the active textures from the material
  26812. * @returns an array of textures
  26813. */
  26814. getActiveTextures(): BaseTexture[];
  26815. /**
  26816. * Specifies if the material uses a texture
  26817. * @param texture defines the texture to check against the material
  26818. * @returns a boolean specifying if the material uses the texture
  26819. */
  26820. hasTexture(texture: BaseTexture): boolean;
  26821. /**
  26822. * Disposes the material
  26823. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26824. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26825. */
  26826. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26827. /**
  26828. * Makes a duplicate of the material, and gives it a new name
  26829. * @param name defines the new name for the duplicated material
  26830. * @returns the cloned material
  26831. */
  26832. clone(name: string): StandardMaterial;
  26833. /**
  26834. * Serializes this material in a JSON representation
  26835. * @returns the serialized material object
  26836. */
  26837. serialize(): any;
  26838. /**
  26839. * Creates a standard material from parsed material data
  26840. * @param source defines the JSON representation of the material
  26841. * @param scene defines the hosting scene
  26842. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26843. * @returns a new standard material
  26844. */
  26845. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26846. /**
  26847. * Are diffuse textures enabled in the application.
  26848. */
  26849. static get DiffuseTextureEnabled(): boolean;
  26850. static set DiffuseTextureEnabled(value: boolean);
  26851. /**
  26852. * Are ambient textures enabled in the application.
  26853. */
  26854. static get AmbientTextureEnabled(): boolean;
  26855. static set AmbientTextureEnabled(value: boolean);
  26856. /**
  26857. * Are opacity textures enabled in the application.
  26858. */
  26859. static get OpacityTextureEnabled(): boolean;
  26860. static set OpacityTextureEnabled(value: boolean);
  26861. /**
  26862. * Are reflection textures enabled in the application.
  26863. */
  26864. static get ReflectionTextureEnabled(): boolean;
  26865. static set ReflectionTextureEnabled(value: boolean);
  26866. /**
  26867. * Are emissive textures enabled in the application.
  26868. */
  26869. static get EmissiveTextureEnabled(): boolean;
  26870. static set EmissiveTextureEnabled(value: boolean);
  26871. /**
  26872. * Are specular textures enabled in the application.
  26873. */
  26874. static get SpecularTextureEnabled(): boolean;
  26875. static set SpecularTextureEnabled(value: boolean);
  26876. /**
  26877. * Are bump textures enabled in the application.
  26878. */
  26879. static get BumpTextureEnabled(): boolean;
  26880. static set BumpTextureEnabled(value: boolean);
  26881. /**
  26882. * Are lightmap textures enabled in the application.
  26883. */
  26884. static get LightmapTextureEnabled(): boolean;
  26885. static set LightmapTextureEnabled(value: boolean);
  26886. /**
  26887. * Are refraction textures enabled in the application.
  26888. */
  26889. static get RefractionTextureEnabled(): boolean;
  26890. static set RefractionTextureEnabled(value: boolean);
  26891. /**
  26892. * Are color grading textures enabled in the application.
  26893. */
  26894. static get ColorGradingTextureEnabled(): boolean;
  26895. static set ColorGradingTextureEnabled(value: boolean);
  26896. /**
  26897. * Are fresnels enabled in the application.
  26898. */
  26899. static get FresnelEnabled(): boolean;
  26900. static set FresnelEnabled(value: boolean);
  26901. }
  26902. }
  26903. declare module BABYLON {
  26904. /**
  26905. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26906. *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.
  26907. * The SPS is also a particle system. It provides some methods to manage the particles.
  26908. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26909. *
  26910. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26911. */
  26912. export class SolidParticleSystem implements IDisposable {
  26913. /**
  26914. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26915. * Example : var p = SPS.particles[i];
  26916. */
  26917. particles: SolidParticle[];
  26918. /**
  26919. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26920. */
  26921. nbParticles: number;
  26922. /**
  26923. * If the particles must ever face the camera (default false). Useful for planar particles.
  26924. */
  26925. billboard: boolean;
  26926. /**
  26927. * Recompute normals when adding a shape
  26928. */
  26929. recomputeNormals: boolean;
  26930. /**
  26931. * This a counter ofr your own usage. It's not set by any SPS functions.
  26932. */
  26933. counter: number;
  26934. /**
  26935. * The SPS name. This name is also given to the underlying mesh.
  26936. */
  26937. name: string;
  26938. /**
  26939. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26940. */
  26941. mesh: Mesh;
  26942. /**
  26943. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26944. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26945. */
  26946. vars: any;
  26947. /**
  26948. * This array is populated when the SPS is set as 'pickable'.
  26949. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26950. * Each element of this array is an object `{idx: int, faceId: int}`.
  26951. * `idx` is the picked particle index in the `SPS.particles` array
  26952. * `faceId` is the picked face index counted within this particle.
  26953. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26954. */
  26955. pickedParticles: {
  26956. idx: number;
  26957. faceId: number;
  26958. }[];
  26959. /**
  26960. * This array is populated when `enableDepthSort` is set to true.
  26961. * Each element of this array is an instance of the class DepthSortedParticle.
  26962. */
  26963. depthSortedParticles: DepthSortedParticle[];
  26964. /**
  26965. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26966. * @hidden
  26967. */
  26968. _bSphereOnly: boolean;
  26969. /**
  26970. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26971. * @hidden
  26972. */
  26973. _bSphereRadiusFactor: number;
  26974. private _scene;
  26975. private _positions;
  26976. private _indices;
  26977. private _normals;
  26978. private _colors;
  26979. private _uvs;
  26980. private _indices32;
  26981. private _positions32;
  26982. private _normals32;
  26983. private _fixedNormal32;
  26984. private _colors32;
  26985. private _uvs32;
  26986. private _index;
  26987. private _updatable;
  26988. private _pickable;
  26989. private _isVisibilityBoxLocked;
  26990. private _alwaysVisible;
  26991. private _depthSort;
  26992. private _expandable;
  26993. private _shapeCounter;
  26994. private _copy;
  26995. private _color;
  26996. private _computeParticleColor;
  26997. private _computeParticleTexture;
  26998. private _computeParticleRotation;
  26999. private _computeParticleVertex;
  27000. private _computeBoundingBox;
  27001. private _depthSortParticles;
  27002. private _camera;
  27003. private _mustUnrotateFixedNormals;
  27004. private _particlesIntersect;
  27005. private _needs32Bits;
  27006. private _isNotBuilt;
  27007. private _lastParticleId;
  27008. private _idxOfId;
  27009. private _multimaterialEnabled;
  27010. private _useModelMaterial;
  27011. private _indicesByMaterial;
  27012. private _materialIndexes;
  27013. private _depthSortFunction;
  27014. private _materialSortFunction;
  27015. private _materials;
  27016. private _multimaterial;
  27017. private _materialIndexesById;
  27018. private _defaultMaterial;
  27019. private _autoUpdateSubMeshes;
  27020. /**
  27021. * Creates a SPS (Solid Particle System) object.
  27022. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27023. * @param scene (Scene) is the scene in which the SPS is added.
  27024. * @param options defines the options of the sps e.g.
  27025. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27026. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27027. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27028. * * 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.
  27029. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27030. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27031. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27032. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27033. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27034. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27035. */
  27036. constructor(name: string, scene: Scene, options?: {
  27037. updatable?: boolean;
  27038. isPickable?: boolean;
  27039. enableDepthSort?: boolean;
  27040. particleIntersection?: boolean;
  27041. boundingSphereOnly?: boolean;
  27042. bSphereRadiusFactor?: number;
  27043. expandable?: boolean;
  27044. useModelMaterial?: boolean;
  27045. enableMultiMaterial?: boolean;
  27046. });
  27047. /**
  27048. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27049. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27050. * @returns the created mesh
  27051. */
  27052. buildMesh(): Mesh;
  27053. /**
  27054. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27055. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27056. * Thus the particles generated from `digest()` have their property `position` set yet.
  27057. * @param mesh ( Mesh ) is the mesh to be digested
  27058. * @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
  27059. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27060. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27061. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27062. * @returns the current SPS
  27063. */
  27064. digest(mesh: Mesh, options?: {
  27065. facetNb?: number;
  27066. number?: number;
  27067. delta?: number;
  27068. storage?: [];
  27069. }): SolidParticleSystem;
  27070. /**
  27071. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27072. * @hidden
  27073. */
  27074. private _unrotateFixedNormals;
  27075. /**
  27076. * Resets the temporary working copy particle
  27077. * @hidden
  27078. */
  27079. private _resetCopy;
  27080. /**
  27081. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27082. * @param p the current index in the positions array to be updated
  27083. * @param ind the current index in the indices array
  27084. * @param shape a Vector3 array, the shape geometry
  27085. * @param positions the positions array to be updated
  27086. * @param meshInd the shape indices array
  27087. * @param indices the indices array to be updated
  27088. * @param meshUV the shape uv array
  27089. * @param uvs the uv array to be updated
  27090. * @param meshCol the shape color array
  27091. * @param colors the color array to be updated
  27092. * @param meshNor the shape normals array
  27093. * @param normals the normals array to be updated
  27094. * @param idx the particle index
  27095. * @param idxInShape the particle index in its shape
  27096. * @param options the addShape() method passed options
  27097. * @model the particle model
  27098. * @hidden
  27099. */
  27100. private _meshBuilder;
  27101. /**
  27102. * Returns a shape Vector3 array from positions float array
  27103. * @param positions float array
  27104. * @returns a vector3 array
  27105. * @hidden
  27106. */
  27107. private _posToShape;
  27108. /**
  27109. * Returns a shapeUV array from a float uvs (array deep copy)
  27110. * @param uvs as a float array
  27111. * @returns a shapeUV array
  27112. * @hidden
  27113. */
  27114. private _uvsToShapeUV;
  27115. /**
  27116. * Adds a new particle object in the particles array
  27117. * @param idx particle index in particles array
  27118. * @param id particle id
  27119. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27120. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27121. * @param model particle ModelShape object
  27122. * @param shapeId model shape identifier
  27123. * @param idxInShape index of the particle in the current model
  27124. * @param bInfo model bounding info object
  27125. * @param storage target storage array, if any
  27126. * @hidden
  27127. */
  27128. private _addParticle;
  27129. /**
  27130. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27131. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27132. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27133. * @param nb (positive integer) the number of particles to be created from this model
  27134. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27135. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27136. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27137. * @returns the number of shapes in the system
  27138. */
  27139. addShape(mesh: Mesh, nb: number, options?: {
  27140. positionFunction?: any;
  27141. vertexFunction?: any;
  27142. storage?: [];
  27143. }): number;
  27144. /**
  27145. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27146. * @hidden
  27147. */
  27148. private _rebuildParticle;
  27149. /**
  27150. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27151. * @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.
  27152. * @returns the SPS.
  27153. */
  27154. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27155. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27156. * Returns an array with the removed particles.
  27157. * 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.
  27158. * The SPS can't be empty so at least one particle needs to remain in place.
  27159. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27160. * @param start index of the first particle to remove
  27161. * @param end index of the last particle to remove (included)
  27162. * @returns an array populated with the removed particles
  27163. */
  27164. removeParticles(start: number, end: number): SolidParticle[];
  27165. /**
  27166. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27167. * @param solidParticleArray an array populated with Solid Particles objects
  27168. * @returns the SPS
  27169. */
  27170. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27171. /**
  27172. * Creates a new particle and modifies the SPS mesh geometry :
  27173. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27174. * - calls _addParticle() to populate the particle array
  27175. * factorized code from addShape() and insertParticlesFromArray()
  27176. * @param idx particle index in the particles array
  27177. * @param i particle index in its shape
  27178. * @param modelShape particle ModelShape object
  27179. * @param shape shape vertex array
  27180. * @param meshInd shape indices array
  27181. * @param meshUV shape uv array
  27182. * @param meshCol shape color array
  27183. * @param meshNor shape normals array
  27184. * @param bbInfo shape bounding info
  27185. * @param storage target particle storage
  27186. * @options addShape() passed options
  27187. * @hidden
  27188. */
  27189. private _insertNewParticle;
  27190. /**
  27191. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27192. * This method calls `updateParticle()` for each particle of the SPS.
  27193. * For an animated SPS, it is usually called within the render loop.
  27194. * 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.
  27195. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27196. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27197. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27198. * @returns the SPS.
  27199. */
  27200. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27201. /**
  27202. * Disposes the SPS.
  27203. */
  27204. dispose(): void;
  27205. /**
  27206. * Returns a SolidParticle object from its identifier : particle.id
  27207. * @param id (integer) the particle Id
  27208. * @returns the searched particle or null if not found in the SPS.
  27209. */
  27210. getParticleById(id: number): Nullable<SolidParticle>;
  27211. /**
  27212. * Returns a new array populated with the particles having the passed shapeId.
  27213. * @param shapeId (integer) the shape identifier
  27214. * @returns a new solid particle array
  27215. */
  27216. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27217. /**
  27218. * Populates the passed array "ref" with the particles having the passed shapeId.
  27219. * @param shapeId the shape identifier
  27220. * @returns the SPS
  27221. * @param ref
  27222. */
  27223. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27224. /**
  27225. * Computes the required SubMeshes according the materials assigned to the particles.
  27226. * @returns the solid particle system.
  27227. * Does nothing if called before the SPS mesh is built.
  27228. */
  27229. computeSubMeshes(): SolidParticleSystem;
  27230. /**
  27231. * Sorts the solid particles by material when MultiMaterial is enabled.
  27232. * Updates the indices32 array.
  27233. * Updates the indicesByMaterial array.
  27234. * Updates the mesh indices array.
  27235. * @returns the SPS
  27236. * @hidden
  27237. */
  27238. private _sortParticlesByMaterial;
  27239. /**
  27240. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27241. * @hidden
  27242. */
  27243. private _setMaterialIndexesById;
  27244. /**
  27245. * Returns an array with unique values of Materials from the passed array
  27246. * @param array the material array to be checked and filtered
  27247. * @hidden
  27248. */
  27249. private _filterUniqueMaterialId;
  27250. /**
  27251. * Sets a new Standard Material as _defaultMaterial if not already set.
  27252. * @hidden
  27253. */
  27254. private _setDefaultMaterial;
  27255. /**
  27256. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27257. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27258. * @returns the SPS.
  27259. */
  27260. refreshVisibleSize(): SolidParticleSystem;
  27261. /**
  27262. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27263. * @param size the size (float) of the visibility box
  27264. * note : this doesn't lock the SPS mesh bounding box.
  27265. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27266. */
  27267. setVisibilityBox(size: number): void;
  27268. /**
  27269. * Gets whether the SPS as always visible or not
  27270. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27271. */
  27272. get isAlwaysVisible(): boolean;
  27273. /**
  27274. * Sets the SPS as always visible or not
  27275. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27276. */
  27277. set isAlwaysVisible(val: boolean);
  27278. /**
  27279. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27280. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27281. */
  27282. set isVisibilityBoxLocked(val: boolean);
  27283. /**
  27284. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27285. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27286. */
  27287. get isVisibilityBoxLocked(): boolean;
  27288. /**
  27289. * Tells to `setParticles()` to compute the particle rotations or not.
  27290. * Default value : true. The SPS is faster when it's set to false.
  27291. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27292. */
  27293. set computeParticleRotation(val: boolean);
  27294. /**
  27295. * Tells to `setParticles()` to compute the particle colors or not.
  27296. * Default value : true. The SPS is faster when it's set to false.
  27297. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27298. */
  27299. set computeParticleColor(val: boolean);
  27300. set computeParticleTexture(val: boolean);
  27301. /**
  27302. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27303. * Default value : false. The SPS is faster when it's set to false.
  27304. * Note : the particle custom vertex positions aren't stored values.
  27305. */
  27306. set computeParticleVertex(val: boolean);
  27307. /**
  27308. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27309. */
  27310. set computeBoundingBox(val: boolean);
  27311. /**
  27312. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27313. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27314. * Default : `true`
  27315. */
  27316. set depthSortParticles(val: boolean);
  27317. /**
  27318. * Gets if `setParticles()` computes the particle rotations or not.
  27319. * Default value : true. The SPS is faster when it's set to false.
  27320. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27321. */
  27322. get computeParticleRotation(): boolean;
  27323. /**
  27324. * Gets if `setParticles()` computes the particle colors or not.
  27325. * Default value : true. The SPS is faster when it's set to false.
  27326. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27327. */
  27328. get computeParticleColor(): boolean;
  27329. /**
  27330. * Gets if `setParticles()` computes the particle textures or not.
  27331. * Default value : true. The SPS is faster when it's set to false.
  27332. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27333. */
  27334. get computeParticleTexture(): boolean;
  27335. /**
  27336. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27337. * Default value : false. The SPS is faster when it's set to false.
  27338. * Note : the particle custom vertex positions aren't stored values.
  27339. */
  27340. get computeParticleVertex(): boolean;
  27341. /**
  27342. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27343. */
  27344. get computeBoundingBox(): boolean;
  27345. /**
  27346. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27347. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27348. * Default : `true`
  27349. */
  27350. get depthSortParticles(): boolean;
  27351. /**
  27352. * Gets if the SPS is created as expandable at construction time.
  27353. * Default : `false`
  27354. */
  27355. get expandable(): boolean;
  27356. /**
  27357. * Gets if the SPS supports the Multi Materials
  27358. */
  27359. get multimaterialEnabled(): boolean;
  27360. /**
  27361. * Gets if the SPS uses the model materials for its own multimaterial.
  27362. */
  27363. get useModelMaterial(): boolean;
  27364. /**
  27365. * The SPS used material array.
  27366. */
  27367. get materials(): Material[];
  27368. /**
  27369. * Sets the SPS MultiMaterial from the passed materials.
  27370. * Note : the passed array is internally copied and not used then by reference.
  27371. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27372. */
  27373. setMultiMaterial(materials: Material[]): void;
  27374. /**
  27375. * The SPS computed multimaterial object
  27376. */
  27377. get multimaterial(): MultiMaterial;
  27378. set multimaterial(mm: MultiMaterial);
  27379. /**
  27380. * If the subMeshes must be updated on the next call to setParticles()
  27381. */
  27382. get autoUpdateSubMeshes(): boolean;
  27383. set autoUpdateSubMeshes(val: boolean);
  27384. /**
  27385. * This function does nothing. It may be overwritten to set all the particle first values.
  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. */
  27389. initParticles(): void;
  27390. /**
  27391. * This function does nothing. It may be overwritten to recycle a particle.
  27392. * The SPS doesn't call this function, you may have to call it by your own.
  27393. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27394. * @param particle The particle to recycle
  27395. * @returns the recycled particle
  27396. */
  27397. recycleParticle(particle: SolidParticle): SolidParticle;
  27398. /**
  27399. * Updates a particle : this function should be overwritten by the user.
  27400. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27401. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27402. * @example : just set a particle position or velocity and recycle conditions
  27403. * @param particle The particle to update
  27404. * @returns the updated particle
  27405. */
  27406. updateParticle(particle: SolidParticle): SolidParticle;
  27407. /**
  27408. * Updates a vertex of a particle : it can be overwritten by the user.
  27409. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27410. * @param particle the current particle
  27411. * @param vertex the current index of the current particle
  27412. * @param pt the index of the current vertex in the particle shape
  27413. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27414. * @example : just set a vertex particle position
  27415. * @returns the updated vertex
  27416. */
  27417. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27418. /**
  27419. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27420. * This does nothing and may be overwritten by the user.
  27421. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27422. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27423. * @param update the boolean update value actually passed to setParticles()
  27424. */
  27425. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27426. /**
  27427. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27428. * This will be passed three parameters.
  27429. * This does nothing and may be overwritten by the user.
  27430. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27431. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27432. * @param update the boolean update value actually passed to setParticles()
  27433. */
  27434. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27435. }
  27436. }
  27437. declare module BABYLON {
  27438. /**
  27439. * Represents one particle of a solid particle system.
  27440. */
  27441. export class SolidParticle {
  27442. /**
  27443. * particle global index
  27444. */
  27445. idx: number;
  27446. /**
  27447. * particle identifier
  27448. */
  27449. id: number;
  27450. /**
  27451. * The color of the particle
  27452. */
  27453. color: Nullable<Color4>;
  27454. /**
  27455. * The world space position of the particle.
  27456. */
  27457. position: Vector3;
  27458. /**
  27459. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27460. */
  27461. rotation: Vector3;
  27462. /**
  27463. * The world space rotation quaternion of the particle.
  27464. */
  27465. rotationQuaternion: Nullable<Quaternion>;
  27466. /**
  27467. * The scaling of the particle.
  27468. */
  27469. scaling: Vector3;
  27470. /**
  27471. * The uvs of the particle.
  27472. */
  27473. uvs: Vector4;
  27474. /**
  27475. * The current speed of the particle.
  27476. */
  27477. velocity: Vector3;
  27478. /**
  27479. * The pivot point in the particle local space.
  27480. */
  27481. pivot: Vector3;
  27482. /**
  27483. * Must the particle be translated from its pivot point in its local space ?
  27484. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27485. * Default : false
  27486. */
  27487. translateFromPivot: boolean;
  27488. /**
  27489. * Is the particle active or not ?
  27490. */
  27491. alive: boolean;
  27492. /**
  27493. * Is the particle visible or not ?
  27494. */
  27495. isVisible: boolean;
  27496. /**
  27497. * Index of this particle in the global "positions" array (Internal use)
  27498. * @hidden
  27499. */
  27500. _pos: number;
  27501. /**
  27502. * @hidden Index of this particle in the global "indices" array (Internal use)
  27503. */
  27504. _ind: number;
  27505. /**
  27506. * @hidden ModelShape of this particle (Internal use)
  27507. */
  27508. _model: ModelShape;
  27509. /**
  27510. * ModelShape id of this particle
  27511. */
  27512. shapeId: number;
  27513. /**
  27514. * Index of the particle in its shape id
  27515. */
  27516. idxInShape: number;
  27517. /**
  27518. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27519. */
  27520. _modelBoundingInfo: BoundingInfo;
  27521. /**
  27522. * @hidden Particle BoundingInfo object (Internal use)
  27523. */
  27524. _boundingInfo: BoundingInfo;
  27525. /**
  27526. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27527. */
  27528. _sps: SolidParticleSystem;
  27529. /**
  27530. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27531. */
  27532. _stillInvisible: boolean;
  27533. /**
  27534. * @hidden Last computed particle rotation matrix
  27535. */
  27536. _rotationMatrix: number[];
  27537. /**
  27538. * Parent particle Id, if any.
  27539. * Default null.
  27540. */
  27541. parentId: Nullable<number>;
  27542. /**
  27543. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27544. */
  27545. materialIndex: Nullable<number>;
  27546. /**
  27547. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27548. * The possible values are :
  27549. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27550. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27551. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27552. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27553. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27554. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27555. * */
  27556. cullingStrategy: number;
  27557. /**
  27558. * @hidden Internal global position in the SPS.
  27559. */
  27560. _globalPosition: Vector3;
  27561. /**
  27562. * Creates a Solid Particle object.
  27563. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27564. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27565. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27566. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27567. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27568. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27569. * @param shapeId (integer) is the model shape identifier in the SPS.
  27570. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27571. * @param sps defines the sps it is associated to
  27572. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27573. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27574. */
  27575. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27576. /**
  27577. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27578. * @param target the particle target
  27579. * @returns the current particle
  27580. */
  27581. copyToRef(target: SolidParticle): SolidParticle;
  27582. /**
  27583. * Legacy support, changed scale to scaling
  27584. */
  27585. get scale(): Vector3;
  27586. /**
  27587. * Legacy support, changed scale to scaling
  27588. */
  27589. set scale(scale: Vector3);
  27590. /**
  27591. * Legacy support, changed quaternion to rotationQuaternion
  27592. */
  27593. get quaternion(): Nullable<Quaternion>;
  27594. /**
  27595. * Legacy support, changed quaternion to rotationQuaternion
  27596. */
  27597. set quaternion(q: Nullable<Quaternion>);
  27598. /**
  27599. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27600. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27601. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27602. * @returns true if it intersects
  27603. */
  27604. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27605. /**
  27606. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27607. * A particle is in the frustum if its bounding box intersects the frustum
  27608. * @param frustumPlanes defines the frustum to test
  27609. * @returns true if the particle is in the frustum planes
  27610. */
  27611. isInFrustum(frustumPlanes: Plane[]): boolean;
  27612. /**
  27613. * get the rotation matrix of the particle
  27614. * @hidden
  27615. */
  27616. getRotationMatrix(m: Matrix): void;
  27617. }
  27618. /**
  27619. * Represents the shape of the model used by one particle of a solid particle system.
  27620. * SPS internal tool, don't use it manually.
  27621. */
  27622. export class ModelShape {
  27623. /**
  27624. * The shape id
  27625. * @hidden
  27626. */
  27627. shapeID: number;
  27628. /**
  27629. * flat array of model positions (internal use)
  27630. * @hidden
  27631. */
  27632. _shape: Vector3[];
  27633. /**
  27634. * flat array of model UVs (internal use)
  27635. * @hidden
  27636. */
  27637. _shapeUV: number[];
  27638. /**
  27639. * color array of the model
  27640. * @hidden
  27641. */
  27642. _shapeColors: number[];
  27643. /**
  27644. * indices array of the model
  27645. * @hidden
  27646. */
  27647. _indices: number[];
  27648. /**
  27649. * normals array of the model
  27650. * @hidden
  27651. */
  27652. _normals: number[];
  27653. /**
  27654. * length of the shape in the model indices array (internal use)
  27655. * @hidden
  27656. */
  27657. _indicesLength: number;
  27658. /**
  27659. * Custom position function (internal use)
  27660. * @hidden
  27661. */
  27662. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27663. /**
  27664. * Custom vertex function (internal use)
  27665. * @hidden
  27666. */
  27667. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27668. /**
  27669. * Model material (internal use)
  27670. * @hidden
  27671. */
  27672. _material: Nullable<Material>;
  27673. /**
  27674. * 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.
  27675. * SPS internal tool, don't use it manually.
  27676. * @hidden
  27677. */
  27678. 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>);
  27679. }
  27680. /**
  27681. * Represents a Depth Sorted Particle in the solid particle system.
  27682. * @hidden
  27683. */
  27684. export class DepthSortedParticle {
  27685. /**
  27686. * Index of the particle in the "indices" array
  27687. */
  27688. ind: number;
  27689. /**
  27690. * Length of the particle shape in the "indices" array
  27691. */
  27692. indicesLength: number;
  27693. /**
  27694. * Squared distance from the particle to the camera
  27695. */
  27696. sqDistance: number;
  27697. /**
  27698. * Material index when used with MultiMaterials
  27699. */
  27700. materialIndex: number;
  27701. /**
  27702. * Creates a new sorted particle
  27703. * @param materialIndex
  27704. */
  27705. constructor(ind: number, indLength: number, materialIndex: number);
  27706. }
  27707. }
  27708. declare module BABYLON {
  27709. /**
  27710. * @hidden
  27711. */
  27712. export class _MeshCollisionData {
  27713. _checkCollisions: boolean;
  27714. _collisionMask: number;
  27715. _collisionGroup: number;
  27716. _collider: Nullable<Collider>;
  27717. _oldPositionForCollisions: Vector3;
  27718. _diffPositionForCollisions: Vector3;
  27719. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27720. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27721. }
  27722. }
  27723. declare module BABYLON {
  27724. /** @hidden */
  27725. class _FacetDataStorage {
  27726. facetPositions: Vector3[];
  27727. facetNormals: Vector3[];
  27728. facetPartitioning: number[][];
  27729. facetNb: number;
  27730. partitioningSubdivisions: number;
  27731. partitioningBBoxRatio: number;
  27732. facetDataEnabled: boolean;
  27733. facetParameters: any;
  27734. bbSize: Vector3;
  27735. subDiv: {
  27736. max: number;
  27737. X: number;
  27738. Y: number;
  27739. Z: number;
  27740. };
  27741. facetDepthSort: boolean;
  27742. facetDepthSortEnabled: boolean;
  27743. depthSortedIndices: IndicesArray;
  27744. depthSortedFacets: {
  27745. ind: number;
  27746. sqDistance: number;
  27747. }[];
  27748. facetDepthSortFunction: (f1: {
  27749. ind: number;
  27750. sqDistance: number;
  27751. }, f2: {
  27752. ind: number;
  27753. sqDistance: number;
  27754. }) => number;
  27755. facetDepthSortFrom: Vector3;
  27756. facetDepthSortOrigin: Vector3;
  27757. invertedMatrix: Matrix;
  27758. }
  27759. /**
  27760. * @hidden
  27761. **/
  27762. class _InternalAbstractMeshDataInfo {
  27763. _hasVertexAlpha: boolean;
  27764. _useVertexColors: boolean;
  27765. _numBoneInfluencers: number;
  27766. _applyFog: boolean;
  27767. _receiveShadows: boolean;
  27768. _facetData: _FacetDataStorage;
  27769. _visibility: number;
  27770. _skeleton: Nullable<Skeleton>;
  27771. _layerMask: number;
  27772. _computeBonesUsingShaders: boolean;
  27773. _isActive: boolean;
  27774. _onlyForInstances: boolean;
  27775. _isActiveIntermediate: boolean;
  27776. _onlyForInstancesIntermediate: boolean;
  27777. _actAsRegularMesh: boolean;
  27778. }
  27779. /**
  27780. * Class used to store all common mesh properties
  27781. */
  27782. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27783. /** No occlusion */
  27784. static OCCLUSION_TYPE_NONE: number;
  27785. /** Occlusion set to optimisitic */
  27786. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27787. /** Occlusion set to strict */
  27788. static OCCLUSION_TYPE_STRICT: number;
  27789. /** Use an accurante occlusion algorithm */
  27790. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27791. /** Use a conservative occlusion algorithm */
  27792. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27793. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27794. * Test order :
  27795. * Is the bounding sphere outside the frustum ?
  27796. * If not, are the bounding box vertices outside the frustum ?
  27797. * It not, then the cullable object is in the frustum.
  27798. */
  27799. static readonly CULLINGSTRATEGY_STANDARD: number;
  27800. /** Culling strategy : Bounding Sphere Only.
  27801. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27802. * It's also less accurate than the standard because some not visible objects can still be selected.
  27803. * Test : is the bounding sphere outside the frustum ?
  27804. * If not, then the cullable object is in the frustum.
  27805. */
  27806. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27807. /** Culling strategy : Optimistic Inclusion.
  27808. * This in an inclusion test first, then the standard exclusion test.
  27809. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27810. * 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.
  27811. * Anyway, it's as accurate as the standard strategy.
  27812. * Test :
  27813. * Is the cullable object bounding sphere center in the frustum ?
  27814. * If not, apply the default culling strategy.
  27815. */
  27816. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27817. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27818. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27819. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27820. * 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.
  27821. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27822. * Test :
  27823. * Is the cullable object bounding sphere center in the frustum ?
  27824. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27825. */
  27826. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27827. /**
  27828. * No billboard
  27829. */
  27830. static get BILLBOARDMODE_NONE(): number;
  27831. /** Billboard on X axis */
  27832. static get BILLBOARDMODE_X(): number;
  27833. /** Billboard on Y axis */
  27834. static get BILLBOARDMODE_Y(): number;
  27835. /** Billboard on Z axis */
  27836. static get BILLBOARDMODE_Z(): number;
  27837. /** Billboard on all axes */
  27838. static get BILLBOARDMODE_ALL(): number;
  27839. /** Billboard on using position instead of orientation */
  27840. static get BILLBOARDMODE_USE_POSITION(): number;
  27841. /** @hidden */
  27842. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27843. /**
  27844. * The culling strategy to use to check whether the mesh must be rendered or not.
  27845. * This value can be changed at any time and will be used on the next render mesh selection.
  27846. * The possible values are :
  27847. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27848. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27849. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27850. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27851. * Please read each static variable documentation to get details about the culling process.
  27852. * */
  27853. cullingStrategy: number;
  27854. /**
  27855. * Gets the number of facets in the mesh
  27856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27857. */
  27858. get facetNb(): number;
  27859. /**
  27860. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27862. */
  27863. get partitioningSubdivisions(): number;
  27864. set partitioningSubdivisions(nb: number);
  27865. /**
  27866. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27867. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27869. */
  27870. get partitioningBBoxRatio(): number;
  27871. set partitioningBBoxRatio(ratio: number);
  27872. /**
  27873. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27874. * Works only for updatable meshes.
  27875. * Doesn't work with multi-materials
  27876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27877. */
  27878. get mustDepthSortFacets(): boolean;
  27879. set mustDepthSortFacets(sort: boolean);
  27880. /**
  27881. * The location (Vector3) where the facet depth sort must be computed from.
  27882. * By default, the active camera position.
  27883. * Used only when facet depth sort is enabled
  27884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27885. */
  27886. get facetDepthSortFrom(): Vector3;
  27887. set facetDepthSortFrom(location: Vector3);
  27888. /**
  27889. * gets a boolean indicating if facetData is enabled
  27890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27891. */
  27892. get isFacetDataEnabled(): boolean;
  27893. /** @hidden */
  27894. _updateNonUniformScalingState(value: boolean): boolean;
  27895. /**
  27896. * An event triggered when this mesh collides with another one
  27897. */
  27898. onCollideObservable: Observable<AbstractMesh>;
  27899. /** Set a function to call when this mesh collides with another one */
  27900. set onCollide(callback: () => void);
  27901. /**
  27902. * An event triggered when the collision's position changes
  27903. */
  27904. onCollisionPositionChangeObservable: Observable<Vector3>;
  27905. /** Set a function to call when the collision's position changes */
  27906. set onCollisionPositionChange(callback: () => void);
  27907. /**
  27908. * An event triggered when material is changed
  27909. */
  27910. onMaterialChangedObservable: Observable<AbstractMesh>;
  27911. /**
  27912. * Gets or sets the orientation for POV movement & rotation
  27913. */
  27914. definedFacingForward: boolean;
  27915. /** @hidden */
  27916. _occlusionQuery: Nullable<WebGLQuery>;
  27917. /** @hidden */
  27918. _renderingGroup: Nullable<RenderingGroup>;
  27919. /**
  27920. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27921. */
  27922. get visibility(): number;
  27923. /**
  27924. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27925. */
  27926. set visibility(value: number);
  27927. /** Gets or sets the alpha index used to sort transparent meshes
  27928. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27929. */
  27930. alphaIndex: number;
  27931. /**
  27932. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27933. */
  27934. isVisible: boolean;
  27935. /**
  27936. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27937. */
  27938. isPickable: boolean;
  27939. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27940. showSubMeshesBoundingBox: boolean;
  27941. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27942. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27943. */
  27944. isBlocker: boolean;
  27945. /**
  27946. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27947. */
  27948. enablePointerMoveEvents: boolean;
  27949. /**
  27950. * Specifies the rendering group id for this mesh (0 by default)
  27951. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27952. */
  27953. renderingGroupId: number;
  27954. private _material;
  27955. /** Gets or sets current material */
  27956. get material(): Nullable<Material>;
  27957. set material(value: Nullable<Material>);
  27958. /**
  27959. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27960. * @see http://doc.babylonjs.com/babylon101/shadows
  27961. */
  27962. get receiveShadows(): boolean;
  27963. set receiveShadows(value: boolean);
  27964. /** Defines color to use when rendering outline */
  27965. outlineColor: Color3;
  27966. /** Define width to use when rendering outline */
  27967. outlineWidth: number;
  27968. /** Defines color to use when rendering overlay */
  27969. overlayColor: Color3;
  27970. /** Defines alpha to use when rendering overlay */
  27971. overlayAlpha: number;
  27972. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27973. get hasVertexAlpha(): boolean;
  27974. set hasVertexAlpha(value: boolean);
  27975. /** 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) */
  27976. get useVertexColors(): boolean;
  27977. set useVertexColors(value: boolean);
  27978. /**
  27979. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27980. */
  27981. get computeBonesUsingShaders(): boolean;
  27982. set computeBonesUsingShaders(value: boolean);
  27983. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27984. get numBoneInfluencers(): number;
  27985. set numBoneInfluencers(value: number);
  27986. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27987. get applyFog(): boolean;
  27988. set applyFog(value: boolean);
  27989. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27990. useOctreeForRenderingSelection: boolean;
  27991. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27992. useOctreeForPicking: boolean;
  27993. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27994. useOctreeForCollisions: boolean;
  27995. /**
  27996. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27997. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27998. */
  27999. get layerMask(): number;
  28000. set layerMask(value: number);
  28001. /**
  28002. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28003. */
  28004. alwaysSelectAsActiveMesh: boolean;
  28005. /**
  28006. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28007. */
  28008. doNotSyncBoundingInfo: boolean;
  28009. /**
  28010. * Gets or sets the current action manager
  28011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28012. */
  28013. actionManager: Nullable<AbstractActionManager>;
  28014. private _meshCollisionData;
  28015. /**
  28016. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28017. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28018. */
  28019. ellipsoid: Vector3;
  28020. /**
  28021. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28022. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28023. */
  28024. ellipsoidOffset: Vector3;
  28025. /**
  28026. * Gets or sets a collision mask used to mask collisions (default is -1).
  28027. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28028. */
  28029. get collisionMask(): number;
  28030. set collisionMask(mask: number);
  28031. /**
  28032. * Gets or sets the current collision group mask (-1 by default).
  28033. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28034. */
  28035. get collisionGroup(): number;
  28036. set collisionGroup(mask: number);
  28037. /**
  28038. * Defines edge width used when edgesRenderer is enabled
  28039. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28040. */
  28041. edgesWidth: number;
  28042. /**
  28043. * Defines edge color used when edgesRenderer is enabled
  28044. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28045. */
  28046. edgesColor: Color4;
  28047. /** @hidden */
  28048. _edgesRenderer: Nullable<IEdgesRenderer>;
  28049. /** @hidden */
  28050. _masterMesh: Nullable<AbstractMesh>;
  28051. /** @hidden */
  28052. _boundingInfo: Nullable<BoundingInfo>;
  28053. /** @hidden */
  28054. _renderId: number;
  28055. /**
  28056. * Gets or sets the list of subMeshes
  28057. * @see http://doc.babylonjs.com/how_to/multi_materials
  28058. */
  28059. subMeshes: SubMesh[];
  28060. /** @hidden */
  28061. _intersectionsInProgress: AbstractMesh[];
  28062. /** @hidden */
  28063. _unIndexed: boolean;
  28064. /** @hidden */
  28065. _lightSources: Light[];
  28066. /** Gets the list of lights affecting that mesh */
  28067. get lightSources(): Light[];
  28068. /** @hidden */
  28069. get _positions(): Nullable<Vector3[]>;
  28070. /** @hidden */
  28071. _waitingData: {
  28072. lods: Nullable<any>;
  28073. actions: Nullable<any>;
  28074. freezeWorldMatrix: Nullable<boolean>;
  28075. };
  28076. /** @hidden */
  28077. _bonesTransformMatrices: Nullable<Float32Array>;
  28078. /** @hidden */
  28079. _transformMatrixTexture: Nullable<RawTexture>;
  28080. /**
  28081. * Gets or sets a skeleton to apply skining transformations
  28082. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28083. */
  28084. set skeleton(value: Nullable<Skeleton>);
  28085. get skeleton(): Nullable<Skeleton>;
  28086. /**
  28087. * An event triggered when the mesh is rebuilt.
  28088. */
  28089. onRebuildObservable: Observable<AbstractMesh>;
  28090. /**
  28091. * Creates a new AbstractMesh
  28092. * @param name defines the name of the mesh
  28093. * @param scene defines the hosting scene
  28094. */
  28095. constructor(name: string, scene?: Nullable<Scene>);
  28096. /**
  28097. * Returns the string "AbstractMesh"
  28098. * @returns "AbstractMesh"
  28099. */
  28100. getClassName(): string;
  28101. /**
  28102. * Gets a string representation of the current mesh
  28103. * @param fullDetails defines a boolean indicating if full details must be included
  28104. * @returns a string representation of the current mesh
  28105. */
  28106. toString(fullDetails?: boolean): string;
  28107. /**
  28108. * @hidden
  28109. */
  28110. protected _getEffectiveParent(): Nullable<Node>;
  28111. /** @hidden */
  28112. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28113. /** @hidden */
  28114. _rebuild(): void;
  28115. /** @hidden */
  28116. _resyncLightSources(): void;
  28117. /** @hidden */
  28118. _resyncLightSource(light: Light): void;
  28119. /** @hidden */
  28120. _unBindEffect(): void;
  28121. /** @hidden */
  28122. _removeLightSource(light: Light, dispose: boolean): void;
  28123. private _markSubMeshesAsDirty;
  28124. /** @hidden */
  28125. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28126. /** @hidden */
  28127. _markSubMeshesAsAttributesDirty(): void;
  28128. /** @hidden */
  28129. _markSubMeshesAsMiscDirty(): void;
  28130. /**
  28131. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28132. */
  28133. get scaling(): Vector3;
  28134. set scaling(newScaling: Vector3);
  28135. /**
  28136. * Returns true if the mesh is blocked. Implemented by child classes
  28137. */
  28138. get isBlocked(): boolean;
  28139. /**
  28140. * Returns the mesh itself by default. Implemented by child classes
  28141. * @param camera defines the camera to use to pick the right LOD level
  28142. * @returns the currentAbstractMesh
  28143. */
  28144. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28145. /**
  28146. * Returns 0 by default. Implemented by child classes
  28147. * @returns an integer
  28148. */
  28149. getTotalVertices(): number;
  28150. /**
  28151. * Returns a positive integer : the total number of indices in this mesh geometry.
  28152. * @returns the numner of indices or zero if the mesh has no geometry.
  28153. */
  28154. getTotalIndices(): number;
  28155. /**
  28156. * Returns null by default. Implemented by child classes
  28157. * @returns null
  28158. */
  28159. getIndices(): Nullable<IndicesArray>;
  28160. /**
  28161. * Returns the array of the requested vertex data kind. Implemented by child classes
  28162. * @param kind defines the vertex data kind to use
  28163. * @returns null
  28164. */
  28165. getVerticesData(kind: string): Nullable<FloatArray>;
  28166. /**
  28167. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28168. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28169. * Note that a new underlying VertexBuffer object is created each call.
  28170. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28171. * @param kind defines vertex data kind:
  28172. * * VertexBuffer.PositionKind
  28173. * * VertexBuffer.UVKind
  28174. * * VertexBuffer.UV2Kind
  28175. * * VertexBuffer.UV3Kind
  28176. * * VertexBuffer.UV4Kind
  28177. * * VertexBuffer.UV5Kind
  28178. * * VertexBuffer.UV6Kind
  28179. * * VertexBuffer.ColorKind
  28180. * * VertexBuffer.MatricesIndicesKind
  28181. * * VertexBuffer.MatricesIndicesExtraKind
  28182. * * VertexBuffer.MatricesWeightsKind
  28183. * * VertexBuffer.MatricesWeightsExtraKind
  28184. * @param data defines the data source
  28185. * @param updatable defines if the data must be flagged as updatable (or static)
  28186. * @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
  28187. * @returns the current mesh
  28188. */
  28189. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28190. /**
  28191. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28192. * If the mesh has no geometry, it is simply returned as it is.
  28193. * @param kind defines vertex data kind:
  28194. * * VertexBuffer.PositionKind
  28195. * * VertexBuffer.UVKind
  28196. * * VertexBuffer.UV2Kind
  28197. * * VertexBuffer.UV3Kind
  28198. * * VertexBuffer.UV4Kind
  28199. * * VertexBuffer.UV5Kind
  28200. * * VertexBuffer.UV6Kind
  28201. * * VertexBuffer.ColorKind
  28202. * * VertexBuffer.MatricesIndicesKind
  28203. * * VertexBuffer.MatricesIndicesExtraKind
  28204. * * VertexBuffer.MatricesWeightsKind
  28205. * * VertexBuffer.MatricesWeightsExtraKind
  28206. * @param data defines the data source
  28207. * @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
  28208. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28209. * @returns the current mesh
  28210. */
  28211. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28212. /**
  28213. * Sets the mesh indices,
  28214. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28215. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28216. * @param totalVertices Defines the total number of vertices
  28217. * @returns the current mesh
  28218. */
  28219. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28220. /**
  28221. * Gets a boolean indicating if specific vertex data is present
  28222. * @param kind defines the vertex data kind to use
  28223. * @returns true is data kind is present
  28224. */
  28225. isVerticesDataPresent(kind: string): boolean;
  28226. /**
  28227. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28228. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28229. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28230. * @returns a BoundingInfo
  28231. */
  28232. getBoundingInfo(): BoundingInfo;
  28233. /**
  28234. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28235. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28236. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28237. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28238. * @returns the current mesh
  28239. */
  28240. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28241. /**
  28242. * Overwrite the current bounding info
  28243. * @param boundingInfo defines the new bounding info
  28244. * @returns the current mesh
  28245. */
  28246. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28247. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28248. get useBones(): boolean;
  28249. /** @hidden */
  28250. _preActivate(): void;
  28251. /** @hidden */
  28252. _preActivateForIntermediateRendering(renderId: number): void;
  28253. /** @hidden */
  28254. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28255. /** @hidden */
  28256. _postActivate(): void;
  28257. /** @hidden */
  28258. _freeze(): void;
  28259. /** @hidden */
  28260. _unFreeze(): void;
  28261. /**
  28262. * Gets the current world matrix
  28263. * @returns a Matrix
  28264. */
  28265. getWorldMatrix(): Matrix;
  28266. /** @hidden */
  28267. _getWorldMatrixDeterminant(): number;
  28268. /**
  28269. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28270. */
  28271. get isAnInstance(): boolean;
  28272. /**
  28273. * Gets a boolean indicating if this mesh has instances
  28274. */
  28275. get hasInstances(): boolean;
  28276. /**
  28277. * Perform relative position change from the point of view of behind the front of the mesh.
  28278. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28279. * Supports definition of mesh facing forward or backward
  28280. * @param amountRight defines the distance on the right axis
  28281. * @param amountUp defines the distance on the up axis
  28282. * @param amountForward defines the distance on the forward axis
  28283. * @returns the current mesh
  28284. */
  28285. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28286. /**
  28287. * Calculate relative position change from the point of view of behind the front of the mesh.
  28288. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28289. * Supports definition of mesh facing forward or backward
  28290. * @param amountRight defines the distance on the right axis
  28291. * @param amountUp defines the distance on the up axis
  28292. * @param amountForward defines the distance on the forward axis
  28293. * @returns the new displacement vector
  28294. */
  28295. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28296. /**
  28297. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28298. * Supports definition of mesh facing forward or backward
  28299. * @param flipBack defines the flip
  28300. * @param twirlClockwise defines the twirl
  28301. * @param tiltRight defines the tilt
  28302. * @returns the current mesh
  28303. */
  28304. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28305. /**
  28306. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28307. * Supports definition of mesh facing forward or backward.
  28308. * @param flipBack defines the flip
  28309. * @param twirlClockwise defines the twirl
  28310. * @param tiltRight defines the tilt
  28311. * @returns the new rotation vector
  28312. */
  28313. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28314. /**
  28315. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28316. * This means the mesh underlying bounding box and sphere are recomputed.
  28317. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28318. * @returns the current mesh
  28319. */
  28320. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28321. /** @hidden */
  28322. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28323. /** @hidden */
  28324. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28325. /** @hidden */
  28326. _updateBoundingInfo(): AbstractMesh;
  28327. /** @hidden */
  28328. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28329. /** @hidden */
  28330. protected _afterComputeWorldMatrix(): void;
  28331. /** @hidden */
  28332. get _effectiveMesh(): AbstractMesh;
  28333. /**
  28334. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28335. * A mesh is in the frustum if its bounding box intersects the frustum
  28336. * @param frustumPlanes defines the frustum to test
  28337. * @returns true if the mesh is in the frustum planes
  28338. */
  28339. isInFrustum(frustumPlanes: Plane[]): boolean;
  28340. /**
  28341. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28342. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28343. * @param frustumPlanes defines the frustum to test
  28344. * @returns true if the mesh is completely in the frustum planes
  28345. */
  28346. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28347. /**
  28348. * True if the mesh intersects another mesh or a SolidParticle object
  28349. * @param mesh defines a target mesh or SolidParticle to test
  28350. * @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)
  28351. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28352. * @returns true if there is an intersection
  28353. */
  28354. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28355. /**
  28356. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28357. * @param point defines the point to test
  28358. * @returns true if there is an intersection
  28359. */
  28360. intersectsPoint(point: Vector3): boolean;
  28361. /**
  28362. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28364. */
  28365. get checkCollisions(): boolean;
  28366. set checkCollisions(collisionEnabled: boolean);
  28367. /**
  28368. * Gets Collider object used to compute collisions (not physics)
  28369. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28370. */
  28371. get collider(): Nullable<Collider>;
  28372. /**
  28373. * Move the mesh using collision engine
  28374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28375. * @param displacement defines the requested displacement vector
  28376. * @returns the current mesh
  28377. */
  28378. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28379. private _onCollisionPositionChange;
  28380. /** @hidden */
  28381. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28382. /** @hidden */
  28383. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28384. /** @hidden */
  28385. _checkCollision(collider: Collider): AbstractMesh;
  28386. /** @hidden */
  28387. _generatePointsArray(): boolean;
  28388. /**
  28389. * Checks if the passed Ray intersects with the mesh
  28390. * @param ray defines the ray to use
  28391. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28392. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28393. * @returns the picking info
  28394. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28395. */
  28396. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28397. /**
  28398. * Clones the current mesh
  28399. * @param name defines the mesh name
  28400. * @param newParent defines the new mesh parent
  28401. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28402. * @returns the new mesh
  28403. */
  28404. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28405. /**
  28406. * Disposes all the submeshes of the current meshnp
  28407. * @returns the current mesh
  28408. */
  28409. releaseSubMeshes(): AbstractMesh;
  28410. /**
  28411. * Releases resources associated with this abstract mesh.
  28412. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28413. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28414. */
  28415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28416. /**
  28417. * Adds the passed mesh as a child to the current mesh
  28418. * @param mesh defines the child mesh
  28419. * @returns the current mesh
  28420. */
  28421. addChild(mesh: AbstractMesh): AbstractMesh;
  28422. /**
  28423. * Removes the passed mesh from the current mesh children list
  28424. * @param mesh defines the child mesh
  28425. * @returns the current mesh
  28426. */
  28427. removeChild(mesh: AbstractMesh): AbstractMesh;
  28428. /** @hidden */
  28429. private _initFacetData;
  28430. /**
  28431. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28432. * This method can be called within the render loop.
  28433. * 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
  28434. * @returns the current mesh
  28435. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28436. */
  28437. updateFacetData(): AbstractMesh;
  28438. /**
  28439. * Returns the facetLocalNormals array.
  28440. * The normals are expressed in the mesh local spac
  28441. * @returns an array of Vector3
  28442. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28443. */
  28444. getFacetLocalNormals(): Vector3[];
  28445. /**
  28446. * Returns the facetLocalPositions array.
  28447. * The facet positions are expressed in the mesh local space
  28448. * @returns an array of Vector3
  28449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28450. */
  28451. getFacetLocalPositions(): Vector3[];
  28452. /**
  28453. * Returns the facetLocalPartioning array
  28454. * @returns an array of array of numbers
  28455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28456. */
  28457. getFacetLocalPartitioning(): number[][];
  28458. /**
  28459. * Returns the i-th facet position in the world system.
  28460. * This method allocates a new Vector3 per call
  28461. * @param i defines the facet index
  28462. * @returns a new Vector3
  28463. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28464. */
  28465. getFacetPosition(i: number): Vector3;
  28466. /**
  28467. * Sets the reference Vector3 with the i-th facet position in the world system
  28468. * @param i defines the facet index
  28469. * @param ref defines the target vector
  28470. * @returns the current mesh
  28471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28472. */
  28473. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28474. /**
  28475. * Returns the i-th facet normal in the world system.
  28476. * This method allocates a new Vector3 per call
  28477. * @param i defines the facet index
  28478. * @returns a new Vector3
  28479. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28480. */
  28481. getFacetNormal(i: number): Vector3;
  28482. /**
  28483. * Sets the reference Vector3 with the i-th facet normal in the world system
  28484. * @param i defines the facet index
  28485. * @param ref defines the target vector
  28486. * @returns the current mesh
  28487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28488. */
  28489. getFacetNormalToRef(i: number, ref: Vector3): this;
  28490. /**
  28491. * 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)
  28492. * @param x defines x coordinate
  28493. * @param y defines y coordinate
  28494. * @param z defines z coordinate
  28495. * @returns the array of facet indexes
  28496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28497. */
  28498. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28499. /**
  28500. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28501. * @param projected sets as the (x,y,z) world projection on the facet
  28502. * @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
  28503. * @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
  28504. * @param x defines x coordinate
  28505. * @param y defines y coordinate
  28506. * @param z defines z coordinate
  28507. * @returns the face index if found (or null instead)
  28508. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28509. */
  28510. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28511. /**
  28512. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28513. * @param projected sets as the (x,y,z) local projection on the facet
  28514. * @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
  28515. * @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
  28516. * @param x defines x coordinate
  28517. * @param y defines y coordinate
  28518. * @param z defines z coordinate
  28519. * @returns the face index if found (or null instead)
  28520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28521. */
  28522. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28523. /**
  28524. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28525. * @returns the parameters
  28526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28527. */
  28528. getFacetDataParameters(): any;
  28529. /**
  28530. * Disables the feature FacetData and frees the related memory
  28531. * @returns the current mesh
  28532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28533. */
  28534. disableFacetData(): AbstractMesh;
  28535. /**
  28536. * Updates the AbstractMesh indices array
  28537. * @param indices defines the data source
  28538. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28539. * @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)
  28540. * @returns the current mesh
  28541. */
  28542. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28543. /**
  28544. * Creates new normals data for the mesh
  28545. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28546. * @returns the current mesh
  28547. */
  28548. createNormals(updatable: boolean): AbstractMesh;
  28549. /**
  28550. * Align the mesh with a normal
  28551. * @param normal defines the normal to use
  28552. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28553. * @returns the current mesh
  28554. */
  28555. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28556. /** @hidden */
  28557. _checkOcclusionQuery(): boolean;
  28558. /**
  28559. * Disables the mesh edge rendering mode
  28560. * @returns the currentAbstractMesh
  28561. */
  28562. disableEdgesRendering(): AbstractMesh;
  28563. /**
  28564. * Enables the edge rendering mode on the mesh.
  28565. * This mode makes the mesh edges visible
  28566. * @param epsilon defines the maximal distance between two angles to detect a face
  28567. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28568. * @returns the currentAbstractMesh
  28569. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28570. */
  28571. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28572. }
  28573. }
  28574. declare module BABYLON {
  28575. /**
  28576. * Interface used to define ActionEvent
  28577. */
  28578. export interface IActionEvent {
  28579. /** The mesh or sprite that triggered the action */
  28580. source: any;
  28581. /** The X mouse cursor position at the time of the event */
  28582. pointerX: number;
  28583. /** The Y mouse cursor position at the time of the event */
  28584. pointerY: number;
  28585. /** The mesh that is currently pointed at (can be null) */
  28586. meshUnderPointer: Nullable<AbstractMesh>;
  28587. /** the original (browser) event that triggered the ActionEvent */
  28588. sourceEvent?: any;
  28589. /** additional data for the event */
  28590. additionalData?: any;
  28591. }
  28592. /**
  28593. * ActionEvent is the event being sent when an action is triggered.
  28594. */
  28595. export class ActionEvent implements IActionEvent {
  28596. /** The mesh or sprite that triggered the action */
  28597. source: any;
  28598. /** The X mouse cursor position at the time of the event */
  28599. pointerX: number;
  28600. /** The Y mouse cursor position at the time of the event */
  28601. pointerY: number;
  28602. /** The mesh that is currently pointed at (can be null) */
  28603. meshUnderPointer: Nullable<AbstractMesh>;
  28604. /** the original (browser) event that triggered the ActionEvent */
  28605. sourceEvent?: any;
  28606. /** additional data for the event */
  28607. additionalData?: any;
  28608. /**
  28609. * Creates a new ActionEvent
  28610. * @param source The mesh or sprite that triggered the action
  28611. * @param pointerX The X mouse cursor position at the time of the event
  28612. * @param pointerY The Y mouse cursor position at the time of the event
  28613. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28614. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28615. * @param additionalData additional data for the event
  28616. */
  28617. constructor(
  28618. /** The mesh or sprite that triggered the action */
  28619. source: any,
  28620. /** The X mouse cursor position at the time of the event */
  28621. pointerX: number,
  28622. /** The Y mouse cursor position at the time of the event */
  28623. pointerY: number,
  28624. /** The mesh that is currently pointed at (can be null) */
  28625. meshUnderPointer: Nullable<AbstractMesh>,
  28626. /** the original (browser) event that triggered the ActionEvent */
  28627. sourceEvent?: any,
  28628. /** additional data for the event */
  28629. additionalData?: any);
  28630. /**
  28631. * Helper function to auto-create an ActionEvent from a source mesh.
  28632. * @param source The source mesh that triggered the event
  28633. * @param evt The original (browser) event
  28634. * @param additionalData additional data for the event
  28635. * @returns the new ActionEvent
  28636. */
  28637. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28638. /**
  28639. * Helper function to auto-create an ActionEvent from a source sprite
  28640. * @param source The source sprite that triggered the event
  28641. * @param scene Scene associated with the sprite
  28642. * @param evt The original (browser) event
  28643. * @param additionalData additional data for the event
  28644. * @returns the new ActionEvent
  28645. */
  28646. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28647. /**
  28648. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28649. * @param scene the scene where the event occurred
  28650. * @param evt The original (browser) event
  28651. * @returns the new ActionEvent
  28652. */
  28653. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28654. /**
  28655. * Helper function to auto-create an ActionEvent from a primitive
  28656. * @param prim defines the target primitive
  28657. * @param pointerPos defines the pointer position
  28658. * @param evt The original (browser) event
  28659. * @param additionalData additional data for the event
  28660. * @returns the new ActionEvent
  28661. */
  28662. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28663. }
  28664. }
  28665. declare module BABYLON {
  28666. /**
  28667. * Abstract class used to decouple action Manager from scene and meshes.
  28668. * Do not instantiate.
  28669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28670. */
  28671. export abstract class AbstractActionManager implements IDisposable {
  28672. /** Gets the list of active triggers */
  28673. static Triggers: {
  28674. [key: string]: number;
  28675. };
  28676. /** Gets the cursor to use when hovering items */
  28677. hoverCursor: string;
  28678. /** Gets the list of actions */
  28679. actions: IAction[];
  28680. /**
  28681. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28682. */
  28683. isRecursive: boolean;
  28684. /**
  28685. * Releases all associated resources
  28686. */
  28687. abstract dispose(): void;
  28688. /**
  28689. * Does this action manager has pointer triggers
  28690. */
  28691. abstract get hasPointerTriggers(): boolean;
  28692. /**
  28693. * Does this action manager has pick triggers
  28694. */
  28695. abstract get hasPickTriggers(): boolean;
  28696. /**
  28697. * Process a specific trigger
  28698. * @param trigger defines the trigger to process
  28699. * @param evt defines the event details to be processed
  28700. */
  28701. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28702. /**
  28703. * Does this action manager handles actions of any of the given triggers
  28704. * @param triggers defines the triggers to be tested
  28705. * @return a boolean indicating whether one (or more) of the triggers is handled
  28706. */
  28707. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28708. /**
  28709. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28710. * speed.
  28711. * @param triggerA defines the trigger to be tested
  28712. * @param triggerB defines the trigger to be tested
  28713. * @return a boolean indicating whether one (or more) of the triggers is handled
  28714. */
  28715. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28716. /**
  28717. * Does this action manager handles actions of a given trigger
  28718. * @param trigger defines the trigger to be tested
  28719. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28720. * @return whether the trigger is handled
  28721. */
  28722. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28723. /**
  28724. * Serialize this manager to a JSON object
  28725. * @param name defines the property name to store this manager
  28726. * @returns a JSON representation of this manager
  28727. */
  28728. abstract serialize(name: string): any;
  28729. /**
  28730. * Registers an action to this action manager
  28731. * @param action defines the action to be registered
  28732. * @return the action amended (prepared) after registration
  28733. */
  28734. abstract registerAction(action: IAction): Nullable<IAction>;
  28735. /**
  28736. * Unregisters an action to this action manager
  28737. * @param action defines the action to be unregistered
  28738. * @return a boolean indicating whether the action has been unregistered
  28739. */
  28740. abstract unregisterAction(action: IAction): Boolean;
  28741. /**
  28742. * Does exist one action manager with at least one trigger
  28743. **/
  28744. static get HasTriggers(): boolean;
  28745. /**
  28746. * Does exist one action manager with at least one pick trigger
  28747. **/
  28748. static get HasPickTriggers(): boolean;
  28749. /**
  28750. * Does exist one action manager that handles actions of a given trigger
  28751. * @param trigger defines the trigger to be tested
  28752. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28753. **/
  28754. static HasSpecificTrigger(trigger: number): boolean;
  28755. }
  28756. }
  28757. declare module BABYLON {
  28758. /**
  28759. * Defines how a node can be built from a string name.
  28760. */
  28761. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28762. /**
  28763. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28764. */
  28765. export class Node implements IBehaviorAware<Node> {
  28766. /** @hidden */
  28767. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28768. private static _NodeConstructors;
  28769. /**
  28770. * Add a new node constructor
  28771. * @param type defines the type name of the node to construct
  28772. * @param constructorFunc defines the constructor function
  28773. */
  28774. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28775. /**
  28776. * Returns a node constructor based on type name
  28777. * @param type defines the type name
  28778. * @param name defines the new node name
  28779. * @param scene defines the hosting scene
  28780. * @param options defines optional options to transmit to constructors
  28781. * @returns the new constructor or null
  28782. */
  28783. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28784. /**
  28785. * Gets or sets the name of the node
  28786. */
  28787. name: string;
  28788. /**
  28789. * Gets or sets the id of the node
  28790. */
  28791. id: string;
  28792. /**
  28793. * Gets or sets the unique id of the node
  28794. */
  28795. uniqueId: number;
  28796. /**
  28797. * Gets or sets a string used to store user defined state for the node
  28798. */
  28799. state: string;
  28800. /**
  28801. * Gets or sets an object used to store user defined information for the node
  28802. */
  28803. metadata: any;
  28804. /**
  28805. * For internal use only. Please do not use.
  28806. */
  28807. reservedDataStore: any;
  28808. /**
  28809. * List of inspectable custom properties (used by the Inspector)
  28810. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28811. */
  28812. inspectableCustomProperties: IInspectable[];
  28813. private _doNotSerialize;
  28814. /**
  28815. * Gets or sets a boolean used to define if the node must be serialized
  28816. */
  28817. get doNotSerialize(): boolean;
  28818. set doNotSerialize(value: boolean);
  28819. /** @hidden */
  28820. _isDisposed: boolean;
  28821. /**
  28822. * Gets a list of Animations associated with the node
  28823. */
  28824. animations: Animation[];
  28825. protected _ranges: {
  28826. [name: string]: Nullable<AnimationRange>;
  28827. };
  28828. /**
  28829. * Callback raised when the node is ready to be used
  28830. */
  28831. onReady: Nullable<(node: Node) => void>;
  28832. private _isEnabled;
  28833. private _isParentEnabled;
  28834. private _isReady;
  28835. /** @hidden */
  28836. _currentRenderId: number;
  28837. private _parentUpdateId;
  28838. /** @hidden */
  28839. _childUpdateId: number;
  28840. /** @hidden */
  28841. _waitingParentId: Nullable<string>;
  28842. /** @hidden */
  28843. _scene: Scene;
  28844. /** @hidden */
  28845. _cache: any;
  28846. private _parentNode;
  28847. private _children;
  28848. /** @hidden */
  28849. _worldMatrix: Matrix;
  28850. /** @hidden */
  28851. _worldMatrixDeterminant: number;
  28852. /** @hidden */
  28853. _worldMatrixDeterminantIsDirty: boolean;
  28854. /** @hidden */
  28855. private _sceneRootNodesIndex;
  28856. /**
  28857. * Gets a boolean indicating if the node has been disposed
  28858. * @returns true if the node was disposed
  28859. */
  28860. isDisposed(): boolean;
  28861. /**
  28862. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28863. * @see https://doc.babylonjs.com/how_to/parenting
  28864. */
  28865. set parent(parent: Nullable<Node>);
  28866. get parent(): Nullable<Node>;
  28867. /** @hidden */
  28868. _addToSceneRootNodes(): void;
  28869. /** @hidden */
  28870. _removeFromSceneRootNodes(): void;
  28871. private _animationPropertiesOverride;
  28872. /**
  28873. * Gets or sets the animation properties override
  28874. */
  28875. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28876. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28877. /**
  28878. * Gets a string idenfifying the name of the class
  28879. * @returns "Node" string
  28880. */
  28881. getClassName(): string;
  28882. /** @hidden */
  28883. readonly _isNode: boolean;
  28884. /**
  28885. * An event triggered when the mesh is disposed
  28886. */
  28887. onDisposeObservable: Observable<Node>;
  28888. private _onDisposeObserver;
  28889. /**
  28890. * Sets a callback that will be raised when the node will be disposed
  28891. */
  28892. set onDispose(callback: () => void);
  28893. /**
  28894. * Creates a new Node
  28895. * @param name the name and id to be given to this node
  28896. * @param scene the scene this node will be added to
  28897. */
  28898. constructor(name: string, scene?: Nullable<Scene>);
  28899. /**
  28900. * Gets the scene of the node
  28901. * @returns a scene
  28902. */
  28903. getScene(): Scene;
  28904. /**
  28905. * Gets the engine of the node
  28906. * @returns a Engine
  28907. */
  28908. getEngine(): Engine;
  28909. private _behaviors;
  28910. /**
  28911. * Attach a behavior to the node
  28912. * @see http://doc.babylonjs.com/features/behaviour
  28913. * @param behavior defines the behavior to attach
  28914. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28915. * @returns the current Node
  28916. */
  28917. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28918. /**
  28919. * Remove an attached behavior
  28920. * @see http://doc.babylonjs.com/features/behaviour
  28921. * @param behavior defines the behavior to attach
  28922. * @returns the current Node
  28923. */
  28924. removeBehavior(behavior: Behavior<Node>): Node;
  28925. /**
  28926. * Gets the list of attached behaviors
  28927. * @see http://doc.babylonjs.com/features/behaviour
  28928. */
  28929. get behaviors(): Behavior<Node>[];
  28930. /**
  28931. * Gets an attached behavior by name
  28932. * @param name defines the name of the behavior to look for
  28933. * @see http://doc.babylonjs.com/features/behaviour
  28934. * @returns null if behavior was not found else the requested behavior
  28935. */
  28936. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28937. /**
  28938. * Returns the latest update of the World matrix
  28939. * @returns a Matrix
  28940. */
  28941. getWorldMatrix(): Matrix;
  28942. /** @hidden */
  28943. _getWorldMatrixDeterminant(): number;
  28944. /**
  28945. * Returns directly the latest state of the mesh World matrix.
  28946. * A Matrix is returned.
  28947. */
  28948. get worldMatrixFromCache(): Matrix;
  28949. /** @hidden */
  28950. _initCache(): void;
  28951. /** @hidden */
  28952. updateCache(force?: boolean): void;
  28953. /** @hidden */
  28954. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28955. /** @hidden */
  28956. _updateCache(ignoreParentClass?: boolean): void;
  28957. /** @hidden */
  28958. _isSynchronized(): boolean;
  28959. /** @hidden */
  28960. _markSyncedWithParent(): void;
  28961. /** @hidden */
  28962. isSynchronizedWithParent(): boolean;
  28963. /** @hidden */
  28964. isSynchronized(): boolean;
  28965. /**
  28966. * Is this node ready to be used/rendered
  28967. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28968. * @return true if the node is ready
  28969. */
  28970. isReady(completeCheck?: boolean): boolean;
  28971. /**
  28972. * Is this node enabled?
  28973. * 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
  28974. * @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
  28975. * @return whether this node (and its parent) is enabled
  28976. */
  28977. isEnabled(checkAncestors?: boolean): boolean;
  28978. /** @hidden */
  28979. protected _syncParentEnabledState(): void;
  28980. /**
  28981. * Set the enabled state of this node
  28982. * @param value defines the new enabled state
  28983. */
  28984. setEnabled(value: boolean): void;
  28985. /**
  28986. * Is this node a descendant of the given node?
  28987. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28988. * @param ancestor defines the parent node to inspect
  28989. * @returns a boolean indicating if this node is a descendant of the given node
  28990. */
  28991. isDescendantOf(ancestor: Node): boolean;
  28992. /** @hidden */
  28993. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28994. /**
  28995. * Will return all nodes that have this node as ascendant
  28996. * @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
  28997. * @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
  28998. * @return all children nodes of all types
  28999. */
  29000. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29001. /**
  29002. * Get all child-meshes of this node
  29003. * @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)
  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. * @returns an array of AbstractMesh
  29006. */
  29007. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29008. /**
  29009. * Get all direct children of this node
  29010. * @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
  29011. * @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)
  29012. * @returns an array of Node
  29013. */
  29014. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29015. /** @hidden */
  29016. _setReady(state: boolean): void;
  29017. /**
  29018. * Get an animation by name
  29019. * @param name defines the name of the animation to look for
  29020. * @returns null if not found else the requested animation
  29021. */
  29022. getAnimationByName(name: string): Nullable<Animation>;
  29023. /**
  29024. * Creates an animation range for this node
  29025. * @param name defines the name of the range
  29026. * @param from defines the starting key
  29027. * @param to defines the end key
  29028. */
  29029. createAnimationRange(name: string, from: number, to: number): void;
  29030. /**
  29031. * Delete a specific animation range
  29032. * @param name defines the name of the range to delete
  29033. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29034. */
  29035. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29036. /**
  29037. * Get an animation range by name
  29038. * @param name defines the name of the animation range to look for
  29039. * @returns null if not found else the requested animation range
  29040. */
  29041. getAnimationRange(name: string): Nullable<AnimationRange>;
  29042. /**
  29043. * Gets the list of all animation ranges defined on this node
  29044. * @returns an array
  29045. */
  29046. getAnimationRanges(): Nullable<AnimationRange>[];
  29047. /**
  29048. * Will start the animation sequence
  29049. * @param name defines the range frames for animation sequence
  29050. * @param loop defines if the animation should loop (false by default)
  29051. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29052. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29053. * @returns the object created for this animation. If range does not exist, it will return null
  29054. */
  29055. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29056. /**
  29057. * Serialize animation ranges into a JSON compatible object
  29058. * @returns serialization object
  29059. */
  29060. serializeAnimationRanges(): any;
  29061. /**
  29062. * Computes the world matrix of the node
  29063. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29064. * @returns the world matrix
  29065. */
  29066. computeWorldMatrix(force?: boolean): Matrix;
  29067. /**
  29068. * Releases resources associated with this node.
  29069. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29070. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29071. */
  29072. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29073. /**
  29074. * Parse animation range data from a serialization object and store them into a given node
  29075. * @param node defines where to store the animation ranges
  29076. * @param parsedNode defines the serialization object to read data from
  29077. * @param scene defines the hosting scene
  29078. */
  29079. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29080. /**
  29081. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29082. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29083. * @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
  29084. * @returns the new bounding vectors
  29085. */
  29086. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29087. min: Vector3;
  29088. max: Vector3;
  29089. };
  29090. }
  29091. }
  29092. declare module BABYLON {
  29093. /**
  29094. * @hidden
  29095. */
  29096. export class _IAnimationState {
  29097. key: number;
  29098. repeatCount: number;
  29099. workValue?: any;
  29100. loopMode?: number;
  29101. offsetValue?: any;
  29102. highLimitValue?: any;
  29103. }
  29104. /**
  29105. * Class used to store any kind of animation
  29106. */
  29107. export class Animation {
  29108. /**Name of the animation */
  29109. name: string;
  29110. /**Property to animate */
  29111. targetProperty: string;
  29112. /**The frames per second of the animation */
  29113. framePerSecond: number;
  29114. /**The data type of the animation */
  29115. dataType: number;
  29116. /**The loop mode of the animation */
  29117. loopMode?: number | undefined;
  29118. /**Specifies if blending should be enabled */
  29119. enableBlending?: boolean | undefined;
  29120. /**
  29121. * Use matrix interpolation instead of using direct key value when animating matrices
  29122. */
  29123. static AllowMatricesInterpolation: boolean;
  29124. /**
  29125. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29126. */
  29127. static AllowMatrixDecomposeForInterpolation: boolean;
  29128. /**
  29129. * Stores the key frames of the animation
  29130. */
  29131. private _keys;
  29132. /**
  29133. * Stores the easing function of the animation
  29134. */
  29135. private _easingFunction;
  29136. /**
  29137. * @hidden Internal use only
  29138. */
  29139. _runtimeAnimations: RuntimeAnimation[];
  29140. /**
  29141. * The set of event that will be linked to this animation
  29142. */
  29143. private _events;
  29144. /**
  29145. * Stores an array of target property paths
  29146. */
  29147. targetPropertyPath: string[];
  29148. /**
  29149. * Stores the blending speed of the animation
  29150. */
  29151. blendingSpeed: number;
  29152. /**
  29153. * Stores the animation ranges for the animation
  29154. */
  29155. private _ranges;
  29156. /**
  29157. * @hidden Internal use
  29158. */
  29159. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29160. /**
  29161. * Sets up an animation
  29162. * @param property The property to animate
  29163. * @param animationType The animation type to apply
  29164. * @param framePerSecond The frames per second of the animation
  29165. * @param easingFunction The easing function used in the animation
  29166. * @returns The created animation
  29167. */
  29168. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29169. /**
  29170. * Create and start an animation on a node
  29171. * @param name defines the name of the global animation that will be run on all nodes
  29172. * @param node defines the root node where the animation will take place
  29173. * @param targetProperty defines property to animate
  29174. * @param framePerSecond defines the number of frame per second yo use
  29175. * @param totalFrame defines the number of frames in total
  29176. * @param from defines the initial value
  29177. * @param to defines the final value
  29178. * @param loopMode defines which loop mode you want to use (off by default)
  29179. * @param easingFunction defines the easing function to use (linear by default)
  29180. * @param onAnimationEnd defines the callback to call when animation end
  29181. * @returns the animatable created for this animation
  29182. */
  29183. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29184. /**
  29185. * Create and start an animation on a node and its descendants
  29186. * @param name defines the name of the global animation that will be run on all nodes
  29187. * @param node defines the root node where the animation will take place
  29188. * @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
  29189. * @param targetProperty defines property to animate
  29190. * @param framePerSecond defines the number of frame per second to use
  29191. * @param totalFrame defines the number of frames in total
  29192. * @param from defines the initial value
  29193. * @param to defines the final value
  29194. * @param loopMode defines which loop mode you want to use (off by default)
  29195. * @param easingFunction defines the easing function to use (linear by default)
  29196. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29197. * @returns the list of animatables created for all nodes
  29198. * @example https://www.babylonjs-playground.com/#MH0VLI
  29199. */
  29200. 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[]>;
  29201. /**
  29202. * Creates a new animation, merges it with the existing animations and starts it
  29203. * @param name Name of the animation
  29204. * @param node Node which contains the scene that begins the animations
  29205. * @param targetProperty Specifies which property to animate
  29206. * @param framePerSecond The frames per second of the animation
  29207. * @param totalFrame The total number of frames
  29208. * @param from The frame at the beginning of the animation
  29209. * @param to The frame at the end of the animation
  29210. * @param loopMode Specifies the loop mode of the animation
  29211. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29212. * @param onAnimationEnd Callback to run once the animation is complete
  29213. * @returns Nullable animation
  29214. */
  29215. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29216. /**
  29217. * Transition property of an host to the target Value
  29218. * @param property The property to transition
  29219. * @param targetValue The target Value of the property
  29220. * @param host The object where the property to animate belongs
  29221. * @param scene Scene used to run the animation
  29222. * @param frameRate Framerate (in frame/s) to use
  29223. * @param transition The transition type we want to use
  29224. * @param duration The duration of the animation, in milliseconds
  29225. * @param onAnimationEnd Callback trigger at the end of the animation
  29226. * @returns Nullable animation
  29227. */
  29228. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29229. /**
  29230. * Return the array of runtime animations currently using this animation
  29231. */
  29232. get runtimeAnimations(): RuntimeAnimation[];
  29233. /**
  29234. * Specifies if any of the runtime animations are currently running
  29235. */
  29236. get hasRunningRuntimeAnimations(): boolean;
  29237. /**
  29238. * Initializes the animation
  29239. * @param name Name of the animation
  29240. * @param targetProperty Property to animate
  29241. * @param framePerSecond The frames per second of the animation
  29242. * @param dataType The data type of the animation
  29243. * @param loopMode The loop mode of the animation
  29244. * @param enableBlending Specifies if blending should be enabled
  29245. */
  29246. constructor(
  29247. /**Name of the animation */
  29248. name: string,
  29249. /**Property to animate */
  29250. targetProperty: string,
  29251. /**The frames per second of the animation */
  29252. framePerSecond: number,
  29253. /**The data type of the animation */
  29254. dataType: number,
  29255. /**The loop mode of the animation */
  29256. loopMode?: number | undefined,
  29257. /**Specifies if blending should be enabled */
  29258. enableBlending?: boolean | undefined);
  29259. /**
  29260. * Converts the animation to a string
  29261. * @param fullDetails support for multiple levels of logging within scene loading
  29262. * @returns String form of the animation
  29263. */
  29264. toString(fullDetails?: boolean): string;
  29265. /**
  29266. * Add an event to this animation
  29267. * @param event Event to add
  29268. */
  29269. addEvent(event: AnimationEvent): void;
  29270. /**
  29271. * Remove all events found at the given frame
  29272. * @param frame The frame to remove events from
  29273. */
  29274. removeEvents(frame: number): void;
  29275. /**
  29276. * Retrieves all the events from the animation
  29277. * @returns Events from the animation
  29278. */
  29279. getEvents(): AnimationEvent[];
  29280. /**
  29281. * Creates an animation range
  29282. * @param name Name of the animation range
  29283. * @param from Starting frame of the animation range
  29284. * @param to Ending frame of the animation
  29285. */
  29286. createRange(name: string, from: number, to: number): void;
  29287. /**
  29288. * Deletes an animation range by name
  29289. * @param name Name of the animation range to delete
  29290. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29291. */
  29292. deleteRange(name: string, deleteFrames?: boolean): void;
  29293. /**
  29294. * Gets the animation range by name, or null if not defined
  29295. * @param name Name of the animation range
  29296. * @returns Nullable animation range
  29297. */
  29298. getRange(name: string): Nullable<AnimationRange>;
  29299. /**
  29300. * Gets the key frames from the animation
  29301. * @returns The key frames of the animation
  29302. */
  29303. getKeys(): Array<IAnimationKey>;
  29304. /**
  29305. * Gets the highest frame rate of the animation
  29306. * @returns Highest frame rate of the animation
  29307. */
  29308. getHighestFrame(): number;
  29309. /**
  29310. * Gets the easing function of the animation
  29311. * @returns Easing function of the animation
  29312. */
  29313. getEasingFunction(): IEasingFunction;
  29314. /**
  29315. * Sets the easing function of the animation
  29316. * @param easingFunction A custom mathematical formula for animation
  29317. */
  29318. setEasingFunction(easingFunction: EasingFunction): void;
  29319. /**
  29320. * Interpolates a scalar linearly
  29321. * @param startValue Start value of the animation curve
  29322. * @param endValue End value of the animation curve
  29323. * @param gradient Scalar amount to interpolate
  29324. * @returns Interpolated scalar value
  29325. */
  29326. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29327. /**
  29328. * Interpolates a scalar cubically
  29329. * @param startValue Start value of the animation curve
  29330. * @param outTangent End tangent of the animation
  29331. * @param endValue End value of the animation curve
  29332. * @param inTangent Start tangent of the animation curve
  29333. * @param gradient Scalar amount to interpolate
  29334. * @returns Interpolated scalar value
  29335. */
  29336. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29337. /**
  29338. * Interpolates a quaternion using a spherical linear interpolation
  29339. * @param startValue Start value of the animation curve
  29340. * @param endValue End value of the animation curve
  29341. * @param gradient Scalar amount to interpolate
  29342. * @returns Interpolated quaternion value
  29343. */
  29344. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29345. /**
  29346. * Interpolates a quaternion cubically
  29347. * @param startValue Start value of the animation curve
  29348. * @param outTangent End tangent of the animation curve
  29349. * @param endValue End value of the animation curve
  29350. * @param inTangent Start tangent of the animation curve
  29351. * @param gradient Scalar amount to interpolate
  29352. * @returns Interpolated quaternion value
  29353. */
  29354. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29355. /**
  29356. * Interpolates a Vector3 linearl
  29357. * @param startValue Start value of the animation curve
  29358. * @param endValue End value of the animation curve
  29359. * @param gradient Scalar amount to interpolate
  29360. * @returns Interpolated scalar value
  29361. */
  29362. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29363. /**
  29364. * Interpolates a Vector3 cubically
  29365. * @param startValue Start value of the animation curve
  29366. * @param outTangent End tangent of the animation
  29367. * @param endValue End value of the animation curve
  29368. * @param inTangent Start tangent of the animation curve
  29369. * @param gradient Scalar amount to interpolate
  29370. * @returns InterpolatedVector3 value
  29371. */
  29372. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29373. /**
  29374. * Interpolates a Vector2 linearly
  29375. * @param startValue Start value of the animation curve
  29376. * @param endValue End value of the animation curve
  29377. * @param gradient Scalar amount to interpolate
  29378. * @returns Interpolated Vector2 value
  29379. */
  29380. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29381. /**
  29382. * Interpolates a Vector2 cubically
  29383. * @param startValue Start value of the animation curve
  29384. * @param outTangent End tangent of the animation
  29385. * @param endValue End value of the animation curve
  29386. * @param inTangent Start tangent of the animation curve
  29387. * @param gradient Scalar amount to interpolate
  29388. * @returns Interpolated Vector2 value
  29389. */
  29390. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29391. /**
  29392. * Interpolates a size linearly
  29393. * @param startValue Start value of the animation curve
  29394. * @param endValue End value of the animation curve
  29395. * @param gradient Scalar amount to interpolate
  29396. * @returns Interpolated Size value
  29397. */
  29398. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29399. /**
  29400. * Interpolates a Color3 linearly
  29401. * @param startValue Start value of the animation curve
  29402. * @param endValue End value of the animation curve
  29403. * @param gradient Scalar amount to interpolate
  29404. * @returns Interpolated Color3 value
  29405. */
  29406. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29407. /**
  29408. * Interpolates a Color4 linearly
  29409. * @param startValue Start value of the animation curve
  29410. * @param endValue End value of the animation curve
  29411. * @param gradient Scalar amount to interpolate
  29412. * @returns Interpolated Color3 value
  29413. */
  29414. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29415. /**
  29416. * @hidden Internal use only
  29417. */
  29418. _getKeyValue(value: any): any;
  29419. /**
  29420. * @hidden Internal use only
  29421. */
  29422. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29423. /**
  29424. * Defines the function to use to interpolate matrices
  29425. * @param startValue defines the start matrix
  29426. * @param endValue defines the end matrix
  29427. * @param gradient defines the gradient between both matrices
  29428. * @param result defines an optional target matrix where to store the interpolation
  29429. * @returns the interpolated matrix
  29430. */
  29431. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29432. /**
  29433. * Makes a copy of the animation
  29434. * @returns Cloned animation
  29435. */
  29436. clone(): Animation;
  29437. /**
  29438. * Sets the key frames of the animation
  29439. * @param values The animation key frames to set
  29440. */
  29441. setKeys(values: Array<IAnimationKey>): void;
  29442. /**
  29443. * Serializes the animation to an object
  29444. * @returns Serialized object
  29445. */
  29446. serialize(): any;
  29447. /**
  29448. * Float animation type
  29449. */
  29450. static readonly ANIMATIONTYPE_FLOAT: number;
  29451. /**
  29452. * Vector3 animation type
  29453. */
  29454. static readonly ANIMATIONTYPE_VECTOR3: number;
  29455. /**
  29456. * Quaternion animation type
  29457. */
  29458. static readonly ANIMATIONTYPE_QUATERNION: number;
  29459. /**
  29460. * Matrix animation type
  29461. */
  29462. static readonly ANIMATIONTYPE_MATRIX: number;
  29463. /**
  29464. * Color3 animation type
  29465. */
  29466. static readonly ANIMATIONTYPE_COLOR3: number;
  29467. /**
  29468. * Color3 animation type
  29469. */
  29470. static readonly ANIMATIONTYPE_COLOR4: number;
  29471. /**
  29472. * Vector2 animation type
  29473. */
  29474. static readonly ANIMATIONTYPE_VECTOR2: number;
  29475. /**
  29476. * Size animation type
  29477. */
  29478. static readonly ANIMATIONTYPE_SIZE: number;
  29479. /**
  29480. * Relative Loop Mode
  29481. */
  29482. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29483. /**
  29484. * Cycle Loop Mode
  29485. */
  29486. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29487. /**
  29488. * Constant Loop Mode
  29489. */
  29490. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29491. /** @hidden */
  29492. static _UniversalLerp(left: any, right: any, amount: number): any;
  29493. /**
  29494. * Parses an animation object and creates an animation
  29495. * @param parsedAnimation Parsed animation object
  29496. * @returns Animation object
  29497. */
  29498. static Parse(parsedAnimation: any): Animation;
  29499. /**
  29500. * Appends the serialized animations from the source animations
  29501. * @param source Source containing the animations
  29502. * @param destination Target to store the animations
  29503. */
  29504. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29505. }
  29506. }
  29507. declare module BABYLON {
  29508. /**
  29509. * Interface containing an array of animations
  29510. */
  29511. export interface IAnimatable {
  29512. /**
  29513. * Array of animations
  29514. */
  29515. animations: Nullable<Array<Animation>>;
  29516. }
  29517. }
  29518. declare module BABYLON {
  29519. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29520. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29521. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29522. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29523. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29524. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29525. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29526. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29527. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29528. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29529. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29530. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29531. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29532. /**
  29533. * Decorator used to define property that can be serialized as reference to a camera
  29534. * @param sourceName defines the name of the property to decorate
  29535. */
  29536. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29537. /**
  29538. * Class used to help serialization objects
  29539. */
  29540. export class SerializationHelper {
  29541. /** @hidden */
  29542. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29543. /** @hidden */
  29544. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29545. /** @hidden */
  29546. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29547. /** @hidden */
  29548. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29549. /**
  29550. * Appends the serialized animations from the source animations
  29551. * @param source Source containing the animations
  29552. * @param destination Target to store the animations
  29553. */
  29554. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29555. /**
  29556. * Static function used to serialized a specific entity
  29557. * @param entity defines the entity to serialize
  29558. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29559. * @returns a JSON compatible object representing the serialization of the entity
  29560. */
  29561. static Serialize<T>(entity: T, serializationObject?: any): any;
  29562. /**
  29563. * Creates a new entity from a serialization data object
  29564. * @param creationFunction defines a function used to instanciated the new entity
  29565. * @param source defines the source serialization data
  29566. * @param scene defines the hosting scene
  29567. * @param rootUrl defines the root url for resources
  29568. * @returns a new entity
  29569. */
  29570. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29571. /**
  29572. * Clones an object
  29573. * @param creationFunction defines the function used to instanciate the new object
  29574. * @param source defines the source object
  29575. * @returns the cloned object
  29576. */
  29577. static Clone<T>(creationFunction: () => T, source: T): T;
  29578. /**
  29579. * Instanciates a new object based on a source one (some data will be shared between both object)
  29580. * @param creationFunction defines the function used to instanciate the new object
  29581. * @param source defines the source object
  29582. * @returns the new object
  29583. */
  29584. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29585. }
  29586. }
  29587. declare module BABYLON {
  29588. /**
  29589. * Class used to manipulate GUIDs
  29590. */
  29591. export class GUID {
  29592. /**
  29593. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29594. * Be aware Math.random() could cause collisions, but:
  29595. * "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"
  29596. * @returns a pseudo random id
  29597. */
  29598. static RandomId(): string;
  29599. }
  29600. }
  29601. declare module BABYLON {
  29602. /**
  29603. * Base class of all the textures in babylon.
  29604. * It groups all the common properties the materials, post process, lights... might need
  29605. * in order to make a correct use of the texture.
  29606. */
  29607. export class BaseTexture implements IAnimatable {
  29608. /**
  29609. * Default anisotropic filtering level for the application.
  29610. * It is set to 4 as a good tradeoff between perf and quality.
  29611. */
  29612. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29613. /**
  29614. * Gets or sets the unique id of the texture
  29615. */
  29616. uniqueId: number;
  29617. /**
  29618. * Define the name of the texture.
  29619. */
  29620. name: string;
  29621. /**
  29622. * Gets or sets an object used to store user defined information.
  29623. */
  29624. metadata: any;
  29625. /**
  29626. * For internal use only. Please do not use.
  29627. */
  29628. reservedDataStore: any;
  29629. private _hasAlpha;
  29630. /**
  29631. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29632. */
  29633. set hasAlpha(value: boolean);
  29634. get hasAlpha(): boolean;
  29635. /**
  29636. * Defines if the alpha value should be determined via the rgb values.
  29637. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29638. */
  29639. getAlphaFromRGB: boolean;
  29640. /**
  29641. * Intensity or strength of the texture.
  29642. * It is commonly used by materials to fine tune the intensity of the texture
  29643. */
  29644. level: number;
  29645. /**
  29646. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29647. * This is part of the texture as textures usually maps to one uv set.
  29648. */
  29649. coordinatesIndex: number;
  29650. private _coordinatesMode;
  29651. /**
  29652. * How a texture is mapped.
  29653. *
  29654. * | Value | Type | Description |
  29655. * | ----- | ----------------------------------- | ----------- |
  29656. * | 0 | EXPLICIT_MODE | |
  29657. * | 1 | SPHERICAL_MODE | |
  29658. * | 2 | PLANAR_MODE | |
  29659. * | 3 | CUBIC_MODE | |
  29660. * | 4 | PROJECTION_MODE | |
  29661. * | 5 | SKYBOX_MODE | |
  29662. * | 6 | INVCUBIC_MODE | |
  29663. * | 7 | EQUIRECTANGULAR_MODE | |
  29664. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29665. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29666. */
  29667. set coordinatesMode(value: number);
  29668. get coordinatesMode(): number;
  29669. /**
  29670. * | Value | Type | Description |
  29671. * | ----- | ------------------ | ----------- |
  29672. * | 0 | CLAMP_ADDRESSMODE | |
  29673. * | 1 | WRAP_ADDRESSMODE | |
  29674. * | 2 | MIRROR_ADDRESSMODE | |
  29675. */
  29676. wrapU: number;
  29677. /**
  29678. * | Value | Type | Description |
  29679. * | ----- | ------------------ | ----------- |
  29680. * | 0 | CLAMP_ADDRESSMODE | |
  29681. * | 1 | WRAP_ADDRESSMODE | |
  29682. * | 2 | MIRROR_ADDRESSMODE | |
  29683. */
  29684. wrapV: number;
  29685. /**
  29686. * | Value | Type | Description |
  29687. * | ----- | ------------------ | ----------- |
  29688. * | 0 | CLAMP_ADDRESSMODE | |
  29689. * | 1 | WRAP_ADDRESSMODE | |
  29690. * | 2 | MIRROR_ADDRESSMODE | |
  29691. */
  29692. wrapR: number;
  29693. /**
  29694. * With compliant hardware and browser (supporting anisotropic filtering)
  29695. * this defines the level of anisotropic filtering in the texture.
  29696. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29697. */
  29698. anisotropicFilteringLevel: number;
  29699. /**
  29700. * Define if the texture is a cube texture or if false a 2d texture.
  29701. */
  29702. get isCube(): boolean;
  29703. set isCube(value: boolean);
  29704. /**
  29705. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29706. */
  29707. get is3D(): boolean;
  29708. set is3D(value: boolean);
  29709. /**
  29710. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29711. */
  29712. get is2DArray(): boolean;
  29713. set is2DArray(value: boolean);
  29714. /**
  29715. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29716. * HDR texture are usually stored in linear space.
  29717. * This only impacts the PBR and Background materials
  29718. */
  29719. gammaSpace: boolean;
  29720. /**
  29721. * Gets or sets whether or not the texture contains RGBD data.
  29722. */
  29723. get isRGBD(): boolean;
  29724. set isRGBD(value: boolean);
  29725. /**
  29726. * Is Z inverted in the texture (useful in a cube texture).
  29727. */
  29728. invertZ: boolean;
  29729. /**
  29730. * Are mip maps generated for this texture or not.
  29731. */
  29732. get noMipmap(): boolean;
  29733. /**
  29734. * @hidden
  29735. */
  29736. lodLevelInAlpha: boolean;
  29737. /**
  29738. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29739. */
  29740. get lodGenerationOffset(): number;
  29741. set lodGenerationOffset(value: number);
  29742. /**
  29743. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29744. */
  29745. get lodGenerationScale(): number;
  29746. set lodGenerationScale(value: number);
  29747. /**
  29748. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29749. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29750. * average roughness values.
  29751. */
  29752. get linearSpecularLOD(): boolean;
  29753. set linearSpecularLOD(value: boolean);
  29754. /**
  29755. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29756. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29757. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29758. */
  29759. get irradianceTexture(): Nullable<BaseTexture>;
  29760. set irradianceTexture(value: Nullable<BaseTexture>);
  29761. /**
  29762. * Define if the texture is a render target.
  29763. */
  29764. isRenderTarget: boolean;
  29765. /**
  29766. * Define the unique id of the texture in the scene.
  29767. */
  29768. get uid(): string;
  29769. /**
  29770. * Return a string representation of the texture.
  29771. * @returns the texture as a string
  29772. */
  29773. toString(): string;
  29774. /**
  29775. * Get the class name of the texture.
  29776. * @returns "BaseTexture"
  29777. */
  29778. getClassName(): string;
  29779. /**
  29780. * Define the list of animation attached to the texture.
  29781. */
  29782. animations: Animation[];
  29783. /**
  29784. * An event triggered when the texture is disposed.
  29785. */
  29786. onDisposeObservable: Observable<BaseTexture>;
  29787. private _onDisposeObserver;
  29788. /**
  29789. * Callback triggered when the texture has been disposed.
  29790. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29791. */
  29792. set onDispose(callback: () => void);
  29793. /**
  29794. * Define the current state of the loading sequence when in delayed load mode.
  29795. */
  29796. delayLoadState: number;
  29797. private _scene;
  29798. /** @hidden */
  29799. _texture: Nullable<InternalTexture>;
  29800. private _uid;
  29801. /**
  29802. * Define if the texture is preventinga material to render or not.
  29803. * If not and the texture is not ready, the engine will use a default black texture instead.
  29804. */
  29805. get isBlocking(): boolean;
  29806. /**
  29807. * Instantiates a new BaseTexture.
  29808. * Base class of all the textures in babylon.
  29809. * It groups all the common properties the materials, post process, lights... might need
  29810. * in order to make a correct use of the texture.
  29811. * @param scene Define the scene the texture blongs to
  29812. */
  29813. constructor(scene: Nullable<Scene>);
  29814. /**
  29815. * Get the scene the texture belongs to.
  29816. * @returns the scene or null if undefined
  29817. */
  29818. getScene(): Nullable<Scene>;
  29819. /**
  29820. * Get the texture transform matrix used to offset tile the texture for istance.
  29821. * @returns the transformation matrix
  29822. */
  29823. getTextureMatrix(): Matrix;
  29824. /**
  29825. * Get the texture reflection matrix used to rotate/transform the reflection.
  29826. * @returns the reflection matrix
  29827. */
  29828. getReflectionTextureMatrix(): Matrix;
  29829. /**
  29830. * Get the underlying lower level texture from Babylon.
  29831. * @returns the insternal texture
  29832. */
  29833. getInternalTexture(): Nullable<InternalTexture>;
  29834. /**
  29835. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29836. * @returns true if ready or not blocking
  29837. */
  29838. isReadyOrNotBlocking(): boolean;
  29839. /**
  29840. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29841. * @returns true if fully ready
  29842. */
  29843. isReady(): boolean;
  29844. private _cachedSize;
  29845. /**
  29846. * Get the size of the texture.
  29847. * @returns the texture size.
  29848. */
  29849. getSize(): ISize;
  29850. /**
  29851. * Get the base size of the texture.
  29852. * It can be different from the size if the texture has been resized for POT for instance
  29853. * @returns the base size
  29854. */
  29855. getBaseSize(): ISize;
  29856. /**
  29857. * Update the sampling mode of the texture.
  29858. * Default is Trilinear mode.
  29859. *
  29860. * | Value | Type | Description |
  29861. * | ----- | ------------------ | ----------- |
  29862. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29863. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29864. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29865. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29866. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29867. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29868. * | 7 | NEAREST_LINEAR | |
  29869. * | 8 | NEAREST_NEAREST | |
  29870. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29871. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29872. * | 11 | LINEAR_LINEAR | |
  29873. * | 12 | LINEAR_NEAREST | |
  29874. *
  29875. * > _mag_: magnification filter (close to the viewer)
  29876. * > _min_: minification filter (far from the viewer)
  29877. * > _mip_: filter used between mip map levels
  29878. *@param samplingMode Define the new sampling mode of the texture
  29879. */
  29880. updateSamplingMode(samplingMode: number): void;
  29881. /**
  29882. * Scales the texture if is `canRescale()`
  29883. * @param ratio the resize factor we want to use to rescale
  29884. */
  29885. scale(ratio: number): void;
  29886. /**
  29887. * Get if the texture can rescale.
  29888. */
  29889. get canRescale(): boolean;
  29890. /** @hidden */
  29891. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29892. /** @hidden */
  29893. _rebuild(): void;
  29894. /**
  29895. * Triggers the load sequence in delayed load mode.
  29896. */
  29897. delayLoad(): void;
  29898. /**
  29899. * Clones the texture.
  29900. * @returns the cloned texture
  29901. */
  29902. clone(): Nullable<BaseTexture>;
  29903. /**
  29904. * Get the texture underlying type (INT, FLOAT...)
  29905. */
  29906. get textureType(): number;
  29907. /**
  29908. * Get the texture underlying format (RGB, RGBA...)
  29909. */
  29910. get textureFormat(): number;
  29911. /**
  29912. * Indicates that textures need to be re-calculated for all materials
  29913. */
  29914. protected _markAllSubMeshesAsTexturesDirty(): void;
  29915. /**
  29916. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29917. * This will returns an RGBA array buffer containing either in values (0-255) or
  29918. * float values (0-1) depending of the underlying buffer type.
  29919. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29920. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29921. * @param buffer defines a user defined buffer to fill with data (can be null)
  29922. * @returns The Array buffer containing the pixels data.
  29923. */
  29924. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29925. /**
  29926. * Release and destroy the underlying lower level texture aka internalTexture.
  29927. */
  29928. releaseInternalTexture(): void;
  29929. /** @hidden */
  29930. get _lodTextureHigh(): Nullable<BaseTexture>;
  29931. /** @hidden */
  29932. get _lodTextureMid(): Nullable<BaseTexture>;
  29933. /** @hidden */
  29934. get _lodTextureLow(): Nullable<BaseTexture>;
  29935. /**
  29936. * Dispose the texture and release its associated resources.
  29937. */
  29938. dispose(): void;
  29939. /**
  29940. * Serialize the texture into a JSON representation that can be parsed later on.
  29941. * @returns the JSON representation of the texture
  29942. */
  29943. serialize(): any;
  29944. /**
  29945. * Helper function to be called back once a list of texture contains only ready textures.
  29946. * @param textures Define the list of textures to wait for
  29947. * @param callback Define the callback triggered once the entire list will be ready
  29948. */
  29949. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29950. }
  29951. }
  29952. declare module BABYLON {
  29953. /**
  29954. * Options to be used when creating an effect.
  29955. */
  29956. export interface IEffectCreationOptions {
  29957. /**
  29958. * Atrributes that will be used in the shader.
  29959. */
  29960. attributes: string[];
  29961. /**
  29962. * Uniform varible names that will be set in the shader.
  29963. */
  29964. uniformsNames: string[];
  29965. /**
  29966. * Uniform buffer variable names that will be set in the shader.
  29967. */
  29968. uniformBuffersNames: string[];
  29969. /**
  29970. * Sampler texture variable names that will be set in the shader.
  29971. */
  29972. samplers: string[];
  29973. /**
  29974. * Define statements that will be set in the shader.
  29975. */
  29976. defines: any;
  29977. /**
  29978. * Possible fallbacks for this effect to improve performance when needed.
  29979. */
  29980. fallbacks: Nullable<IEffectFallbacks>;
  29981. /**
  29982. * Callback that will be called when the shader is compiled.
  29983. */
  29984. onCompiled: Nullable<(effect: Effect) => void>;
  29985. /**
  29986. * Callback that will be called if an error occurs during shader compilation.
  29987. */
  29988. onError: Nullable<(effect: Effect, errors: string) => void>;
  29989. /**
  29990. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29991. */
  29992. indexParameters?: any;
  29993. /**
  29994. * Max number of lights that can be used in the shader.
  29995. */
  29996. maxSimultaneousLights?: number;
  29997. /**
  29998. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29999. */
  30000. transformFeedbackVaryings?: Nullable<string[]>;
  30001. }
  30002. /**
  30003. * Effect containing vertex and fragment shader that can be executed on an object.
  30004. */
  30005. export class Effect implements IDisposable {
  30006. /**
  30007. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30008. */
  30009. static ShadersRepository: string;
  30010. /**
  30011. * Enable logging of the shader code when a compilation error occurs
  30012. */
  30013. static LogShaderCodeOnCompilationError: boolean;
  30014. /**
  30015. * Name of the effect.
  30016. */
  30017. name: any;
  30018. /**
  30019. * String container all the define statements that should be set on the shader.
  30020. */
  30021. defines: string;
  30022. /**
  30023. * Callback that will be called when the shader is compiled.
  30024. */
  30025. onCompiled: Nullable<(effect: Effect) => void>;
  30026. /**
  30027. * Callback that will be called if an error occurs during shader compilation.
  30028. */
  30029. onError: Nullable<(effect: Effect, errors: string) => void>;
  30030. /**
  30031. * Callback that will be called when effect is bound.
  30032. */
  30033. onBind: Nullable<(effect: Effect) => void>;
  30034. /**
  30035. * Unique ID of the effect.
  30036. */
  30037. uniqueId: number;
  30038. /**
  30039. * Observable that will be called when the shader is compiled.
  30040. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30041. */
  30042. onCompileObservable: Observable<Effect>;
  30043. /**
  30044. * Observable that will be called if an error occurs during shader compilation.
  30045. */
  30046. onErrorObservable: Observable<Effect>;
  30047. /** @hidden */
  30048. _onBindObservable: Nullable<Observable<Effect>>;
  30049. /**
  30050. * @hidden
  30051. * Specifies if the effect was previously ready
  30052. */
  30053. _wasPreviouslyReady: boolean;
  30054. /**
  30055. * Observable that will be called when effect is bound.
  30056. */
  30057. get onBindObservable(): Observable<Effect>;
  30058. /** @hidden */
  30059. _bonesComputationForcedToCPU: boolean;
  30060. private static _uniqueIdSeed;
  30061. private _engine;
  30062. private _uniformBuffersNames;
  30063. private _uniformsNames;
  30064. private _samplerList;
  30065. private _samplers;
  30066. private _isReady;
  30067. private _compilationError;
  30068. private _allFallbacksProcessed;
  30069. private _attributesNames;
  30070. private _attributes;
  30071. private _attributeLocationByName;
  30072. private _uniforms;
  30073. /**
  30074. * Key for the effect.
  30075. * @hidden
  30076. */
  30077. _key: string;
  30078. private _indexParameters;
  30079. private _fallbacks;
  30080. private _vertexSourceCode;
  30081. private _fragmentSourceCode;
  30082. private _vertexSourceCodeOverride;
  30083. private _fragmentSourceCodeOverride;
  30084. private _transformFeedbackVaryings;
  30085. /**
  30086. * Compiled shader to webGL program.
  30087. * @hidden
  30088. */
  30089. _pipelineContext: Nullable<IPipelineContext>;
  30090. private _valueCache;
  30091. private static _baseCache;
  30092. /**
  30093. * Instantiates an effect.
  30094. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30095. * @param baseName Name of the effect.
  30096. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30097. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30098. * @param samplers List of sampler variables that will be passed to the shader.
  30099. * @param engine Engine to be used to render the effect
  30100. * @param defines Define statements to be added to the shader.
  30101. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30102. * @param onCompiled Callback that will be called when the shader is compiled.
  30103. * @param onError Callback that will be called if an error occurs during shader compilation.
  30104. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30105. */
  30106. 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);
  30107. private _useFinalCode;
  30108. /**
  30109. * Unique key for this effect
  30110. */
  30111. get key(): string;
  30112. /**
  30113. * If the effect has been compiled and prepared.
  30114. * @returns if the effect is compiled and prepared.
  30115. */
  30116. isReady(): boolean;
  30117. private _isReadyInternal;
  30118. /**
  30119. * The engine the effect was initialized with.
  30120. * @returns the engine.
  30121. */
  30122. getEngine(): Engine;
  30123. /**
  30124. * The pipeline context for this effect
  30125. * @returns the associated pipeline context
  30126. */
  30127. getPipelineContext(): Nullable<IPipelineContext>;
  30128. /**
  30129. * The set of names of attribute variables for the shader.
  30130. * @returns An array of attribute names.
  30131. */
  30132. getAttributesNames(): string[];
  30133. /**
  30134. * Returns the attribute at the given index.
  30135. * @param index The index of the attribute.
  30136. * @returns The location of the attribute.
  30137. */
  30138. getAttributeLocation(index: number): number;
  30139. /**
  30140. * Returns the attribute based on the name of the variable.
  30141. * @param name of the attribute to look up.
  30142. * @returns the attribute location.
  30143. */
  30144. getAttributeLocationByName(name: string): number;
  30145. /**
  30146. * The number of attributes.
  30147. * @returns the numnber of attributes.
  30148. */
  30149. getAttributesCount(): number;
  30150. /**
  30151. * Gets the index of a uniform variable.
  30152. * @param uniformName of the uniform to look up.
  30153. * @returns the index.
  30154. */
  30155. getUniformIndex(uniformName: string): number;
  30156. /**
  30157. * Returns the attribute based on the name of the variable.
  30158. * @param uniformName of the uniform to look up.
  30159. * @returns the location of the uniform.
  30160. */
  30161. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30162. /**
  30163. * Returns an array of sampler variable names
  30164. * @returns The array of sampler variable neames.
  30165. */
  30166. getSamplers(): string[];
  30167. /**
  30168. * The error from the last compilation.
  30169. * @returns the error string.
  30170. */
  30171. getCompilationError(): string;
  30172. /**
  30173. * Gets a boolean indicating that all fallbacks were used during compilation
  30174. * @returns true if all fallbacks were used
  30175. */
  30176. allFallbacksProcessed(): boolean;
  30177. /**
  30178. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30179. * @param func The callback to be used.
  30180. */
  30181. executeWhenCompiled(func: (effect: Effect) => void): void;
  30182. private _checkIsReady;
  30183. private _loadShader;
  30184. /**
  30185. * Recompiles the webGL program
  30186. * @param vertexSourceCode The source code for the vertex shader.
  30187. * @param fragmentSourceCode The source code for the fragment shader.
  30188. * @param onCompiled Callback called when completed.
  30189. * @param onError Callback called on error.
  30190. * @hidden
  30191. */
  30192. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30193. /**
  30194. * Prepares the effect
  30195. * @hidden
  30196. */
  30197. _prepareEffect(): void;
  30198. private _getShaderCodeAndErrorLine;
  30199. private _processCompilationErrors;
  30200. /**
  30201. * Checks if the effect is supported. (Must be called after compilation)
  30202. */
  30203. get isSupported(): boolean;
  30204. /**
  30205. * Binds a texture to the engine to be used as output of the shader.
  30206. * @param channel Name of the output variable.
  30207. * @param texture Texture to bind.
  30208. * @hidden
  30209. */
  30210. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30211. /**
  30212. * Sets a texture on the engine to be used in the shader.
  30213. * @param channel Name of the sampler variable.
  30214. * @param texture Texture to set.
  30215. */
  30216. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30217. /**
  30218. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30219. * @param channel Name of the sampler variable.
  30220. * @param texture Texture to set.
  30221. */
  30222. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30223. /**
  30224. * Sets an array of textures on the engine to be used in the shader.
  30225. * @param channel Name of the variable.
  30226. * @param textures Textures to set.
  30227. */
  30228. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30229. /**
  30230. * 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)
  30231. * @param channel Name of the sampler variable.
  30232. * @param postProcess Post process to get the input texture from.
  30233. */
  30234. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30235. /**
  30236. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30237. * 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)
  30238. * @param channel Name of the sampler variable.
  30239. * @param postProcess Post process to get the output texture from.
  30240. */
  30241. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30242. /** @hidden */
  30243. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30244. /** @hidden */
  30245. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30246. /** @hidden */
  30247. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30248. /** @hidden */
  30249. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30250. /**
  30251. * Binds a buffer to a uniform.
  30252. * @param buffer Buffer to bind.
  30253. * @param name Name of the uniform variable to bind to.
  30254. */
  30255. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30256. /**
  30257. * Binds block to a uniform.
  30258. * @param blockName Name of the block to bind.
  30259. * @param index Index to bind.
  30260. */
  30261. bindUniformBlock(blockName: string, index: number): void;
  30262. /**
  30263. * Sets an interger value on a uniform variable.
  30264. * @param uniformName Name of the variable.
  30265. * @param value Value to be set.
  30266. * @returns this effect.
  30267. */
  30268. setInt(uniformName: string, value: number): Effect;
  30269. /**
  30270. * Sets an int array on a uniform variable.
  30271. * @param uniformName Name of the variable.
  30272. * @param array array to be set.
  30273. * @returns this effect.
  30274. */
  30275. setIntArray(uniformName: string, array: Int32Array): Effect;
  30276. /**
  30277. * 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)
  30278. * @param uniformName Name of the variable.
  30279. * @param array array to be set.
  30280. * @returns this effect.
  30281. */
  30282. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30283. /**
  30284. * 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)
  30285. * @param uniformName Name of the variable.
  30286. * @param array array to be set.
  30287. * @returns this effect.
  30288. */
  30289. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30290. /**
  30291. * 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)
  30292. * @param uniformName Name of the variable.
  30293. * @param array array to be set.
  30294. * @returns this effect.
  30295. */
  30296. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30297. /**
  30298. * Sets an float array on a uniform variable.
  30299. * @param uniformName Name of the variable.
  30300. * @param array array to be set.
  30301. * @returns this effect.
  30302. */
  30303. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30304. /**
  30305. * 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)
  30306. * @param uniformName Name of the variable.
  30307. * @param array array to be set.
  30308. * @returns this effect.
  30309. */
  30310. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30311. /**
  30312. * 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)
  30313. * @param uniformName Name of the variable.
  30314. * @param array array to be set.
  30315. * @returns this effect.
  30316. */
  30317. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30318. /**
  30319. * 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)
  30320. * @param uniformName Name of the variable.
  30321. * @param array array to be set.
  30322. * @returns this effect.
  30323. */
  30324. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30325. /**
  30326. * Sets an array on a uniform variable.
  30327. * @param uniformName Name of the variable.
  30328. * @param array array to be set.
  30329. * @returns this effect.
  30330. */
  30331. setArray(uniformName: string, array: number[]): Effect;
  30332. /**
  30333. * 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)
  30334. * @param uniformName Name of the variable.
  30335. * @param array array to be set.
  30336. * @returns this effect.
  30337. */
  30338. setArray2(uniformName: string, array: number[]): Effect;
  30339. /**
  30340. * 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)
  30341. * @param uniformName Name of the variable.
  30342. * @param array array to be set.
  30343. * @returns this effect.
  30344. */
  30345. setArray3(uniformName: string, array: number[]): Effect;
  30346. /**
  30347. * 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)
  30348. * @param uniformName Name of the variable.
  30349. * @param array array to be set.
  30350. * @returns this effect.
  30351. */
  30352. setArray4(uniformName: string, array: number[]): Effect;
  30353. /**
  30354. * Sets matrices on a uniform variable.
  30355. * @param uniformName Name of the variable.
  30356. * @param matrices matrices to be set.
  30357. * @returns this effect.
  30358. */
  30359. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30360. /**
  30361. * Sets matrix on a uniform variable.
  30362. * @param uniformName Name of the variable.
  30363. * @param matrix matrix to be set.
  30364. * @returns this effect.
  30365. */
  30366. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30367. /**
  30368. * 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)
  30369. * @param uniformName Name of the variable.
  30370. * @param matrix matrix to be set.
  30371. * @returns this effect.
  30372. */
  30373. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30374. /**
  30375. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30376. * @param uniformName Name of the variable.
  30377. * @param matrix matrix to be set.
  30378. * @returns this effect.
  30379. */
  30380. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30381. /**
  30382. * Sets a float on a uniform variable.
  30383. * @param uniformName Name of the variable.
  30384. * @param value value to be set.
  30385. * @returns this effect.
  30386. */
  30387. setFloat(uniformName: string, value: number): Effect;
  30388. /**
  30389. * Sets a boolean on a uniform variable.
  30390. * @param uniformName Name of the variable.
  30391. * @param bool value to be set.
  30392. * @returns this effect.
  30393. */
  30394. setBool(uniformName: string, bool: boolean): Effect;
  30395. /**
  30396. * Sets a Vector2 on a uniform variable.
  30397. * @param uniformName Name of the variable.
  30398. * @param vector2 vector2 to be set.
  30399. * @returns this effect.
  30400. */
  30401. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30402. /**
  30403. * Sets a float2 on a uniform variable.
  30404. * @param uniformName Name of the variable.
  30405. * @param x First float in float2.
  30406. * @param y Second float in float2.
  30407. * @returns this effect.
  30408. */
  30409. setFloat2(uniformName: string, x: number, y: number): Effect;
  30410. /**
  30411. * Sets a Vector3 on a uniform variable.
  30412. * @param uniformName Name of the variable.
  30413. * @param vector3 Value to be set.
  30414. * @returns this effect.
  30415. */
  30416. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30417. /**
  30418. * Sets a float3 on a uniform variable.
  30419. * @param uniformName Name of the variable.
  30420. * @param x First float in float3.
  30421. * @param y Second float in float3.
  30422. * @param z Third float in float3.
  30423. * @returns this effect.
  30424. */
  30425. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30426. /**
  30427. * Sets a Vector4 on a uniform variable.
  30428. * @param uniformName Name of the variable.
  30429. * @param vector4 Value to be set.
  30430. * @returns this effect.
  30431. */
  30432. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30433. /**
  30434. * Sets a float4 on a uniform variable.
  30435. * @param uniformName Name of the variable.
  30436. * @param x First float in float4.
  30437. * @param y Second float in float4.
  30438. * @param z Third float in float4.
  30439. * @param w Fourth float in float4.
  30440. * @returns this effect.
  30441. */
  30442. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30443. /**
  30444. * Sets a Color3 on a uniform variable.
  30445. * @param uniformName Name of the variable.
  30446. * @param color3 Value to be set.
  30447. * @returns this effect.
  30448. */
  30449. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30450. /**
  30451. * Sets a Color4 on a uniform variable.
  30452. * @param uniformName Name of the variable.
  30453. * @param color3 Value to be set.
  30454. * @param alpha Alpha value to be set.
  30455. * @returns this effect.
  30456. */
  30457. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30458. /**
  30459. * Sets a Color4 on a uniform variable
  30460. * @param uniformName defines the name of the variable
  30461. * @param color4 defines the value to be set
  30462. * @returns this effect.
  30463. */
  30464. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30465. /** Release all associated resources */
  30466. dispose(): void;
  30467. /**
  30468. * This function will add a new shader to the shader store
  30469. * @param name the name of the shader
  30470. * @param pixelShader optional pixel shader content
  30471. * @param vertexShader optional vertex shader content
  30472. */
  30473. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30474. /**
  30475. * Store of each shader (The can be looked up using effect.key)
  30476. */
  30477. static ShadersStore: {
  30478. [key: string]: string;
  30479. };
  30480. /**
  30481. * Store of each included file for a shader (The can be looked up using effect.key)
  30482. */
  30483. static IncludesShadersStore: {
  30484. [key: string]: string;
  30485. };
  30486. /**
  30487. * Resets the cache of effects.
  30488. */
  30489. static ResetCache(): void;
  30490. }
  30491. }
  30492. declare module BABYLON {
  30493. /**
  30494. * Interface used to describe the capabilities of the engine relatively to the current browser
  30495. */
  30496. export interface EngineCapabilities {
  30497. /** Maximum textures units per fragment shader */
  30498. maxTexturesImageUnits: number;
  30499. /** Maximum texture units per vertex shader */
  30500. maxVertexTextureImageUnits: number;
  30501. /** Maximum textures units in the entire pipeline */
  30502. maxCombinedTexturesImageUnits: number;
  30503. /** Maximum texture size */
  30504. maxTextureSize: number;
  30505. /** Maximum texture samples */
  30506. maxSamples?: number;
  30507. /** Maximum cube texture size */
  30508. maxCubemapTextureSize: number;
  30509. /** Maximum render texture size */
  30510. maxRenderTextureSize: number;
  30511. /** Maximum number of vertex attributes */
  30512. maxVertexAttribs: number;
  30513. /** Maximum number of varyings */
  30514. maxVaryingVectors: number;
  30515. /** Maximum number of uniforms per vertex shader */
  30516. maxVertexUniformVectors: number;
  30517. /** Maximum number of uniforms per fragment shader */
  30518. maxFragmentUniformVectors: number;
  30519. /** Defines if standard derivates (dx/dy) are supported */
  30520. standardDerivatives: boolean;
  30521. /** Defines if s3tc texture compression is supported */
  30522. s3tc?: WEBGL_compressed_texture_s3tc;
  30523. /** Defines if pvrtc texture compression is supported */
  30524. pvrtc: any;
  30525. /** Defines if etc1 texture compression is supported */
  30526. etc1: any;
  30527. /** Defines if etc2 texture compression is supported */
  30528. etc2: any;
  30529. /** Defines if astc texture compression is supported */
  30530. astc: any;
  30531. /** Defines if float textures are supported */
  30532. textureFloat: boolean;
  30533. /** Defines if vertex array objects are supported */
  30534. vertexArrayObject: boolean;
  30535. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30536. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30537. /** Gets the maximum level of anisotropy supported */
  30538. maxAnisotropy: number;
  30539. /** Defines if instancing is supported */
  30540. instancedArrays: boolean;
  30541. /** Defines if 32 bits indices are supported */
  30542. uintIndices: boolean;
  30543. /** Defines if high precision shaders are supported */
  30544. highPrecisionShaderSupported: boolean;
  30545. /** Defines if depth reading in the fragment shader is supported */
  30546. fragmentDepthSupported: boolean;
  30547. /** Defines if float texture linear filtering is supported*/
  30548. textureFloatLinearFiltering: boolean;
  30549. /** Defines if rendering to float textures is supported */
  30550. textureFloatRender: boolean;
  30551. /** Defines if half float textures are supported*/
  30552. textureHalfFloat: boolean;
  30553. /** Defines if half float texture linear filtering is supported*/
  30554. textureHalfFloatLinearFiltering: boolean;
  30555. /** Defines if rendering to half float textures is supported */
  30556. textureHalfFloatRender: boolean;
  30557. /** Defines if textureLOD shader command is supported */
  30558. textureLOD: boolean;
  30559. /** Defines if draw buffers extension is supported */
  30560. drawBuffersExtension: boolean;
  30561. /** Defines if depth textures are supported */
  30562. depthTextureExtension: boolean;
  30563. /** Defines if float color buffer are supported */
  30564. colorBufferFloat: boolean;
  30565. /** Gets disjoint timer query extension (null if not supported) */
  30566. timerQuery?: EXT_disjoint_timer_query;
  30567. /** Defines if timestamp can be used with timer query */
  30568. canUseTimestampForTimerQuery: boolean;
  30569. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30570. multiview?: any;
  30571. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30572. oculusMultiview?: any;
  30573. /** Function used to let the system compiles shaders in background */
  30574. parallelShaderCompile?: {
  30575. COMPLETION_STATUS_KHR: number;
  30576. };
  30577. /** Max number of texture samples for MSAA */
  30578. maxMSAASamples: number;
  30579. /** Defines if the blend min max extension is supported */
  30580. blendMinMax: boolean;
  30581. }
  30582. }
  30583. declare module BABYLON {
  30584. /**
  30585. * @hidden
  30586. **/
  30587. export class DepthCullingState {
  30588. private _isDepthTestDirty;
  30589. private _isDepthMaskDirty;
  30590. private _isDepthFuncDirty;
  30591. private _isCullFaceDirty;
  30592. private _isCullDirty;
  30593. private _isZOffsetDirty;
  30594. private _isFrontFaceDirty;
  30595. private _depthTest;
  30596. private _depthMask;
  30597. private _depthFunc;
  30598. private _cull;
  30599. private _cullFace;
  30600. private _zOffset;
  30601. private _frontFace;
  30602. /**
  30603. * Initializes the state.
  30604. */
  30605. constructor();
  30606. get isDirty(): boolean;
  30607. get zOffset(): number;
  30608. set zOffset(value: number);
  30609. get cullFace(): Nullable<number>;
  30610. set cullFace(value: Nullable<number>);
  30611. get cull(): Nullable<boolean>;
  30612. set cull(value: Nullable<boolean>);
  30613. get depthFunc(): Nullable<number>;
  30614. set depthFunc(value: Nullable<number>);
  30615. get depthMask(): boolean;
  30616. set depthMask(value: boolean);
  30617. get depthTest(): boolean;
  30618. set depthTest(value: boolean);
  30619. get frontFace(): Nullable<number>;
  30620. set frontFace(value: Nullable<number>);
  30621. reset(): void;
  30622. apply(gl: WebGLRenderingContext): void;
  30623. }
  30624. }
  30625. declare module BABYLON {
  30626. /**
  30627. * @hidden
  30628. **/
  30629. export class StencilState {
  30630. /** 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 */
  30631. static readonly ALWAYS: number;
  30632. /** Passed to stencilOperation to specify that stencil value must be kept */
  30633. static readonly KEEP: number;
  30634. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30635. static readonly REPLACE: number;
  30636. private _isStencilTestDirty;
  30637. private _isStencilMaskDirty;
  30638. private _isStencilFuncDirty;
  30639. private _isStencilOpDirty;
  30640. private _stencilTest;
  30641. private _stencilMask;
  30642. private _stencilFunc;
  30643. private _stencilFuncRef;
  30644. private _stencilFuncMask;
  30645. private _stencilOpStencilFail;
  30646. private _stencilOpDepthFail;
  30647. private _stencilOpStencilDepthPass;
  30648. get isDirty(): boolean;
  30649. get stencilFunc(): number;
  30650. set stencilFunc(value: number);
  30651. get stencilFuncRef(): number;
  30652. set stencilFuncRef(value: number);
  30653. get stencilFuncMask(): number;
  30654. set stencilFuncMask(value: number);
  30655. get stencilOpStencilFail(): number;
  30656. set stencilOpStencilFail(value: number);
  30657. get stencilOpDepthFail(): number;
  30658. set stencilOpDepthFail(value: number);
  30659. get stencilOpStencilDepthPass(): number;
  30660. set stencilOpStencilDepthPass(value: number);
  30661. get stencilMask(): number;
  30662. set stencilMask(value: number);
  30663. get stencilTest(): boolean;
  30664. set stencilTest(value: boolean);
  30665. constructor();
  30666. reset(): void;
  30667. apply(gl: WebGLRenderingContext): void;
  30668. }
  30669. }
  30670. declare module BABYLON {
  30671. /**
  30672. * @hidden
  30673. **/
  30674. export class AlphaState {
  30675. private _isAlphaBlendDirty;
  30676. private _isBlendFunctionParametersDirty;
  30677. private _isBlendEquationParametersDirty;
  30678. private _isBlendConstantsDirty;
  30679. private _alphaBlend;
  30680. private _blendFunctionParameters;
  30681. private _blendEquationParameters;
  30682. private _blendConstants;
  30683. /**
  30684. * Initializes the state.
  30685. */
  30686. constructor();
  30687. get isDirty(): boolean;
  30688. get alphaBlend(): boolean;
  30689. set alphaBlend(value: boolean);
  30690. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30691. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30692. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30693. reset(): void;
  30694. apply(gl: WebGLRenderingContext): void;
  30695. }
  30696. }
  30697. declare module BABYLON {
  30698. /** @hidden */
  30699. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30700. attributeProcessor(attribute: string): string;
  30701. varyingProcessor(varying: string, isFragment: boolean): string;
  30702. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30703. }
  30704. }
  30705. declare module BABYLON {
  30706. /**
  30707. * Interface for attribute information associated with buffer instanciation
  30708. */
  30709. export interface InstancingAttributeInfo {
  30710. /**
  30711. * Name of the GLSL attribute
  30712. * if attribute index is not specified, this is used to retrieve the index from the effect
  30713. */
  30714. attributeName: string;
  30715. /**
  30716. * Index/offset of the attribute in the vertex shader
  30717. * if not specified, this will be computes from the name.
  30718. */
  30719. index?: number;
  30720. /**
  30721. * size of the attribute, 1, 2, 3 or 4
  30722. */
  30723. attributeSize: number;
  30724. /**
  30725. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30726. */
  30727. offset: number;
  30728. /**
  30729. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30730. * default to 1
  30731. */
  30732. divisor?: number;
  30733. /**
  30734. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30735. * default is FLOAT
  30736. */
  30737. attributeType?: number;
  30738. /**
  30739. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30740. */
  30741. normalized?: boolean;
  30742. }
  30743. }
  30744. declare module BABYLON {
  30745. interface ThinEngine {
  30746. /**
  30747. * Update a video texture
  30748. * @param texture defines the texture to update
  30749. * @param video defines the video element to use
  30750. * @param invertY defines if data must be stored with Y axis inverted
  30751. */
  30752. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30753. }
  30754. }
  30755. declare module BABYLON {
  30756. /**
  30757. * Settings for finer control over video usage
  30758. */
  30759. export interface VideoTextureSettings {
  30760. /**
  30761. * Applies `autoplay` to video, if specified
  30762. */
  30763. autoPlay?: boolean;
  30764. /**
  30765. * Applies `loop` to video, if specified
  30766. */
  30767. loop?: boolean;
  30768. /**
  30769. * Automatically updates internal texture from video at every frame in the render loop
  30770. */
  30771. autoUpdateTexture: boolean;
  30772. /**
  30773. * Image src displayed during the video loading or until the user interacts with the video.
  30774. */
  30775. poster?: string;
  30776. }
  30777. /**
  30778. * If you want to display a video in your scene, this is the special texture for that.
  30779. * This special texture works similar to other textures, with the exception of a few parameters.
  30780. * @see https://doc.babylonjs.com/how_to/video_texture
  30781. */
  30782. export class VideoTexture extends Texture {
  30783. /**
  30784. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30785. */
  30786. readonly autoUpdateTexture: boolean;
  30787. /**
  30788. * The video instance used by the texture internally
  30789. */
  30790. readonly video: HTMLVideoElement;
  30791. private _onUserActionRequestedObservable;
  30792. /**
  30793. * Event triggerd when a dom action is required by the user to play the video.
  30794. * This happens due to recent changes in browser policies preventing video to auto start.
  30795. */
  30796. get onUserActionRequestedObservable(): Observable<Texture>;
  30797. private _generateMipMaps;
  30798. private _engine;
  30799. private _stillImageCaptured;
  30800. private _displayingPosterTexture;
  30801. private _settings;
  30802. private _createInternalTextureOnEvent;
  30803. private _frameId;
  30804. private _currentSrc;
  30805. /**
  30806. * Creates a video texture.
  30807. * If you want to display a video in your scene, this is the special texture for that.
  30808. * This special texture works similar to other textures, with the exception of a few parameters.
  30809. * @see https://doc.babylonjs.com/how_to/video_texture
  30810. * @param name optional name, will detect from video source, if not defined
  30811. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30812. * @param scene is obviously the current scene.
  30813. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30814. * @param invertY is false by default but can be used to invert video on Y axis
  30815. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30816. * @param settings allows finer control over video usage
  30817. */
  30818. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30819. private _getName;
  30820. private _getVideo;
  30821. private _createInternalTexture;
  30822. private reset;
  30823. /**
  30824. * @hidden Internal method to initiate `update`.
  30825. */
  30826. _rebuild(): void;
  30827. /**
  30828. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30829. */
  30830. update(): void;
  30831. /**
  30832. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30833. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30834. */
  30835. updateTexture(isVisible: boolean): void;
  30836. protected _updateInternalTexture: () => void;
  30837. /**
  30838. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30839. * @param url New url.
  30840. */
  30841. updateURL(url: string): void;
  30842. /**
  30843. * Clones the texture.
  30844. * @returns the cloned texture
  30845. */
  30846. clone(): VideoTexture;
  30847. /**
  30848. * Dispose the texture and release its associated resources.
  30849. */
  30850. dispose(): void;
  30851. /**
  30852. * Creates a video texture straight from a stream.
  30853. * @param scene Define the scene the texture should be created in
  30854. * @param stream Define the stream the texture should be created from
  30855. * @returns The created video texture as a promise
  30856. */
  30857. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30858. /**
  30859. * Creates a video texture straight from your WebCam video feed.
  30860. * @param scene Define the scene the texture should be created in
  30861. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30862. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30863. * @returns The created video texture as a promise
  30864. */
  30865. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30866. minWidth: number;
  30867. maxWidth: number;
  30868. minHeight: number;
  30869. maxHeight: number;
  30870. deviceId: string;
  30871. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30872. /**
  30873. * Creates a video texture straight from your WebCam video feed.
  30874. * @param scene Define the scene the texture should be created in
  30875. * @param onReady Define a callback to triggered once the texture will be ready
  30876. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30877. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30878. */
  30879. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30880. minWidth: number;
  30881. maxWidth: number;
  30882. minHeight: number;
  30883. maxHeight: number;
  30884. deviceId: string;
  30885. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30886. }
  30887. }
  30888. declare module BABYLON {
  30889. /**
  30890. * Defines the interface used by objects working like Scene
  30891. * @hidden
  30892. */
  30893. export interface ISceneLike {
  30894. _addPendingData(data: any): void;
  30895. _removePendingData(data: any): void;
  30896. offlineProvider: IOfflineProvider;
  30897. }
  30898. /** Interface defining initialization parameters for Engine class */
  30899. export interface EngineOptions extends WebGLContextAttributes {
  30900. /**
  30901. * Defines if the engine should no exceed a specified device ratio
  30902. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30903. */
  30904. limitDeviceRatio?: number;
  30905. /**
  30906. * Defines if webvr should be enabled automatically
  30907. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30908. */
  30909. autoEnableWebVR?: boolean;
  30910. /**
  30911. * Defines if webgl2 should be turned off even if supported
  30912. * @see http://doc.babylonjs.com/features/webgl2
  30913. */
  30914. disableWebGL2Support?: boolean;
  30915. /**
  30916. * Defines if webaudio should be initialized as well
  30917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30918. */
  30919. audioEngine?: boolean;
  30920. /**
  30921. * Defines if animations should run using a deterministic lock step
  30922. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30923. */
  30924. deterministicLockstep?: boolean;
  30925. /** Defines the maximum steps to use with deterministic lock step mode */
  30926. lockstepMaxSteps?: number;
  30927. /** Defines the seconds between each deterministic lock step */
  30928. timeStep?: number;
  30929. /**
  30930. * Defines that engine should ignore context lost events
  30931. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30932. */
  30933. doNotHandleContextLost?: boolean;
  30934. /**
  30935. * Defines that engine should ignore modifying touch action attribute and style
  30936. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30937. */
  30938. doNotHandleTouchAction?: boolean;
  30939. /**
  30940. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30941. */
  30942. useHighPrecisionFloats?: boolean;
  30943. }
  30944. /**
  30945. * The base engine class (root of all engines)
  30946. */
  30947. export class ThinEngine {
  30948. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30949. static ExceptionList: ({
  30950. key: string;
  30951. capture: string;
  30952. captureConstraint: number;
  30953. targets: string[];
  30954. } | {
  30955. key: string;
  30956. capture: null;
  30957. captureConstraint: null;
  30958. targets: string[];
  30959. })[];
  30960. /** @hidden */
  30961. static _TextureLoaders: IInternalTextureLoader[];
  30962. /**
  30963. * Returns the current npm package of the sdk
  30964. */
  30965. static get NpmPackage(): string;
  30966. /**
  30967. * Returns the current version of the framework
  30968. */
  30969. static get Version(): string;
  30970. /**
  30971. * Returns a string describing the current engine
  30972. */
  30973. get description(): string;
  30974. /**
  30975. * Gets or sets the epsilon value used by collision engine
  30976. */
  30977. static CollisionsEpsilon: number;
  30978. /**
  30979. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30980. */
  30981. static get ShadersRepository(): string;
  30982. static set ShadersRepository(value: string);
  30983. /** @hidden */
  30984. _shaderProcessor: IShaderProcessor;
  30985. /**
  30986. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30987. */
  30988. forcePOTTextures: boolean;
  30989. /**
  30990. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30991. */
  30992. isFullscreen: boolean;
  30993. /**
  30994. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30995. */
  30996. cullBackFaces: boolean;
  30997. /**
  30998. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30999. */
  31000. renderEvenInBackground: boolean;
  31001. /**
  31002. * Gets or sets a boolean indicating that cache can be kept between frames
  31003. */
  31004. preventCacheWipeBetweenFrames: boolean;
  31005. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31006. validateShaderPrograms: boolean;
  31007. /**
  31008. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31009. * This can provide greater z depth for distant objects.
  31010. */
  31011. useReverseDepthBuffer: boolean;
  31012. /**
  31013. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31014. */
  31015. disableUniformBuffers: boolean;
  31016. /** @hidden */
  31017. _uniformBuffers: UniformBuffer[];
  31018. /**
  31019. * Gets a boolean indicating that the engine supports uniform buffers
  31020. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31021. */
  31022. get supportsUniformBuffers(): boolean;
  31023. /** @hidden */
  31024. _gl: WebGLRenderingContext;
  31025. /** @hidden */
  31026. _webGLVersion: number;
  31027. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31028. protected _windowIsBackground: boolean;
  31029. protected _creationOptions: EngineOptions;
  31030. protected _highPrecisionShadersAllowed: boolean;
  31031. /** @hidden */
  31032. get _shouldUseHighPrecisionShader(): boolean;
  31033. /**
  31034. * Gets a boolean indicating that only power of 2 textures are supported
  31035. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31036. */
  31037. get needPOTTextures(): boolean;
  31038. /** @hidden */
  31039. _badOS: boolean;
  31040. /** @hidden */
  31041. _badDesktopOS: boolean;
  31042. private _hardwareScalingLevel;
  31043. /** @hidden */
  31044. _caps: EngineCapabilities;
  31045. private _isStencilEnable;
  31046. private _glVersion;
  31047. private _glRenderer;
  31048. private _glVendor;
  31049. /** @hidden */
  31050. _videoTextureSupported: boolean;
  31051. protected _renderingQueueLaunched: boolean;
  31052. protected _activeRenderLoops: (() => void)[];
  31053. /**
  31054. * Observable signaled when a context lost event is raised
  31055. */
  31056. onContextLostObservable: Observable<ThinEngine>;
  31057. /**
  31058. * Observable signaled when a context restored event is raised
  31059. */
  31060. onContextRestoredObservable: Observable<ThinEngine>;
  31061. private _onContextLost;
  31062. private _onContextRestored;
  31063. protected _contextWasLost: boolean;
  31064. /** @hidden */
  31065. _doNotHandleContextLost: boolean;
  31066. /**
  31067. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31068. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31069. */
  31070. get doNotHandleContextLost(): boolean;
  31071. set doNotHandleContextLost(value: boolean);
  31072. /**
  31073. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31074. */
  31075. disableVertexArrayObjects: boolean;
  31076. /** @hidden */
  31077. protected _colorWrite: boolean;
  31078. /** @hidden */
  31079. protected _colorWriteChanged: boolean;
  31080. /** @hidden */
  31081. protected _depthCullingState: DepthCullingState;
  31082. /** @hidden */
  31083. protected _stencilState: StencilState;
  31084. /** @hidden */
  31085. _alphaState: AlphaState;
  31086. /** @hidden */
  31087. _alphaMode: number;
  31088. /** @hidden */
  31089. _alphaEquation: number;
  31090. /** @hidden */
  31091. _internalTexturesCache: InternalTexture[];
  31092. /** @hidden */
  31093. protected _activeChannel: number;
  31094. private _currentTextureChannel;
  31095. /** @hidden */
  31096. protected _boundTexturesCache: {
  31097. [key: string]: Nullable<InternalTexture>;
  31098. };
  31099. /** @hidden */
  31100. protected _currentEffect: Nullable<Effect>;
  31101. /** @hidden */
  31102. protected _currentProgram: Nullable<WebGLProgram>;
  31103. private _compiledEffects;
  31104. private _vertexAttribArraysEnabled;
  31105. /** @hidden */
  31106. protected _cachedViewport: Nullable<IViewportLike>;
  31107. private _cachedVertexArrayObject;
  31108. /** @hidden */
  31109. protected _cachedVertexBuffers: any;
  31110. /** @hidden */
  31111. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31112. /** @hidden */
  31113. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31114. /** @hidden */
  31115. _currentRenderTarget: Nullable<InternalTexture>;
  31116. private _uintIndicesCurrentlySet;
  31117. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31118. /** @hidden */
  31119. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31120. private _currentBufferPointers;
  31121. private _currentInstanceLocations;
  31122. private _currentInstanceBuffers;
  31123. private _textureUnits;
  31124. /** @hidden */
  31125. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31126. /** @hidden */
  31127. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31128. /** @hidden */
  31129. _boundRenderFunction: any;
  31130. private _vaoRecordInProgress;
  31131. private _mustWipeVertexAttributes;
  31132. private _emptyTexture;
  31133. private _emptyCubeTexture;
  31134. private _emptyTexture3D;
  31135. private _emptyTexture2DArray;
  31136. /** @hidden */
  31137. _frameHandler: number;
  31138. private _nextFreeTextureSlots;
  31139. private _maxSimultaneousTextures;
  31140. private _activeRequests;
  31141. protected _texturesSupported: string[];
  31142. /** @hidden */
  31143. _textureFormatInUse: Nullable<string>;
  31144. protected get _supportsHardwareTextureRescaling(): boolean;
  31145. private _framebufferDimensionsObject;
  31146. /**
  31147. * sets the object from which width and height will be taken from when getting render width and height
  31148. * Will fallback to the gl object
  31149. * @param dimensions the framebuffer width and height that will be used.
  31150. */
  31151. set framebufferDimensionsObject(dimensions: Nullable<{
  31152. framebufferWidth: number;
  31153. framebufferHeight: number;
  31154. }>);
  31155. /**
  31156. * Gets the list of texture formats supported
  31157. */
  31158. get texturesSupported(): Array<string>;
  31159. /**
  31160. * Gets the list of texture formats in use
  31161. */
  31162. get textureFormatInUse(): Nullable<string>;
  31163. /**
  31164. * Gets the current viewport
  31165. */
  31166. get currentViewport(): Nullable<IViewportLike>;
  31167. /**
  31168. * Gets the default empty texture
  31169. */
  31170. get emptyTexture(): InternalTexture;
  31171. /**
  31172. * Gets the default empty 3D texture
  31173. */
  31174. get emptyTexture3D(): InternalTexture;
  31175. /**
  31176. * Gets the default empty 2D array texture
  31177. */
  31178. get emptyTexture2DArray(): InternalTexture;
  31179. /**
  31180. * Gets the default empty cube texture
  31181. */
  31182. get emptyCubeTexture(): InternalTexture;
  31183. /**
  31184. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31185. */
  31186. readonly premultipliedAlpha: boolean;
  31187. /**
  31188. * Observable event triggered before each texture is initialized
  31189. */
  31190. onBeforeTextureInitObservable: Observable<Texture>;
  31191. /**
  31192. * Creates a new engine
  31193. * @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
  31194. * @param antialias defines enable antialiasing (default: false)
  31195. * @param options defines further options to be sent to the getContext() function
  31196. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31197. */
  31198. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31199. private _rebuildInternalTextures;
  31200. private _rebuildEffects;
  31201. /**
  31202. * Gets a boolean indicating if all created effects are ready
  31203. * @returns true if all effects are ready
  31204. */
  31205. areAllEffectsReady(): boolean;
  31206. protected _rebuildBuffers(): void;
  31207. private _initGLContext;
  31208. /**
  31209. * Gets version of the current webGL context
  31210. */
  31211. get webGLVersion(): number;
  31212. /**
  31213. * Gets a string idenfifying the name of the class
  31214. * @returns "Engine" string
  31215. */
  31216. getClassName(): string;
  31217. /**
  31218. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31219. */
  31220. get isStencilEnable(): boolean;
  31221. /** @hidden */
  31222. _prepareWorkingCanvas(): void;
  31223. /**
  31224. * Reset the texture cache to empty state
  31225. */
  31226. resetTextureCache(): void;
  31227. /**
  31228. * Gets an object containing information about the current webGL context
  31229. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31230. */
  31231. getGlInfo(): {
  31232. vendor: string;
  31233. renderer: string;
  31234. version: string;
  31235. };
  31236. /**
  31237. * Defines the hardware scaling level.
  31238. * By default the hardware scaling level is computed from the window device ratio.
  31239. * 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.
  31240. * @param level defines the level to use
  31241. */
  31242. setHardwareScalingLevel(level: number): void;
  31243. /**
  31244. * Gets the current hardware scaling level.
  31245. * By default the hardware scaling level is computed from the window device ratio.
  31246. * 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.
  31247. * @returns a number indicating the current hardware scaling level
  31248. */
  31249. getHardwareScalingLevel(): number;
  31250. /**
  31251. * Gets the list of loaded textures
  31252. * @returns an array containing all loaded textures
  31253. */
  31254. getLoadedTexturesCache(): InternalTexture[];
  31255. /**
  31256. * Gets the object containing all engine capabilities
  31257. * @returns the EngineCapabilities object
  31258. */
  31259. getCaps(): EngineCapabilities;
  31260. /**
  31261. * stop executing a render loop function and remove it from the execution array
  31262. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31263. */
  31264. stopRenderLoop(renderFunction?: () => void): void;
  31265. /** @hidden */
  31266. _renderLoop(): void;
  31267. /**
  31268. * Gets the HTML canvas attached with the current webGL context
  31269. * @returns a HTML canvas
  31270. */
  31271. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31272. /**
  31273. * Gets host window
  31274. * @returns the host window object
  31275. */
  31276. getHostWindow(): Nullable<Window>;
  31277. /**
  31278. * Gets the current render width
  31279. * @param useScreen defines if screen size must be used (or the current render target if any)
  31280. * @returns a number defining the current render width
  31281. */
  31282. getRenderWidth(useScreen?: boolean): number;
  31283. /**
  31284. * Gets the current render height
  31285. * @param useScreen defines if screen size must be used (or the current render target if any)
  31286. * @returns a number defining the current render height
  31287. */
  31288. getRenderHeight(useScreen?: boolean): number;
  31289. /**
  31290. * Can be used to override the current requestAnimationFrame requester.
  31291. * @hidden
  31292. */
  31293. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31294. /**
  31295. * Register and execute a render loop. The engine can have more than one render function
  31296. * @param renderFunction defines the function to continuously execute
  31297. */
  31298. runRenderLoop(renderFunction: () => void): void;
  31299. /**
  31300. * Clear the current render buffer or the current render target (if any is set up)
  31301. * @param color defines the color to use
  31302. * @param backBuffer defines if the back buffer must be cleared
  31303. * @param depth defines if the depth buffer must be cleared
  31304. * @param stencil defines if the stencil buffer must be cleared
  31305. */
  31306. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31307. private _viewportCached;
  31308. /** @hidden */
  31309. _viewport(x: number, y: number, width: number, height: number): void;
  31310. /**
  31311. * Set the WebGL's viewport
  31312. * @param viewport defines the viewport element to be used
  31313. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31314. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31315. */
  31316. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31317. /**
  31318. * Begin a new frame
  31319. */
  31320. beginFrame(): void;
  31321. /**
  31322. * Enf the current frame
  31323. */
  31324. endFrame(): void;
  31325. /**
  31326. * Resize the view according to the canvas' size
  31327. */
  31328. resize(): void;
  31329. /**
  31330. * Force a specific size of the canvas
  31331. * @param width defines the new canvas' width
  31332. * @param height defines the new canvas' height
  31333. */
  31334. setSize(width: number, height: number): void;
  31335. /**
  31336. * Binds the frame buffer to the specified texture.
  31337. * @param texture The texture to render to or null for the default canvas
  31338. * @param faceIndex The face of the texture to render to in case of cube texture
  31339. * @param requiredWidth The width of the target to render to
  31340. * @param requiredHeight The height of the target to render to
  31341. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31342. * @param lodLevel defines the lod level to bind to the frame buffer
  31343. * @param layer defines the 2d array index to bind to frame buffer to
  31344. */
  31345. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31346. /** @hidden */
  31347. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31348. /**
  31349. * Unbind the current render target texture from the webGL context
  31350. * @param texture defines the render target texture to unbind
  31351. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31352. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31353. */
  31354. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31355. /**
  31356. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31357. */
  31358. flushFramebuffer(): void;
  31359. /**
  31360. * Unbind the current render target and bind the default framebuffer
  31361. */
  31362. restoreDefaultFramebuffer(): void;
  31363. /** @hidden */
  31364. protected _resetVertexBufferBinding(): void;
  31365. /**
  31366. * Creates a vertex buffer
  31367. * @param data the data for the vertex buffer
  31368. * @returns the new WebGL static buffer
  31369. */
  31370. createVertexBuffer(data: DataArray): DataBuffer;
  31371. private _createVertexBuffer;
  31372. /**
  31373. * Creates a dynamic vertex buffer
  31374. * @param data the data for the dynamic vertex buffer
  31375. * @returns the new WebGL dynamic buffer
  31376. */
  31377. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31378. protected _resetIndexBufferBinding(): void;
  31379. /**
  31380. * Creates a new index buffer
  31381. * @param indices defines the content of the index buffer
  31382. * @param updatable defines if the index buffer must be updatable
  31383. * @returns a new webGL buffer
  31384. */
  31385. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31386. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31387. /**
  31388. * Bind a webGL buffer to the webGL context
  31389. * @param buffer defines the buffer to bind
  31390. */
  31391. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31392. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31393. private bindBuffer;
  31394. /**
  31395. * update the bound buffer with the given data
  31396. * @param data defines the data to update
  31397. */
  31398. updateArrayBuffer(data: Float32Array): void;
  31399. private _vertexAttribPointer;
  31400. /** @hidden */
  31401. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31402. private _bindVertexBuffersAttributes;
  31403. /**
  31404. * Records a vertex array object
  31405. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31406. * @param vertexBuffers defines the list of vertex buffers to store
  31407. * @param indexBuffer defines the index buffer to store
  31408. * @param effect defines the effect to store
  31409. * @returns the new vertex array object
  31410. */
  31411. recordVertexArrayObject(vertexBuffers: {
  31412. [key: string]: VertexBuffer;
  31413. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31414. /**
  31415. * Bind a specific vertex array object
  31416. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31417. * @param vertexArrayObject defines the vertex array object to bind
  31418. * @param indexBuffer defines the index buffer to bind
  31419. */
  31420. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31421. /**
  31422. * Bind webGl buffers directly to the webGL context
  31423. * @param vertexBuffer defines the vertex buffer to bind
  31424. * @param indexBuffer defines the index buffer to bind
  31425. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31426. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31427. * @param effect defines the effect associated with the vertex buffer
  31428. */
  31429. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31430. private _unbindVertexArrayObject;
  31431. /**
  31432. * Bind a list of vertex buffers to the webGL context
  31433. * @param vertexBuffers defines the list of vertex buffers to bind
  31434. * @param indexBuffer defines the index buffer to bind
  31435. * @param effect defines the effect associated with the vertex buffers
  31436. */
  31437. bindBuffers(vertexBuffers: {
  31438. [key: string]: Nullable<VertexBuffer>;
  31439. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31440. /**
  31441. * Unbind all instance attributes
  31442. */
  31443. unbindInstanceAttributes(): void;
  31444. /**
  31445. * Release and free the memory of a vertex array object
  31446. * @param vao defines the vertex array object to delete
  31447. */
  31448. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31449. /** @hidden */
  31450. _releaseBuffer(buffer: DataBuffer): boolean;
  31451. protected _deleteBuffer(buffer: DataBuffer): void;
  31452. /**
  31453. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31454. * @param instancesBuffer defines the webGL buffer to update and bind
  31455. * @param data defines the data to store in the buffer
  31456. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31457. */
  31458. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31459. /**
  31460. * Bind the content of a webGL buffer used with instantiation
  31461. * @param instancesBuffer defines the webGL buffer to bind
  31462. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31463. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31464. */
  31465. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31466. /**
  31467. * Disable the instance attribute corresponding to the name in parameter
  31468. * @param name defines the name of the attribute to disable
  31469. */
  31470. disableInstanceAttributeByName(name: string): void;
  31471. /**
  31472. * Disable the instance attribute corresponding to the location in parameter
  31473. * @param attributeLocation defines the attribute location of the attribute to disable
  31474. */
  31475. disableInstanceAttribute(attributeLocation: number): void;
  31476. /**
  31477. * Disable the attribute corresponding to the location in parameter
  31478. * @param attributeLocation defines the attribute location of the attribute to disable
  31479. */
  31480. disableAttributeByIndex(attributeLocation: number): void;
  31481. /**
  31482. * Send a draw order
  31483. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31484. * @param indexStart defines the starting index
  31485. * @param indexCount defines the number of index to draw
  31486. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31487. */
  31488. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31489. /**
  31490. * Draw a list of points
  31491. * @param verticesStart defines the index of first vertex to draw
  31492. * @param verticesCount defines the count of vertices to draw
  31493. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31494. */
  31495. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31496. /**
  31497. * Draw a list of unindexed primitives
  31498. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31499. * @param verticesStart defines the index of first vertex to draw
  31500. * @param verticesCount defines the count of vertices to draw
  31501. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31502. */
  31503. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31504. /**
  31505. * Draw a list of indexed primitives
  31506. * @param fillMode defines the primitive to use
  31507. * @param indexStart defines the starting index
  31508. * @param indexCount defines the number of index to draw
  31509. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31510. */
  31511. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31512. /**
  31513. * Draw a list of unindexed primitives
  31514. * @param fillMode defines the primitive to use
  31515. * @param verticesStart defines the index of first vertex to draw
  31516. * @param verticesCount defines the count of vertices to draw
  31517. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31518. */
  31519. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31520. private _drawMode;
  31521. /** @hidden */
  31522. protected _reportDrawCall(): void;
  31523. /** @hidden */
  31524. _releaseEffect(effect: Effect): void;
  31525. /** @hidden */
  31526. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31527. /**
  31528. * Create a new effect (used to store vertex/fragment shaders)
  31529. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31530. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31531. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31532. * @param samplers defines an array of string used to represent textures
  31533. * @param defines defines the string containing the defines to use to compile the shaders
  31534. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31535. * @param onCompiled defines a function to call when the effect creation is successful
  31536. * @param onError defines a function to call when the effect creation has failed
  31537. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31538. * @returns the new Effect
  31539. */
  31540. 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;
  31541. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31542. private _compileShader;
  31543. private _compileRawShader;
  31544. /** @hidden */
  31545. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31546. /**
  31547. * Directly creates a webGL program
  31548. * @param pipelineContext defines the pipeline context to attach to
  31549. * @param vertexCode defines the vertex shader code to use
  31550. * @param fragmentCode defines the fragment shader code to use
  31551. * @param context defines the webGL context to use (if not set, the current one will be used)
  31552. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31553. * @returns the new webGL program
  31554. */
  31555. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31556. /**
  31557. * Creates a webGL program
  31558. * @param pipelineContext defines the pipeline context to attach to
  31559. * @param vertexCode defines the vertex shader code to use
  31560. * @param fragmentCode defines the fragment shader code to use
  31561. * @param defines defines the string containing the defines to use to compile the shaders
  31562. * @param context defines the webGL context to use (if not set, the current one will be used)
  31563. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31564. * @returns the new webGL program
  31565. */
  31566. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31567. /**
  31568. * Creates a new pipeline context
  31569. * @returns the new pipeline
  31570. */
  31571. createPipelineContext(): IPipelineContext;
  31572. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31573. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31574. /** @hidden */
  31575. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31576. /** @hidden */
  31577. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31578. /** @hidden */
  31579. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31580. /**
  31581. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31582. * @param pipelineContext defines the pipeline context to use
  31583. * @param uniformsNames defines the list of uniform names
  31584. * @returns an array of webGL uniform locations
  31585. */
  31586. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31587. /**
  31588. * Gets the lsit of active attributes for a given webGL program
  31589. * @param pipelineContext defines the pipeline context to use
  31590. * @param attributesNames defines the list of attribute names to get
  31591. * @returns an array of indices indicating the offset of each attribute
  31592. */
  31593. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31594. /**
  31595. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31596. * @param effect defines the effect to activate
  31597. */
  31598. enableEffect(effect: Nullable<Effect>): void;
  31599. /**
  31600. * Set the value of an uniform to a number (int)
  31601. * @param uniform defines the webGL uniform location where to store the value
  31602. * @param value defines the int number to store
  31603. */
  31604. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31605. /**
  31606. * Set the value of an uniform to an array of int32
  31607. * @param uniform defines the webGL uniform location where to store the value
  31608. * @param array defines the array of int32 to store
  31609. */
  31610. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31611. /**
  31612. * Set the value of an uniform to an array of int32 (stored as vec2)
  31613. * @param uniform defines the webGL uniform location where to store the value
  31614. * @param array defines the array of int32 to store
  31615. */
  31616. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31617. /**
  31618. * Set the value of an uniform to an array of int32 (stored as vec3)
  31619. * @param uniform defines the webGL uniform location where to store the value
  31620. * @param array defines the array of int32 to store
  31621. */
  31622. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31623. /**
  31624. * Set the value of an uniform to an array of int32 (stored as vec4)
  31625. * @param uniform defines the webGL uniform location where to store the value
  31626. * @param array defines the array of int32 to store
  31627. */
  31628. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31629. /**
  31630. * Set the value of an uniform to an array of number
  31631. * @param uniform defines the webGL uniform location where to store the value
  31632. * @param array defines the array of number to store
  31633. */
  31634. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31635. /**
  31636. * Set the value of an uniform to an array of number (stored as vec2)
  31637. * @param uniform defines the webGL uniform location where to store the value
  31638. * @param array defines the array of number to store
  31639. */
  31640. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31641. /**
  31642. * Set the value of an uniform to an array of number (stored as vec3)
  31643. * @param uniform defines the webGL uniform location where to store the value
  31644. * @param array defines the array of number to store
  31645. */
  31646. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31647. /**
  31648. * Set the value of an uniform to an array of number (stored as vec4)
  31649. * @param uniform defines the webGL uniform location where to store the value
  31650. * @param array defines the array of number to store
  31651. */
  31652. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31653. /**
  31654. * Set the value of an uniform to an array of float32 (stored as matrices)
  31655. * @param uniform defines the webGL uniform location where to store the value
  31656. * @param matrices defines the array of float32 to store
  31657. */
  31658. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31659. /**
  31660. * Set the value of an uniform to a matrix (3x3)
  31661. * @param uniform defines the webGL uniform location where to store the value
  31662. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31663. */
  31664. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31665. /**
  31666. * Set the value of an uniform to a matrix (2x2)
  31667. * @param uniform defines the webGL uniform location where to store the value
  31668. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31669. */
  31670. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31671. /**
  31672. * Set the value of an uniform to a number (float)
  31673. * @param uniform defines the webGL uniform location where to store the value
  31674. * @param value defines the float number to store
  31675. */
  31676. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31677. /**
  31678. * Set the value of an uniform to a vec2
  31679. * @param uniform defines the webGL uniform location where to store the value
  31680. * @param x defines the 1st component of the value
  31681. * @param y defines the 2nd component of the value
  31682. */
  31683. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31684. /**
  31685. * Set the value of an uniform to a vec3
  31686. * @param uniform defines the webGL uniform location where to store the value
  31687. * @param x defines the 1st component of the value
  31688. * @param y defines the 2nd component of the value
  31689. * @param z defines the 3rd component of the value
  31690. */
  31691. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31692. /**
  31693. * Set the value of an uniform to a vec4
  31694. * @param uniform defines the webGL uniform location where to store the value
  31695. * @param x defines the 1st component of the value
  31696. * @param y defines the 2nd component of the value
  31697. * @param z defines the 3rd component of the value
  31698. * @param w defines the 4th component of the value
  31699. */
  31700. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31701. /**
  31702. * Apply all cached states (depth, culling, stencil and alpha)
  31703. */
  31704. applyStates(): void;
  31705. /**
  31706. * Enable or disable color writing
  31707. * @param enable defines the state to set
  31708. */
  31709. setColorWrite(enable: boolean): void;
  31710. /**
  31711. * Gets a boolean indicating if color writing is enabled
  31712. * @returns the current color writing state
  31713. */
  31714. getColorWrite(): boolean;
  31715. /**
  31716. * Gets the depth culling state manager
  31717. */
  31718. get depthCullingState(): DepthCullingState;
  31719. /**
  31720. * Gets the alpha state manager
  31721. */
  31722. get alphaState(): AlphaState;
  31723. /**
  31724. * Gets the stencil state manager
  31725. */
  31726. get stencilState(): StencilState;
  31727. /**
  31728. * Clears the list of texture accessible through engine.
  31729. * This can help preventing texture load conflict due to name collision.
  31730. */
  31731. clearInternalTexturesCache(): void;
  31732. /**
  31733. * Force the entire cache to be cleared
  31734. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31735. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31736. */
  31737. wipeCaches(bruteForce?: boolean): void;
  31738. /** @hidden */
  31739. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31740. min: number;
  31741. mag: number;
  31742. };
  31743. /** @hidden */
  31744. _createTexture(): WebGLTexture;
  31745. /**
  31746. * Usually called from Texture.ts.
  31747. * Passed information to create a WebGLTexture
  31748. * @param urlArg defines a value which contains one of the following:
  31749. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31750. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31751. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31752. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31753. * @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)
  31754. * @param scene needed for loading to the correct scene
  31755. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31756. * @param onLoad optional callback to be called upon successful completion
  31757. * @param onError optional callback to be called upon failure
  31758. * @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
  31759. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31760. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31761. * @param forcedExtension defines the extension to use to pick the right loader
  31762. * @param mimeType defines an optional mime type
  31763. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31764. */
  31765. 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;
  31766. /**
  31767. * Loads an image as an HTMLImageElement.
  31768. * @param input url string, ArrayBuffer, or Blob to load
  31769. * @param onLoad callback called when the image successfully loads
  31770. * @param onError callback called when the image fails to load
  31771. * @param offlineProvider offline provider for caching
  31772. * @param mimeType optional mime type
  31773. * @returns the HTMLImageElement of the loaded image
  31774. * @hidden
  31775. */
  31776. 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>;
  31777. /**
  31778. * @hidden
  31779. */
  31780. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31781. /**
  31782. * Creates a raw texture
  31783. * @param data defines the data to store in the texture
  31784. * @param width defines the width of the texture
  31785. * @param height defines the height of the texture
  31786. * @param format defines the format of the data
  31787. * @param generateMipMaps defines if the engine should generate the mip levels
  31788. * @param invertY defines if data must be stored with Y axis inverted
  31789. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31790. * @param compression defines the compression used (null by default)
  31791. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31792. * @returns the raw texture inside an InternalTexture
  31793. */
  31794. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31795. /**
  31796. * Creates a new raw cube texture
  31797. * @param data defines the array of data to use to create each face
  31798. * @param size defines the size of the textures
  31799. * @param format defines the format of the data
  31800. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31801. * @param generateMipMaps defines if the engine should generate the mip levels
  31802. * @param invertY defines if data must be stored with Y axis inverted
  31803. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31804. * @param compression defines the compression used (null by default)
  31805. * @returns the cube texture as an InternalTexture
  31806. */
  31807. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31808. /**
  31809. * Creates a new raw 3D texture
  31810. * @param data defines the data used to create the texture
  31811. * @param width defines the width of the texture
  31812. * @param height defines the height of the texture
  31813. * @param depth defines the depth of the texture
  31814. * @param format defines the format of the texture
  31815. * @param generateMipMaps defines if the engine must generate mip levels
  31816. * @param invertY defines if data must be stored with Y axis inverted
  31817. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31818. * @param compression defines the compressed used (can be null)
  31819. * @param textureType defines the compressed used (can be null)
  31820. * @returns a new raw 3D texture (stored in an InternalTexture)
  31821. */
  31822. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31823. /**
  31824. * Creates a new raw 2D array texture
  31825. * @param data defines the data used to create the texture
  31826. * @param width defines the width of the texture
  31827. * @param height defines the height of the texture
  31828. * @param depth defines the number of layers of the texture
  31829. * @param format defines the format of the texture
  31830. * @param generateMipMaps defines if the engine must generate mip levels
  31831. * @param invertY defines if data must be stored with Y axis inverted
  31832. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31833. * @param compression defines the compressed used (can be null)
  31834. * @param textureType defines the compressed used (can be null)
  31835. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31836. */
  31837. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31838. private _unpackFlipYCached;
  31839. /**
  31840. * In case you are sharing the context with other applications, it might
  31841. * be interested to not cache the unpack flip y state to ensure a consistent
  31842. * value would be set.
  31843. */
  31844. enableUnpackFlipYCached: boolean;
  31845. /** @hidden */
  31846. _unpackFlipY(value: boolean): void;
  31847. /** @hidden */
  31848. _getUnpackAlignement(): number;
  31849. private _getTextureTarget;
  31850. /**
  31851. * Update the sampling mode of a given texture
  31852. * @param samplingMode defines the required sampling mode
  31853. * @param texture defines the texture to update
  31854. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31855. */
  31856. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31857. /**
  31858. * Update the sampling mode of a given texture
  31859. * @param texture defines the texture to update
  31860. * @param wrapU defines the texture wrap mode of the u coordinates
  31861. * @param wrapV defines the texture wrap mode of the v coordinates
  31862. * @param wrapR defines the texture wrap mode of the r coordinates
  31863. */
  31864. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31865. /** @hidden */
  31866. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31867. width: number;
  31868. height: number;
  31869. layers?: number;
  31870. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31871. /** @hidden */
  31872. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31873. /** @hidden */
  31874. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31875. /**
  31876. * Update a portion of an internal texture
  31877. * @param texture defines the texture to update
  31878. * @param imageData defines the data to store into the texture
  31879. * @param xOffset defines the x coordinates of the update rectangle
  31880. * @param yOffset defines the y coordinates of the update rectangle
  31881. * @param width defines the width of the update rectangle
  31882. * @param height defines the height of the update rectangle
  31883. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31884. * @param lod defines the lod level to update (0 by default)
  31885. */
  31886. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31887. /** @hidden */
  31888. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31889. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31890. private _prepareWebGLTexture;
  31891. /** @hidden */
  31892. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31893. private _getDepthStencilBuffer;
  31894. /** @hidden */
  31895. _releaseFramebufferObjects(texture: InternalTexture): void;
  31896. /** @hidden */
  31897. _releaseTexture(texture: InternalTexture): void;
  31898. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31899. protected _setProgram(program: WebGLProgram): void;
  31900. protected _boundUniforms: {
  31901. [key: number]: WebGLUniformLocation;
  31902. };
  31903. /**
  31904. * Binds an effect to the webGL context
  31905. * @param effect defines the effect to bind
  31906. */
  31907. bindSamplers(effect: Effect): void;
  31908. private _activateCurrentTexture;
  31909. /** @hidden */
  31910. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31911. /** @hidden */
  31912. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31913. /**
  31914. * Unbind all textures from the webGL context
  31915. */
  31916. unbindAllTextures(): void;
  31917. /**
  31918. * Sets a texture to the according uniform.
  31919. * @param channel The texture channel
  31920. * @param uniform The uniform to set
  31921. * @param texture The texture to apply
  31922. */
  31923. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31924. private _bindSamplerUniformToChannel;
  31925. private _getTextureWrapMode;
  31926. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31927. /**
  31928. * Sets an array of texture to the webGL context
  31929. * @param channel defines the channel where the texture array must be set
  31930. * @param uniform defines the associated uniform location
  31931. * @param textures defines the array of textures to bind
  31932. */
  31933. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31934. /** @hidden */
  31935. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31936. private _setTextureParameterFloat;
  31937. private _setTextureParameterInteger;
  31938. /**
  31939. * Unbind all vertex attributes from the webGL context
  31940. */
  31941. unbindAllAttributes(): void;
  31942. /**
  31943. * 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
  31944. */
  31945. releaseEffects(): void;
  31946. /**
  31947. * Dispose and release all associated resources
  31948. */
  31949. dispose(): void;
  31950. /**
  31951. * Attach a new callback raised when context lost event is fired
  31952. * @param callback defines the callback to call
  31953. */
  31954. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31955. /**
  31956. * Attach a new callback raised when context restored event is fired
  31957. * @param callback defines the callback to call
  31958. */
  31959. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31960. /**
  31961. * Get the current error code of the webGL context
  31962. * @returns the error code
  31963. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31964. */
  31965. getError(): number;
  31966. private _canRenderToFloatFramebuffer;
  31967. private _canRenderToHalfFloatFramebuffer;
  31968. private _canRenderToFramebuffer;
  31969. /** @hidden */
  31970. _getWebGLTextureType(type: number): number;
  31971. /** @hidden */
  31972. _getInternalFormat(format: number): number;
  31973. /** @hidden */
  31974. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31975. /** @hidden */
  31976. _getRGBAMultiSampleBufferFormat(type: number): number;
  31977. /** @hidden */
  31978. _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;
  31979. /**
  31980. * Loads a file from a url
  31981. * @param url url to load
  31982. * @param onSuccess callback called when the file successfully loads
  31983. * @param onProgress callback called while file is loading (if the server supports this mode)
  31984. * @param offlineProvider defines the offline provider for caching
  31985. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31986. * @param onError callback called when the file fails to load
  31987. * @returns a file request object
  31988. * @hidden
  31989. */
  31990. 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;
  31991. /**
  31992. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31993. * @param x defines the x coordinate of the rectangle where pixels must be read
  31994. * @param y defines the y coordinate of the rectangle where pixels must be read
  31995. * @param width defines the width of the rectangle where pixels must be read
  31996. * @param height defines the height of the rectangle where pixels must be read
  31997. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  31998. * @returns a Uint8Array containing RGBA colors
  31999. */
  32000. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32001. private static _isSupported;
  32002. /**
  32003. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32004. * @returns true if the engine can be created
  32005. * @ignorenaming
  32006. */
  32007. static isSupported(): boolean;
  32008. /**
  32009. * Find the next highest power of two.
  32010. * @param x Number to start search from.
  32011. * @return Next highest power of two.
  32012. */
  32013. static CeilingPOT(x: number): number;
  32014. /**
  32015. * Find the next lowest power of two.
  32016. * @param x Number to start search from.
  32017. * @return Next lowest power of two.
  32018. */
  32019. static FloorPOT(x: number): number;
  32020. /**
  32021. * Find the nearest power of two.
  32022. * @param x Number to start search from.
  32023. * @return Next nearest power of two.
  32024. */
  32025. static NearestPOT(x: number): number;
  32026. /**
  32027. * Get the closest exponent of two
  32028. * @param value defines the value to approximate
  32029. * @param max defines the maximum value to return
  32030. * @param mode defines how to define the closest value
  32031. * @returns closest exponent of two of the given value
  32032. */
  32033. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32034. /**
  32035. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32036. * @param func - the function to be called
  32037. * @param requester - the object that will request the next frame. Falls back to window.
  32038. * @returns frame number
  32039. */
  32040. static QueueNewFrame(func: () => void, requester?: any): number;
  32041. /**
  32042. * Gets host document
  32043. * @returns the host document object
  32044. */
  32045. getHostDocument(): Nullable<Document>;
  32046. }
  32047. }
  32048. declare module BABYLON {
  32049. /**
  32050. * Class representing spherical harmonics coefficients to the 3rd degree
  32051. */
  32052. export class SphericalHarmonics {
  32053. /**
  32054. * Defines whether or not the harmonics have been prescaled for rendering.
  32055. */
  32056. preScaled: boolean;
  32057. /**
  32058. * The l0,0 coefficients of the spherical harmonics
  32059. */
  32060. l00: Vector3;
  32061. /**
  32062. * The l1,-1 coefficients of the spherical harmonics
  32063. */
  32064. l1_1: Vector3;
  32065. /**
  32066. * The l1,0 coefficients of the spherical harmonics
  32067. */
  32068. l10: Vector3;
  32069. /**
  32070. * The l1,1 coefficients of the spherical harmonics
  32071. */
  32072. l11: Vector3;
  32073. /**
  32074. * The l2,-2 coefficients of the spherical harmonics
  32075. */
  32076. l2_2: Vector3;
  32077. /**
  32078. * The l2,-1 coefficients of the spherical harmonics
  32079. */
  32080. l2_1: Vector3;
  32081. /**
  32082. * The l2,0 coefficients of the spherical harmonics
  32083. */
  32084. l20: Vector3;
  32085. /**
  32086. * The l2,1 coefficients of the spherical harmonics
  32087. */
  32088. l21: Vector3;
  32089. /**
  32090. * The l2,2 coefficients of the spherical harmonics
  32091. */
  32092. l22: Vector3;
  32093. /**
  32094. * Adds a light to the spherical harmonics
  32095. * @param direction the direction of the light
  32096. * @param color the color of the light
  32097. * @param deltaSolidAngle the delta solid angle of the light
  32098. */
  32099. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32100. /**
  32101. * Scales the spherical harmonics by the given amount
  32102. * @param scale the amount to scale
  32103. */
  32104. scaleInPlace(scale: number): void;
  32105. /**
  32106. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32107. *
  32108. * ```
  32109. * E_lm = A_l * L_lm
  32110. * ```
  32111. *
  32112. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32113. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32114. * the scaling factors are given in equation 9.
  32115. */
  32116. convertIncidentRadianceToIrradiance(): void;
  32117. /**
  32118. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32119. *
  32120. * ```
  32121. * L = (1/pi) * E * rho
  32122. * ```
  32123. *
  32124. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32125. */
  32126. convertIrradianceToLambertianRadiance(): void;
  32127. /**
  32128. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32129. * required operations at run time.
  32130. *
  32131. * This is simply done by scaling back the SH with Ylm constants parameter.
  32132. * The trigonometric part being applied by the shader at run time.
  32133. */
  32134. preScaleForRendering(): void;
  32135. /**
  32136. * Constructs a spherical harmonics from an array.
  32137. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32138. * @returns the spherical harmonics
  32139. */
  32140. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32141. /**
  32142. * Gets the spherical harmonics from polynomial
  32143. * @param polynomial the spherical polynomial
  32144. * @returns the spherical harmonics
  32145. */
  32146. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32147. }
  32148. /**
  32149. * Class representing spherical polynomial coefficients to the 3rd degree
  32150. */
  32151. export class SphericalPolynomial {
  32152. private _harmonics;
  32153. /**
  32154. * The spherical harmonics used to create the polynomials.
  32155. */
  32156. get preScaledHarmonics(): SphericalHarmonics;
  32157. /**
  32158. * The x coefficients of the spherical polynomial
  32159. */
  32160. x: Vector3;
  32161. /**
  32162. * The y coefficients of the spherical polynomial
  32163. */
  32164. y: Vector3;
  32165. /**
  32166. * The z coefficients of the spherical polynomial
  32167. */
  32168. z: Vector3;
  32169. /**
  32170. * The xx coefficients of the spherical polynomial
  32171. */
  32172. xx: Vector3;
  32173. /**
  32174. * The yy coefficients of the spherical polynomial
  32175. */
  32176. yy: Vector3;
  32177. /**
  32178. * The zz coefficients of the spherical polynomial
  32179. */
  32180. zz: Vector3;
  32181. /**
  32182. * The xy coefficients of the spherical polynomial
  32183. */
  32184. xy: Vector3;
  32185. /**
  32186. * The yz coefficients of the spherical polynomial
  32187. */
  32188. yz: Vector3;
  32189. /**
  32190. * The zx coefficients of the spherical polynomial
  32191. */
  32192. zx: Vector3;
  32193. /**
  32194. * Adds an ambient color to the spherical polynomial
  32195. * @param color the color to add
  32196. */
  32197. addAmbient(color: Color3): void;
  32198. /**
  32199. * Scales the spherical polynomial by the given amount
  32200. * @param scale the amount to scale
  32201. */
  32202. scaleInPlace(scale: number): void;
  32203. /**
  32204. * Gets the spherical polynomial from harmonics
  32205. * @param harmonics the spherical harmonics
  32206. * @returns the spherical polynomial
  32207. */
  32208. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32209. /**
  32210. * Constructs a spherical polynomial from an array.
  32211. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32212. * @returns the spherical polynomial
  32213. */
  32214. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32215. }
  32216. }
  32217. declare module BABYLON {
  32218. /**
  32219. * Defines the source of the internal texture
  32220. */
  32221. export enum InternalTextureSource {
  32222. /**
  32223. * The source of the texture data is unknown
  32224. */
  32225. Unknown = 0,
  32226. /**
  32227. * Texture data comes from an URL
  32228. */
  32229. Url = 1,
  32230. /**
  32231. * Texture data is only used for temporary storage
  32232. */
  32233. Temp = 2,
  32234. /**
  32235. * Texture data comes from raw data (ArrayBuffer)
  32236. */
  32237. Raw = 3,
  32238. /**
  32239. * Texture content is dynamic (video or dynamic texture)
  32240. */
  32241. Dynamic = 4,
  32242. /**
  32243. * Texture content is generated by rendering to it
  32244. */
  32245. RenderTarget = 5,
  32246. /**
  32247. * Texture content is part of a multi render target process
  32248. */
  32249. MultiRenderTarget = 6,
  32250. /**
  32251. * Texture data comes from a cube data file
  32252. */
  32253. Cube = 7,
  32254. /**
  32255. * Texture data comes from a raw cube data
  32256. */
  32257. CubeRaw = 8,
  32258. /**
  32259. * Texture data come from a prefiltered cube data file
  32260. */
  32261. CubePrefiltered = 9,
  32262. /**
  32263. * Texture content is raw 3D data
  32264. */
  32265. Raw3D = 10,
  32266. /**
  32267. * Texture content is raw 2D array data
  32268. */
  32269. Raw2DArray = 11,
  32270. /**
  32271. * Texture content is a depth texture
  32272. */
  32273. Depth = 12,
  32274. /**
  32275. * Texture data comes from a raw cube data encoded with RGBD
  32276. */
  32277. CubeRawRGBD = 13
  32278. }
  32279. /**
  32280. * Class used to store data associated with WebGL texture data for the engine
  32281. * This class should not be used directly
  32282. */
  32283. export class InternalTexture {
  32284. /** @hidden */
  32285. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32286. /**
  32287. * Defines if the texture is ready
  32288. */
  32289. isReady: boolean;
  32290. /**
  32291. * Defines if the texture is a cube texture
  32292. */
  32293. isCube: boolean;
  32294. /**
  32295. * Defines if the texture contains 3D data
  32296. */
  32297. is3D: boolean;
  32298. /**
  32299. * Defines if the texture contains 2D array data
  32300. */
  32301. is2DArray: boolean;
  32302. /**
  32303. * Defines if the texture contains multiview data
  32304. */
  32305. isMultiview: boolean;
  32306. /**
  32307. * Gets the URL used to load this texture
  32308. */
  32309. url: string;
  32310. /**
  32311. * Gets the sampling mode of the texture
  32312. */
  32313. samplingMode: number;
  32314. /**
  32315. * Gets a boolean indicating if the texture needs mipmaps generation
  32316. */
  32317. generateMipMaps: boolean;
  32318. /**
  32319. * Gets the number of samples used by the texture (WebGL2+ only)
  32320. */
  32321. samples: number;
  32322. /**
  32323. * Gets the type of the texture (int, float...)
  32324. */
  32325. type: number;
  32326. /**
  32327. * Gets the format of the texture (RGB, RGBA...)
  32328. */
  32329. format: number;
  32330. /**
  32331. * Observable called when the texture is loaded
  32332. */
  32333. onLoadedObservable: Observable<InternalTexture>;
  32334. /**
  32335. * Gets the width of the texture
  32336. */
  32337. width: number;
  32338. /**
  32339. * Gets the height of the texture
  32340. */
  32341. height: number;
  32342. /**
  32343. * Gets the depth of the texture
  32344. */
  32345. depth: number;
  32346. /**
  32347. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32348. */
  32349. baseWidth: number;
  32350. /**
  32351. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32352. */
  32353. baseHeight: number;
  32354. /**
  32355. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32356. */
  32357. baseDepth: number;
  32358. /**
  32359. * Gets a boolean indicating if the texture is inverted on Y axis
  32360. */
  32361. invertY: boolean;
  32362. /** @hidden */
  32363. _invertVScale: boolean;
  32364. /** @hidden */
  32365. _associatedChannel: number;
  32366. /** @hidden */
  32367. _source: InternalTextureSource;
  32368. /** @hidden */
  32369. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32370. /** @hidden */
  32371. _bufferView: Nullable<ArrayBufferView>;
  32372. /** @hidden */
  32373. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32374. /** @hidden */
  32375. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32376. /** @hidden */
  32377. _size: number;
  32378. /** @hidden */
  32379. _extension: string;
  32380. /** @hidden */
  32381. _files: Nullable<string[]>;
  32382. /** @hidden */
  32383. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32384. /** @hidden */
  32385. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32386. /** @hidden */
  32387. _framebuffer: Nullable<WebGLFramebuffer>;
  32388. /** @hidden */
  32389. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32390. /** @hidden */
  32391. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32392. /** @hidden */
  32393. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32394. /** @hidden */
  32395. _attachments: Nullable<number[]>;
  32396. /** @hidden */
  32397. _cachedCoordinatesMode: Nullable<number>;
  32398. /** @hidden */
  32399. _cachedWrapU: Nullable<number>;
  32400. /** @hidden */
  32401. _cachedWrapV: Nullable<number>;
  32402. /** @hidden */
  32403. _cachedWrapR: Nullable<number>;
  32404. /** @hidden */
  32405. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32406. /** @hidden */
  32407. _isDisabled: boolean;
  32408. /** @hidden */
  32409. _compression: Nullable<string>;
  32410. /** @hidden */
  32411. _generateStencilBuffer: boolean;
  32412. /** @hidden */
  32413. _generateDepthBuffer: boolean;
  32414. /** @hidden */
  32415. _comparisonFunction: number;
  32416. /** @hidden */
  32417. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32418. /** @hidden */
  32419. _lodGenerationScale: number;
  32420. /** @hidden */
  32421. _lodGenerationOffset: number;
  32422. /** @hidden */
  32423. _depthStencilTexture: Nullable<InternalTexture>;
  32424. /** @hidden */
  32425. _colorTextureArray: Nullable<WebGLTexture>;
  32426. /** @hidden */
  32427. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32428. /** @hidden */
  32429. _lodTextureHigh: Nullable<BaseTexture>;
  32430. /** @hidden */
  32431. _lodTextureMid: Nullable<BaseTexture>;
  32432. /** @hidden */
  32433. _lodTextureLow: Nullable<BaseTexture>;
  32434. /** @hidden */
  32435. _isRGBD: boolean;
  32436. /** @hidden */
  32437. _linearSpecularLOD: boolean;
  32438. /** @hidden */
  32439. _irradianceTexture: Nullable<BaseTexture>;
  32440. /** @hidden */
  32441. _webGLTexture: Nullable<WebGLTexture>;
  32442. /** @hidden */
  32443. _references: number;
  32444. private _engine;
  32445. /**
  32446. * Gets the Engine the texture belongs to.
  32447. * @returns The babylon engine
  32448. */
  32449. getEngine(): ThinEngine;
  32450. /**
  32451. * Gets the data source type of the texture
  32452. */
  32453. get source(): InternalTextureSource;
  32454. /**
  32455. * Creates a new InternalTexture
  32456. * @param engine defines the engine to use
  32457. * @param source defines the type of data that will be used
  32458. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32459. */
  32460. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32461. /**
  32462. * Increments the number of references (ie. the number of Texture that point to it)
  32463. */
  32464. incrementReferences(): void;
  32465. /**
  32466. * Change the size of the texture (not the size of the content)
  32467. * @param width defines the new width
  32468. * @param height defines the new height
  32469. * @param depth defines the new depth (1 by default)
  32470. */
  32471. updateSize(width: int, height: int, depth?: int): void;
  32472. /** @hidden */
  32473. _rebuild(): void;
  32474. /** @hidden */
  32475. _swapAndDie(target: InternalTexture): void;
  32476. /**
  32477. * Dispose the current allocated resources
  32478. */
  32479. dispose(): void;
  32480. }
  32481. }
  32482. declare module BABYLON {
  32483. /**
  32484. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32486. */
  32487. export class Analyser {
  32488. /**
  32489. * Gets or sets the smoothing
  32490. * @ignorenaming
  32491. */
  32492. SMOOTHING: number;
  32493. /**
  32494. * Gets or sets the FFT table size
  32495. * @ignorenaming
  32496. */
  32497. FFT_SIZE: number;
  32498. /**
  32499. * Gets or sets the bar graph amplitude
  32500. * @ignorenaming
  32501. */
  32502. BARGRAPHAMPLITUDE: number;
  32503. /**
  32504. * Gets or sets the position of the debug canvas
  32505. * @ignorenaming
  32506. */
  32507. DEBUGCANVASPOS: {
  32508. x: number;
  32509. y: number;
  32510. };
  32511. /**
  32512. * Gets or sets the debug canvas size
  32513. * @ignorenaming
  32514. */
  32515. DEBUGCANVASSIZE: {
  32516. width: number;
  32517. height: number;
  32518. };
  32519. private _byteFreqs;
  32520. private _byteTime;
  32521. private _floatFreqs;
  32522. private _webAudioAnalyser;
  32523. private _debugCanvas;
  32524. private _debugCanvasContext;
  32525. private _scene;
  32526. private _registerFunc;
  32527. private _audioEngine;
  32528. /**
  32529. * Creates a new analyser
  32530. * @param scene defines hosting scene
  32531. */
  32532. constructor(scene: Scene);
  32533. /**
  32534. * Get the number of data values you will have to play with for the visualization
  32535. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32536. * @returns a number
  32537. */
  32538. getFrequencyBinCount(): number;
  32539. /**
  32540. * Gets the current frequency data as a byte array
  32541. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32542. * @returns a Uint8Array
  32543. */
  32544. getByteFrequencyData(): Uint8Array;
  32545. /**
  32546. * Gets the current waveform as a byte array
  32547. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32548. * @returns a Uint8Array
  32549. */
  32550. getByteTimeDomainData(): Uint8Array;
  32551. /**
  32552. * Gets the current frequency data as a float array
  32553. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32554. * @returns a Float32Array
  32555. */
  32556. getFloatFrequencyData(): Float32Array;
  32557. /**
  32558. * Renders the debug canvas
  32559. */
  32560. drawDebugCanvas(): void;
  32561. /**
  32562. * Stops rendering the debug canvas and removes it
  32563. */
  32564. stopDebugCanvas(): void;
  32565. /**
  32566. * Connects two audio nodes
  32567. * @param inputAudioNode defines first node to connect
  32568. * @param outputAudioNode defines second node to connect
  32569. */
  32570. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32571. /**
  32572. * Releases all associated resources
  32573. */
  32574. dispose(): void;
  32575. }
  32576. }
  32577. declare module BABYLON {
  32578. /**
  32579. * This represents an audio engine and it is responsible
  32580. * to play, synchronize and analyse sounds throughout the application.
  32581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32582. */
  32583. export interface IAudioEngine extends IDisposable {
  32584. /**
  32585. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32586. */
  32587. readonly canUseWebAudio: boolean;
  32588. /**
  32589. * Gets the current AudioContext if available.
  32590. */
  32591. readonly audioContext: Nullable<AudioContext>;
  32592. /**
  32593. * The master gain node defines the global audio volume of your audio engine.
  32594. */
  32595. readonly masterGain: GainNode;
  32596. /**
  32597. * Gets whether or not mp3 are supported by your browser.
  32598. */
  32599. readonly isMP3supported: boolean;
  32600. /**
  32601. * Gets whether or not ogg are supported by your browser.
  32602. */
  32603. readonly isOGGsupported: boolean;
  32604. /**
  32605. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32606. * @ignoreNaming
  32607. */
  32608. WarnedWebAudioUnsupported: boolean;
  32609. /**
  32610. * Defines if the audio engine relies on a custom unlocked button.
  32611. * In this case, the embedded button will not be displayed.
  32612. */
  32613. useCustomUnlockedButton: boolean;
  32614. /**
  32615. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32616. */
  32617. readonly unlocked: boolean;
  32618. /**
  32619. * Event raised when audio has been unlocked on the browser.
  32620. */
  32621. onAudioUnlockedObservable: Observable<AudioEngine>;
  32622. /**
  32623. * Event raised when audio has been locked on the browser.
  32624. */
  32625. onAudioLockedObservable: Observable<AudioEngine>;
  32626. /**
  32627. * Flags the audio engine in Locked state.
  32628. * This happens due to new browser policies preventing audio to autoplay.
  32629. */
  32630. lock(): void;
  32631. /**
  32632. * Unlocks the audio engine once a user action has been done on the dom.
  32633. * This is helpful to resume play once browser policies have been satisfied.
  32634. */
  32635. unlock(): void;
  32636. /**
  32637. * Gets the global volume sets on the master gain.
  32638. * @returns the global volume if set or -1 otherwise
  32639. */
  32640. getGlobalVolume(): number;
  32641. /**
  32642. * Sets the global volume of your experience (sets on the master gain).
  32643. * @param newVolume Defines the new global volume of the application
  32644. */
  32645. setGlobalVolume(newVolume: number): void;
  32646. /**
  32647. * Connect the audio engine to an audio analyser allowing some amazing
  32648. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32650. * @param analyser The analyser to connect to the engine
  32651. */
  32652. connectToAnalyser(analyser: Analyser): void;
  32653. }
  32654. /**
  32655. * This represents the default audio engine used in babylon.
  32656. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32658. */
  32659. export class AudioEngine implements IAudioEngine {
  32660. private _audioContext;
  32661. private _audioContextInitialized;
  32662. private _muteButton;
  32663. private _hostElement;
  32664. /**
  32665. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32666. */
  32667. canUseWebAudio: boolean;
  32668. /**
  32669. * The master gain node defines the global audio volume of your audio engine.
  32670. */
  32671. masterGain: GainNode;
  32672. /**
  32673. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32674. * @ignoreNaming
  32675. */
  32676. WarnedWebAudioUnsupported: boolean;
  32677. /**
  32678. * Gets whether or not mp3 are supported by your browser.
  32679. */
  32680. isMP3supported: boolean;
  32681. /**
  32682. * Gets whether or not ogg are supported by your browser.
  32683. */
  32684. isOGGsupported: boolean;
  32685. /**
  32686. * Gets whether audio has been unlocked on the device.
  32687. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32688. * a user interaction has happened.
  32689. */
  32690. unlocked: boolean;
  32691. /**
  32692. * Defines if the audio engine relies on a custom unlocked button.
  32693. * In this case, the embedded button will not be displayed.
  32694. */
  32695. useCustomUnlockedButton: boolean;
  32696. /**
  32697. * Event raised when audio has been unlocked on the browser.
  32698. */
  32699. onAudioUnlockedObservable: Observable<AudioEngine>;
  32700. /**
  32701. * Event raised when audio has been locked on the browser.
  32702. */
  32703. onAudioLockedObservable: Observable<AudioEngine>;
  32704. /**
  32705. * Gets the current AudioContext if available.
  32706. */
  32707. get audioContext(): Nullable<AudioContext>;
  32708. private _connectedAnalyser;
  32709. /**
  32710. * Instantiates a new audio engine.
  32711. *
  32712. * There should be only one per page as some browsers restrict the number
  32713. * of audio contexts you can create.
  32714. * @param hostElement defines the host element where to display the mute icon if necessary
  32715. */
  32716. constructor(hostElement?: Nullable<HTMLElement>);
  32717. /**
  32718. * Flags the audio engine in Locked state.
  32719. * This happens due to new browser policies preventing audio to autoplay.
  32720. */
  32721. lock(): void;
  32722. /**
  32723. * Unlocks the audio engine once a user action has been done on the dom.
  32724. * This is helpful to resume play once browser policies have been satisfied.
  32725. */
  32726. unlock(): void;
  32727. private _resumeAudioContext;
  32728. private _initializeAudioContext;
  32729. private _tryToRun;
  32730. private _triggerRunningState;
  32731. private _triggerSuspendedState;
  32732. private _displayMuteButton;
  32733. private _moveButtonToTopLeft;
  32734. private _onResize;
  32735. private _hideMuteButton;
  32736. /**
  32737. * Destroy and release the resources associated with the audio ccontext.
  32738. */
  32739. dispose(): void;
  32740. /**
  32741. * Gets the global volume sets on the master gain.
  32742. * @returns the global volume if set or -1 otherwise
  32743. */
  32744. getGlobalVolume(): number;
  32745. /**
  32746. * Sets the global volume of your experience (sets on the master gain).
  32747. * @param newVolume Defines the new global volume of the application
  32748. */
  32749. setGlobalVolume(newVolume: number): void;
  32750. /**
  32751. * Connect the audio engine to an audio analyser allowing some amazing
  32752. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32754. * @param analyser The analyser to connect to the engine
  32755. */
  32756. connectToAnalyser(analyser: Analyser): void;
  32757. }
  32758. }
  32759. declare module BABYLON {
  32760. /**
  32761. * Interface used to present a loading screen while loading a scene
  32762. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32763. */
  32764. export interface ILoadingScreen {
  32765. /**
  32766. * Function called to display the loading screen
  32767. */
  32768. displayLoadingUI: () => void;
  32769. /**
  32770. * Function called to hide the loading screen
  32771. */
  32772. hideLoadingUI: () => void;
  32773. /**
  32774. * Gets or sets the color to use for the background
  32775. */
  32776. loadingUIBackgroundColor: string;
  32777. /**
  32778. * Gets or sets the text to display while loading
  32779. */
  32780. loadingUIText: string;
  32781. }
  32782. /**
  32783. * Class used for the default loading screen
  32784. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32785. */
  32786. export class DefaultLoadingScreen implements ILoadingScreen {
  32787. private _renderingCanvas;
  32788. private _loadingText;
  32789. private _loadingDivBackgroundColor;
  32790. private _loadingDiv;
  32791. private _loadingTextDiv;
  32792. /** Gets or sets the logo url to use for the default loading screen */
  32793. static DefaultLogoUrl: string;
  32794. /** Gets or sets the spinner url to use for the default loading screen */
  32795. static DefaultSpinnerUrl: string;
  32796. /**
  32797. * Creates a new default loading screen
  32798. * @param _renderingCanvas defines the canvas used to render the scene
  32799. * @param _loadingText defines the default text to display
  32800. * @param _loadingDivBackgroundColor defines the default background color
  32801. */
  32802. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32803. /**
  32804. * Function called to display the loading screen
  32805. */
  32806. displayLoadingUI(): void;
  32807. /**
  32808. * Function called to hide the loading screen
  32809. */
  32810. hideLoadingUI(): void;
  32811. /**
  32812. * Gets or sets the text to display while loading
  32813. */
  32814. set loadingUIText(text: string);
  32815. get loadingUIText(): string;
  32816. /**
  32817. * Gets or sets the color to use for the background
  32818. */
  32819. get loadingUIBackgroundColor(): string;
  32820. set loadingUIBackgroundColor(color: string);
  32821. private _resizeLoadingUI;
  32822. }
  32823. }
  32824. declare module BABYLON {
  32825. /**
  32826. * Interface for any object that can request an animation frame
  32827. */
  32828. export interface ICustomAnimationFrameRequester {
  32829. /**
  32830. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32831. */
  32832. renderFunction?: Function;
  32833. /**
  32834. * Called to request the next frame to render to
  32835. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32836. */
  32837. requestAnimationFrame: Function;
  32838. /**
  32839. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32840. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32841. */
  32842. requestID?: number;
  32843. }
  32844. }
  32845. declare module BABYLON {
  32846. /**
  32847. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32848. */
  32849. export class PerformanceMonitor {
  32850. private _enabled;
  32851. private _rollingFrameTime;
  32852. private _lastFrameTimeMs;
  32853. /**
  32854. * constructor
  32855. * @param frameSampleSize The number of samples required to saturate the sliding window
  32856. */
  32857. constructor(frameSampleSize?: number);
  32858. /**
  32859. * Samples current frame
  32860. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32861. */
  32862. sampleFrame(timeMs?: number): void;
  32863. /**
  32864. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32865. */
  32866. get averageFrameTime(): number;
  32867. /**
  32868. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32869. */
  32870. get averageFrameTimeVariance(): number;
  32871. /**
  32872. * Returns the frame time of the most recent frame
  32873. */
  32874. get instantaneousFrameTime(): number;
  32875. /**
  32876. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32877. */
  32878. get averageFPS(): number;
  32879. /**
  32880. * Returns the average framerate in frames per second using the most recent frame time
  32881. */
  32882. get instantaneousFPS(): number;
  32883. /**
  32884. * Returns true if enough samples have been taken to completely fill the sliding window
  32885. */
  32886. get isSaturated(): boolean;
  32887. /**
  32888. * Enables contributions to the sliding window sample set
  32889. */
  32890. enable(): void;
  32891. /**
  32892. * Disables contributions to the sliding window sample set
  32893. * Samples will not be interpolated over the disabled period
  32894. */
  32895. disable(): void;
  32896. /**
  32897. * Returns true if sampling is enabled
  32898. */
  32899. get isEnabled(): boolean;
  32900. /**
  32901. * Resets performance monitor
  32902. */
  32903. reset(): void;
  32904. }
  32905. /**
  32906. * RollingAverage
  32907. *
  32908. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32909. */
  32910. export class RollingAverage {
  32911. /**
  32912. * Current average
  32913. */
  32914. average: number;
  32915. /**
  32916. * Current variance
  32917. */
  32918. variance: number;
  32919. protected _samples: Array<number>;
  32920. protected _sampleCount: number;
  32921. protected _pos: number;
  32922. protected _m2: number;
  32923. /**
  32924. * constructor
  32925. * @param length The number of samples required to saturate the sliding window
  32926. */
  32927. constructor(length: number);
  32928. /**
  32929. * Adds a sample to the sample set
  32930. * @param v The sample value
  32931. */
  32932. add(v: number): void;
  32933. /**
  32934. * Returns previously added values or null if outside of history or outside the sliding window domain
  32935. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32936. * @return Value previously recorded with add() or null if outside of range
  32937. */
  32938. history(i: number): number;
  32939. /**
  32940. * Returns true if enough samples have been taken to completely fill the sliding window
  32941. * @return true if sample-set saturated
  32942. */
  32943. isSaturated(): boolean;
  32944. /**
  32945. * Resets the rolling average (equivalent to 0 samples taken so far)
  32946. */
  32947. reset(): void;
  32948. /**
  32949. * Wraps a value around the sample range boundaries
  32950. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32951. * @return Wrapped position in sample range
  32952. */
  32953. protected _wrapPosition(i: number): number;
  32954. }
  32955. }
  32956. declare module BABYLON {
  32957. /**
  32958. * This class is used to track a performance counter which is number based.
  32959. * The user has access to many properties which give statistics of different nature.
  32960. *
  32961. * The implementer can track two kinds of Performance Counter: time and count.
  32962. * 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.
  32963. * 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.
  32964. */
  32965. export class PerfCounter {
  32966. /**
  32967. * Gets or sets a global boolean to turn on and off all the counters
  32968. */
  32969. static Enabled: boolean;
  32970. /**
  32971. * Returns the smallest value ever
  32972. */
  32973. get min(): number;
  32974. /**
  32975. * Returns the biggest value ever
  32976. */
  32977. get max(): number;
  32978. /**
  32979. * Returns the average value since the performance counter is running
  32980. */
  32981. get average(): number;
  32982. /**
  32983. * Returns the average value of the last second the counter was monitored
  32984. */
  32985. get lastSecAverage(): number;
  32986. /**
  32987. * Returns the current value
  32988. */
  32989. get current(): number;
  32990. /**
  32991. * Gets the accumulated total
  32992. */
  32993. get total(): number;
  32994. /**
  32995. * Gets the total value count
  32996. */
  32997. get count(): number;
  32998. /**
  32999. * Creates a new counter
  33000. */
  33001. constructor();
  33002. /**
  33003. * Call this method to start monitoring a new frame.
  33004. * 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.
  33005. */
  33006. fetchNewFrame(): void;
  33007. /**
  33008. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33009. * @param newCount the count value to add to the monitored count
  33010. * @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.
  33011. */
  33012. addCount(newCount: number, fetchResult: boolean): void;
  33013. /**
  33014. * Start monitoring this performance counter
  33015. */
  33016. beginMonitoring(): void;
  33017. /**
  33018. * Compute the time lapsed since the previous beginMonitoring() call.
  33019. * @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
  33020. */
  33021. endMonitoring(newFrame?: boolean): void;
  33022. private _fetchResult;
  33023. private _startMonitoringTime;
  33024. private _min;
  33025. private _max;
  33026. private _average;
  33027. private _current;
  33028. private _totalValueCount;
  33029. private _totalAccumulated;
  33030. private _lastSecAverage;
  33031. private _lastSecAccumulated;
  33032. private _lastSecTime;
  33033. private _lastSecValueCount;
  33034. }
  33035. }
  33036. declare module BABYLON {
  33037. interface ThinEngine {
  33038. /**
  33039. * Sets alpha constants used by some alpha blending modes
  33040. * @param r defines the red component
  33041. * @param g defines the green component
  33042. * @param b defines the blue component
  33043. * @param a defines the alpha component
  33044. */
  33045. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33046. /**
  33047. * Sets the current alpha mode
  33048. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33049. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33050. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33051. */
  33052. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33053. /**
  33054. * Gets the current alpha mode
  33055. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33056. * @returns the current alpha mode
  33057. */
  33058. getAlphaMode(): number;
  33059. /**
  33060. * Sets the current alpha equation
  33061. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33062. */
  33063. setAlphaEquation(equation: number): void;
  33064. /**
  33065. * Gets the current alpha equation.
  33066. * @returns the current alpha equation
  33067. */
  33068. getAlphaEquation(): number;
  33069. }
  33070. }
  33071. declare module BABYLON {
  33072. /**
  33073. * Defines the interface used by display changed events
  33074. */
  33075. export interface IDisplayChangedEventArgs {
  33076. /** Gets the vrDisplay object (if any) */
  33077. vrDisplay: Nullable<any>;
  33078. /** Gets a boolean indicating if webVR is supported */
  33079. vrSupported: boolean;
  33080. }
  33081. /**
  33082. * Defines the interface used by objects containing a viewport (like a camera)
  33083. */
  33084. interface IViewportOwnerLike {
  33085. /**
  33086. * Gets or sets the viewport
  33087. */
  33088. viewport: IViewportLike;
  33089. }
  33090. /**
  33091. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33092. */
  33093. export class Engine extends ThinEngine {
  33094. /** Defines that alpha blending is disabled */
  33095. static readonly ALPHA_DISABLE: number;
  33096. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33097. static readonly ALPHA_ADD: number;
  33098. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33099. static readonly ALPHA_COMBINE: number;
  33100. /** Defines that alpha blending to DEST - SRC * DEST */
  33101. static readonly ALPHA_SUBTRACT: number;
  33102. /** Defines that alpha blending to SRC * DEST */
  33103. static readonly ALPHA_MULTIPLY: number;
  33104. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33105. static readonly ALPHA_MAXIMIZED: number;
  33106. /** Defines that alpha blending to SRC + DEST */
  33107. static readonly ALPHA_ONEONE: number;
  33108. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33109. static readonly ALPHA_PREMULTIPLIED: number;
  33110. /**
  33111. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33112. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33113. */
  33114. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33115. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33116. static readonly ALPHA_INTERPOLATE: number;
  33117. /**
  33118. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33119. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33120. */
  33121. static readonly ALPHA_SCREENMODE: number;
  33122. /** Defines that the ressource is not delayed*/
  33123. static readonly DELAYLOADSTATE_NONE: number;
  33124. /** Defines that the ressource was successfully delay loaded */
  33125. static readonly DELAYLOADSTATE_LOADED: number;
  33126. /** Defines that the ressource is currently delay loading */
  33127. static readonly DELAYLOADSTATE_LOADING: number;
  33128. /** Defines that the ressource is delayed and has not started loading */
  33129. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33130. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33131. static readonly NEVER: number;
  33132. /** 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 */
  33133. static readonly ALWAYS: number;
  33134. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33135. static readonly LESS: number;
  33136. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33137. static readonly EQUAL: number;
  33138. /** 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 */
  33139. static readonly LEQUAL: number;
  33140. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33141. static readonly GREATER: number;
  33142. /** 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 */
  33143. static readonly GEQUAL: number;
  33144. /** 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 */
  33145. static readonly NOTEQUAL: number;
  33146. /** Passed to stencilOperation to specify that stencil value must be kept */
  33147. static readonly KEEP: number;
  33148. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33149. static readonly REPLACE: number;
  33150. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33151. static readonly INCR: number;
  33152. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33153. static readonly DECR: number;
  33154. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33155. static readonly INVERT: number;
  33156. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33157. static readonly INCR_WRAP: number;
  33158. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33159. static readonly DECR_WRAP: number;
  33160. /** Texture is not repeating outside of 0..1 UVs */
  33161. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33162. /** Texture is repeating outside of 0..1 UVs */
  33163. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33164. /** Texture is repeating and mirrored */
  33165. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33166. /** ALPHA */
  33167. static readonly TEXTUREFORMAT_ALPHA: number;
  33168. /** LUMINANCE */
  33169. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33170. /** LUMINANCE_ALPHA */
  33171. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33172. /** RGB */
  33173. static readonly TEXTUREFORMAT_RGB: number;
  33174. /** RGBA */
  33175. static readonly TEXTUREFORMAT_RGBA: number;
  33176. /** RED */
  33177. static readonly TEXTUREFORMAT_RED: number;
  33178. /** RED (2nd reference) */
  33179. static readonly TEXTUREFORMAT_R: number;
  33180. /** RG */
  33181. static readonly TEXTUREFORMAT_RG: number;
  33182. /** RED_INTEGER */
  33183. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33184. /** RED_INTEGER (2nd reference) */
  33185. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33186. /** RG_INTEGER */
  33187. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33188. /** RGB_INTEGER */
  33189. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33190. /** RGBA_INTEGER */
  33191. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33192. /** UNSIGNED_BYTE */
  33193. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33194. /** UNSIGNED_BYTE (2nd reference) */
  33195. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33196. /** FLOAT */
  33197. static readonly TEXTURETYPE_FLOAT: number;
  33198. /** HALF_FLOAT */
  33199. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33200. /** BYTE */
  33201. static readonly TEXTURETYPE_BYTE: number;
  33202. /** SHORT */
  33203. static readonly TEXTURETYPE_SHORT: number;
  33204. /** UNSIGNED_SHORT */
  33205. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33206. /** INT */
  33207. static readonly TEXTURETYPE_INT: number;
  33208. /** UNSIGNED_INT */
  33209. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33210. /** UNSIGNED_SHORT_4_4_4_4 */
  33211. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33212. /** UNSIGNED_SHORT_5_5_5_1 */
  33213. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33214. /** UNSIGNED_SHORT_5_6_5 */
  33215. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33216. /** UNSIGNED_INT_2_10_10_10_REV */
  33217. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33218. /** UNSIGNED_INT_24_8 */
  33219. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33220. /** UNSIGNED_INT_10F_11F_11F_REV */
  33221. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33222. /** UNSIGNED_INT_5_9_9_9_REV */
  33223. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33224. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33225. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33226. /** nearest is mag = nearest and min = nearest and mip = linear */
  33227. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33228. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33229. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33230. /** Trilinear is mag = linear and min = linear and mip = linear */
  33231. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33232. /** nearest is mag = nearest and min = nearest and mip = linear */
  33233. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33234. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33235. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33236. /** Trilinear is mag = linear and min = linear and mip = linear */
  33237. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33238. /** mag = nearest and min = nearest and mip = nearest */
  33239. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33240. /** mag = nearest and min = linear and mip = nearest */
  33241. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33242. /** mag = nearest and min = linear and mip = linear */
  33243. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33244. /** mag = nearest and min = linear and mip = none */
  33245. static readonly TEXTURE_NEAREST_LINEAR: number;
  33246. /** mag = nearest and min = nearest and mip = none */
  33247. static readonly TEXTURE_NEAREST_NEAREST: number;
  33248. /** mag = linear and min = nearest and mip = nearest */
  33249. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33250. /** mag = linear and min = nearest and mip = linear */
  33251. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33252. /** mag = linear and min = linear and mip = none */
  33253. static readonly TEXTURE_LINEAR_LINEAR: number;
  33254. /** mag = linear and min = nearest and mip = none */
  33255. static readonly TEXTURE_LINEAR_NEAREST: number;
  33256. /** Explicit coordinates mode */
  33257. static readonly TEXTURE_EXPLICIT_MODE: number;
  33258. /** Spherical coordinates mode */
  33259. static readonly TEXTURE_SPHERICAL_MODE: number;
  33260. /** Planar coordinates mode */
  33261. static readonly TEXTURE_PLANAR_MODE: number;
  33262. /** Cubic coordinates mode */
  33263. static readonly TEXTURE_CUBIC_MODE: number;
  33264. /** Projection coordinates mode */
  33265. static readonly TEXTURE_PROJECTION_MODE: number;
  33266. /** Skybox coordinates mode */
  33267. static readonly TEXTURE_SKYBOX_MODE: number;
  33268. /** Inverse Cubic coordinates mode */
  33269. static readonly TEXTURE_INVCUBIC_MODE: number;
  33270. /** Equirectangular coordinates mode */
  33271. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33272. /** Equirectangular Fixed coordinates mode */
  33273. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33274. /** Equirectangular Fixed Mirrored coordinates mode */
  33275. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33276. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33277. static readonly SCALEMODE_FLOOR: number;
  33278. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33279. static readonly SCALEMODE_NEAREST: number;
  33280. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33281. static readonly SCALEMODE_CEILING: number;
  33282. /**
  33283. * Returns the current npm package of the sdk
  33284. */
  33285. static get NpmPackage(): string;
  33286. /**
  33287. * Returns the current version of the framework
  33288. */
  33289. static get Version(): string;
  33290. /** Gets the list of created engines */
  33291. static get Instances(): Engine[];
  33292. /**
  33293. * Gets the latest created engine
  33294. */
  33295. static get LastCreatedEngine(): Nullable<Engine>;
  33296. /**
  33297. * Gets the latest created scene
  33298. */
  33299. static get LastCreatedScene(): Nullable<Scene>;
  33300. /**
  33301. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33302. * @param flag defines which part of the materials must be marked as dirty
  33303. * @param predicate defines a predicate used to filter which materials should be affected
  33304. */
  33305. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33306. /**
  33307. * Method called to create the default loading screen.
  33308. * This can be overriden in your own app.
  33309. * @param canvas The rendering canvas element
  33310. * @returns The loading screen
  33311. */
  33312. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33313. /**
  33314. * Method called to create the default rescale post process on each engine.
  33315. */
  33316. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33317. /**
  33318. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33319. **/
  33320. enableOfflineSupport: boolean;
  33321. /**
  33322. * 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)
  33323. **/
  33324. disableManifestCheck: boolean;
  33325. /**
  33326. * Gets the list of created scenes
  33327. */
  33328. scenes: Scene[];
  33329. /**
  33330. * Event raised when a new scene is created
  33331. */
  33332. onNewSceneAddedObservable: Observable<Scene>;
  33333. /**
  33334. * Gets the list of created postprocesses
  33335. */
  33336. postProcesses: PostProcess[];
  33337. /**
  33338. * Gets a boolean indicating if the pointer is currently locked
  33339. */
  33340. isPointerLock: boolean;
  33341. /**
  33342. * Observable event triggered each time the rendering canvas is resized
  33343. */
  33344. onResizeObservable: Observable<Engine>;
  33345. /**
  33346. * Observable event triggered each time the canvas loses focus
  33347. */
  33348. onCanvasBlurObservable: Observable<Engine>;
  33349. /**
  33350. * Observable event triggered each time the canvas gains focus
  33351. */
  33352. onCanvasFocusObservable: Observable<Engine>;
  33353. /**
  33354. * Observable event triggered each time the canvas receives pointerout event
  33355. */
  33356. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33357. /**
  33358. * Observable raised when the engine begins a new frame
  33359. */
  33360. onBeginFrameObservable: Observable<Engine>;
  33361. /**
  33362. * If set, will be used to request the next animation frame for the render loop
  33363. */
  33364. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33365. /**
  33366. * Observable raised when the engine ends the current frame
  33367. */
  33368. onEndFrameObservable: Observable<Engine>;
  33369. /**
  33370. * Observable raised when the engine is about to compile a shader
  33371. */
  33372. onBeforeShaderCompilationObservable: Observable<Engine>;
  33373. /**
  33374. * Observable raised when the engine has jsut compiled a shader
  33375. */
  33376. onAfterShaderCompilationObservable: Observable<Engine>;
  33377. /**
  33378. * Gets the audio engine
  33379. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33380. * @ignorenaming
  33381. */
  33382. static audioEngine: IAudioEngine;
  33383. /**
  33384. * Default AudioEngine factory responsible of creating the Audio Engine.
  33385. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33386. */
  33387. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33388. /**
  33389. * Default offline support factory responsible of creating a tool used to store data locally.
  33390. * By default, this will create a Database object if the workload has been embedded.
  33391. */
  33392. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33393. private _loadingScreen;
  33394. private _pointerLockRequested;
  33395. private _dummyFramebuffer;
  33396. private _rescalePostProcess;
  33397. private _deterministicLockstep;
  33398. private _lockstepMaxSteps;
  33399. private _timeStep;
  33400. protected get _supportsHardwareTextureRescaling(): boolean;
  33401. private _fps;
  33402. private _deltaTime;
  33403. /** @hidden */
  33404. _drawCalls: PerfCounter;
  33405. /** 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 */
  33406. canvasTabIndex: number;
  33407. /**
  33408. * Turn this value on if you want to pause FPS computation when in background
  33409. */
  33410. disablePerformanceMonitorInBackground: boolean;
  33411. private _performanceMonitor;
  33412. /**
  33413. * Gets the performance monitor attached to this engine
  33414. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33415. */
  33416. get performanceMonitor(): PerformanceMonitor;
  33417. private _onFocus;
  33418. private _onBlur;
  33419. private _onCanvasPointerOut;
  33420. private _onCanvasBlur;
  33421. private _onCanvasFocus;
  33422. private _onFullscreenChange;
  33423. private _onPointerLockChange;
  33424. /**
  33425. * Gets the HTML element used to attach event listeners
  33426. * @returns a HTML element
  33427. */
  33428. getInputElement(): Nullable<HTMLElement>;
  33429. /**
  33430. * Creates a new engine
  33431. * @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
  33432. * @param antialias defines enable antialiasing (default: false)
  33433. * @param options defines further options to be sent to the getContext() function
  33434. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33435. */
  33436. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33437. /**
  33438. * Gets current aspect ratio
  33439. * @param viewportOwner defines the camera to use to get the aspect ratio
  33440. * @param useScreen defines if screen size must be used (or the current render target if any)
  33441. * @returns a number defining the aspect ratio
  33442. */
  33443. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33444. /**
  33445. * Gets current screen aspect ratio
  33446. * @returns a number defining the aspect ratio
  33447. */
  33448. getScreenAspectRatio(): number;
  33449. /**
  33450. * Gets the client rect of the HTML canvas attached with the current webGL context
  33451. * @returns a client rectanglee
  33452. */
  33453. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33454. /**
  33455. * Gets the client rect of the HTML element used for events
  33456. * @returns a client rectanglee
  33457. */
  33458. getInputElementClientRect(): Nullable<ClientRect>;
  33459. /**
  33460. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33461. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33462. * @returns true if engine is in deterministic lock step mode
  33463. */
  33464. isDeterministicLockStep(): boolean;
  33465. /**
  33466. * Gets the max steps when engine is running in deterministic lock step
  33467. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33468. * @returns the max steps
  33469. */
  33470. getLockstepMaxSteps(): number;
  33471. /**
  33472. * Returns the time in ms between steps when using deterministic lock step.
  33473. * @returns time step in (ms)
  33474. */
  33475. getTimeStep(): number;
  33476. /**
  33477. * Force the mipmap generation for the given render target texture
  33478. * @param texture defines the render target texture to use
  33479. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33480. */
  33481. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33482. /** States */
  33483. /**
  33484. * Set various states to the webGL context
  33485. * @param culling defines backface culling state
  33486. * @param zOffset defines the value to apply to zOffset (0 by default)
  33487. * @param force defines if states must be applied even if cache is up to date
  33488. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33489. */
  33490. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33491. /**
  33492. * Set the z offset to apply to current rendering
  33493. * @param value defines the offset to apply
  33494. */
  33495. setZOffset(value: number): void;
  33496. /**
  33497. * Gets the current value of the zOffset
  33498. * @returns the current zOffset state
  33499. */
  33500. getZOffset(): number;
  33501. /**
  33502. * Enable or disable depth buffering
  33503. * @param enable defines the state to set
  33504. */
  33505. setDepthBuffer(enable: boolean): void;
  33506. /**
  33507. * Gets a boolean indicating if depth writing is enabled
  33508. * @returns the current depth writing state
  33509. */
  33510. getDepthWrite(): boolean;
  33511. /**
  33512. * Enable or disable depth writing
  33513. * @param enable defines the state to set
  33514. */
  33515. setDepthWrite(enable: boolean): void;
  33516. /**
  33517. * Gets a boolean indicating if stencil buffer is enabled
  33518. * @returns the current stencil buffer state
  33519. */
  33520. getStencilBuffer(): boolean;
  33521. /**
  33522. * Enable or disable the stencil buffer
  33523. * @param enable defines if the stencil buffer must be enabled or disabled
  33524. */
  33525. setStencilBuffer(enable: boolean): void;
  33526. /**
  33527. * Gets the current stencil mask
  33528. * @returns a number defining the new stencil mask to use
  33529. */
  33530. getStencilMask(): number;
  33531. /**
  33532. * Sets the current stencil mask
  33533. * @param mask defines the new stencil mask to use
  33534. */
  33535. setStencilMask(mask: number): void;
  33536. /**
  33537. * Gets the current stencil function
  33538. * @returns a number defining the stencil function to use
  33539. */
  33540. getStencilFunction(): number;
  33541. /**
  33542. * Gets the current stencil reference value
  33543. * @returns a number defining the stencil reference value to use
  33544. */
  33545. getStencilFunctionReference(): number;
  33546. /**
  33547. * Gets the current stencil mask
  33548. * @returns a number defining the stencil mask to use
  33549. */
  33550. getStencilFunctionMask(): number;
  33551. /**
  33552. * Sets the current stencil function
  33553. * @param stencilFunc defines the new stencil function to use
  33554. */
  33555. setStencilFunction(stencilFunc: number): void;
  33556. /**
  33557. * Sets the current stencil reference
  33558. * @param reference defines the new stencil reference to use
  33559. */
  33560. setStencilFunctionReference(reference: number): void;
  33561. /**
  33562. * Sets the current stencil mask
  33563. * @param mask defines the new stencil mask to use
  33564. */
  33565. setStencilFunctionMask(mask: number): void;
  33566. /**
  33567. * Gets the current stencil operation when stencil fails
  33568. * @returns a number defining stencil operation to use when stencil fails
  33569. */
  33570. getStencilOperationFail(): number;
  33571. /**
  33572. * Gets the current stencil operation when depth fails
  33573. * @returns a number defining stencil operation to use when depth fails
  33574. */
  33575. getStencilOperationDepthFail(): number;
  33576. /**
  33577. * Gets the current stencil operation when stencil passes
  33578. * @returns a number defining stencil operation to use when stencil passes
  33579. */
  33580. getStencilOperationPass(): number;
  33581. /**
  33582. * Sets the stencil operation to use when stencil fails
  33583. * @param operation defines the stencil operation to use when stencil fails
  33584. */
  33585. setStencilOperationFail(operation: number): void;
  33586. /**
  33587. * Sets the stencil operation to use when depth fails
  33588. * @param operation defines the stencil operation to use when depth fails
  33589. */
  33590. setStencilOperationDepthFail(operation: number): void;
  33591. /**
  33592. * Sets the stencil operation to use when stencil passes
  33593. * @param operation defines the stencil operation to use when stencil passes
  33594. */
  33595. setStencilOperationPass(operation: number): void;
  33596. /**
  33597. * Sets a boolean indicating if the dithering state is enabled or disabled
  33598. * @param value defines the dithering state
  33599. */
  33600. setDitheringState(value: boolean): void;
  33601. /**
  33602. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33603. * @param value defines the rasterizer state
  33604. */
  33605. setRasterizerState(value: boolean): void;
  33606. /**
  33607. * Gets the current depth function
  33608. * @returns a number defining the depth function
  33609. */
  33610. getDepthFunction(): Nullable<number>;
  33611. /**
  33612. * Sets the current depth function
  33613. * @param depthFunc defines the function to use
  33614. */
  33615. setDepthFunction(depthFunc: number): void;
  33616. /**
  33617. * Sets the current depth function to GREATER
  33618. */
  33619. setDepthFunctionToGreater(): void;
  33620. /**
  33621. * Sets the current depth function to GEQUAL
  33622. */
  33623. setDepthFunctionToGreaterOrEqual(): void;
  33624. /**
  33625. * Sets the current depth function to LESS
  33626. */
  33627. setDepthFunctionToLess(): void;
  33628. /**
  33629. * Sets the current depth function to LEQUAL
  33630. */
  33631. setDepthFunctionToLessOrEqual(): void;
  33632. private _cachedStencilBuffer;
  33633. private _cachedStencilFunction;
  33634. private _cachedStencilMask;
  33635. private _cachedStencilOperationPass;
  33636. private _cachedStencilOperationFail;
  33637. private _cachedStencilOperationDepthFail;
  33638. private _cachedStencilReference;
  33639. /**
  33640. * Caches the the state of the stencil buffer
  33641. */
  33642. cacheStencilState(): void;
  33643. /**
  33644. * Restores the state of the stencil buffer
  33645. */
  33646. restoreStencilState(): void;
  33647. /**
  33648. * Directly set the WebGL Viewport
  33649. * @param x defines the x coordinate of the viewport (in screen space)
  33650. * @param y defines the y coordinate of the viewport (in screen space)
  33651. * @param width defines the width of the viewport (in screen space)
  33652. * @param height defines the height of the viewport (in screen space)
  33653. * @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
  33654. */
  33655. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33656. /**
  33657. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33658. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33659. * @param y defines the y-coordinate of the corner of the clear rectangle
  33660. * @param width defines the width of the clear rectangle
  33661. * @param height defines the height of the clear rectangle
  33662. * @param clearColor defines the clear color
  33663. */
  33664. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33665. /**
  33666. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33667. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33668. * @param y defines the y-coordinate of the corner of the clear rectangle
  33669. * @param width defines the width of the clear rectangle
  33670. * @param height defines the height of the clear rectangle
  33671. */
  33672. enableScissor(x: number, y: number, width: number, height: number): void;
  33673. /**
  33674. * Disable previously set scissor test rectangle
  33675. */
  33676. disableScissor(): void;
  33677. protected _reportDrawCall(): void;
  33678. /**
  33679. * Initializes a webVR display and starts listening to display change events
  33680. * The onVRDisplayChangedObservable will be notified upon these changes
  33681. * @returns The onVRDisplayChangedObservable
  33682. */
  33683. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33684. /** @hidden */
  33685. _prepareVRComponent(): void;
  33686. /** @hidden */
  33687. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33688. /** @hidden */
  33689. _submitVRFrame(): void;
  33690. /**
  33691. * Call this function to leave webVR mode
  33692. * Will do nothing if webVR is not supported or if there is no webVR device
  33693. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33694. */
  33695. disableVR(): void;
  33696. /**
  33697. * Gets a boolean indicating that the system is in VR mode and is presenting
  33698. * @returns true if VR mode is engaged
  33699. */
  33700. isVRPresenting(): boolean;
  33701. /** @hidden */
  33702. _requestVRFrame(): void;
  33703. /** @hidden */
  33704. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33705. /**
  33706. * Gets the source code of the vertex shader associated with a specific webGL program
  33707. * @param program defines the program to use
  33708. * @returns a string containing the source code of the vertex shader associated with the program
  33709. */
  33710. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33711. /**
  33712. * Gets the source code of the fragment shader associated with a specific webGL program
  33713. * @param program defines the program to use
  33714. * @returns a string containing the source code of the fragment shader associated with the program
  33715. */
  33716. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33717. /**
  33718. * Sets a depth stencil texture from a render target to the according uniform.
  33719. * @param channel The texture channel
  33720. * @param uniform The uniform to set
  33721. * @param texture The render target texture containing the depth stencil texture to apply
  33722. */
  33723. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33724. /**
  33725. * Sets a texture to the webGL context from a postprocess
  33726. * @param channel defines the channel to use
  33727. * @param postProcess defines the source postprocess
  33728. */
  33729. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33730. /**
  33731. * Binds the output of the passed in post process to the texture channel specified
  33732. * @param channel The channel the texture should be bound to
  33733. * @param postProcess The post process which's output should be bound
  33734. */
  33735. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33736. /** @hidden */
  33737. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33738. protected _rebuildBuffers(): void;
  33739. /** @hidden */
  33740. _renderFrame(): void;
  33741. _renderLoop(): void;
  33742. /** @hidden */
  33743. _renderViews(): boolean;
  33744. /**
  33745. * Toggle full screen mode
  33746. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33747. */
  33748. switchFullscreen(requestPointerLock: boolean): void;
  33749. /**
  33750. * Enters full screen mode
  33751. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33752. */
  33753. enterFullscreen(requestPointerLock: boolean): void;
  33754. /**
  33755. * Exits full screen mode
  33756. */
  33757. exitFullscreen(): void;
  33758. /**
  33759. * Enters Pointerlock mode
  33760. */
  33761. enterPointerlock(): void;
  33762. /**
  33763. * Exits Pointerlock mode
  33764. */
  33765. exitPointerlock(): void;
  33766. /**
  33767. * Begin a new frame
  33768. */
  33769. beginFrame(): void;
  33770. /**
  33771. * Enf the current frame
  33772. */
  33773. endFrame(): void;
  33774. resize(): void;
  33775. /**
  33776. * Force a specific size of the canvas
  33777. * @param width defines the new canvas' width
  33778. * @param height defines the new canvas' height
  33779. */
  33780. setSize(width: number, height: number): void;
  33781. /**
  33782. * Updates a dynamic vertex buffer.
  33783. * @param vertexBuffer the vertex buffer to update
  33784. * @param data the data used to update the vertex buffer
  33785. * @param byteOffset the byte offset of the data
  33786. * @param byteLength the byte length of the data
  33787. */
  33788. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33789. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33790. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33791. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33792. _releaseTexture(texture: InternalTexture): void;
  33793. /**
  33794. * @hidden
  33795. * Rescales a texture
  33796. * @param source input texutre
  33797. * @param destination destination texture
  33798. * @param scene scene to use to render the resize
  33799. * @param internalFormat format to use when resizing
  33800. * @param onComplete callback to be called when resize has completed
  33801. */
  33802. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33803. /**
  33804. * Gets the current framerate
  33805. * @returns a number representing the framerate
  33806. */
  33807. getFps(): number;
  33808. /**
  33809. * Gets the time spent between current and previous frame
  33810. * @returns a number representing the delta time in ms
  33811. */
  33812. getDeltaTime(): number;
  33813. private _measureFps;
  33814. /** @hidden */
  33815. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33816. /**
  33817. * Update a dynamic index buffer
  33818. * @param indexBuffer defines the target index buffer
  33819. * @param indices defines the data to update
  33820. * @param offset defines the offset in the target index buffer where update should start
  33821. */
  33822. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33823. /**
  33824. * Updates the sample count of a render target texture
  33825. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33826. * @param texture defines the texture to update
  33827. * @param samples defines the sample count to set
  33828. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33829. */
  33830. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33831. /**
  33832. * Updates a depth texture Comparison Mode and Function.
  33833. * If the comparison Function is equal to 0, the mode will be set to none.
  33834. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33835. * @param texture The texture to set the comparison function for
  33836. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33837. */
  33838. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33839. /**
  33840. * Creates a webGL buffer to use with instanciation
  33841. * @param capacity defines the size of the buffer
  33842. * @returns the webGL buffer
  33843. */
  33844. createInstancesBuffer(capacity: number): DataBuffer;
  33845. /**
  33846. * Delete a webGL buffer used with instanciation
  33847. * @param buffer defines the webGL buffer to delete
  33848. */
  33849. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33850. private _clientWaitAsync;
  33851. /** @hidden */
  33852. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  33853. /** @hidden */
  33854. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33855. dispose(): void;
  33856. private _disableTouchAction;
  33857. /**
  33858. * Display the loading screen
  33859. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33860. */
  33861. displayLoadingUI(): void;
  33862. /**
  33863. * Hide the loading screen
  33864. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33865. */
  33866. hideLoadingUI(): void;
  33867. /**
  33868. * Gets the current loading screen object
  33869. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33870. */
  33871. get loadingScreen(): ILoadingScreen;
  33872. /**
  33873. * Sets the current loading screen object
  33874. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33875. */
  33876. set loadingScreen(loadingScreen: ILoadingScreen);
  33877. /**
  33878. * Sets the current loading screen text
  33879. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33880. */
  33881. set loadingUIText(text: string);
  33882. /**
  33883. * Sets the current loading screen background color
  33884. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33885. */
  33886. set loadingUIBackgroundColor(color: string);
  33887. /** Pointerlock and fullscreen */
  33888. /**
  33889. * Ask the browser to promote the current element to pointerlock mode
  33890. * @param element defines the DOM element to promote
  33891. */
  33892. static _RequestPointerlock(element: HTMLElement): void;
  33893. /**
  33894. * Asks the browser to exit pointerlock mode
  33895. */
  33896. static _ExitPointerlock(): void;
  33897. /**
  33898. * Ask the browser to promote the current element to fullscreen rendering mode
  33899. * @param element defines the DOM element to promote
  33900. */
  33901. static _RequestFullscreen(element: HTMLElement): void;
  33902. /**
  33903. * Asks the browser to exit fullscreen mode
  33904. */
  33905. static _ExitFullscreen(): void;
  33906. }
  33907. }
  33908. declare module BABYLON {
  33909. /**
  33910. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33911. * during the life time of the application.
  33912. */
  33913. export class EngineStore {
  33914. /** Gets the list of created engines */
  33915. static Instances: Engine[];
  33916. /** @hidden */
  33917. static _LastCreatedScene: Nullable<Scene>;
  33918. /**
  33919. * Gets the latest created engine
  33920. */
  33921. static get LastCreatedEngine(): Nullable<Engine>;
  33922. /**
  33923. * Gets the latest created scene
  33924. */
  33925. static get LastCreatedScene(): Nullable<Scene>;
  33926. /**
  33927. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33928. * @ignorenaming
  33929. */
  33930. static UseFallbackTexture: boolean;
  33931. /**
  33932. * Texture content used if a texture cannot loaded
  33933. * @ignorenaming
  33934. */
  33935. static FallbackTexture: string;
  33936. }
  33937. }
  33938. declare module BABYLON {
  33939. /**
  33940. * Helper class that provides a small promise polyfill
  33941. */
  33942. export class PromisePolyfill {
  33943. /**
  33944. * Static function used to check if the polyfill is required
  33945. * If this is the case then the function will inject the polyfill to window.Promise
  33946. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33947. */
  33948. static Apply(force?: boolean): void;
  33949. }
  33950. }
  33951. declare module BABYLON {
  33952. /**
  33953. * Interface for screenshot methods with describe argument called `size` as object with options
  33954. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33955. */
  33956. export interface IScreenshotSize {
  33957. /**
  33958. * number in pixels for canvas height
  33959. */
  33960. height?: number;
  33961. /**
  33962. * multiplier allowing render at a higher or lower resolution
  33963. * If value is defined then height and width will be ignored and taken from camera
  33964. */
  33965. precision?: number;
  33966. /**
  33967. * number in pixels for canvas width
  33968. */
  33969. width?: number;
  33970. }
  33971. }
  33972. declare module BABYLON {
  33973. interface IColor4Like {
  33974. r: float;
  33975. g: float;
  33976. b: float;
  33977. a: float;
  33978. }
  33979. /**
  33980. * Class containing a set of static utilities functions
  33981. */
  33982. export class Tools {
  33983. /**
  33984. * Gets or sets the base URL to use to load assets
  33985. */
  33986. static get BaseUrl(): string;
  33987. static set BaseUrl(value: string);
  33988. /**
  33989. * Enable/Disable Custom HTTP Request Headers globally.
  33990. * default = false
  33991. * @see CustomRequestHeaders
  33992. */
  33993. static UseCustomRequestHeaders: boolean;
  33994. /**
  33995. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33996. * i.e. when loading files, where the server/service expects an Authorization header
  33997. */
  33998. static CustomRequestHeaders: {
  33999. [key: string]: string;
  34000. };
  34001. /**
  34002. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34003. */
  34004. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34005. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34006. /**
  34007. * Default behaviour for cors in the application.
  34008. * It can be a string if the expected behavior is identical in the entire app.
  34009. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34010. */
  34011. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34012. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34013. /**
  34014. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34015. * @ignorenaming
  34016. */
  34017. static get UseFallbackTexture(): boolean;
  34018. static set UseFallbackTexture(value: boolean);
  34019. /**
  34020. * Use this object to register external classes like custom textures or material
  34021. * to allow the laoders to instantiate them
  34022. */
  34023. static get RegisteredExternalClasses(): {
  34024. [key: string]: Object;
  34025. };
  34026. static set RegisteredExternalClasses(classes: {
  34027. [key: string]: Object;
  34028. });
  34029. /**
  34030. * Texture content used if a texture cannot loaded
  34031. * @ignorenaming
  34032. */
  34033. static get fallbackTexture(): string;
  34034. static set fallbackTexture(value: string);
  34035. /**
  34036. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34037. * @param u defines the coordinate on X axis
  34038. * @param v defines the coordinate on Y axis
  34039. * @param width defines the width of the source data
  34040. * @param height defines the height of the source data
  34041. * @param pixels defines the source byte array
  34042. * @param color defines the output color
  34043. */
  34044. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34045. /**
  34046. * Interpolates between a and b via alpha
  34047. * @param a The lower value (returned when alpha = 0)
  34048. * @param b The upper value (returned when alpha = 1)
  34049. * @param alpha The interpolation-factor
  34050. * @return The mixed value
  34051. */
  34052. static Mix(a: number, b: number, alpha: number): number;
  34053. /**
  34054. * Tries to instantiate a new object from a given class name
  34055. * @param className defines the class name to instantiate
  34056. * @returns the new object or null if the system was not able to do the instantiation
  34057. */
  34058. static Instantiate(className: string): any;
  34059. /**
  34060. * Provides a slice function that will work even on IE
  34061. * @param data defines the array to slice
  34062. * @param start defines the start of the data (optional)
  34063. * @param end defines the end of the data (optional)
  34064. * @returns the new sliced array
  34065. */
  34066. static Slice<T>(data: T, start?: number, end?: number): T;
  34067. /**
  34068. * Polyfill for setImmediate
  34069. * @param action defines the action to execute after the current execution block
  34070. */
  34071. static SetImmediate(action: () => void): void;
  34072. /**
  34073. * Function indicating if a number is an exponent of 2
  34074. * @param value defines the value to test
  34075. * @returns true if the value is an exponent of 2
  34076. */
  34077. static IsExponentOfTwo(value: number): boolean;
  34078. private static _tmpFloatArray;
  34079. /**
  34080. * Returns the nearest 32-bit single precision float representation of a Number
  34081. * @param value A Number. If the parameter is of a different type, it will get converted
  34082. * to a number or to NaN if it cannot be converted
  34083. * @returns number
  34084. */
  34085. static FloatRound(value: number): number;
  34086. /**
  34087. * Extracts the filename from a path
  34088. * @param path defines the path to use
  34089. * @returns the filename
  34090. */
  34091. static GetFilename(path: string): string;
  34092. /**
  34093. * Extracts the "folder" part of a path (everything before the filename).
  34094. * @param uri The URI to extract the info from
  34095. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34096. * @returns The "folder" part of the path
  34097. */
  34098. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34099. /**
  34100. * Extracts text content from a DOM element hierarchy
  34101. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34102. */
  34103. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34104. /**
  34105. * Convert an angle in radians to degrees
  34106. * @param angle defines the angle to convert
  34107. * @returns the angle in degrees
  34108. */
  34109. static ToDegrees(angle: number): number;
  34110. /**
  34111. * Convert an angle in degrees to radians
  34112. * @param angle defines the angle to convert
  34113. * @returns the angle in radians
  34114. */
  34115. static ToRadians(angle: number): number;
  34116. /**
  34117. * Returns an array if obj is not an array
  34118. * @param obj defines the object to evaluate as an array
  34119. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34120. * @returns either obj directly if obj is an array or a new array containing obj
  34121. */
  34122. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34123. /**
  34124. * Gets the pointer prefix to use
  34125. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34126. */
  34127. static GetPointerPrefix(): string;
  34128. /**
  34129. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34130. * @param url define the url we are trying
  34131. * @param element define the dom element where to configure the cors policy
  34132. */
  34133. static SetCorsBehavior(url: string | string[], element: {
  34134. crossOrigin: string | null;
  34135. }): void;
  34136. /**
  34137. * Removes unwanted characters from an url
  34138. * @param url defines the url to clean
  34139. * @returns the cleaned url
  34140. */
  34141. static CleanUrl(url: string): string;
  34142. /**
  34143. * Gets or sets a function used to pre-process url before using them to load assets
  34144. */
  34145. static get PreprocessUrl(): (url: string) => string;
  34146. static set PreprocessUrl(processor: (url: string) => string);
  34147. /**
  34148. * Loads an image as an HTMLImageElement.
  34149. * @param input url string, ArrayBuffer, or Blob to load
  34150. * @param onLoad callback called when the image successfully loads
  34151. * @param onError callback called when the image fails to load
  34152. * @param offlineProvider offline provider for caching
  34153. * @param mimeType optional mime type
  34154. * @returns the HTMLImageElement of the loaded image
  34155. */
  34156. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34157. /**
  34158. * Loads a file from a url
  34159. * @param url url string, ArrayBuffer, or Blob to load
  34160. * @param onSuccess callback called when the file successfully loads
  34161. * @param onProgress callback called while file is loading (if the server supports this mode)
  34162. * @param offlineProvider defines the offline provider for caching
  34163. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34164. * @param onError callback called when the file fails to load
  34165. * @returns a file request object
  34166. */
  34167. 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;
  34168. /**
  34169. * Loads a file from a url
  34170. * @param url the file url to load
  34171. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34172. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34173. */
  34174. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34175. /**
  34176. * Load a script (identified by an url). When the url returns, the
  34177. * content of this file is added into a new script element, attached to the DOM (body element)
  34178. * @param scriptUrl defines the url of the script to laod
  34179. * @param onSuccess defines the callback called when the script is loaded
  34180. * @param onError defines the callback to call if an error occurs
  34181. * @param scriptId defines the id of the script element
  34182. */
  34183. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34184. /**
  34185. * Load an asynchronous script (identified by an url). When the url returns, the
  34186. * content of this file is added into a new script element, attached to the DOM (body element)
  34187. * @param scriptUrl defines the url of the script to laod
  34188. * @param scriptId defines the id of the script element
  34189. * @returns a promise request object
  34190. */
  34191. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34192. /**
  34193. * Loads a file from a blob
  34194. * @param fileToLoad defines the blob to use
  34195. * @param callback defines the callback to call when data is loaded
  34196. * @param progressCallback defines the callback to call during loading process
  34197. * @returns a file request object
  34198. */
  34199. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34200. /**
  34201. * Reads a file from a File object
  34202. * @param file defines the file to load
  34203. * @param onSuccess defines the callback to call when data is loaded
  34204. * @param onProgress defines the callback to call during loading process
  34205. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34206. * @param onError defines the callback to call when an error occurs
  34207. * @returns a file request object
  34208. */
  34209. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34210. /**
  34211. * Creates a data url from a given string content
  34212. * @param content defines the content to convert
  34213. * @returns the new data url link
  34214. */
  34215. static FileAsURL(content: string): string;
  34216. /**
  34217. * Format the given number to a specific decimal format
  34218. * @param value defines the number to format
  34219. * @param decimals defines the number of decimals to use
  34220. * @returns the formatted string
  34221. */
  34222. static Format(value: number, decimals?: number): string;
  34223. /**
  34224. * Tries to copy an object by duplicating every property
  34225. * @param source defines the source object
  34226. * @param destination defines the target object
  34227. * @param doNotCopyList defines a list of properties to avoid
  34228. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34229. */
  34230. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34231. /**
  34232. * Gets a boolean indicating if the given object has no own property
  34233. * @param obj defines the object to test
  34234. * @returns true if object has no own property
  34235. */
  34236. static IsEmpty(obj: any): boolean;
  34237. /**
  34238. * Function used to register events at window level
  34239. * @param windowElement defines the Window object to use
  34240. * @param events defines the events to register
  34241. */
  34242. static RegisterTopRootEvents(windowElement: Window, events: {
  34243. name: string;
  34244. handler: Nullable<(e: FocusEvent) => any>;
  34245. }[]): void;
  34246. /**
  34247. * Function used to unregister events from window level
  34248. * @param windowElement defines the Window object to use
  34249. * @param events defines the events to unregister
  34250. */
  34251. static UnregisterTopRootEvents(windowElement: Window, events: {
  34252. name: string;
  34253. handler: Nullable<(e: FocusEvent) => any>;
  34254. }[]): void;
  34255. /**
  34256. * @ignore
  34257. */
  34258. static _ScreenshotCanvas: HTMLCanvasElement;
  34259. /**
  34260. * Dumps the current bound framebuffer
  34261. * @param width defines the rendering width
  34262. * @param height defines the rendering height
  34263. * @param engine defines the hosting engine
  34264. * @param successCallback defines the callback triggered once the data are available
  34265. * @param mimeType defines the mime type of the result
  34266. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34267. */
  34268. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34269. /**
  34270. * Converts the canvas data to blob.
  34271. * This acts as a polyfill for browsers not supporting the to blob function.
  34272. * @param canvas Defines the canvas to extract the data from
  34273. * @param successCallback Defines the callback triggered once the data are available
  34274. * @param mimeType Defines the mime type of the result
  34275. */
  34276. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34277. /**
  34278. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34279. * @param successCallback defines the callback triggered once the data are available
  34280. * @param mimeType defines the mime type of the result
  34281. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34282. */
  34283. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34284. /**
  34285. * Downloads a blob in the browser
  34286. * @param blob defines the blob to download
  34287. * @param fileName defines the name of the downloaded file
  34288. */
  34289. static Download(blob: Blob, fileName: string): void;
  34290. /**
  34291. * Captures a screenshot of the current rendering
  34292. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34293. * @param engine defines the rendering engine
  34294. * @param camera defines the source camera
  34295. * @param size This parameter can be set to a single number or to an object with the
  34296. * following (optional) properties: precision, width, height. If a single number is passed,
  34297. * it will be used for both width and height. If an object is passed, the screenshot size
  34298. * will be derived from the parameters. The precision property is a multiplier allowing
  34299. * rendering at a higher or lower resolution
  34300. * @param successCallback defines the callback receives a single parameter which contains the
  34301. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34302. * src parameter of an <img> to display it
  34303. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34304. * Check your browser for supported MIME types
  34305. */
  34306. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34307. /**
  34308. * Captures a screenshot of the current rendering
  34309. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34310. * @param engine defines the rendering engine
  34311. * @param camera defines the source camera
  34312. * @param size This parameter can be set to a single number or to an object with the
  34313. * following (optional) properties: precision, width, height. If a single number is passed,
  34314. * it will be used for both width and height. If an object is passed, the screenshot size
  34315. * will be derived from the parameters. The precision property is a multiplier allowing
  34316. * rendering at a higher or lower resolution
  34317. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34318. * Check your browser for supported MIME types
  34319. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34320. * to the src parameter of an <img> to display it
  34321. */
  34322. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34323. /**
  34324. * Generates an image screenshot from the specified camera.
  34325. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34326. * @param engine The engine to use for rendering
  34327. * @param camera The camera to use for rendering
  34328. * @param size This parameter can be set to a single number or to an object with the
  34329. * following (optional) properties: precision, width, height. If a single number is passed,
  34330. * it will be used for both width and height. If an object is passed, the screenshot size
  34331. * will be derived from the parameters. The precision property is a multiplier allowing
  34332. * rendering at a higher or lower resolution
  34333. * @param successCallback The callback receives a single parameter which contains the
  34334. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34335. * src parameter of an <img> to display it
  34336. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34337. * Check your browser for supported MIME types
  34338. * @param samples Texture samples (default: 1)
  34339. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34340. * @param fileName A name for for the downloaded file.
  34341. */
  34342. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34343. /**
  34344. * Generates an image screenshot from the specified camera.
  34345. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34346. * @param engine The engine to use for rendering
  34347. * @param camera The camera to use for rendering
  34348. * @param size This parameter can be set to a single number or to an object with the
  34349. * following (optional) properties: precision, width, height. If a single number is passed,
  34350. * it will be used for both width and height. If an object is passed, the screenshot size
  34351. * will be derived from the parameters. The precision property is a multiplier allowing
  34352. * rendering at a higher or lower resolution
  34353. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34354. * Check your browser for supported MIME types
  34355. * @param samples Texture samples (default: 1)
  34356. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34357. * @param fileName A name for for the downloaded file.
  34358. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34359. * to the src parameter of an <img> to display it
  34360. */
  34361. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34362. /**
  34363. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34364. * Be aware Math.random() could cause collisions, but:
  34365. * "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"
  34366. * @returns a pseudo random id
  34367. */
  34368. static RandomId(): string;
  34369. /**
  34370. * Test if the given uri is a base64 string
  34371. * @param uri The uri to test
  34372. * @return True if the uri is a base64 string or false otherwise
  34373. */
  34374. static IsBase64(uri: string): boolean;
  34375. /**
  34376. * Decode the given base64 uri.
  34377. * @param uri The uri to decode
  34378. * @return The decoded base64 data.
  34379. */
  34380. static DecodeBase64(uri: string): ArrayBuffer;
  34381. /**
  34382. * Gets the absolute url.
  34383. * @param url the input url
  34384. * @return the absolute url
  34385. */
  34386. static GetAbsoluteUrl(url: string): string;
  34387. /**
  34388. * No log
  34389. */
  34390. static readonly NoneLogLevel: number;
  34391. /**
  34392. * Only message logs
  34393. */
  34394. static readonly MessageLogLevel: number;
  34395. /**
  34396. * Only warning logs
  34397. */
  34398. static readonly WarningLogLevel: number;
  34399. /**
  34400. * Only error logs
  34401. */
  34402. static readonly ErrorLogLevel: number;
  34403. /**
  34404. * All logs
  34405. */
  34406. static readonly AllLogLevel: number;
  34407. /**
  34408. * Gets a value indicating the number of loading errors
  34409. * @ignorenaming
  34410. */
  34411. static get errorsCount(): number;
  34412. /**
  34413. * Callback called when a new log is added
  34414. */
  34415. static OnNewCacheEntry: (entry: string) => void;
  34416. /**
  34417. * Log a message to the console
  34418. * @param message defines the message to log
  34419. */
  34420. static Log(message: string): void;
  34421. /**
  34422. * Write a warning message to the console
  34423. * @param message defines the message to log
  34424. */
  34425. static Warn(message: string): void;
  34426. /**
  34427. * Write an error message to the console
  34428. * @param message defines the message to log
  34429. */
  34430. static Error(message: string): void;
  34431. /**
  34432. * Gets current log cache (list of logs)
  34433. */
  34434. static get LogCache(): string;
  34435. /**
  34436. * Clears the log cache
  34437. */
  34438. static ClearLogCache(): void;
  34439. /**
  34440. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34441. */
  34442. static set LogLevels(level: number);
  34443. /**
  34444. * Checks if the window object exists
  34445. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34446. */
  34447. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34448. /**
  34449. * No performance log
  34450. */
  34451. static readonly PerformanceNoneLogLevel: number;
  34452. /**
  34453. * Use user marks to log performance
  34454. */
  34455. static readonly PerformanceUserMarkLogLevel: number;
  34456. /**
  34457. * Log performance to the console
  34458. */
  34459. static readonly PerformanceConsoleLogLevel: number;
  34460. private static _performance;
  34461. /**
  34462. * Sets the current performance log level
  34463. */
  34464. static set PerformanceLogLevel(level: number);
  34465. private static _StartPerformanceCounterDisabled;
  34466. private static _EndPerformanceCounterDisabled;
  34467. private static _StartUserMark;
  34468. private static _EndUserMark;
  34469. private static _StartPerformanceConsole;
  34470. private static _EndPerformanceConsole;
  34471. /**
  34472. * Starts a performance counter
  34473. */
  34474. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34475. /**
  34476. * Ends a specific performance coutner
  34477. */
  34478. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34479. /**
  34480. * Gets either window.performance.now() if supported or Date.now() else
  34481. */
  34482. static get Now(): number;
  34483. /**
  34484. * This method will return the name of the class used to create the instance of the given object.
  34485. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34486. * @param object the object to get the class name from
  34487. * @param isType defines if the object is actually a type
  34488. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34489. */
  34490. static GetClassName(object: any, isType?: boolean): string;
  34491. /**
  34492. * Gets the first element of an array satisfying a given predicate
  34493. * @param array defines the array to browse
  34494. * @param predicate defines the predicate to use
  34495. * @returns null if not found or the element
  34496. */
  34497. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34498. /**
  34499. * This method will return the name of the full name of the class, including its owning module (if any).
  34500. * 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).
  34501. * @param object the object to get the class name from
  34502. * @param isType defines if the object is actually a type
  34503. * @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.
  34504. * @ignorenaming
  34505. */
  34506. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34507. /**
  34508. * Returns a promise that resolves after the given amount of time.
  34509. * @param delay Number of milliseconds to delay
  34510. * @returns Promise that resolves after the given amount of time
  34511. */
  34512. static DelayAsync(delay: number): Promise<void>;
  34513. /**
  34514. * Utility function to detect if the current user agent is Safari
  34515. * @returns whether or not the current user agent is safari
  34516. */
  34517. static IsSafari(): boolean;
  34518. }
  34519. /**
  34520. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34521. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34522. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34523. * @param name The name of the class, case should be preserved
  34524. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34525. */
  34526. export function className(name: string, module?: string): (target: Object) => void;
  34527. /**
  34528. * An implementation of a loop for asynchronous functions.
  34529. */
  34530. export class AsyncLoop {
  34531. /**
  34532. * Defines the number of iterations for the loop
  34533. */
  34534. iterations: number;
  34535. /**
  34536. * Defines the current index of the loop.
  34537. */
  34538. index: number;
  34539. private _done;
  34540. private _fn;
  34541. private _successCallback;
  34542. /**
  34543. * Constructor.
  34544. * @param iterations the number of iterations.
  34545. * @param func the function to run each iteration
  34546. * @param successCallback the callback that will be called upon succesful execution
  34547. * @param offset starting offset.
  34548. */
  34549. constructor(
  34550. /**
  34551. * Defines the number of iterations for the loop
  34552. */
  34553. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34554. /**
  34555. * Execute the next iteration. Must be called after the last iteration was finished.
  34556. */
  34557. executeNext(): void;
  34558. /**
  34559. * Break the loop and run the success callback.
  34560. */
  34561. breakLoop(): void;
  34562. /**
  34563. * Create and run an async loop.
  34564. * @param iterations the number of iterations.
  34565. * @param fn the function to run each iteration
  34566. * @param successCallback the callback that will be called upon succesful execution
  34567. * @param offset starting offset.
  34568. * @returns the created async loop object
  34569. */
  34570. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34571. /**
  34572. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34573. * @param iterations total number of iterations
  34574. * @param syncedIterations number of synchronous iterations in each async iteration.
  34575. * @param fn the function to call each iteration.
  34576. * @param callback a success call back that will be called when iterating stops.
  34577. * @param breakFunction a break condition (optional)
  34578. * @param timeout timeout settings for the setTimeout function. default - 0.
  34579. * @returns the created async loop object
  34580. */
  34581. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34582. }
  34583. }
  34584. declare module BABYLON {
  34585. /**
  34586. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34587. * The underlying implementation relies on an associative array to ensure the best performances.
  34588. * The value can be anything including 'null' but except 'undefined'
  34589. */
  34590. export class StringDictionary<T> {
  34591. /**
  34592. * This will clear this dictionary and copy the content from the 'source' one.
  34593. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34594. * @param source the dictionary to take the content from and copy to this dictionary
  34595. */
  34596. copyFrom(source: StringDictionary<T>): void;
  34597. /**
  34598. * Get a value based from its key
  34599. * @param key the given key to get the matching value from
  34600. * @return the value if found, otherwise undefined is returned
  34601. */
  34602. get(key: string): T | undefined;
  34603. /**
  34604. * Get a value from its key or add it if it doesn't exist.
  34605. * This method will ensure you that a given key/data will be present in the dictionary.
  34606. * @param key the given key to get the matching value from
  34607. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34608. * The factory will only be invoked if there's no data for the given key.
  34609. * @return the value corresponding to the key.
  34610. */
  34611. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34612. /**
  34613. * Get a value from its key if present in the dictionary otherwise add it
  34614. * @param key the key to get the value from
  34615. * @param val if there's no such key/value pair in the dictionary add it with this value
  34616. * @return the value corresponding to the key
  34617. */
  34618. getOrAdd(key: string, val: T): T;
  34619. /**
  34620. * Check if there's a given key in the dictionary
  34621. * @param key the key to check for
  34622. * @return true if the key is present, false otherwise
  34623. */
  34624. contains(key: string): boolean;
  34625. /**
  34626. * Add a new key and its corresponding value
  34627. * @param key the key to add
  34628. * @param value the value corresponding to the key
  34629. * @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
  34630. */
  34631. add(key: string, value: T): boolean;
  34632. /**
  34633. * Update a specific value associated to a key
  34634. * @param key defines the key to use
  34635. * @param value defines the value to store
  34636. * @returns true if the value was updated (or false if the key was not found)
  34637. */
  34638. set(key: string, value: T): boolean;
  34639. /**
  34640. * Get the element of the given key and remove it from the dictionary
  34641. * @param key defines the key to search
  34642. * @returns the value associated with the key or null if not found
  34643. */
  34644. getAndRemove(key: string): Nullable<T>;
  34645. /**
  34646. * Remove a key/value from the dictionary.
  34647. * @param key the key to remove
  34648. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34649. */
  34650. remove(key: string): boolean;
  34651. /**
  34652. * Clear the whole content of the dictionary
  34653. */
  34654. clear(): void;
  34655. /**
  34656. * Gets the current count
  34657. */
  34658. get count(): number;
  34659. /**
  34660. * Execute a callback on each key/val of the dictionary.
  34661. * Note that you can remove any element in this dictionary in the callback implementation
  34662. * @param callback the callback to execute on a given key/value pair
  34663. */
  34664. forEach(callback: (key: string, val: T) => void): void;
  34665. /**
  34666. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34667. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34668. * Note that you can remove any element in this dictionary in the callback implementation
  34669. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34670. * @returns the first item
  34671. */
  34672. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34673. private _count;
  34674. private _data;
  34675. }
  34676. }
  34677. declare module BABYLON {
  34678. /** @hidden */
  34679. export interface ICollisionCoordinator {
  34680. createCollider(): Collider;
  34681. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34682. init(scene: Scene): void;
  34683. }
  34684. /** @hidden */
  34685. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34686. private _scene;
  34687. private _scaledPosition;
  34688. private _scaledVelocity;
  34689. private _finalPosition;
  34690. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34691. createCollider(): Collider;
  34692. init(scene: Scene): void;
  34693. private _collideWithWorld;
  34694. }
  34695. }
  34696. declare module BABYLON {
  34697. /**
  34698. * Class used to manage all inputs for the scene.
  34699. */
  34700. export class InputManager {
  34701. /** The distance in pixel that you have to move to prevent some events */
  34702. static DragMovementThreshold: number;
  34703. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34704. static LongPressDelay: number;
  34705. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34706. static DoubleClickDelay: number;
  34707. /** If you need to check double click without raising a single click at first click, enable this flag */
  34708. static ExclusiveDoubleClickMode: boolean;
  34709. private _wheelEventName;
  34710. private _onPointerMove;
  34711. private _onPointerDown;
  34712. private _onPointerUp;
  34713. private _initClickEvent;
  34714. private _initActionManager;
  34715. private _delayedSimpleClick;
  34716. private _delayedSimpleClickTimeout;
  34717. private _previousDelayedSimpleClickTimeout;
  34718. private _meshPickProceed;
  34719. private _previousButtonPressed;
  34720. private _currentPickResult;
  34721. private _previousPickResult;
  34722. private _totalPointersPressed;
  34723. private _doubleClickOccured;
  34724. private _pointerOverMesh;
  34725. private _pickedDownMesh;
  34726. private _pickedUpMesh;
  34727. private _pointerX;
  34728. private _pointerY;
  34729. private _unTranslatedPointerX;
  34730. private _unTranslatedPointerY;
  34731. private _startingPointerPosition;
  34732. private _previousStartingPointerPosition;
  34733. private _startingPointerTime;
  34734. private _previousStartingPointerTime;
  34735. private _pointerCaptures;
  34736. private _onKeyDown;
  34737. private _onKeyUp;
  34738. private _onCanvasFocusObserver;
  34739. private _onCanvasBlurObserver;
  34740. private _scene;
  34741. /**
  34742. * Creates a new InputManager
  34743. * @param scene defines the hosting scene
  34744. */
  34745. constructor(scene: Scene);
  34746. /**
  34747. * Gets the mesh that is currently under the pointer
  34748. */
  34749. get meshUnderPointer(): Nullable<AbstractMesh>;
  34750. /**
  34751. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34752. */
  34753. get unTranslatedPointer(): Vector2;
  34754. /**
  34755. * Gets or sets the current on-screen X position of the pointer
  34756. */
  34757. get pointerX(): number;
  34758. set pointerX(value: number);
  34759. /**
  34760. * Gets or sets the current on-screen Y position of the pointer
  34761. */
  34762. get pointerY(): number;
  34763. set pointerY(value: number);
  34764. private _updatePointerPosition;
  34765. private _processPointerMove;
  34766. private _setRayOnPointerInfo;
  34767. private _checkPrePointerObservable;
  34768. /**
  34769. * Use this method to simulate a pointer move on a mesh
  34770. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34771. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34772. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34773. */
  34774. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34775. /**
  34776. * Use this method to simulate a pointer down on a mesh
  34777. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34778. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34779. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34780. */
  34781. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34782. private _processPointerDown;
  34783. /** @hidden */
  34784. _isPointerSwiping(): boolean;
  34785. /**
  34786. * Use this method to simulate a pointer up on a mesh
  34787. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34788. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34789. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34790. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34791. */
  34792. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34793. private _processPointerUp;
  34794. /**
  34795. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34796. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34797. * @returns true if the pointer was captured
  34798. */
  34799. isPointerCaptured(pointerId?: number): boolean;
  34800. /**
  34801. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34802. * @param attachUp defines if you want to attach events to pointerup
  34803. * @param attachDown defines if you want to attach events to pointerdown
  34804. * @param attachMove defines if you want to attach events to pointermove
  34805. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34806. */
  34807. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34808. /**
  34809. * Detaches all event handlers
  34810. */
  34811. detachControl(): void;
  34812. /**
  34813. * Force the value of meshUnderPointer
  34814. * @param mesh defines the mesh to use
  34815. */
  34816. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34817. /**
  34818. * Gets the mesh under the pointer
  34819. * @returns a Mesh or null if no mesh is under the pointer
  34820. */
  34821. getPointerOverMesh(): Nullable<AbstractMesh>;
  34822. }
  34823. }
  34824. declare module BABYLON {
  34825. /**
  34826. * Helper class used to generate session unique ID
  34827. */
  34828. export class UniqueIdGenerator {
  34829. private static _UniqueIdCounter;
  34830. /**
  34831. * Gets an unique (relatively to the current scene) Id
  34832. */
  34833. static get UniqueId(): number;
  34834. }
  34835. }
  34836. declare module BABYLON {
  34837. /**
  34838. * This class defines the direct association between an animation and a target
  34839. */
  34840. export class TargetedAnimation {
  34841. /**
  34842. * Animation to perform
  34843. */
  34844. animation: Animation;
  34845. /**
  34846. * Target to animate
  34847. */
  34848. target: any;
  34849. /**
  34850. * Serialize the object
  34851. * @returns the JSON object representing the current entity
  34852. */
  34853. serialize(): any;
  34854. }
  34855. /**
  34856. * Use this class to create coordinated animations on multiple targets
  34857. */
  34858. export class AnimationGroup implements IDisposable {
  34859. /** The name of the animation group */
  34860. name: string;
  34861. private _scene;
  34862. private _targetedAnimations;
  34863. private _animatables;
  34864. private _from;
  34865. private _to;
  34866. private _isStarted;
  34867. private _isPaused;
  34868. private _speedRatio;
  34869. private _loopAnimation;
  34870. /**
  34871. * Gets or sets the unique id of the node
  34872. */
  34873. uniqueId: number;
  34874. /**
  34875. * This observable will notify when one animation have ended
  34876. */
  34877. onAnimationEndObservable: Observable<TargetedAnimation>;
  34878. /**
  34879. * Observer raised when one animation loops
  34880. */
  34881. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34882. /**
  34883. * Observer raised when all animations have looped
  34884. */
  34885. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34886. /**
  34887. * This observable will notify when all animations have ended.
  34888. */
  34889. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34890. /**
  34891. * This observable will notify when all animations have paused.
  34892. */
  34893. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34894. /**
  34895. * This observable will notify when all animations are playing.
  34896. */
  34897. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34898. /**
  34899. * Gets the first frame
  34900. */
  34901. get from(): number;
  34902. /**
  34903. * Gets the last frame
  34904. */
  34905. get to(): number;
  34906. /**
  34907. * Define if the animations are started
  34908. */
  34909. get isStarted(): boolean;
  34910. /**
  34911. * Gets a value indicating that the current group is playing
  34912. */
  34913. get isPlaying(): boolean;
  34914. /**
  34915. * Gets or sets the speed ratio to use for all animations
  34916. */
  34917. get speedRatio(): number;
  34918. /**
  34919. * Gets or sets the speed ratio to use for all animations
  34920. */
  34921. set speedRatio(value: number);
  34922. /**
  34923. * Gets or sets if all animations should loop or not
  34924. */
  34925. get loopAnimation(): boolean;
  34926. set loopAnimation(value: boolean);
  34927. /**
  34928. * Gets the targeted animations for this animation group
  34929. */
  34930. get targetedAnimations(): Array<TargetedAnimation>;
  34931. /**
  34932. * returning the list of animatables controlled by this animation group.
  34933. */
  34934. get animatables(): Array<Animatable>;
  34935. /**
  34936. * Instantiates a new Animation Group.
  34937. * This helps managing several animations at once.
  34938. * @see http://doc.babylonjs.com/how_to/group
  34939. * @param name Defines the name of the group
  34940. * @param scene Defines the scene the group belongs to
  34941. */
  34942. constructor(
  34943. /** The name of the animation group */
  34944. name: string, scene?: Nullable<Scene>);
  34945. /**
  34946. * Add an animation (with its target) in the group
  34947. * @param animation defines the animation we want to add
  34948. * @param target defines the target of the animation
  34949. * @returns the TargetedAnimation object
  34950. */
  34951. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34952. /**
  34953. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34954. * It can add constant keys at begin or end
  34955. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34956. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34957. * @returns the animation group
  34958. */
  34959. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34960. private _animationLoopCount;
  34961. private _animationLoopFlags;
  34962. private _processLoop;
  34963. /**
  34964. * Start all animations on given targets
  34965. * @param loop defines if animations must loop
  34966. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34967. * @param from defines the from key (optional)
  34968. * @param to defines the to key (optional)
  34969. * @returns the current animation group
  34970. */
  34971. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34972. /**
  34973. * Pause all animations
  34974. * @returns the animation group
  34975. */
  34976. pause(): AnimationGroup;
  34977. /**
  34978. * Play all animations to initial state
  34979. * This function will start() the animations if they were not started or will restart() them if they were paused
  34980. * @param loop defines if animations must loop
  34981. * @returns the animation group
  34982. */
  34983. play(loop?: boolean): AnimationGroup;
  34984. /**
  34985. * Reset all animations to initial state
  34986. * @returns the animation group
  34987. */
  34988. reset(): AnimationGroup;
  34989. /**
  34990. * Restart animations from key 0
  34991. * @returns the animation group
  34992. */
  34993. restart(): AnimationGroup;
  34994. /**
  34995. * Stop all animations
  34996. * @returns the animation group
  34997. */
  34998. stop(): AnimationGroup;
  34999. /**
  35000. * Set animation weight for all animatables
  35001. * @param weight defines the weight to use
  35002. * @return the animationGroup
  35003. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35004. */
  35005. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35006. /**
  35007. * Synchronize and normalize all animatables with a source animatable
  35008. * @param root defines the root animatable to synchronize with
  35009. * @return the animationGroup
  35010. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35011. */
  35012. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35013. /**
  35014. * Goes to a specific frame in this animation group
  35015. * @param frame the frame number to go to
  35016. * @return the animationGroup
  35017. */
  35018. goToFrame(frame: number): AnimationGroup;
  35019. /**
  35020. * Dispose all associated resources
  35021. */
  35022. dispose(): void;
  35023. private _checkAnimationGroupEnded;
  35024. /**
  35025. * Clone the current animation group and returns a copy
  35026. * @param newName defines the name of the new group
  35027. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35028. * @returns the new aniamtion group
  35029. */
  35030. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35031. /**
  35032. * Serializes the animationGroup to an object
  35033. * @returns Serialized object
  35034. */
  35035. serialize(): any;
  35036. /**
  35037. * Returns a new AnimationGroup object parsed from the source provided.
  35038. * @param parsedAnimationGroup defines the source
  35039. * @param scene defines the scene that will receive the animationGroup
  35040. * @returns a new AnimationGroup
  35041. */
  35042. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35043. /**
  35044. * Returns the string "AnimationGroup"
  35045. * @returns "AnimationGroup"
  35046. */
  35047. getClassName(): string;
  35048. /**
  35049. * Creates a detailled string about the object
  35050. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35051. * @returns a string representing the object
  35052. */
  35053. toString(fullDetails?: boolean): string;
  35054. }
  35055. }
  35056. declare module BABYLON {
  35057. /**
  35058. * Define an interface for all classes that will hold resources
  35059. */
  35060. export interface IDisposable {
  35061. /**
  35062. * Releases all held resources
  35063. */
  35064. dispose(): void;
  35065. }
  35066. /** Interface defining initialization parameters for Scene class */
  35067. export interface SceneOptions {
  35068. /**
  35069. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35070. * It will improve performance when the number of geometries becomes important.
  35071. */
  35072. useGeometryUniqueIdsMap?: boolean;
  35073. /**
  35074. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35075. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35076. */
  35077. useMaterialMeshMap?: boolean;
  35078. /**
  35079. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35080. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35081. */
  35082. useClonedMeshMap?: boolean;
  35083. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35084. virtual?: boolean;
  35085. }
  35086. /**
  35087. * Represents a scene to be rendered by the engine.
  35088. * @see http://doc.babylonjs.com/features/scene
  35089. */
  35090. export class Scene extends AbstractScene implements IAnimatable {
  35091. /** The fog is deactivated */
  35092. static readonly FOGMODE_NONE: number;
  35093. /** The fog density is following an exponential function */
  35094. static readonly FOGMODE_EXP: number;
  35095. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35096. static readonly FOGMODE_EXP2: number;
  35097. /** The fog density is following a linear function. */
  35098. static readonly FOGMODE_LINEAR: number;
  35099. /**
  35100. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35101. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35102. */
  35103. static MinDeltaTime: number;
  35104. /**
  35105. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35106. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35107. */
  35108. static MaxDeltaTime: number;
  35109. /**
  35110. * Factory used to create the default material.
  35111. * @param name The name of the material to create
  35112. * @param scene The scene to create the material for
  35113. * @returns The default material
  35114. */
  35115. static DefaultMaterialFactory(scene: Scene): Material;
  35116. /**
  35117. * Factory used to create the a collision coordinator.
  35118. * @returns The collision coordinator
  35119. */
  35120. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35121. /** @hidden */
  35122. _inputManager: InputManager;
  35123. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35124. cameraToUseForPointers: Nullable<Camera>;
  35125. /** @hidden */
  35126. readonly _isScene: boolean;
  35127. /** @hidden */
  35128. _blockEntityCollection: boolean;
  35129. /**
  35130. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35131. */
  35132. autoClear: boolean;
  35133. /**
  35134. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35135. */
  35136. autoClearDepthAndStencil: boolean;
  35137. /**
  35138. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35139. */
  35140. clearColor: Color4;
  35141. /**
  35142. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35143. */
  35144. ambientColor: Color3;
  35145. /**
  35146. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35147. * It should only be one of the following (if not the default embedded one):
  35148. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35149. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35150. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35151. * The material properties need to be setup according to the type of texture in use.
  35152. */
  35153. environmentBRDFTexture: BaseTexture;
  35154. /** @hidden */
  35155. protected _environmentTexture: Nullable<BaseTexture>;
  35156. /**
  35157. * Texture used in all pbr material as the reflection texture.
  35158. * As in the majority of the scene they are the same (exception for multi room and so on),
  35159. * this is easier to reference from here than from all the materials.
  35160. */
  35161. get environmentTexture(): Nullable<BaseTexture>;
  35162. /**
  35163. * Texture used in all pbr material as the reflection texture.
  35164. * As in the majority of the scene they are the same (exception for multi room and so on),
  35165. * this is easier to set here than in all the materials.
  35166. */
  35167. set environmentTexture(value: Nullable<BaseTexture>);
  35168. /** @hidden */
  35169. protected _environmentIntensity: number;
  35170. /**
  35171. * Intensity of the environment in all pbr material.
  35172. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35173. * As in the majority of the scene they are the same (exception for multi room and so on),
  35174. * this is easier to reference from here than from all the materials.
  35175. */
  35176. get environmentIntensity(): number;
  35177. /**
  35178. * Intensity of the environment in all pbr material.
  35179. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35180. * As in the majority of the scene they are the same (exception for multi room and so on),
  35181. * this is easier to set here than in all the materials.
  35182. */
  35183. set environmentIntensity(value: number);
  35184. /** @hidden */
  35185. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35186. /**
  35187. * Default image processing configuration used either in the rendering
  35188. * Forward main pass or through the imageProcessingPostProcess if present.
  35189. * As in the majority of the scene they are the same (exception for multi camera),
  35190. * this is easier to reference from here than from all the materials and post process.
  35191. *
  35192. * No setter as we it is a shared configuration, you can set the values instead.
  35193. */
  35194. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35195. private _forceWireframe;
  35196. /**
  35197. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35198. */
  35199. set forceWireframe(value: boolean);
  35200. get forceWireframe(): boolean;
  35201. private _skipFrustumClipping;
  35202. /**
  35203. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35204. */
  35205. set skipFrustumClipping(value: boolean);
  35206. get skipFrustumClipping(): boolean;
  35207. private _forcePointsCloud;
  35208. /**
  35209. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35210. */
  35211. set forcePointsCloud(value: boolean);
  35212. get forcePointsCloud(): boolean;
  35213. /**
  35214. * Gets or sets the active clipplane 1
  35215. */
  35216. clipPlane: Nullable<Plane>;
  35217. /**
  35218. * Gets or sets the active clipplane 2
  35219. */
  35220. clipPlane2: Nullable<Plane>;
  35221. /**
  35222. * Gets or sets the active clipplane 3
  35223. */
  35224. clipPlane3: Nullable<Plane>;
  35225. /**
  35226. * Gets or sets the active clipplane 4
  35227. */
  35228. clipPlane4: Nullable<Plane>;
  35229. /**
  35230. * Gets or sets the active clipplane 5
  35231. */
  35232. clipPlane5: Nullable<Plane>;
  35233. /**
  35234. * Gets or sets the active clipplane 6
  35235. */
  35236. clipPlane6: Nullable<Plane>;
  35237. /**
  35238. * Gets or sets a boolean indicating if animations are enabled
  35239. */
  35240. animationsEnabled: boolean;
  35241. private _animationPropertiesOverride;
  35242. /**
  35243. * Gets or sets the animation properties override
  35244. */
  35245. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35246. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35247. /**
  35248. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35249. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35250. */
  35251. useConstantAnimationDeltaTime: boolean;
  35252. /**
  35253. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35254. * Please note that it requires to run a ray cast through the scene on every frame
  35255. */
  35256. constantlyUpdateMeshUnderPointer: boolean;
  35257. /**
  35258. * Defines the HTML cursor to use when hovering over interactive elements
  35259. */
  35260. hoverCursor: string;
  35261. /**
  35262. * Defines the HTML default cursor to use (empty by default)
  35263. */
  35264. defaultCursor: string;
  35265. /**
  35266. * Defines whether cursors are handled by the scene.
  35267. */
  35268. doNotHandleCursors: boolean;
  35269. /**
  35270. * This is used to call preventDefault() on pointer down
  35271. * in order to block unwanted artifacts like system double clicks
  35272. */
  35273. preventDefaultOnPointerDown: boolean;
  35274. /**
  35275. * This is used to call preventDefault() on pointer up
  35276. * in order to block unwanted artifacts like system double clicks
  35277. */
  35278. preventDefaultOnPointerUp: boolean;
  35279. /**
  35280. * Gets or sets user defined metadata
  35281. */
  35282. metadata: any;
  35283. /**
  35284. * For internal use only. Please do not use.
  35285. */
  35286. reservedDataStore: any;
  35287. /**
  35288. * Gets the name of the plugin used to load this scene (null by default)
  35289. */
  35290. loadingPluginName: string;
  35291. /**
  35292. * Use this array to add regular expressions used to disable offline support for specific urls
  35293. */
  35294. disableOfflineSupportExceptionRules: RegExp[];
  35295. /**
  35296. * An event triggered when the scene is disposed.
  35297. */
  35298. onDisposeObservable: Observable<Scene>;
  35299. private _onDisposeObserver;
  35300. /** Sets a function to be executed when this scene is disposed. */
  35301. set onDispose(callback: () => void);
  35302. /**
  35303. * An event triggered before rendering the scene (right after animations and physics)
  35304. */
  35305. onBeforeRenderObservable: Observable<Scene>;
  35306. private _onBeforeRenderObserver;
  35307. /** Sets a function to be executed before rendering this scene */
  35308. set beforeRender(callback: Nullable<() => void>);
  35309. /**
  35310. * An event triggered after rendering the scene
  35311. */
  35312. onAfterRenderObservable: Observable<Scene>;
  35313. /**
  35314. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35315. */
  35316. onAfterRenderCameraObservable: Observable<Camera>;
  35317. private _onAfterRenderObserver;
  35318. /** Sets a function to be executed after rendering this scene */
  35319. set afterRender(callback: Nullable<() => void>);
  35320. /**
  35321. * An event triggered before animating the scene
  35322. */
  35323. onBeforeAnimationsObservable: Observable<Scene>;
  35324. /**
  35325. * An event triggered after animations processing
  35326. */
  35327. onAfterAnimationsObservable: Observable<Scene>;
  35328. /**
  35329. * An event triggered before draw calls are ready to be sent
  35330. */
  35331. onBeforeDrawPhaseObservable: Observable<Scene>;
  35332. /**
  35333. * An event triggered after draw calls have been sent
  35334. */
  35335. onAfterDrawPhaseObservable: Observable<Scene>;
  35336. /**
  35337. * An event triggered when the scene is ready
  35338. */
  35339. onReadyObservable: Observable<Scene>;
  35340. /**
  35341. * An event triggered before rendering a camera
  35342. */
  35343. onBeforeCameraRenderObservable: Observable<Camera>;
  35344. private _onBeforeCameraRenderObserver;
  35345. /** Sets a function to be executed before rendering a camera*/
  35346. set beforeCameraRender(callback: () => void);
  35347. /**
  35348. * An event triggered after rendering a camera
  35349. */
  35350. onAfterCameraRenderObservable: Observable<Camera>;
  35351. private _onAfterCameraRenderObserver;
  35352. /** Sets a function to be executed after rendering a camera*/
  35353. set afterCameraRender(callback: () => void);
  35354. /**
  35355. * An event triggered when active meshes evaluation is about to start
  35356. */
  35357. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35358. /**
  35359. * An event triggered when active meshes evaluation is done
  35360. */
  35361. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35362. /**
  35363. * An event triggered when particles rendering is about to start
  35364. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35365. */
  35366. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35367. /**
  35368. * An event triggered when particles rendering is done
  35369. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35370. */
  35371. onAfterParticlesRenderingObservable: Observable<Scene>;
  35372. /**
  35373. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35374. */
  35375. onDataLoadedObservable: Observable<Scene>;
  35376. /**
  35377. * An event triggered when a camera is created
  35378. */
  35379. onNewCameraAddedObservable: Observable<Camera>;
  35380. /**
  35381. * An event triggered when a camera is removed
  35382. */
  35383. onCameraRemovedObservable: Observable<Camera>;
  35384. /**
  35385. * An event triggered when a light is created
  35386. */
  35387. onNewLightAddedObservable: Observable<Light>;
  35388. /**
  35389. * An event triggered when a light is removed
  35390. */
  35391. onLightRemovedObservable: Observable<Light>;
  35392. /**
  35393. * An event triggered when a geometry is created
  35394. */
  35395. onNewGeometryAddedObservable: Observable<Geometry>;
  35396. /**
  35397. * An event triggered when a geometry is removed
  35398. */
  35399. onGeometryRemovedObservable: Observable<Geometry>;
  35400. /**
  35401. * An event triggered when a transform node is created
  35402. */
  35403. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35404. /**
  35405. * An event triggered when a transform node is removed
  35406. */
  35407. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35408. /**
  35409. * An event triggered when a mesh is created
  35410. */
  35411. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35412. /**
  35413. * An event triggered when a mesh is removed
  35414. */
  35415. onMeshRemovedObservable: Observable<AbstractMesh>;
  35416. /**
  35417. * An event triggered when a skeleton is created
  35418. */
  35419. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35420. /**
  35421. * An event triggered when a skeleton is removed
  35422. */
  35423. onSkeletonRemovedObservable: Observable<Skeleton>;
  35424. /**
  35425. * An event triggered when a material is created
  35426. */
  35427. onNewMaterialAddedObservable: Observable<Material>;
  35428. /**
  35429. * An event triggered when a material is removed
  35430. */
  35431. onMaterialRemovedObservable: Observable<Material>;
  35432. /**
  35433. * An event triggered when a texture is created
  35434. */
  35435. onNewTextureAddedObservable: Observable<BaseTexture>;
  35436. /**
  35437. * An event triggered when a texture is removed
  35438. */
  35439. onTextureRemovedObservable: Observable<BaseTexture>;
  35440. /**
  35441. * An event triggered when render targets are about to be rendered
  35442. * Can happen multiple times per frame.
  35443. */
  35444. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35445. /**
  35446. * An event triggered when render targets were rendered.
  35447. * Can happen multiple times per frame.
  35448. */
  35449. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35450. /**
  35451. * An event triggered before calculating deterministic simulation step
  35452. */
  35453. onBeforeStepObservable: Observable<Scene>;
  35454. /**
  35455. * An event triggered after calculating deterministic simulation step
  35456. */
  35457. onAfterStepObservable: Observable<Scene>;
  35458. /**
  35459. * An event triggered when the activeCamera property is updated
  35460. */
  35461. onActiveCameraChanged: Observable<Scene>;
  35462. /**
  35463. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35464. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35465. * 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)
  35466. */
  35467. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35468. /**
  35469. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35470. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35471. * 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)
  35472. */
  35473. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35474. /**
  35475. * This Observable will when a mesh has been imported into the scene.
  35476. */
  35477. onMeshImportedObservable: Observable<AbstractMesh>;
  35478. /**
  35479. * This Observable will when an animation file has been imported into the scene.
  35480. */
  35481. onAnimationFileImportedObservable: Observable<Scene>;
  35482. /**
  35483. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35484. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35485. */
  35486. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35487. /** @hidden */
  35488. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35489. /**
  35490. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35491. */
  35492. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35493. /**
  35494. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35495. */
  35496. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35497. /**
  35498. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35499. */
  35500. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35501. /** Callback called when a pointer move is detected */
  35502. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35503. /** Callback called when a pointer down is detected */
  35504. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35505. /** Callback called when a pointer up is detected */
  35506. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35507. /** Callback called when a pointer pick is detected */
  35508. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35509. /**
  35510. * 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).
  35511. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35512. */
  35513. onPrePointerObservable: Observable<PointerInfoPre>;
  35514. /**
  35515. * Observable event triggered each time an input event is received from the rendering canvas
  35516. */
  35517. onPointerObservable: Observable<PointerInfo>;
  35518. /**
  35519. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35520. */
  35521. get unTranslatedPointer(): Vector2;
  35522. /**
  35523. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35524. */
  35525. static get DragMovementThreshold(): number;
  35526. static set DragMovementThreshold(value: number);
  35527. /**
  35528. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35529. */
  35530. static get LongPressDelay(): number;
  35531. static set LongPressDelay(value: number);
  35532. /**
  35533. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35534. */
  35535. static get DoubleClickDelay(): number;
  35536. static set DoubleClickDelay(value: number);
  35537. /** If you need to check double click without raising a single click at first click, enable this flag */
  35538. static get ExclusiveDoubleClickMode(): boolean;
  35539. static set ExclusiveDoubleClickMode(value: boolean);
  35540. /** @hidden */
  35541. _mirroredCameraPosition: Nullable<Vector3>;
  35542. /**
  35543. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35544. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35545. */
  35546. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35547. /**
  35548. * Observable event triggered each time an keyboard event is received from the hosting window
  35549. */
  35550. onKeyboardObservable: Observable<KeyboardInfo>;
  35551. private _useRightHandedSystem;
  35552. /**
  35553. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35554. */
  35555. set useRightHandedSystem(value: boolean);
  35556. get useRightHandedSystem(): boolean;
  35557. private _timeAccumulator;
  35558. private _currentStepId;
  35559. private _currentInternalStep;
  35560. /**
  35561. * Sets the step Id used by deterministic lock step
  35562. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35563. * @param newStepId defines the step Id
  35564. */
  35565. setStepId(newStepId: number): void;
  35566. /**
  35567. * Gets the step Id used by deterministic lock step
  35568. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35569. * @returns the step Id
  35570. */
  35571. getStepId(): number;
  35572. /**
  35573. * Gets the internal step used by deterministic lock step
  35574. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35575. * @returns the internal step
  35576. */
  35577. getInternalStep(): number;
  35578. private _fogEnabled;
  35579. /**
  35580. * Gets or sets a boolean indicating if fog is enabled on this scene
  35581. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35582. * (Default is true)
  35583. */
  35584. set fogEnabled(value: boolean);
  35585. get fogEnabled(): boolean;
  35586. private _fogMode;
  35587. /**
  35588. * Gets or sets the fog mode to use
  35589. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35590. * | mode | value |
  35591. * | --- | --- |
  35592. * | FOGMODE_NONE | 0 |
  35593. * | FOGMODE_EXP | 1 |
  35594. * | FOGMODE_EXP2 | 2 |
  35595. * | FOGMODE_LINEAR | 3 |
  35596. */
  35597. set fogMode(value: number);
  35598. get fogMode(): number;
  35599. /**
  35600. * Gets or sets the fog color to use
  35601. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35602. * (Default is Color3(0.2, 0.2, 0.3))
  35603. */
  35604. fogColor: Color3;
  35605. /**
  35606. * Gets or sets the fog density to use
  35607. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35608. * (Default is 0.1)
  35609. */
  35610. fogDensity: number;
  35611. /**
  35612. * Gets or sets the fog start distance to use
  35613. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35614. * (Default is 0)
  35615. */
  35616. fogStart: number;
  35617. /**
  35618. * Gets or sets the fog end distance to use
  35619. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35620. * (Default is 1000)
  35621. */
  35622. fogEnd: number;
  35623. private _shadowsEnabled;
  35624. /**
  35625. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35626. */
  35627. set shadowsEnabled(value: boolean);
  35628. get shadowsEnabled(): boolean;
  35629. private _lightsEnabled;
  35630. /**
  35631. * Gets or sets a boolean indicating if lights are enabled on this scene
  35632. */
  35633. set lightsEnabled(value: boolean);
  35634. get lightsEnabled(): boolean;
  35635. /** All of the active cameras added to this scene. */
  35636. activeCameras: Camera[];
  35637. /** @hidden */
  35638. _activeCamera: Nullable<Camera>;
  35639. /** Gets or sets the current active camera */
  35640. get activeCamera(): Nullable<Camera>;
  35641. set activeCamera(value: Nullable<Camera>);
  35642. private _defaultMaterial;
  35643. /** The default material used on meshes when no material is affected */
  35644. get defaultMaterial(): Material;
  35645. /** The default material used on meshes when no material is affected */
  35646. set defaultMaterial(value: Material);
  35647. private _texturesEnabled;
  35648. /**
  35649. * Gets or sets a boolean indicating if textures are enabled on this scene
  35650. */
  35651. set texturesEnabled(value: boolean);
  35652. get texturesEnabled(): boolean;
  35653. /**
  35654. * Gets or sets a boolean indicating if particles are enabled on this scene
  35655. */
  35656. particlesEnabled: boolean;
  35657. /**
  35658. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35659. */
  35660. spritesEnabled: boolean;
  35661. private _skeletonsEnabled;
  35662. /**
  35663. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35664. */
  35665. set skeletonsEnabled(value: boolean);
  35666. get skeletonsEnabled(): boolean;
  35667. /**
  35668. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35669. */
  35670. lensFlaresEnabled: boolean;
  35671. /**
  35672. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35673. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35674. */
  35675. collisionsEnabled: boolean;
  35676. private _collisionCoordinator;
  35677. /** @hidden */
  35678. get collisionCoordinator(): ICollisionCoordinator;
  35679. /**
  35680. * Defines the gravity applied to this scene (used only for collisions)
  35681. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35682. */
  35683. gravity: Vector3;
  35684. /**
  35685. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35686. */
  35687. postProcessesEnabled: boolean;
  35688. /**
  35689. * The list of postprocesses added to the scene
  35690. */
  35691. postProcesses: PostProcess[];
  35692. /**
  35693. * Gets the current postprocess manager
  35694. */
  35695. postProcessManager: PostProcessManager;
  35696. /**
  35697. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35698. */
  35699. renderTargetsEnabled: boolean;
  35700. /**
  35701. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35702. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35703. */
  35704. dumpNextRenderTargets: boolean;
  35705. /**
  35706. * The list of user defined render targets added to the scene
  35707. */
  35708. customRenderTargets: RenderTargetTexture[];
  35709. /**
  35710. * Defines if texture loading must be delayed
  35711. * If true, textures will only be loaded when they need to be rendered
  35712. */
  35713. useDelayedTextureLoading: boolean;
  35714. /**
  35715. * Gets the list of meshes imported to the scene through SceneLoader
  35716. */
  35717. importedMeshesFiles: String[];
  35718. /**
  35719. * Gets or sets a boolean indicating if probes are enabled on this scene
  35720. */
  35721. probesEnabled: boolean;
  35722. /**
  35723. * Gets or sets the current offline provider to use to store scene data
  35724. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35725. */
  35726. offlineProvider: IOfflineProvider;
  35727. /**
  35728. * Gets or sets the action manager associated with the scene
  35729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35730. */
  35731. actionManager: AbstractActionManager;
  35732. private _meshesForIntersections;
  35733. /**
  35734. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35735. */
  35736. proceduralTexturesEnabled: boolean;
  35737. private _engine;
  35738. private _totalVertices;
  35739. /** @hidden */
  35740. _activeIndices: PerfCounter;
  35741. /** @hidden */
  35742. _activeParticles: PerfCounter;
  35743. /** @hidden */
  35744. _activeBones: PerfCounter;
  35745. private _animationRatio;
  35746. /** @hidden */
  35747. _animationTimeLast: number;
  35748. /** @hidden */
  35749. _animationTime: number;
  35750. /**
  35751. * Gets or sets a general scale for animation speed
  35752. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35753. */
  35754. animationTimeScale: number;
  35755. /** @hidden */
  35756. _cachedMaterial: Nullable<Material>;
  35757. /** @hidden */
  35758. _cachedEffect: Nullable<Effect>;
  35759. /** @hidden */
  35760. _cachedVisibility: Nullable<number>;
  35761. private _renderId;
  35762. private _frameId;
  35763. private _executeWhenReadyTimeoutId;
  35764. private _intermediateRendering;
  35765. private _viewUpdateFlag;
  35766. private _projectionUpdateFlag;
  35767. /** @hidden */
  35768. _toBeDisposed: Nullable<IDisposable>[];
  35769. private _activeRequests;
  35770. /** @hidden */
  35771. _pendingData: any[];
  35772. private _isDisposed;
  35773. /**
  35774. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35775. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35776. */
  35777. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35778. private _activeMeshes;
  35779. private _processedMaterials;
  35780. private _renderTargets;
  35781. /** @hidden */
  35782. _activeParticleSystems: SmartArray<IParticleSystem>;
  35783. private _activeSkeletons;
  35784. private _softwareSkinnedMeshes;
  35785. private _renderingManager;
  35786. /** @hidden */
  35787. _activeAnimatables: Animatable[];
  35788. private _transformMatrix;
  35789. private _sceneUbo;
  35790. /** @hidden */
  35791. _viewMatrix: Matrix;
  35792. private _projectionMatrix;
  35793. /** @hidden */
  35794. _forcedViewPosition: Nullable<Vector3>;
  35795. /** @hidden */
  35796. _frustumPlanes: Plane[];
  35797. /**
  35798. * Gets the list of frustum planes (built from the active camera)
  35799. */
  35800. get frustumPlanes(): Plane[];
  35801. /**
  35802. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35803. * This is useful if there are more lights that the maximum simulteanous authorized
  35804. */
  35805. requireLightSorting: boolean;
  35806. /** @hidden */
  35807. readonly useMaterialMeshMap: boolean;
  35808. /** @hidden */
  35809. readonly useClonedMeshMap: boolean;
  35810. private _externalData;
  35811. private _uid;
  35812. /**
  35813. * @hidden
  35814. * Backing store of defined scene components.
  35815. */
  35816. _components: ISceneComponent[];
  35817. /**
  35818. * @hidden
  35819. * Backing store of defined scene components.
  35820. */
  35821. _serializableComponents: ISceneSerializableComponent[];
  35822. /**
  35823. * List of components to register on the next registration step.
  35824. */
  35825. private _transientComponents;
  35826. /**
  35827. * Registers the transient components if needed.
  35828. */
  35829. private _registerTransientComponents;
  35830. /**
  35831. * @hidden
  35832. * Add a component to the scene.
  35833. * Note that the ccomponent could be registered on th next frame if this is called after
  35834. * the register component stage.
  35835. * @param component Defines the component to add to the scene
  35836. */
  35837. _addComponent(component: ISceneComponent): void;
  35838. /**
  35839. * @hidden
  35840. * Gets a component from the scene.
  35841. * @param name defines the name of the component to retrieve
  35842. * @returns the component or null if not present
  35843. */
  35844. _getComponent(name: string): Nullable<ISceneComponent>;
  35845. /**
  35846. * @hidden
  35847. * Defines the actions happening before camera updates.
  35848. */
  35849. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35850. /**
  35851. * @hidden
  35852. * Defines the actions happening before clear the canvas.
  35853. */
  35854. _beforeClearStage: Stage<SimpleStageAction>;
  35855. /**
  35856. * @hidden
  35857. * Defines the actions when collecting render targets for the frame.
  35858. */
  35859. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35860. /**
  35861. * @hidden
  35862. * Defines the actions happening for one camera in the frame.
  35863. */
  35864. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35865. /**
  35866. * @hidden
  35867. * Defines the actions happening during the per mesh ready checks.
  35868. */
  35869. _isReadyForMeshStage: Stage<MeshStageAction>;
  35870. /**
  35871. * @hidden
  35872. * Defines the actions happening before evaluate active mesh checks.
  35873. */
  35874. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35875. /**
  35876. * @hidden
  35877. * Defines the actions happening during the evaluate sub mesh checks.
  35878. */
  35879. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35880. /**
  35881. * @hidden
  35882. * Defines the actions happening during the active mesh stage.
  35883. */
  35884. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35885. /**
  35886. * @hidden
  35887. * Defines the actions happening during the per camera render target step.
  35888. */
  35889. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35890. /**
  35891. * @hidden
  35892. * Defines the actions happening just before the active camera is drawing.
  35893. */
  35894. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35895. /**
  35896. * @hidden
  35897. * Defines the actions happening just before a render target is drawing.
  35898. */
  35899. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35900. /**
  35901. * @hidden
  35902. * Defines the actions happening just before a rendering group is drawing.
  35903. */
  35904. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35905. /**
  35906. * @hidden
  35907. * Defines the actions happening just before a mesh is drawing.
  35908. */
  35909. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35910. /**
  35911. * @hidden
  35912. * Defines the actions happening just after a mesh has been drawn.
  35913. */
  35914. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35915. /**
  35916. * @hidden
  35917. * Defines the actions happening just after a rendering group has been drawn.
  35918. */
  35919. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35920. /**
  35921. * @hidden
  35922. * Defines the actions happening just after the active camera has been drawn.
  35923. */
  35924. _afterCameraDrawStage: Stage<CameraStageAction>;
  35925. /**
  35926. * @hidden
  35927. * Defines the actions happening just after a render target has been drawn.
  35928. */
  35929. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35930. /**
  35931. * @hidden
  35932. * Defines the actions happening just after rendering all cameras and computing intersections.
  35933. */
  35934. _afterRenderStage: Stage<SimpleStageAction>;
  35935. /**
  35936. * @hidden
  35937. * Defines the actions happening when a pointer move event happens.
  35938. */
  35939. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35940. /**
  35941. * @hidden
  35942. * Defines the actions happening when a pointer down event happens.
  35943. */
  35944. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35945. /**
  35946. * @hidden
  35947. * Defines the actions happening when a pointer up event happens.
  35948. */
  35949. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35950. /**
  35951. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35952. */
  35953. private geometriesByUniqueId;
  35954. /**
  35955. * Creates a new Scene
  35956. * @param engine defines the engine to use to render this scene
  35957. * @param options defines the scene options
  35958. */
  35959. constructor(engine: Engine, options?: SceneOptions);
  35960. /**
  35961. * Gets a string idenfifying the name of the class
  35962. * @returns "Scene" string
  35963. */
  35964. getClassName(): string;
  35965. private _defaultMeshCandidates;
  35966. /**
  35967. * @hidden
  35968. */
  35969. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35970. private _defaultSubMeshCandidates;
  35971. /**
  35972. * @hidden
  35973. */
  35974. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35975. /**
  35976. * Sets the default candidate providers for the scene.
  35977. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35978. * and getCollidingSubMeshCandidates to their default function
  35979. */
  35980. setDefaultCandidateProviders(): void;
  35981. /**
  35982. * Gets the mesh that is currently under the pointer
  35983. */
  35984. get meshUnderPointer(): Nullable<AbstractMesh>;
  35985. /**
  35986. * Gets or sets the current on-screen X position of the pointer
  35987. */
  35988. get pointerX(): number;
  35989. set pointerX(value: number);
  35990. /**
  35991. * Gets or sets the current on-screen Y position of the pointer
  35992. */
  35993. get pointerY(): number;
  35994. set pointerY(value: number);
  35995. /**
  35996. * Gets the cached material (ie. the latest rendered one)
  35997. * @returns the cached material
  35998. */
  35999. getCachedMaterial(): Nullable<Material>;
  36000. /**
  36001. * Gets the cached effect (ie. the latest rendered one)
  36002. * @returns the cached effect
  36003. */
  36004. getCachedEffect(): Nullable<Effect>;
  36005. /**
  36006. * Gets the cached visibility state (ie. the latest rendered one)
  36007. * @returns the cached visibility state
  36008. */
  36009. getCachedVisibility(): Nullable<number>;
  36010. /**
  36011. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36012. * @param material defines the current material
  36013. * @param effect defines the current effect
  36014. * @param visibility defines the current visibility state
  36015. * @returns true if one parameter is not cached
  36016. */
  36017. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36018. /**
  36019. * Gets the engine associated with the scene
  36020. * @returns an Engine
  36021. */
  36022. getEngine(): Engine;
  36023. /**
  36024. * Gets the total number of vertices rendered per frame
  36025. * @returns the total number of vertices rendered per frame
  36026. */
  36027. getTotalVertices(): number;
  36028. /**
  36029. * Gets the performance counter for total vertices
  36030. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36031. */
  36032. get totalVerticesPerfCounter(): PerfCounter;
  36033. /**
  36034. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36035. * @returns the total number of active indices rendered per frame
  36036. */
  36037. getActiveIndices(): number;
  36038. /**
  36039. * Gets the performance counter for active indices
  36040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36041. */
  36042. get totalActiveIndicesPerfCounter(): PerfCounter;
  36043. /**
  36044. * Gets the total number of active particles rendered per frame
  36045. * @returns the total number of active particles rendered per frame
  36046. */
  36047. getActiveParticles(): number;
  36048. /**
  36049. * Gets the performance counter for active particles
  36050. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36051. */
  36052. get activeParticlesPerfCounter(): PerfCounter;
  36053. /**
  36054. * Gets the total number of active bones rendered per frame
  36055. * @returns the total number of active bones rendered per frame
  36056. */
  36057. getActiveBones(): number;
  36058. /**
  36059. * Gets the performance counter for active bones
  36060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36061. */
  36062. get activeBonesPerfCounter(): PerfCounter;
  36063. /**
  36064. * Gets the array of active meshes
  36065. * @returns an array of AbstractMesh
  36066. */
  36067. getActiveMeshes(): SmartArray<AbstractMesh>;
  36068. /**
  36069. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36070. * @returns a number
  36071. */
  36072. getAnimationRatio(): number;
  36073. /**
  36074. * Gets an unique Id for the current render phase
  36075. * @returns a number
  36076. */
  36077. getRenderId(): number;
  36078. /**
  36079. * Gets an unique Id for the current frame
  36080. * @returns a number
  36081. */
  36082. getFrameId(): number;
  36083. /** Call this function if you want to manually increment the render Id*/
  36084. incrementRenderId(): void;
  36085. private _createUbo;
  36086. /**
  36087. * Use this method to simulate a pointer move on a mesh
  36088. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36089. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36090. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36091. * @returns the current scene
  36092. */
  36093. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36094. /**
  36095. * Use this method to simulate a pointer down on a mesh
  36096. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36097. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36098. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36099. * @returns the current scene
  36100. */
  36101. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36102. /**
  36103. * Use this method to simulate a pointer up on a mesh
  36104. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36105. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36106. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36107. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36108. * @returns the current scene
  36109. */
  36110. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36111. /**
  36112. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36113. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36114. * @returns true if the pointer was captured
  36115. */
  36116. isPointerCaptured(pointerId?: number): boolean;
  36117. /**
  36118. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36119. * @param attachUp defines if you want to attach events to pointerup
  36120. * @param attachDown defines if you want to attach events to pointerdown
  36121. * @param attachMove defines if you want to attach events to pointermove
  36122. */
  36123. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36124. /** Detaches all event handlers*/
  36125. detachControl(): void;
  36126. /**
  36127. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36128. * Delay loaded resources are not taking in account
  36129. * @return true if all required resources are ready
  36130. */
  36131. isReady(): boolean;
  36132. /** Resets all cached information relative to material (including effect and visibility) */
  36133. resetCachedMaterial(): void;
  36134. /**
  36135. * Registers a function to be called before every frame render
  36136. * @param func defines the function to register
  36137. */
  36138. registerBeforeRender(func: () => void): void;
  36139. /**
  36140. * Unregisters a function called before every frame render
  36141. * @param func defines the function to unregister
  36142. */
  36143. unregisterBeforeRender(func: () => void): void;
  36144. /**
  36145. * Registers a function to be called after every frame render
  36146. * @param func defines the function to register
  36147. */
  36148. registerAfterRender(func: () => void): void;
  36149. /**
  36150. * Unregisters a function called after every frame render
  36151. * @param func defines the function to unregister
  36152. */
  36153. unregisterAfterRender(func: () => void): void;
  36154. private _executeOnceBeforeRender;
  36155. /**
  36156. * The provided function will run before render once and will be disposed afterwards.
  36157. * A timeout delay can be provided so that the function will be executed in N ms.
  36158. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36159. * @param func The function to be executed.
  36160. * @param timeout optional delay in ms
  36161. */
  36162. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36163. /** @hidden */
  36164. _addPendingData(data: any): void;
  36165. /** @hidden */
  36166. _removePendingData(data: any): void;
  36167. /**
  36168. * Returns the number of items waiting to be loaded
  36169. * @returns the number of items waiting to be loaded
  36170. */
  36171. getWaitingItemsCount(): number;
  36172. /**
  36173. * Returns a boolean indicating if the scene is still loading data
  36174. */
  36175. get isLoading(): boolean;
  36176. /**
  36177. * Registers a function to be executed when the scene is ready
  36178. * @param {Function} func - the function to be executed
  36179. */
  36180. executeWhenReady(func: () => void): void;
  36181. /**
  36182. * Returns a promise that resolves when the scene is ready
  36183. * @returns A promise that resolves when the scene is ready
  36184. */
  36185. whenReadyAsync(): Promise<void>;
  36186. /** @hidden */
  36187. _checkIsReady(): void;
  36188. /**
  36189. * Gets all animatable attached to the scene
  36190. */
  36191. get animatables(): Animatable[];
  36192. /**
  36193. * Resets the last animation time frame.
  36194. * Useful to override when animations start running when loading a scene for the first time.
  36195. */
  36196. resetLastAnimationTimeFrame(): void;
  36197. /**
  36198. * Gets the current view matrix
  36199. * @returns a Matrix
  36200. */
  36201. getViewMatrix(): Matrix;
  36202. /**
  36203. * Gets the current projection matrix
  36204. * @returns a Matrix
  36205. */
  36206. getProjectionMatrix(): Matrix;
  36207. /**
  36208. * Gets the current transform matrix
  36209. * @returns a Matrix made of View * Projection
  36210. */
  36211. getTransformMatrix(): Matrix;
  36212. /**
  36213. * Sets the current transform matrix
  36214. * @param viewL defines the View matrix to use
  36215. * @param projectionL defines the Projection matrix to use
  36216. * @param viewR defines the right View matrix to use (if provided)
  36217. * @param projectionR defines the right Projection matrix to use (if provided)
  36218. */
  36219. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36220. /**
  36221. * Gets the uniform buffer used to store scene data
  36222. * @returns a UniformBuffer
  36223. */
  36224. getSceneUniformBuffer(): UniformBuffer;
  36225. /**
  36226. * Gets an unique (relatively to the current scene) Id
  36227. * @returns an unique number for the scene
  36228. */
  36229. getUniqueId(): number;
  36230. /**
  36231. * Add a mesh to the list of scene's meshes
  36232. * @param newMesh defines the mesh to add
  36233. * @param recursive if all child meshes should also be added to the scene
  36234. */
  36235. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36236. /**
  36237. * Remove a mesh for the list of scene's meshes
  36238. * @param toRemove defines the mesh to remove
  36239. * @param recursive if all child meshes should also be removed from the scene
  36240. * @returns the index where the mesh was in the mesh list
  36241. */
  36242. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36243. /**
  36244. * Add a transform node to the list of scene's transform nodes
  36245. * @param newTransformNode defines the transform node to add
  36246. */
  36247. addTransformNode(newTransformNode: TransformNode): void;
  36248. /**
  36249. * Remove a transform node for the list of scene's transform nodes
  36250. * @param toRemove defines the transform node to remove
  36251. * @returns the index where the transform node was in the transform node list
  36252. */
  36253. removeTransformNode(toRemove: TransformNode): number;
  36254. /**
  36255. * Remove a skeleton for the list of scene's skeletons
  36256. * @param toRemove defines the skeleton to remove
  36257. * @returns the index where the skeleton was in the skeleton list
  36258. */
  36259. removeSkeleton(toRemove: Skeleton): number;
  36260. /**
  36261. * Remove a morph target for the list of scene's morph targets
  36262. * @param toRemove defines the morph target to remove
  36263. * @returns the index where the morph target was in the morph target list
  36264. */
  36265. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36266. /**
  36267. * Remove a light for the list of scene's lights
  36268. * @param toRemove defines the light to remove
  36269. * @returns the index where the light was in the light list
  36270. */
  36271. removeLight(toRemove: Light): number;
  36272. /**
  36273. * Remove a camera for the list of scene's cameras
  36274. * @param toRemove defines the camera to remove
  36275. * @returns the index where the camera was in the camera list
  36276. */
  36277. removeCamera(toRemove: Camera): number;
  36278. /**
  36279. * Remove a particle system for the list of scene's particle systems
  36280. * @param toRemove defines the particle system to remove
  36281. * @returns the index where the particle system was in the particle system list
  36282. */
  36283. removeParticleSystem(toRemove: IParticleSystem): number;
  36284. /**
  36285. * Remove a animation for the list of scene's animations
  36286. * @param toRemove defines the animation to remove
  36287. * @returns the index where the animation was in the animation list
  36288. */
  36289. removeAnimation(toRemove: Animation): number;
  36290. /**
  36291. * Will stop the animation of the given target
  36292. * @param target - the target
  36293. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36294. * @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)
  36295. */
  36296. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36297. /**
  36298. * Removes the given animation group from this scene.
  36299. * @param toRemove The animation group to remove
  36300. * @returns The index of the removed animation group
  36301. */
  36302. removeAnimationGroup(toRemove: AnimationGroup): number;
  36303. /**
  36304. * Removes the given multi-material from this scene.
  36305. * @param toRemove The multi-material to remove
  36306. * @returns The index of the removed multi-material
  36307. */
  36308. removeMultiMaterial(toRemove: MultiMaterial): number;
  36309. /**
  36310. * Removes the given material from this scene.
  36311. * @param toRemove The material to remove
  36312. * @returns The index of the removed material
  36313. */
  36314. removeMaterial(toRemove: Material): number;
  36315. /**
  36316. * Removes the given action manager from this scene.
  36317. * @param toRemove The action manager to remove
  36318. * @returns The index of the removed action manager
  36319. */
  36320. removeActionManager(toRemove: AbstractActionManager): number;
  36321. /**
  36322. * Removes the given texture from this scene.
  36323. * @param toRemove The texture to remove
  36324. * @returns The index of the removed texture
  36325. */
  36326. removeTexture(toRemove: BaseTexture): number;
  36327. /**
  36328. * Adds the given light to this scene
  36329. * @param newLight The light to add
  36330. */
  36331. addLight(newLight: Light): void;
  36332. /**
  36333. * Sorts the list list based on light priorities
  36334. */
  36335. sortLightsByPriority(): void;
  36336. /**
  36337. * Adds the given camera to this scene
  36338. * @param newCamera The camera to add
  36339. */
  36340. addCamera(newCamera: Camera): void;
  36341. /**
  36342. * Adds the given skeleton to this scene
  36343. * @param newSkeleton The skeleton to add
  36344. */
  36345. addSkeleton(newSkeleton: Skeleton): void;
  36346. /**
  36347. * Adds the given particle system to this scene
  36348. * @param newParticleSystem The particle system to add
  36349. */
  36350. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36351. /**
  36352. * Adds the given animation to this scene
  36353. * @param newAnimation The animation to add
  36354. */
  36355. addAnimation(newAnimation: Animation): void;
  36356. /**
  36357. * Adds the given animation group to this scene.
  36358. * @param newAnimationGroup The animation group to add
  36359. */
  36360. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36361. /**
  36362. * Adds the given multi-material to this scene
  36363. * @param newMultiMaterial The multi-material to add
  36364. */
  36365. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36366. /**
  36367. * Adds the given material to this scene
  36368. * @param newMaterial The material to add
  36369. */
  36370. addMaterial(newMaterial: Material): void;
  36371. /**
  36372. * Adds the given morph target to this scene
  36373. * @param newMorphTargetManager The morph target to add
  36374. */
  36375. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36376. /**
  36377. * Adds the given geometry to this scene
  36378. * @param newGeometry The geometry to add
  36379. */
  36380. addGeometry(newGeometry: Geometry): void;
  36381. /**
  36382. * Adds the given action manager to this scene
  36383. * @param newActionManager The action manager to add
  36384. */
  36385. addActionManager(newActionManager: AbstractActionManager): void;
  36386. /**
  36387. * Adds the given texture to this scene.
  36388. * @param newTexture The texture to add
  36389. */
  36390. addTexture(newTexture: BaseTexture): void;
  36391. /**
  36392. * Switch active camera
  36393. * @param newCamera defines the new active camera
  36394. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36395. */
  36396. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36397. /**
  36398. * sets the active camera of the scene using its ID
  36399. * @param id defines the camera's ID
  36400. * @return the new active camera or null if none found.
  36401. */
  36402. setActiveCameraByID(id: string): Nullable<Camera>;
  36403. /**
  36404. * sets the active camera of the scene using its name
  36405. * @param name defines the camera's name
  36406. * @returns the new active camera or null if none found.
  36407. */
  36408. setActiveCameraByName(name: string): Nullable<Camera>;
  36409. /**
  36410. * get an animation group using its name
  36411. * @param name defines the material's name
  36412. * @return the animation group or null if none found.
  36413. */
  36414. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36415. /**
  36416. * Get a material using its unique id
  36417. * @param uniqueId defines the material's unique id
  36418. * @return the material or null if none found.
  36419. */
  36420. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36421. /**
  36422. * get a material using its id
  36423. * @param id defines the material's ID
  36424. * @return the material or null if none found.
  36425. */
  36426. getMaterialByID(id: string): Nullable<Material>;
  36427. /**
  36428. * Gets a the last added material using a given id
  36429. * @param id defines the material's ID
  36430. * @return the last material with the given id or null if none found.
  36431. */
  36432. getLastMaterialByID(id: string): Nullable<Material>;
  36433. /**
  36434. * Gets a material using its name
  36435. * @param name defines the material's name
  36436. * @return the material or null if none found.
  36437. */
  36438. getMaterialByName(name: string): Nullable<Material>;
  36439. /**
  36440. * Get a texture using its unique id
  36441. * @param uniqueId defines the texture's unique id
  36442. * @return the texture or null if none found.
  36443. */
  36444. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36445. /**
  36446. * Gets a camera using its id
  36447. * @param id defines the id to look for
  36448. * @returns the camera or null if not found
  36449. */
  36450. getCameraByID(id: string): Nullable<Camera>;
  36451. /**
  36452. * Gets a camera using its unique id
  36453. * @param uniqueId defines the unique id to look for
  36454. * @returns the camera or null if not found
  36455. */
  36456. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36457. /**
  36458. * Gets a camera using its name
  36459. * @param name defines the camera's name
  36460. * @return the camera or null if none found.
  36461. */
  36462. getCameraByName(name: string): Nullable<Camera>;
  36463. /**
  36464. * Gets a bone using its id
  36465. * @param id defines the bone's id
  36466. * @return the bone or null if not found
  36467. */
  36468. getBoneByID(id: string): Nullable<Bone>;
  36469. /**
  36470. * Gets a bone using its id
  36471. * @param name defines the bone's name
  36472. * @return the bone or null if not found
  36473. */
  36474. getBoneByName(name: string): Nullable<Bone>;
  36475. /**
  36476. * Gets a light node using its name
  36477. * @param name defines the the light's name
  36478. * @return the light or null if none found.
  36479. */
  36480. getLightByName(name: string): Nullable<Light>;
  36481. /**
  36482. * Gets a light node using its id
  36483. * @param id defines the light's id
  36484. * @return the light or null if none found.
  36485. */
  36486. getLightByID(id: string): Nullable<Light>;
  36487. /**
  36488. * Gets a light node using its scene-generated unique ID
  36489. * @param uniqueId defines the light's unique id
  36490. * @return the light or null if none found.
  36491. */
  36492. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36493. /**
  36494. * Gets a particle system by id
  36495. * @param id defines the particle system id
  36496. * @return the corresponding system or null if none found
  36497. */
  36498. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36499. /**
  36500. * Gets a geometry using its ID
  36501. * @param id defines the geometry's id
  36502. * @return the geometry or null if none found.
  36503. */
  36504. getGeometryByID(id: string): Nullable<Geometry>;
  36505. private _getGeometryByUniqueID;
  36506. /**
  36507. * Add a new geometry to this scene
  36508. * @param geometry defines the geometry to be added to the scene.
  36509. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36510. * @return a boolean defining if the geometry was added or not
  36511. */
  36512. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36513. /**
  36514. * Removes an existing geometry
  36515. * @param geometry defines the geometry to be removed from the scene
  36516. * @return a boolean defining if the geometry was removed or not
  36517. */
  36518. removeGeometry(geometry: Geometry): boolean;
  36519. /**
  36520. * Gets the list of geometries attached to the scene
  36521. * @returns an array of Geometry
  36522. */
  36523. getGeometries(): Geometry[];
  36524. /**
  36525. * Gets the first added mesh found of a given ID
  36526. * @param id defines the id to search for
  36527. * @return the mesh found or null if not found at all
  36528. */
  36529. getMeshByID(id: string): Nullable<AbstractMesh>;
  36530. /**
  36531. * Gets a list of meshes using their id
  36532. * @param id defines the id to search for
  36533. * @returns a list of meshes
  36534. */
  36535. getMeshesByID(id: string): Array<AbstractMesh>;
  36536. /**
  36537. * Gets the first added transform node found of a given ID
  36538. * @param id defines the id to search for
  36539. * @return the found transform node or null if not found at all.
  36540. */
  36541. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36542. /**
  36543. * Gets a transform node with its auto-generated unique id
  36544. * @param uniqueId efines the unique id to search for
  36545. * @return the found transform node or null if not found at all.
  36546. */
  36547. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36548. /**
  36549. * Gets a list of transform nodes using their id
  36550. * @param id defines the id to search for
  36551. * @returns a list of transform nodes
  36552. */
  36553. getTransformNodesByID(id: string): Array<TransformNode>;
  36554. /**
  36555. * Gets a mesh with its auto-generated unique id
  36556. * @param uniqueId defines the unique id to search for
  36557. * @return the found mesh or null if not found at all.
  36558. */
  36559. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36560. /**
  36561. * Gets a the last added mesh using a given id
  36562. * @param id defines the id to search for
  36563. * @return the found mesh or null if not found at all.
  36564. */
  36565. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36566. /**
  36567. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36568. * @param id defines the id to search for
  36569. * @return the found node or null if not found at all
  36570. */
  36571. getLastEntryByID(id: string): Nullable<Node>;
  36572. /**
  36573. * Gets a node (Mesh, Camera, Light) using a given id
  36574. * @param id defines the id to search for
  36575. * @return the found node or null if not found at all
  36576. */
  36577. getNodeByID(id: string): Nullable<Node>;
  36578. /**
  36579. * Gets a node (Mesh, Camera, Light) using a given name
  36580. * @param name defines the name to search for
  36581. * @return the found node or null if not found at all.
  36582. */
  36583. getNodeByName(name: string): Nullable<Node>;
  36584. /**
  36585. * Gets a mesh using a given name
  36586. * @param name defines the name to search for
  36587. * @return the found mesh or null if not found at all.
  36588. */
  36589. getMeshByName(name: string): Nullable<AbstractMesh>;
  36590. /**
  36591. * Gets a transform node using a given name
  36592. * @param name defines the name to search for
  36593. * @return the found transform node or null if not found at all.
  36594. */
  36595. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36596. /**
  36597. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36598. * @param id defines the id to search for
  36599. * @return the found skeleton or null if not found at all.
  36600. */
  36601. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36602. /**
  36603. * Gets a skeleton using a given auto generated unique id
  36604. * @param uniqueId defines the unique id to search for
  36605. * @return the found skeleton or null if not found at all.
  36606. */
  36607. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36608. /**
  36609. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36610. * @param id defines the id to search for
  36611. * @return the found skeleton or null if not found at all.
  36612. */
  36613. getSkeletonById(id: string): Nullable<Skeleton>;
  36614. /**
  36615. * Gets a skeleton using a given name
  36616. * @param name defines the name to search for
  36617. * @return the found skeleton or null if not found at all.
  36618. */
  36619. getSkeletonByName(name: string): Nullable<Skeleton>;
  36620. /**
  36621. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36622. * @param id defines the id to search for
  36623. * @return the found morph target manager or null if not found at all.
  36624. */
  36625. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36626. /**
  36627. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36628. * @param id defines the id to search for
  36629. * @return the found morph target or null if not found at all.
  36630. */
  36631. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36632. /**
  36633. * Gets a boolean indicating if the given mesh is active
  36634. * @param mesh defines the mesh to look for
  36635. * @returns true if the mesh is in the active list
  36636. */
  36637. isActiveMesh(mesh: AbstractMesh): boolean;
  36638. /**
  36639. * Return a unique id as a string which can serve as an identifier for the scene
  36640. */
  36641. get uid(): string;
  36642. /**
  36643. * Add an externaly attached data from its key.
  36644. * This method call will fail and return false, if such key already exists.
  36645. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36646. * @param key the unique key that identifies the data
  36647. * @param data the data object to associate to the key for this Engine instance
  36648. * @return true if no such key were already present and the data was added successfully, false otherwise
  36649. */
  36650. addExternalData<T>(key: string, data: T): boolean;
  36651. /**
  36652. * Get an externaly attached data from its key
  36653. * @param key the unique key that identifies the data
  36654. * @return the associated data, if present (can be null), or undefined if not present
  36655. */
  36656. getExternalData<T>(key: string): Nullable<T>;
  36657. /**
  36658. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36659. * @param key the unique key that identifies the data
  36660. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36661. * @return the associated data, can be null if the factory returned null.
  36662. */
  36663. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36664. /**
  36665. * Remove an externaly attached data from the Engine instance
  36666. * @param key the unique key that identifies the data
  36667. * @return true if the data was successfully removed, false if it doesn't exist
  36668. */
  36669. removeExternalData(key: string): boolean;
  36670. private _evaluateSubMesh;
  36671. /**
  36672. * Clear the processed materials smart array preventing retention point in material dispose.
  36673. */
  36674. freeProcessedMaterials(): void;
  36675. private _preventFreeActiveMeshesAndRenderingGroups;
  36676. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36677. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36678. * when disposing several meshes in a row or a hierarchy of meshes.
  36679. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36680. */
  36681. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36682. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36683. /**
  36684. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36685. */
  36686. freeActiveMeshes(): void;
  36687. /**
  36688. * Clear the info related to rendering groups preventing retention points during dispose.
  36689. */
  36690. freeRenderingGroups(): void;
  36691. /** @hidden */
  36692. _isInIntermediateRendering(): boolean;
  36693. /**
  36694. * Lambda returning the list of potentially active meshes.
  36695. */
  36696. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36697. /**
  36698. * Lambda returning the list of potentially active sub meshes.
  36699. */
  36700. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36701. /**
  36702. * Lambda returning the list of potentially intersecting sub meshes.
  36703. */
  36704. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36705. /**
  36706. * Lambda returning the list of potentially colliding sub meshes.
  36707. */
  36708. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36709. private _activeMeshesFrozen;
  36710. private _skipEvaluateActiveMeshesCompletely;
  36711. /**
  36712. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36713. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36714. * @returns the current scene
  36715. */
  36716. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36717. /**
  36718. * Use this function to restart evaluating active meshes on every frame
  36719. * @returns the current scene
  36720. */
  36721. unfreezeActiveMeshes(): Scene;
  36722. private _evaluateActiveMeshes;
  36723. private _activeMesh;
  36724. /**
  36725. * Update the transform matrix to update from the current active camera
  36726. * @param force defines a boolean used to force the update even if cache is up to date
  36727. */
  36728. updateTransformMatrix(force?: boolean): void;
  36729. private _bindFrameBuffer;
  36730. /** @hidden */
  36731. _allowPostProcessClearColor: boolean;
  36732. /** @hidden */
  36733. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36734. private _processSubCameras;
  36735. private _checkIntersections;
  36736. /** @hidden */
  36737. _advancePhysicsEngineStep(step: number): void;
  36738. /**
  36739. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36740. */
  36741. getDeterministicFrameTime: () => number;
  36742. /** @hidden */
  36743. _animate(): void;
  36744. /** Execute all animations (for a frame) */
  36745. animate(): void;
  36746. /**
  36747. * Render the scene
  36748. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36749. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36750. */
  36751. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36752. /**
  36753. * Freeze all materials
  36754. * A frozen material will not be updatable but should be faster to render
  36755. */
  36756. freezeMaterials(): void;
  36757. /**
  36758. * Unfreeze all materials
  36759. * A frozen material will not be updatable but should be faster to render
  36760. */
  36761. unfreezeMaterials(): void;
  36762. /**
  36763. * Releases all held ressources
  36764. */
  36765. dispose(): void;
  36766. /**
  36767. * Gets if the scene is already disposed
  36768. */
  36769. get isDisposed(): boolean;
  36770. /**
  36771. * Call this function to reduce memory footprint of the scene.
  36772. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36773. */
  36774. clearCachedVertexData(): void;
  36775. /**
  36776. * This function will remove the local cached buffer data from texture.
  36777. * It will save memory but will prevent the texture from being rebuilt
  36778. */
  36779. cleanCachedTextureBuffer(): void;
  36780. /**
  36781. * Get the world extend vectors with an optional filter
  36782. *
  36783. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36784. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36785. */
  36786. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36787. min: Vector3;
  36788. max: Vector3;
  36789. };
  36790. /**
  36791. * Creates a ray that can be used to pick in the scene
  36792. * @param x defines the x coordinate of the origin (on-screen)
  36793. * @param y defines the y coordinate of the origin (on-screen)
  36794. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36795. * @param camera defines the camera to use for the picking
  36796. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36797. * @returns a Ray
  36798. */
  36799. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36800. /**
  36801. * Creates a ray that can be used to pick in the scene
  36802. * @param x defines the x coordinate of the origin (on-screen)
  36803. * @param y defines the y coordinate of the origin (on-screen)
  36804. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36805. * @param result defines the ray where to store the picking ray
  36806. * @param camera defines the camera to use for the picking
  36807. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36808. * @returns the current scene
  36809. */
  36810. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36811. /**
  36812. * Creates a ray that can be used to pick in the scene
  36813. * @param x defines the x coordinate of the origin (on-screen)
  36814. * @param y defines the y coordinate of the origin (on-screen)
  36815. * @param camera defines the camera to use for the picking
  36816. * @returns a Ray
  36817. */
  36818. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36819. /**
  36820. * Creates a ray that can be used to pick in the scene
  36821. * @param x defines the x coordinate of the origin (on-screen)
  36822. * @param y defines the y coordinate of the origin (on-screen)
  36823. * @param result defines the ray where to store the picking ray
  36824. * @param camera defines the camera to use for the picking
  36825. * @returns the current scene
  36826. */
  36827. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36828. /** Launch a ray to try to pick a mesh in the scene
  36829. * @param x position on screen
  36830. * @param y position on screen
  36831. * @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
  36832. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36833. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36834. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36835. * @returns a PickingInfo
  36836. */
  36837. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36838. /** Use the given ray to pick a mesh in the scene
  36839. * @param ray The ray to use to pick meshes
  36840. * @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
  36841. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36842. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36843. * @returns a PickingInfo
  36844. */
  36845. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36846. /**
  36847. * Launch a ray to try to pick a mesh in the scene
  36848. * @param x X position on screen
  36849. * @param y Y position on screen
  36850. * @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
  36851. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36852. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36853. * @returns an array of PickingInfo
  36854. */
  36855. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36856. /**
  36857. * Launch a ray to try to pick a mesh in the scene
  36858. * @param ray Ray to use
  36859. * @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
  36860. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36861. * @returns an array of PickingInfo
  36862. */
  36863. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36864. /**
  36865. * Force the value of meshUnderPointer
  36866. * @param mesh defines the mesh to use
  36867. */
  36868. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36869. /**
  36870. * Gets the mesh under the pointer
  36871. * @returns a Mesh or null if no mesh is under the pointer
  36872. */
  36873. getPointerOverMesh(): Nullable<AbstractMesh>;
  36874. /** @hidden */
  36875. _rebuildGeometries(): void;
  36876. /** @hidden */
  36877. _rebuildTextures(): void;
  36878. private _getByTags;
  36879. /**
  36880. * Get a list of meshes by tags
  36881. * @param tagsQuery defines the tags query to use
  36882. * @param forEach defines a predicate used to filter results
  36883. * @returns an array of Mesh
  36884. */
  36885. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36886. /**
  36887. * Get a list of cameras by tags
  36888. * @param tagsQuery defines the tags query to use
  36889. * @param forEach defines a predicate used to filter results
  36890. * @returns an array of Camera
  36891. */
  36892. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36893. /**
  36894. * Get a list of lights by tags
  36895. * @param tagsQuery defines the tags query to use
  36896. * @param forEach defines a predicate used to filter results
  36897. * @returns an array of Light
  36898. */
  36899. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36900. /**
  36901. * Get a list of materials by tags
  36902. * @param tagsQuery defines the tags query to use
  36903. * @param forEach defines a predicate used to filter results
  36904. * @returns an array of Material
  36905. */
  36906. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36907. /**
  36908. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36909. * This allowed control for front to back rendering or reversly depending of the special needs.
  36910. *
  36911. * @param renderingGroupId The rendering group id corresponding to its index
  36912. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36913. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36914. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36915. */
  36916. 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;
  36917. /**
  36918. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36919. *
  36920. * @param renderingGroupId The rendering group id corresponding to its index
  36921. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36922. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36923. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36924. */
  36925. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36926. /**
  36927. * Gets the current auto clear configuration for one rendering group of the rendering
  36928. * manager.
  36929. * @param index the rendering group index to get the information for
  36930. * @returns The auto clear setup for the requested rendering group
  36931. */
  36932. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36933. private _blockMaterialDirtyMechanism;
  36934. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36935. get blockMaterialDirtyMechanism(): boolean;
  36936. set blockMaterialDirtyMechanism(value: boolean);
  36937. /**
  36938. * Will flag all materials as dirty to trigger new shader compilation
  36939. * @param flag defines the flag used to specify which material part must be marked as dirty
  36940. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36941. */
  36942. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36943. /** @hidden */
  36944. _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;
  36945. /** @hidden */
  36946. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36947. /** @hidden */
  36948. _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;
  36949. /** @hidden */
  36950. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36951. /** @hidden */
  36952. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36953. /** @hidden */
  36954. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36955. }
  36956. }
  36957. declare module BABYLON {
  36958. /**
  36959. * Set of assets to keep when moving a scene into an asset container.
  36960. */
  36961. export class KeepAssets extends AbstractScene {
  36962. }
  36963. /**
  36964. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36965. */
  36966. export class InstantiatedEntries {
  36967. /**
  36968. * List of new root nodes (eg. nodes with no parent)
  36969. */
  36970. rootNodes: TransformNode[];
  36971. /**
  36972. * List of new skeletons
  36973. */
  36974. skeletons: Skeleton[];
  36975. /**
  36976. * List of new animation groups
  36977. */
  36978. animationGroups: AnimationGroup[];
  36979. }
  36980. /**
  36981. * Container with a set of assets that can be added or removed from a scene.
  36982. */
  36983. export class AssetContainer extends AbstractScene {
  36984. private _wasAddedToScene;
  36985. /**
  36986. * The scene the AssetContainer belongs to.
  36987. */
  36988. scene: Scene;
  36989. /**
  36990. * Instantiates an AssetContainer.
  36991. * @param scene The scene the AssetContainer belongs to.
  36992. */
  36993. constructor(scene: Scene);
  36994. /**
  36995. * Instantiate or clone all meshes and add the new ones to the scene.
  36996. * Skeletons and animation groups will all be cloned
  36997. * @param nameFunction defines an optional function used to get new names for clones
  36998. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36999. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37000. */
  37001. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37002. /**
  37003. * Adds all the assets from the container to the scene.
  37004. */
  37005. addAllToScene(): void;
  37006. /**
  37007. * Removes all the assets in the container from the scene
  37008. */
  37009. removeAllFromScene(): void;
  37010. /**
  37011. * Disposes all the assets in the container
  37012. */
  37013. dispose(): void;
  37014. private _moveAssets;
  37015. /**
  37016. * Removes all the assets contained in the scene and adds them to the container.
  37017. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37018. */
  37019. moveAllFromScene(keepAssets?: KeepAssets): void;
  37020. /**
  37021. * 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.
  37022. * @returns the root mesh
  37023. */
  37024. createRootMesh(): Mesh;
  37025. /**
  37026. * Merge animations from this asset container into a scene
  37027. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37028. * @param animatables set of animatables to retarget to a node from the scene
  37029. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37030. */
  37031. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37032. }
  37033. }
  37034. declare module BABYLON {
  37035. /**
  37036. * Defines how the parser contract is defined.
  37037. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37038. */
  37039. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37040. /**
  37041. * Defines how the individual parser contract is defined.
  37042. * These parser can parse an individual asset
  37043. */
  37044. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37045. /**
  37046. * Base class of the scene acting as a container for the different elements composing a scene.
  37047. * This class is dynamically extended by the different components of the scene increasing
  37048. * flexibility and reducing coupling
  37049. */
  37050. export abstract class AbstractScene {
  37051. /**
  37052. * Stores the list of available parsers in the application.
  37053. */
  37054. private static _BabylonFileParsers;
  37055. /**
  37056. * Stores the list of available individual parsers in the application.
  37057. */
  37058. private static _IndividualBabylonFileParsers;
  37059. /**
  37060. * Adds a parser in the list of available ones
  37061. * @param name Defines the name of the parser
  37062. * @param parser Defines the parser to add
  37063. */
  37064. static AddParser(name: string, parser: BabylonFileParser): void;
  37065. /**
  37066. * Gets a general parser from the list of avaialble ones
  37067. * @param name Defines the name of the parser
  37068. * @returns the requested parser or null
  37069. */
  37070. static GetParser(name: string): Nullable<BabylonFileParser>;
  37071. /**
  37072. * Adds n individual parser in the list of available ones
  37073. * @param name Defines the name of the parser
  37074. * @param parser Defines the parser to add
  37075. */
  37076. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37077. /**
  37078. * Gets an individual parser from the list of avaialble ones
  37079. * @param name Defines the name of the parser
  37080. * @returns the requested parser or null
  37081. */
  37082. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37083. /**
  37084. * Parser json data and populate both a scene and its associated container object
  37085. * @param jsonData Defines the data to parse
  37086. * @param scene Defines the scene to parse the data for
  37087. * @param container Defines the container attached to the parsing sequence
  37088. * @param rootUrl Defines the root url of the data
  37089. */
  37090. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37091. /**
  37092. * Gets the list of root nodes (ie. nodes with no parent)
  37093. */
  37094. rootNodes: Node[];
  37095. /** All of the cameras added to this scene
  37096. * @see http://doc.babylonjs.com/babylon101/cameras
  37097. */
  37098. cameras: Camera[];
  37099. /**
  37100. * All of the lights added to this scene
  37101. * @see http://doc.babylonjs.com/babylon101/lights
  37102. */
  37103. lights: Light[];
  37104. /**
  37105. * All of the (abstract) meshes added to this scene
  37106. */
  37107. meshes: AbstractMesh[];
  37108. /**
  37109. * The list of skeletons added to the scene
  37110. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37111. */
  37112. skeletons: Skeleton[];
  37113. /**
  37114. * All of the particle systems added to this scene
  37115. * @see http://doc.babylonjs.com/babylon101/particles
  37116. */
  37117. particleSystems: IParticleSystem[];
  37118. /**
  37119. * Gets a list of Animations associated with the scene
  37120. */
  37121. animations: Animation[];
  37122. /**
  37123. * All of the animation groups added to this scene
  37124. * @see http://doc.babylonjs.com/how_to/group
  37125. */
  37126. animationGroups: AnimationGroup[];
  37127. /**
  37128. * All of the multi-materials added to this scene
  37129. * @see http://doc.babylonjs.com/how_to/multi_materials
  37130. */
  37131. multiMaterials: MultiMaterial[];
  37132. /**
  37133. * All of the materials added to this scene
  37134. * In the context of a Scene, it is not supposed to be modified manually.
  37135. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37136. * Note also that the order of the Material within the array is not significant and might change.
  37137. * @see http://doc.babylonjs.com/babylon101/materials
  37138. */
  37139. materials: Material[];
  37140. /**
  37141. * The list of morph target managers added to the scene
  37142. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37143. */
  37144. morphTargetManagers: MorphTargetManager[];
  37145. /**
  37146. * The list of geometries used in the scene.
  37147. */
  37148. geometries: Geometry[];
  37149. /**
  37150. * All of the tranform nodes added to this scene
  37151. * In the context of a Scene, it is not supposed to be modified manually.
  37152. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37153. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37154. * @see http://doc.babylonjs.com/how_to/transformnode
  37155. */
  37156. transformNodes: TransformNode[];
  37157. /**
  37158. * ActionManagers available on the scene.
  37159. */
  37160. actionManagers: AbstractActionManager[];
  37161. /**
  37162. * Textures to keep.
  37163. */
  37164. textures: BaseTexture[];
  37165. /**
  37166. * Environment texture for the scene
  37167. */
  37168. environmentTexture: Nullable<BaseTexture>;
  37169. /**
  37170. * @returns all meshes, lights, cameras, transformNodes and bones
  37171. */
  37172. getNodes(): Array<Node>;
  37173. }
  37174. }
  37175. declare module BABYLON {
  37176. /**
  37177. * Interface used to define options for Sound class
  37178. */
  37179. export interface ISoundOptions {
  37180. /**
  37181. * Does the sound autoplay once loaded.
  37182. */
  37183. autoplay?: boolean;
  37184. /**
  37185. * Does the sound loop after it finishes playing once.
  37186. */
  37187. loop?: boolean;
  37188. /**
  37189. * Sound's volume
  37190. */
  37191. volume?: number;
  37192. /**
  37193. * Is it a spatial sound?
  37194. */
  37195. spatialSound?: boolean;
  37196. /**
  37197. * Maximum distance to hear that sound
  37198. */
  37199. maxDistance?: number;
  37200. /**
  37201. * Uses user defined attenuation function
  37202. */
  37203. useCustomAttenuation?: boolean;
  37204. /**
  37205. * Define the roll off factor of spatial sounds.
  37206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37207. */
  37208. rolloffFactor?: number;
  37209. /**
  37210. * Define the reference distance the sound should be heard perfectly.
  37211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37212. */
  37213. refDistance?: number;
  37214. /**
  37215. * Define the distance attenuation model the sound will follow.
  37216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37217. */
  37218. distanceModel?: string;
  37219. /**
  37220. * Defines the playback speed (1 by default)
  37221. */
  37222. playbackRate?: number;
  37223. /**
  37224. * Defines if the sound is from a streaming source
  37225. */
  37226. streaming?: boolean;
  37227. /**
  37228. * Defines an optional length (in seconds) inside the sound file
  37229. */
  37230. length?: number;
  37231. /**
  37232. * Defines an optional offset (in seconds) inside the sound file
  37233. */
  37234. offset?: number;
  37235. /**
  37236. * If true, URLs will not be required to state the audio file codec to use.
  37237. */
  37238. skipCodecCheck?: boolean;
  37239. }
  37240. /**
  37241. * Defines a sound that can be played in the application.
  37242. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37244. */
  37245. export class Sound {
  37246. /**
  37247. * The name of the sound in the scene.
  37248. */
  37249. name: string;
  37250. /**
  37251. * Does the sound autoplay once loaded.
  37252. */
  37253. autoplay: boolean;
  37254. /**
  37255. * Does the sound loop after it finishes playing once.
  37256. */
  37257. loop: boolean;
  37258. /**
  37259. * Does the sound use a custom attenuation curve to simulate the falloff
  37260. * happening when the source gets further away from the camera.
  37261. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37262. */
  37263. useCustomAttenuation: boolean;
  37264. /**
  37265. * The sound track id this sound belongs to.
  37266. */
  37267. soundTrackId: number;
  37268. /**
  37269. * Is this sound currently played.
  37270. */
  37271. isPlaying: boolean;
  37272. /**
  37273. * Is this sound currently paused.
  37274. */
  37275. isPaused: boolean;
  37276. /**
  37277. * Does this sound enables spatial sound.
  37278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37279. */
  37280. spatialSound: boolean;
  37281. /**
  37282. * Define the reference distance the sound should be heard perfectly.
  37283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37284. */
  37285. refDistance: number;
  37286. /**
  37287. * Define the roll off factor of spatial sounds.
  37288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37289. */
  37290. rolloffFactor: number;
  37291. /**
  37292. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37294. */
  37295. maxDistance: number;
  37296. /**
  37297. * Define the distance attenuation model the sound will follow.
  37298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37299. */
  37300. distanceModel: string;
  37301. /**
  37302. * @hidden
  37303. * Back Compat
  37304. **/
  37305. onended: () => any;
  37306. /**
  37307. * Observable event when the current playing sound finishes.
  37308. */
  37309. onEndedObservable: Observable<Sound>;
  37310. private _panningModel;
  37311. private _playbackRate;
  37312. private _streaming;
  37313. private _startTime;
  37314. private _startOffset;
  37315. private _position;
  37316. /** @hidden */
  37317. _positionInEmitterSpace: boolean;
  37318. private _localDirection;
  37319. private _volume;
  37320. private _isReadyToPlay;
  37321. private _isDirectional;
  37322. private _readyToPlayCallback;
  37323. private _audioBuffer;
  37324. private _soundSource;
  37325. private _streamingSource;
  37326. private _soundPanner;
  37327. private _soundGain;
  37328. private _inputAudioNode;
  37329. private _outputAudioNode;
  37330. private _coneInnerAngle;
  37331. private _coneOuterAngle;
  37332. private _coneOuterGain;
  37333. private _scene;
  37334. private _connectedTransformNode;
  37335. private _customAttenuationFunction;
  37336. private _registerFunc;
  37337. private _isOutputConnected;
  37338. private _htmlAudioElement;
  37339. private _urlType;
  37340. private _length?;
  37341. private _offset?;
  37342. /** @hidden */
  37343. static _SceneComponentInitialization: (scene: Scene) => void;
  37344. /**
  37345. * Create a sound and attach it to a scene
  37346. * @param name Name of your sound
  37347. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37348. * @param scene defines the scene the sound belongs to
  37349. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37350. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37351. */
  37352. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37353. /**
  37354. * Release the sound and its associated resources
  37355. */
  37356. dispose(): void;
  37357. /**
  37358. * Gets if the sounds is ready to be played or not.
  37359. * @returns true if ready, otherwise false
  37360. */
  37361. isReady(): boolean;
  37362. private _soundLoaded;
  37363. /**
  37364. * Sets the data of the sound from an audiobuffer
  37365. * @param audioBuffer The audioBuffer containing the data
  37366. */
  37367. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37368. /**
  37369. * Updates the current sounds options such as maxdistance, loop...
  37370. * @param options A JSON object containing values named as the object properties
  37371. */
  37372. updateOptions(options: ISoundOptions): void;
  37373. private _createSpatialParameters;
  37374. private _updateSpatialParameters;
  37375. /**
  37376. * Switch the panning model to HRTF:
  37377. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37378. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37379. */
  37380. switchPanningModelToHRTF(): void;
  37381. /**
  37382. * Switch the panning model to Equal Power:
  37383. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37385. */
  37386. switchPanningModelToEqualPower(): void;
  37387. private _switchPanningModel;
  37388. /**
  37389. * Connect this sound to a sound track audio node like gain...
  37390. * @param soundTrackAudioNode the sound track audio node to connect to
  37391. */
  37392. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37393. /**
  37394. * Transform this sound into a directional source
  37395. * @param coneInnerAngle Size of the inner cone in degree
  37396. * @param coneOuterAngle Size of the outer cone in degree
  37397. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37398. */
  37399. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37400. /**
  37401. * Gets or sets the inner angle for the directional cone.
  37402. */
  37403. get directionalConeInnerAngle(): number;
  37404. /**
  37405. * Gets or sets the inner angle for the directional cone.
  37406. */
  37407. set directionalConeInnerAngle(value: number);
  37408. /**
  37409. * Gets or sets the outer angle for the directional cone.
  37410. */
  37411. get directionalConeOuterAngle(): number;
  37412. /**
  37413. * Gets or sets the outer angle for the directional cone.
  37414. */
  37415. set directionalConeOuterAngle(value: number);
  37416. /**
  37417. * Sets the position of the emitter if spatial sound is enabled
  37418. * @param newPosition Defines the new posisiton
  37419. */
  37420. setPosition(newPosition: Vector3): void;
  37421. /**
  37422. * Sets the local direction of the emitter if spatial sound is enabled
  37423. * @param newLocalDirection Defines the new local direction
  37424. */
  37425. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37426. private _updateDirection;
  37427. /** @hidden */
  37428. updateDistanceFromListener(): void;
  37429. /**
  37430. * Sets a new custom attenuation function for the sound.
  37431. * @param callback Defines the function used for the attenuation
  37432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37433. */
  37434. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37435. /**
  37436. * Play the sound
  37437. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37438. * @param offset (optional) Start the sound at a specific time in seconds
  37439. * @param length (optional) Sound duration (in seconds)
  37440. */
  37441. play(time?: number, offset?: number, length?: number): void;
  37442. private _onended;
  37443. /**
  37444. * Stop the sound
  37445. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37446. */
  37447. stop(time?: number): void;
  37448. /**
  37449. * Put the sound in pause
  37450. */
  37451. pause(): void;
  37452. /**
  37453. * Sets a dedicated volume for this sounds
  37454. * @param newVolume Define the new volume of the sound
  37455. * @param time Define time for gradual change to new volume
  37456. */
  37457. setVolume(newVolume: number, time?: number): void;
  37458. /**
  37459. * Set the sound play back rate
  37460. * @param newPlaybackRate Define the playback rate the sound should be played at
  37461. */
  37462. setPlaybackRate(newPlaybackRate: number): void;
  37463. /**
  37464. * Gets the volume of the sound.
  37465. * @returns the volume of the sound
  37466. */
  37467. getVolume(): number;
  37468. /**
  37469. * Attach the sound to a dedicated mesh
  37470. * @param transformNode The transform node to connect the sound with
  37471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37472. */
  37473. attachToMesh(transformNode: TransformNode): void;
  37474. /**
  37475. * Detach the sound from the previously attached mesh
  37476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37477. */
  37478. detachFromMesh(): void;
  37479. private _onRegisterAfterWorldMatrixUpdate;
  37480. /**
  37481. * Clone the current sound in the scene.
  37482. * @returns the new sound clone
  37483. */
  37484. clone(): Nullable<Sound>;
  37485. /**
  37486. * Gets the current underlying audio buffer containing the data
  37487. * @returns the audio buffer
  37488. */
  37489. getAudioBuffer(): Nullable<AudioBuffer>;
  37490. /**
  37491. * Serializes the Sound in a JSON representation
  37492. * @returns the JSON representation of the sound
  37493. */
  37494. serialize(): any;
  37495. /**
  37496. * Parse a JSON representation of a sound to innstantiate in a given scene
  37497. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37498. * @param scene Define the scene the new parsed sound should be created in
  37499. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37500. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37501. * @returns the newly parsed sound
  37502. */
  37503. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37504. }
  37505. }
  37506. declare module BABYLON {
  37507. /**
  37508. * This defines an action helpful to play a defined sound on a triggered action.
  37509. */
  37510. export class PlaySoundAction extends Action {
  37511. private _sound;
  37512. /**
  37513. * Instantiate the action
  37514. * @param triggerOptions defines the trigger options
  37515. * @param sound defines the sound to play
  37516. * @param condition defines the trigger related conditions
  37517. */
  37518. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37519. /** @hidden */
  37520. _prepare(): void;
  37521. /**
  37522. * Execute the action and play the sound.
  37523. */
  37524. execute(): void;
  37525. /**
  37526. * Serializes the actions and its related information.
  37527. * @param parent defines the object to serialize in
  37528. * @returns the serialized object
  37529. */
  37530. serialize(parent: any): any;
  37531. }
  37532. /**
  37533. * This defines an action helpful to stop a defined sound on a triggered action.
  37534. */
  37535. export class StopSoundAction extends Action {
  37536. private _sound;
  37537. /**
  37538. * Instantiate the action
  37539. * @param triggerOptions defines the trigger options
  37540. * @param sound defines the sound to stop
  37541. * @param condition defines the trigger related conditions
  37542. */
  37543. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37544. /** @hidden */
  37545. _prepare(): void;
  37546. /**
  37547. * Execute the action and stop the sound.
  37548. */
  37549. execute(): void;
  37550. /**
  37551. * Serializes the actions and its related information.
  37552. * @param parent defines the object to serialize in
  37553. * @returns the serialized object
  37554. */
  37555. serialize(parent: any): any;
  37556. }
  37557. }
  37558. declare module BABYLON {
  37559. /**
  37560. * This defines an action responsible to change the value of a property
  37561. * by interpolating between its current value and the newly set one once triggered.
  37562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37563. */
  37564. export class InterpolateValueAction extends Action {
  37565. /**
  37566. * Defines the path of the property where the value should be interpolated
  37567. */
  37568. propertyPath: string;
  37569. /**
  37570. * Defines the target value at the end of the interpolation.
  37571. */
  37572. value: any;
  37573. /**
  37574. * Defines the time it will take for the property to interpolate to the value.
  37575. */
  37576. duration: number;
  37577. /**
  37578. * Defines if the other scene animations should be stopped when the action has been triggered
  37579. */
  37580. stopOtherAnimations?: boolean;
  37581. /**
  37582. * Defines a callback raised once the interpolation animation has been done.
  37583. */
  37584. onInterpolationDone?: () => void;
  37585. /**
  37586. * Observable triggered once the interpolation animation has been done.
  37587. */
  37588. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37589. private _target;
  37590. private _effectiveTarget;
  37591. private _property;
  37592. /**
  37593. * Instantiate the action
  37594. * @param triggerOptions defines the trigger options
  37595. * @param target defines the object containing the value to interpolate
  37596. * @param propertyPath defines the path to the property in the target object
  37597. * @param value defines the target value at the end of the interpolation
  37598. * @param duration deines the time it will take for the property to interpolate to the value.
  37599. * @param condition defines the trigger related conditions
  37600. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37601. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37602. */
  37603. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37604. /** @hidden */
  37605. _prepare(): void;
  37606. /**
  37607. * Execute the action starts the value interpolation.
  37608. */
  37609. execute(): void;
  37610. /**
  37611. * Serializes the actions and its related information.
  37612. * @param parent defines the object to serialize in
  37613. * @returns the serialized object
  37614. */
  37615. serialize(parent: any): any;
  37616. }
  37617. }
  37618. declare module BABYLON {
  37619. /**
  37620. * Options allowed during the creation of a sound track.
  37621. */
  37622. export interface ISoundTrackOptions {
  37623. /**
  37624. * The volume the sound track should take during creation
  37625. */
  37626. volume?: number;
  37627. /**
  37628. * Define if the sound track is the main sound track of the scene
  37629. */
  37630. mainTrack?: boolean;
  37631. }
  37632. /**
  37633. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37634. * It will be also used in a future release to apply effects on a specific track.
  37635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37636. */
  37637. export class SoundTrack {
  37638. /**
  37639. * The unique identifier of the sound track in the scene.
  37640. */
  37641. id: number;
  37642. /**
  37643. * The list of sounds included in the sound track.
  37644. */
  37645. soundCollection: Array<Sound>;
  37646. private _outputAudioNode;
  37647. private _scene;
  37648. private _connectedAnalyser;
  37649. private _options;
  37650. private _isInitialized;
  37651. /**
  37652. * Creates a new sound track.
  37653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37654. * @param scene Define the scene the sound track belongs to
  37655. * @param options
  37656. */
  37657. constructor(scene: Scene, options?: ISoundTrackOptions);
  37658. private _initializeSoundTrackAudioGraph;
  37659. /**
  37660. * Release the sound track and its associated resources
  37661. */
  37662. dispose(): void;
  37663. /**
  37664. * Adds a sound to this sound track
  37665. * @param sound define the cound to add
  37666. * @ignoreNaming
  37667. */
  37668. AddSound(sound: Sound): void;
  37669. /**
  37670. * Removes a sound to this sound track
  37671. * @param sound define the cound to remove
  37672. * @ignoreNaming
  37673. */
  37674. RemoveSound(sound: Sound): void;
  37675. /**
  37676. * Set a global volume for the full sound track.
  37677. * @param newVolume Define the new volume of the sound track
  37678. */
  37679. setVolume(newVolume: number): void;
  37680. /**
  37681. * Switch the panning model to HRTF:
  37682. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37684. */
  37685. switchPanningModelToHRTF(): void;
  37686. /**
  37687. * Switch the panning model to Equal Power:
  37688. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37690. */
  37691. switchPanningModelToEqualPower(): void;
  37692. /**
  37693. * Connect the sound track to an audio analyser allowing some amazing
  37694. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37696. * @param analyser The analyser to connect to the engine
  37697. */
  37698. connectToAnalyser(analyser: Analyser): void;
  37699. }
  37700. }
  37701. declare module BABYLON {
  37702. interface AbstractScene {
  37703. /**
  37704. * The list of sounds used in the scene.
  37705. */
  37706. sounds: Nullable<Array<Sound>>;
  37707. }
  37708. interface Scene {
  37709. /**
  37710. * @hidden
  37711. * Backing field
  37712. */
  37713. _mainSoundTrack: SoundTrack;
  37714. /**
  37715. * The main sound track played by the scene.
  37716. * It cotains your primary collection of sounds.
  37717. */
  37718. mainSoundTrack: SoundTrack;
  37719. /**
  37720. * The list of sound tracks added to the scene
  37721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37722. */
  37723. soundTracks: Nullable<Array<SoundTrack>>;
  37724. /**
  37725. * Gets a sound using a given name
  37726. * @param name defines the name to search for
  37727. * @return the found sound or null if not found at all.
  37728. */
  37729. getSoundByName(name: string): Nullable<Sound>;
  37730. /**
  37731. * Gets or sets if audio support is enabled
  37732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37733. */
  37734. audioEnabled: boolean;
  37735. /**
  37736. * Gets or sets if audio will be output to headphones
  37737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37738. */
  37739. headphone: boolean;
  37740. /**
  37741. * Gets or sets custom audio listener position provider
  37742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37743. */
  37744. audioListenerPositionProvider: Nullable<() => Vector3>;
  37745. /**
  37746. * Gets or sets a refresh rate when using 3D audio positioning
  37747. */
  37748. audioPositioningRefreshRate: number;
  37749. }
  37750. /**
  37751. * Defines the sound scene component responsible to manage any sounds
  37752. * in a given scene.
  37753. */
  37754. export class AudioSceneComponent implements ISceneSerializableComponent {
  37755. /**
  37756. * The component name helpfull to identify the component in the list of scene components.
  37757. */
  37758. readonly name: string;
  37759. /**
  37760. * The scene the component belongs to.
  37761. */
  37762. scene: Scene;
  37763. private _audioEnabled;
  37764. /**
  37765. * Gets whether audio is enabled or not.
  37766. * Please use related enable/disable method to switch state.
  37767. */
  37768. get audioEnabled(): boolean;
  37769. private _headphone;
  37770. /**
  37771. * Gets whether audio is outputing to headphone or not.
  37772. * Please use the according Switch methods to change output.
  37773. */
  37774. get headphone(): boolean;
  37775. /**
  37776. * Gets or sets a refresh rate when using 3D audio positioning
  37777. */
  37778. audioPositioningRefreshRate: number;
  37779. private _audioListenerPositionProvider;
  37780. /**
  37781. * Gets the current audio listener position provider
  37782. */
  37783. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37784. /**
  37785. * Sets a custom listener position for all sounds in the scene
  37786. * By default, this is the position of the first active camera
  37787. */
  37788. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37789. /**
  37790. * Creates a new instance of the component for the given scene
  37791. * @param scene Defines the scene to register the component in
  37792. */
  37793. constructor(scene: Scene);
  37794. /**
  37795. * Registers the component in a given scene
  37796. */
  37797. register(): void;
  37798. /**
  37799. * Rebuilds the elements related to this component in case of
  37800. * context lost for instance.
  37801. */
  37802. rebuild(): void;
  37803. /**
  37804. * Serializes the component data to the specified json object
  37805. * @param serializationObject The object to serialize to
  37806. */
  37807. serialize(serializationObject: any): void;
  37808. /**
  37809. * Adds all the elements from the container to the scene
  37810. * @param container the container holding the elements
  37811. */
  37812. addFromContainer(container: AbstractScene): void;
  37813. /**
  37814. * Removes all the elements in the container from the scene
  37815. * @param container contains the elements to remove
  37816. * @param dispose if the removed element should be disposed (default: false)
  37817. */
  37818. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37819. /**
  37820. * Disposes the component and the associated ressources.
  37821. */
  37822. dispose(): void;
  37823. /**
  37824. * Disables audio in the associated scene.
  37825. */
  37826. disableAudio(): void;
  37827. /**
  37828. * Enables audio in the associated scene.
  37829. */
  37830. enableAudio(): void;
  37831. /**
  37832. * Switch audio to headphone output.
  37833. */
  37834. switchAudioModeForHeadphones(): void;
  37835. /**
  37836. * Switch audio to normal speakers.
  37837. */
  37838. switchAudioModeForNormalSpeakers(): void;
  37839. private _cachedCameraDirection;
  37840. private _cachedCameraPosition;
  37841. private _lastCheck;
  37842. private _afterRender;
  37843. }
  37844. }
  37845. declare module BABYLON {
  37846. /**
  37847. * Wraps one or more Sound objects and selects one with random weight for playback.
  37848. */
  37849. export class WeightedSound {
  37850. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37851. loop: boolean;
  37852. private _coneInnerAngle;
  37853. private _coneOuterAngle;
  37854. private _volume;
  37855. /** A Sound is currently playing. */
  37856. isPlaying: boolean;
  37857. /** A Sound is currently paused. */
  37858. isPaused: boolean;
  37859. private _sounds;
  37860. private _weights;
  37861. private _currentIndex?;
  37862. /**
  37863. * Creates a new WeightedSound from the list of sounds given.
  37864. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37865. * @param sounds Array of Sounds that will be selected from.
  37866. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37867. */
  37868. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37869. /**
  37870. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37871. */
  37872. get directionalConeInnerAngle(): number;
  37873. /**
  37874. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37875. */
  37876. set directionalConeInnerAngle(value: number);
  37877. /**
  37878. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37879. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37880. */
  37881. get directionalConeOuterAngle(): number;
  37882. /**
  37883. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37884. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37885. */
  37886. set directionalConeOuterAngle(value: number);
  37887. /**
  37888. * Playback volume.
  37889. */
  37890. get volume(): number;
  37891. /**
  37892. * Playback volume.
  37893. */
  37894. set volume(value: number);
  37895. private _onended;
  37896. /**
  37897. * Suspend playback
  37898. */
  37899. pause(): void;
  37900. /**
  37901. * Stop playback
  37902. */
  37903. stop(): void;
  37904. /**
  37905. * Start playback.
  37906. * @param startOffset Position the clip head at a specific time in seconds.
  37907. */
  37908. play(startOffset?: number): void;
  37909. }
  37910. }
  37911. declare module BABYLON {
  37912. /**
  37913. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37914. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37915. */
  37916. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37917. /**
  37918. * Gets the name of the behavior.
  37919. */
  37920. get name(): string;
  37921. /**
  37922. * The easing function used by animations
  37923. */
  37924. static EasingFunction: BackEase;
  37925. /**
  37926. * The easing mode used by animations
  37927. */
  37928. static EasingMode: number;
  37929. /**
  37930. * The duration of the animation, in milliseconds
  37931. */
  37932. transitionDuration: number;
  37933. /**
  37934. * Length of the distance animated by the transition when lower radius is reached
  37935. */
  37936. lowerRadiusTransitionRange: number;
  37937. /**
  37938. * Length of the distance animated by the transition when upper radius is reached
  37939. */
  37940. upperRadiusTransitionRange: number;
  37941. private _autoTransitionRange;
  37942. /**
  37943. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37944. */
  37945. get autoTransitionRange(): boolean;
  37946. /**
  37947. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37948. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37949. */
  37950. set autoTransitionRange(value: boolean);
  37951. private _attachedCamera;
  37952. private _onAfterCheckInputsObserver;
  37953. private _onMeshTargetChangedObserver;
  37954. /**
  37955. * Initializes the behavior.
  37956. */
  37957. init(): void;
  37958. /**
  37959. * Attaches the behavior to its arc rotate camera.
  37960. * @param camera Defines the camera to attach the behavior to
  37961. */
  37962. attach(camera: ArcRotateCamera): void;
  37963. /**
  37964. * Detaches the behavior from its current arc rotate camera.
  37965. */
  37966. detach(): void;
  37967. private _radiusIsAnimating;
  37968. private _radiusBounceTransition;
  37969. private _animatables;
  37970. private _cachedWheelPrecision;
  37971. /**
  37972. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37973. * @param radiusLimit The limit to check against.
  37974. * @return Bool to indicate if at limit.
  37975. */
  37976. private _isRadiusAtLimit;
  37977. /**
  37978. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37979. * @param radiusDelta The delta by which to animate to. Can be negative.
  37980. */
  37981. private _applyBoundRadiusAnimation;
  37982. /**
  37983. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37984. */
  37985. protected _clearAnimationLocks(): void;
  37986. /**
  37987. * Stops and removes all animations that have been applied to the camera
  37988. */
  37989. stopAllAnimations(): void;
  37990. }
  37991. }
  37992. declare module BABYLON {
  37993. /**
  37994. * 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.
  37995. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37996. */
  37997. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37998. /**
  37999. * Gets the name of the behavior.
  38000. */
  38001. get name(): string;
  38002. private _mode;
  38003. private _radiusScale;
  38004. private _positionScale;
  38005. private _defaultElevation;
  38006. private _elevationReturnTime;
  38007. private _elevationReturnWaitTime;
  38008. private _zoomStopsAnimation;
  38009. private _framingTime;
  38010. /**
  38011. * The easing function used by animations
  38012. */
  38013. static EasingFunction: ExponentialEase;
  38014. /**
  38015. * The easing mode used by animations
  38016. */
  38017. static EasingMode: number;
  38018. /**
  38019. * Sets the current mode used by the behavior
  38020. */
  38021. set mode(mode: number);
  38022. /**
  38023. * Gets current mode used by the behavior.
  38024. */
  38025. get mode(): number;
  38026. /**
  38027. * Sets the scale applied to the radius (1 by default)
  38028. */
  38029. set radiusScale(radius: number);
  38030. /**
  38031. * Gets the scale applied to the radius
  38032. */
  38033. get radiusScale(): number;
  38034. /**
  38035. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38036. */
  38037. set positionScale(scale: number);
  38038. /**
  38039. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38040. */
  38041. get positionScale(): number;
  38042. /**
  38043. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38044. * behaviour is triggered, in radians.
  38045. */
  38046. set defaultElevation(elevation: number);
  38047. /**
  38048. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38049. * behaviour is triggered, in radians.
  38050. */
  38051. get defaultElevation(): number;
  38052. /**
  38053. * Sets the time (in milliseconds) taken to return to the default beta position.
  38054. * Negative value indicates camera should not return to default.
  38055. */
  38056. set elevationReturnTime(speed: number);
  38057. /**
  38058. * Gets the time (in milliseconds) taken to return to the default beta position.
  38059. * Negative value indicates camera should not return to default.
  38060. */
  38061. get elevationReturnTime(): number;
  38062. /**
  38063. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38064. */
  38065. set elevationReturnWaitTime(time: number);
  38066. /**
  38067. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38068. */
  38069. get elevationReturnWaitTime(): number;
  38070. /**
  38071. * Sets the flag that indicates if user zooming should stop animation.
  38072. */
  38073. set zoomStopsAnimation(flag: boolean);
  38074. /**
  38075. * Gets the flag that indicates if user zooming should stop animation.
  38076. */
  38077. get zoomStopsAnimation(): boolean;
  38078. /**
  38079. * Sets the transition time when framing the mesh, in milliseconds
  38080. */
  38081. set framingTime(time: number);
  38082. /**
  38083. * Gets the transition time when framing the mesh, in milliseconds
  38084. */
  38085. get framingTime(): number;
  38086. /**
  38087. * Define if the behavior should automatically change the configured
  38088. * camera limits and sensibilities.
  38089. */
  38090. autoCorrectCameraLimitsAndSensibility: boolean;
  38091. private _onPrePointerObservableObserver;
  38092. private _onAfterCheckInputsObserver;
  38093. private _onMeshTargetChangedObserver;
  38094. private _attachedCamera;
  38095. private _isPointerDown;
  38096. private _lastInteractionTime;
  38097. /**
  38098. * Initializes the behavior.
  38099. */
  38100. init(): void;
  38101. /**
  38102. * Attaches the behavior to its arc rotate camera.
  38103. * @param camera Defines the camera to attach the behavior to
  38104. */
  38105. attach(camera: ArcRotateCamera): void;
  38106. /**
  38107. * Detaches the behavior from its current arc rotate camera.
  38108. */
  38109. detach(): void;
  38110. private _animatables;
  38111. private _betaIsAnimating;
  38112. private _betaTransition;
  38113. private _radiusTransition;
  38114. private _vectorTransition;
  38115. /**
  38116. * Targets the given mesh and updates zoom level accordingly.
  38117. * @param mesh The mesh to target.
  38118. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38119. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38120. */
  38121. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38122. /**
  38123. * Targets the given mesh with its children and updates zoom level accordingly.
  38124. * @param mesh The mesh to target.
  38125. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38126. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38127. */
  38128. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38129. /**
  38130. * Targets the given meshes with their children and updates zoom level accordingly.
  38131. * @param meshes The mesh to target.
  38132. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38133. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38134. */
  38135. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38136. /**
  38137. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38138. * @param minimumWorld Determines the smaller position of the bounding box extend
  38139. * @param maximumWorld Determines the bigger position of the bounding box extend
  38140. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38141. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38142. */
  38143. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38144. /**
  38145. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38146. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38147. * frustum width.
  38148. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38149. * to fully enclose the mesh in the viewing frustum.
  38150. */
  38151. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38152. /**
  38153. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38154. * is automatically returned to its default position (expected to be above ground plane).
  38155. */
  38156. private _maintainCameraAboveGround;
  38157. /**
  38158. * Returns the frustum slope based on the canvas ratio and camera FOV
  38159. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38160. */
  38161. private _getFrustumSlope;
  38162. /**
  38163. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38164. */
  38165. private _clearAnimationLocks;
  38166. /**
  38167. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38168. */
  38169. private _applyUserInteraction;
  38170. /**
  38171. * Stops and removes all animations that have been applied to the camera
  38172. */
  38173. stopAllAnimations(): void;
  38174. /**
  38175. * Gets a value indicating if the user is moving the camera
  38176. */
  38177. get isUserIsMoving(): boolean;
  38178. /**
  38179. * The camera can move all the way towards the mesh.
  38180. */
  38181. static IgnoreBoundsSizeMode: number;
  38182. /**
  38183. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38184. */
  38185. static FitFrustumSidesMode: number;
  38186. }
  38187. }
  38188. declare module BABYLON {
  38189. /**
  38190. * Base class for Camera Pointer Inputs.
  38191. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38192. * for example usage.
  38193. */
  38194. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38195. /**
  38196. * Defines the camera the input is attached to.
  38197. */
  38198. abstract camera: Camera;
  38199. /**
  38200. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38201. */
  38202. protected _altKey: boolean;
  38203. protected _ctrlKey: boolean;
  38204. protected _metaKey: boolean;
  38205. protected _shiftKey: boolean;
  38206. /**
  38207. * Which mouse buttons were pressed at time of last mouse event.
  38208. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38209. */
  38210. protected _buttonsPressed: number;
  38211. /**
  38212. * Defines the buttons associated with the input to handle camera move.
  38213. */
  38214. buttons: number[];
  38215. /**
  38216. * Attach the input controls to a specific dom element to get the input from.
  38217. * @param element Defines the element the controls should be listened from
  38218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38219. */
  38220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38221. /**
  38222. * Detach the current controls from the specified dom element.
  38223. * @param element Defines the element to stop listening the inputs from
  38224. */
  38225. detachControl(element: Nullable<HTMLElement>): void;
  38226. /**
  38227. * Gets the class name of the current input.
  38228. * @returns the class name
  38229. */
  38230. getClassName(): string;
  38231. /**
  38232. * Get the friendly name associated with the input class.
  38233. * @returns the input friendly name
  38234. */
  38235. getSimpleName(): string;
  38236. /**
  38237. * Called on pointer POINTERDOUBLETAP event.
  38238. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38239. */
  38240. protected onDoubleTap(type: string): void;
  38241. /**
  38242. * Called on pointer POINTERMOVE event if only a single touch is active.
  38243. * Override this method to provide functionality.
  38244. */
  38245. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38246. /**
  38247. * Called on pointer POINTERMOVE event if multiple touches are active.
  38248. * Override this method to provide functionality.
  38249. */
  38250. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38251. /**
  38252. * Called on JS contextmenu event.
  38253. * Override this method to provide functionality.
  38254. */
  38255. protected onContextMenu(evt: PointerEvent): void;
  38256. /**
  38257. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38258. * press.
  38259. * Override this method to provide functionality.
  38260. */
  38261. protected onButtonDown(evt: PointerEvent): void;
  38262. /**
  38263. * Called each time a new POINTERUP event occurs. Ie, for each button
  38264. * release.
  38265. * Override this method to provide functionality.
  38266. */
  38267. protected onButtonUp(evt: PointerEvent): void;
  38268. /**
  38269. * Called when window becomes inactive.
  38270. * Override this method to provide functionality.
  38271. */
  38272. protected onLostFocus(): void;
  38273. private _pointerInput;
  38274. private _observer;
  38275. private _onLostFocus;
  38276. private pointA;
  38277. private pointB;
  38278. }
  38279. }
  38280. declare module BABYLON {
  38281. /**
  38282. * Manage the pointers inputs to control an arc rotate camera.
  38283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38284. */
  38285. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38286. /**
  38287. * Defines the camera the input is attached to.
  38288. */
  38289. camera: ArcRotateCamera;
  38290. /**
  38291. * Gets the class name of the current input.
  38292. * @returns the class name
  38293. */
  38294. getClassName(): string;
  38295. /**
  38296. * Defines the buttons associated with the input to handle camera move.
  38297. */
  38298. buttons: number[];
  38299. /**
  38300. * Defines the pointer angular sensibility along the X axis or how fast is
  38301. * the camera rotating.
  38302. */
  38303. angularSensibilityX: number;
  38304. /**
  38305. * Defines the pointer angular sensibility along the Y axis or how fast is
  38306. * the camera rotating.
  38307. */
  38308. angularSensibilityY: number;
  38309. /**
  38310. * Defines the pointer pinch precision or how fast is the camera zooming.
  38311. */
  38312. pinchPrecision: number;
  38313. /**
  38314. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38315. * from 0.
  38316. * It defines the percentage of current camera.radius to use as delta when
  38317. * pinch zoom is used.
  38318. */
  38319. pinchDeltaPercentage: number;
  38320. /**
  38321. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38322. * that any object in the plane at the camera's target point will scale
  38323. * perfectly with finger motion.
  38324. * Overrides pinchDeltaPercentage and pinchPrecision.
  38325. */
  38326. useNaturalPinchZoom: boolean;
  38327. /**
  38328. * Defines the pointer panning sensibility or how fast is the camera moving.
  38329. */
  38330. panningSensibility: number;
  38331. /**
  38332. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38333. */
  38334. multiTouchPanning: boolean;
  38335. /**
  38336. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38337. * zoom (pinch) through multitouch.
  38338. */
  38339. multiTouchPanAndZoom: boolean;
  38340. /**
  38341. * Revers pinch action direction.
  38342. */
  38343. pinchInwards: boolean;
  38344. private _isPanClick;
  38345. private _twoFingerActivityCount;
  38346. private _isPinching;
  38347. /**
  38348. * Called on pointer POINTERMOVE event if only a single touch is active.
  38349. */
  38350. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38351. /**
  38352. * Called on pointer POINTERDOUBLETAP event.
  38353. */
  38354. protected onDoubleTap(type: string): void;
  38355. /**
  38356. * Called on pointer POINTERMOVE event if multiple touches are active.
  38357. */
  38358. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38359. /**
  38360. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38361. * press.
  38362. */
  38363. protected onButtonDown(evt: PointerEvent): void;
  38364. /**
  38365. * Called each time a new POINTERUP event occurs. Ie, for each button
  38366. * release.
  38367. */
  38368. protected onButtonUp(evt: PointerEvent): void;
  38369. /**
  38370. * Called when window becomes inactive.
  38371. */
  38372. protected onLostFocus(): void;
  38373. }
  38374. }
  38375. declare module BABYLON {
  38376. /**
  38377. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38379. */
  38380. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38381. /**
  38382. * Defines the camera the input is attached to.
  38383. */
  38384. camera: ArcRotateCamera;
  38385. /**
  38386. * Defines the list of key codes associated with the up action (increase alpha)
  38387. */
  38388. keysUp: number[];
  38389. /**
  38390. * Defines the list of key codes associated with the down action (decrease alpha)
  38391. */
  38392. keysDown: number[];
  38393. /**
  38394. * Defines the list of key codes associated with the left action (increase beta)
  38395. */
  38396. keysLeft: number[];
  38397. /**
  38398. * Defines the list of key codes associated with the right action (decrease beta)
  38399. */
  38400. keysRight: number[];
  38401. /**
  38402. * Defines the list of key codes associated with the reset action.
  38403. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38404. */
  38405. keysReset: number[];
  38406. /**
  38407. * Defines the panning sensibility of the inputs.
  38408. * (How fast is the camera panning)
  38409. */
  38410. panningSensibility: number;
  38411. /**
  38412. * Defines the zooming sensibility of the inputs.
  38413. * (How fast is the camera zooming)
  38414. */
  38415. zoomingSensibility: number;
  38416. /**
  38417. * Defines whether maintaining the alt key down switch the movement mode from
  38418. * orientation to zoom.
  38419. */
  38420. useAltToZoom: boolean;
  38421. /**
  38422. * Rotation speed of the camera
  38423. */
  38424. angularSpeed: number;
  38425. private _keys;
  38426. private _ctrlPressed;
  38427. private _altPressed;
  38428. private _onCanvasBlurObserver;
  38429. private _onKeyboardObserver;
  38430. private _engine;
  38431. private _scene;
  38432. /**
  38433. * Attach the input controls to a specific dom element to get the input from.
  38434. * @param element Defines the element the controls should be listened from
  38435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38436. */
  38437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38438. /**
  38439. * Detach the current controls from the specified dom element.
  38440. * @param element Defines the element to stop listening the inputs from
  38441. */
  38442. detachControl(element: Nullable<HTMLElement>): void;
  38443. /**
  38444. * Update the current camera state depending on the inputs that have been used this frame.
  38445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38446. */
  38447. checkInputs(): void;
  38448. /**
  38449. * Gets the class name of the current intput.
  38450. * @returns the class name
  38451. */
  38452. getClassName(): string;
  38453. /**
  38454. * Get the friendly name associated with the input class.
  38455. * @returns the input friendly name
  38456. */
  38457. getSimpleName(): string;
  38458. }
  38459. }
  38460. declare module BABYLON {
  38461. /**
  38462. * Manage the mouse wheel inputs to control an arc rotate camera.
  38463. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38464. */
  38465. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38466. /**
  38467. * Defines the camera the input is attached to.
  38468. */
  38469. camera: ArcRotateCamera;
  38470. /**
  38471. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38472. */
  38473. wheelPrecision: number;
  38474. /**
  38475. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38476. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38477. */
  38478. wheelDeltaPercentage: number;
  38479. private _wheel;
  38480. private _observer;
  38481. private computeDeltaFromMouseWheelLegacyEvent;
  38482. /**
  38483. * Attach the input controls to a specific dom element to get the input from.
  38484. * @param element Defines the element the controls should be listened from
  38485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38486. */
  38487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38488. /**
  38489. * Detach the current controls from the specified dom element.
  38490. * @param element Defines the element to stop listening the inputs from
  38491. */
  38492. detachControl(element: Nullable<HTMLElement>): void;
  38493. /**
  38494. * Gets the class name of the current intput.
  38495. * @returns the class name
  38496. */
  38497. getClassName(): string;
  38498. /**
  38499. * Get the friendly name associated with the input class.
  38500. * @returns the input friendly name
  38501. */
  38502. getSimpleName(): string;
  38503. }
  38504. }
  38505. declare module BABYLON {
  38506. /**
  38507. * Default Inputs manager for the ArcRotateCamera.
  38508. * It groups all the default supported inputs for ease of use.
  38509. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38510. */
  38511. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38512. /**
  38513. * Instantiates a new ArcRotateCameraInputsManager.
  38514. * @param camera Defines the camera the inputs belong to
  38515. */
  38516. constructor(camera: ArcRotateCamera);
  38517. /**
  38518. * Add mouse wheel input support to the input manager.
  38519. * @returns the current input manager
  38520. */
  38521. addMouseWheel(): ArcRotateCameraInputsManager;
  38522. /**
  38523. * Add pointers input support to the input manager.
  38524. * @returns the current input manager
  38525. */
  38526. addPointers(): ArcRotateCameraInputsManager;
  38527. /**
  38528. * Add keyboard input support to the input manager.
  38529. * @returns the current input manager
  38530. */
  38531. addKeyboard(): ArcRotateCameraInputsManager;
  38532. }
  38533. }
  38534. declare module BABYLON {
  38535. /**
  38536. * This represents an orbital type of camera.
  38537. *
  38538. * 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.
  38539. * 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.
  38540. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38541. */
  38542. export class ArcRotateCamera extends TargetCamera {
  38543. /**
  38544. * Defines the rotation angle of the camera along the longitudinal axis.
  38545. */
  38546. alpha: number;
  38547. /**
  38548. * Defines the rotation angle of the camera along the latitudinal axis.
  38549. */
  38550. beta: number;
  38551. /**
  38552. * Defines the radius of the camera from it s target point.
  38553. */
  38554. radius: number;
  38555. protected _target: Vector3;
  38556. protected _targetHost: Nullable<AbstractMesh>;
  38557. /**
  38558. * Defines the target point of the camera.
  38559. * The camera looks towards it form the radius distance.
  38560. */
  38561. get target(): Vector3;
  38562. set target(value: Vector3);
  38563. /**
  38564. * Define the current local position of the camera in the scene
  38565. */
  38566. get position(): Vector3;
  38567. set position(newPosition: Vector3);
  38568. protected _upVector: Vector3;
  38569. protected _upToYMatrix: Matrix;
  38570. protected _YToUpMatrix: Matrix;
  38571. /**
  38572. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38573. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38574. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38575. */
  38576. set upVector(vec: Vector3);
  38577. get upVector(): Vector3;
  38578. /**
  38579. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38580. */
  38581. setMatUp(): void;
  38582. /**
  38583. * Current inertia value on the longitudinal axis.
  38584. * The bigger this number the longer it will take for the camera to stop.
  38585. */
  38586. inertialAlphaOffset: number;
  38587. /**
  38588. * Current inertia value on the latitudinal axis.
  38589. * The bigger this number the longer it will take for the camera to stop.
  38590. */
  38591. inertialBetaOffset: number;
  38592. /**
  38593. * Current inertia value on the radius axis.
  38594. * The bigger this number the longer it will take for the camera to stop.
  38595. */
  38596. inertialRadiusOffset: number;
  38597. /**
  38598. * Minimum allowed angle on the longitudinal axis.
  38599. * This can help limiting how the Camera is able to move in the scene.
  38600. */
  38601. lowerAlphaLimit: Nullable<number>;
  38602. /**
  38603. * Maximum allowed angle on the longitudinal axis.
  38604. * This can help limiting how the Camera is able to move in the scene.
  38605. */
  38606. upperAlphaLimit: Nullable<number>;
  38607. /**
  38608. * Minimum allowed angle on the latitudinal axis.
  38609. * This can help limiting how the Camera is able to move in the scene.
  38610. */
  38611. lowerBetaLimit: number;
  38612. /**
  38613. * Maximum allowed angle on the latitudinal axis.
  38614. * This can help limiting how the Camera is able to move in the scene.
  38615. */
  38616. upperBetaLimit: number;
  38617. /**
  38618. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38619. * This can help limiting how the Camera is able to move in the scene.
  38620. */
  38621. lowerRadiusLimit: Nullable<number>;
  38622. /**
  38623. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38624. * This can help limiting how the Camera is able to move in the scene.
  38625. */
  38626. upperRadiusLimit: Nullable<number>;
  38627. /**
  38628. * Defines the current inertia value used during panning of the camera along the X axis.
  38629. */
  38630. inertialPanningX: number;
  38631. /**
  38632. * Defines the current inertia value used during panning of the camera along the Y axis.
  38633. */
  38634. inertialPanningY: number;
  38635. /**
  38636. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38637. * Basically if your fingers moves away from more than this distance you will be considered
  38638. * in pinch mode.
  38639. */
  38640. pinchToPanMaxDistance: number;
  38641. /**
  38642. * Defines the maximum distance the camera can pan.
  38643. * This could help keeping the cammera always in your scene.
  38644. */
  38645. panningDistanceLimit: Nullable<number>;
  38646. /**
  38647. * Defines the target of the camera before paning.
  38648. */
  38649. panningOriginTarget: Vector3;
  38650. /**
  38651. * Defines the value of the inertia used during panning.
  38652. * 0 would mean stop inertia and one would mean no decelleration at all.
  38653. */
  38654. panningInertia: number;
  38655. /**
  38656. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38657. */
  38658. get angularSensibilityX(): number;
  38659. set angularSensibilityX(value: number);
  38660. /**
  38661. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38662. */
  38663. get angularSensibilityY(): number;
  38664. set angularSensibilityY(value: number);
  38665. /**
  38666. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38667. */
  38668. get pinchPrecision(): number;
  38669. set pinchPrecision(value: number);
  38670. /**
  38671. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38672. * It will be used instead of pinchDeltaPrecision if different from 0.
  38673. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38674. */
  38675. get pinchDeltaPercentage(): number;
  38676. set pinchDeltaPercentage(value: number);
  38677. /**
  38678. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38679. * and pinch delta percentage.
  38680. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38681. * that any object in the plane at the camera's target point will scale
  38682. * perfectly with finger motion.
  38683. */
  38684. get useNaturalPinchZoom(): boolean;
  38685. set useNaturalPinchZoom(value: boolean);
  38686. /**
  38687. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38688. */
  38689. get panningSensibility(): number;
  38690. set panningSensibility(value: number);
  38691. /**
  38692. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38693. */
  38694. get keysUp(): number[];
  38695. set keysUp(value: number[]);
  38696. /**
  38697. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38698. */
  38699. get keysDown(): number[];
  38700. set keysDown(value: number[]);
  38701. /**
  38702. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38703. */
  38704. get keysLeft(): number[];
  38705. set keysLeft(value: number[]);
  38706. /**
  38707. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38708. */
  38709. get keysRight(): number[];
  38710. set keysRight(value: number[]);
  38711. /**
  38712. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38713. */
  38714. get wheelPrecision(): number;
  38715. set wheelPrecision(value: number);
  38716. /**
  38717. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38718. * It will be used instead of pinchDeltaPrecision if different from 0.
  38719. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38720. */
  38721. get wheelDeltaPercentage(): number;
  38722. set wheelDeltaPercentage(value: number);
  38723. /**
  38724. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38725. */
  38726. zoomOnFactor: number;
  38727. /**
  38728. * Defines a screen offset for the camera position.
  38729. */
  38730. targetScreenOffset: Vector2;
  38731. /**
  38732. * Allows the camera to be completely reversed.
  38733. * If false the camera can not arrive upside down.
  38734. */
  38735. allowUpsideDown: boolean;
  38736. /**
  38737. * Define if double tap/click is used to restore the previously saved state of the camera.
  38738. */
  38739. useInputToRestoreState: boolean;
  38740. /** @hidden */
  38741. _viewMatrix: Matrix;
  38742. /** @hidden */
  38743. _useCtrlForPanning: boolean;
  38744. /** @hidden */
  38745. _panningMouseButton: number;
  38746. /**
  38747. * Defines the input associated to the camera.
  38748. */
  38749. inputs: ArcRotateCameraInputsManager;
  38750. /** @hidden */
  38751. _reset: () => void;
  38752. /**
  38753. * Defines the allowed panning axis.
  38754. */
  38755. panningAxis: Vector3;
  38756. protected _localDirection: Vector3;
  38757. protected _transformedDirection: Vector3;
  38758. private _bouncingBehavior;
  38759. /**
  38760. * Gets the bouncing behavior of the camera if it has been enabled.
  38761. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38762. */
  38763. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38764. /**
  38765. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38766. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38767. */
  38768. get useBouncingBehavior(): boolean;
  38769. set useBouncingBehavior(value: boolean);
  38770. private _framingBehavior;
  38771. /**
  38772. * Gets the framing behavior of the camera if it has been enabled.
  38773. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38774. */
  38775. get framingBehavior(): Nullable<FramingBehavior>;
  38776. /**
  38777. * Defines if the framing behavior of the camera is enabled on the camera.
  38778. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38779. */
  38780. get useFramingBehavior(): boolean;
  38781. set useFramingBehavior(value: boolean);
  38782. private _autoRotationBehavior;
  38783. /**
  38784. * Gets the auto rotation behavior of the camera if it has been enabled.
  38785. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38786. */
  38787. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38788. /**
  38789. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38790. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38791. */
  38792. get useAutoRotationBehavior(): boolean;
  38793. set useAutoRotationBehavior(value: boolean);
  38794. /**
  38795. * Observable triggered when the mesh target has been changed on the camera.
  38796. */
  38797. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38798. /**
  38799. * Event raised when the camera is colliding with a mesh.
  38800. */
  38801. onCollide: (collidedMesh: AbstractMesh) => void;
  38802. /**
  38803. * Defines whether the camera should check collision with the objects oh the scene.
  38804. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38805. */
  38806. checkCollisions: boolean;
  38807. /**
  38808. * Defines the collision radius of the camera.
  38809. * This simulates a sphere around the camera.
  38810. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38811. */
  38812. collisionRadius: Vector3;
  38813. protected _collider: Collider;
  38814. protected _previousPosition: Vector3;
  38815. protected _collisionVelocity: Vector3;
  38816. protected _newPosition: Vector3;
  38817. protected _previousAlpha: number;
  38818. protected _previousBeta: number;
  38819. protected _previousRadius: number;
  38820. protected _collisionTriggered: boolean;
  38821. protected _targetBoundingCenter: Nullable<Vector3>;
  38822. private _computationVector;
  38823. /**
  38824. * Instantiates a new ArcRotateCamera in a given scene
  38825. * @param name Defines the name of the camera
  38826. * @param alpha Defines the camera rotation along the logitudinal axis
  38827. * @param beta Defines the camera rotation along the latitudinal axis
  38828. * @param radius Defines the camera distance from its target
  38829. * @param target Defines the camera target
  38830. * @param scene Defines the scene the camera belongs to
  38831. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38832. */
  38833. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38834. /** @hidden */
  38835. _initCache(): void;
  38836. /** @hidden */
  38837. _updateCache(ignoreParentClass?: boolean): void;
  38838. protected _getTargetPosition(): Vector3;
  38839. private _storedAlpha;
  38840. private _storedBeta;
  38841. private _storedRadius;
  38842. private _storedTarget;
  38843. private _storedTargetScreenOffset;
  38844. /**
  38845. * Stores the current state of the camera (alpha, beta, radius and target)
  38846. * @returns the camera itself
  38847. */
  38848. storeState(): Camera;
  38849. /**
  38850. * @hidden
  38851. * Restored camera state. You must call storeState() first
  38852. */
  38853. _restoreStateValues(): boolean;
  38854. /** @hidden */
  38855. _isSynchronizedViewMatrix(): boolean;
  38856. /**
  38857. * Attached controls to the current camera.
  38858. * @param element Defines the element the controls should be listened from
  38859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38860. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38861. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38862. */
  38863. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38864. /**
  38865. * Detach the current controls from the camera.
  38866. * The camera will stop reacting to inputs.
  38867. * @param element Defines the element to stop listening the inputs from
  38868. */
  38869. detachControl(element: HTMLElement): void;
  38870. /** @hidden */
  38871. _checkInputs(): void;
  38872. protected _checkLimits(): void;
  38873. /**
  38874. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38875. */
  38876. rebuildAnglesAndRadius(): void;
  38877. /**
  38878. * Use a position to define the current camera related information like alpha, beta and radius
  38879. * @param position Defines the position to set the camera at
  38880. */
  38881. setPosition(position: Vector3): void;
  38882. /**
  38883. * Defines the target the camera should look at.
  38884. * This will automatically adapt alpha beta and radius to fit within the new target.
  38885. * @param target Defines the new target as a Vector or a mesh
  38886. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  38887. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38888. */
  38889. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38890. /** @hidden */
  38891. _getViewMatrix(): Matrix;
  38892. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38893. /**
  38894. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38895. * @param meshes Defines the mesh to zoom on
  38896. * @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)
  38897. */
  38898. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38899. /**
  38900. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38901. * The target will be changed but the radius
  38902. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38903. * @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)
  38904. */
  38905. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38906. min: Vector3;
  38907. max: Vector3;
  38908. distance: number;
  38909. }, doNotUpdateMaxZ?: boolean): void;
  38910. /**
  38911. * @override
  38912. * Override Camera.createRigCamera
  38913. */
  38914. createRigCamera(name: string, cameraIndex: number): Camera;
  38915. /**
  38916. * @hidden
  38917. * @override
  38918. * Override Camera._updateRigCameras
  38919. */
  38920. _updateRigCameras(): void;
  38921. /**
  38922. * Destroy the camera and release the current resources hold by it.
  38923. */
  38924. dispose(): void;
  38925. /**
  38926. * Gets the current object class name.
  38927. * @return the class name
  38928. */
  38929. getClassName(): string;
  38930. }
  38931. }
  38932. declare module BABYLON {
  38933. /**
  38934. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38935. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38936. */
  38937. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38938. /**
  38939. * Gets the name of the behavior.
  38940. */
  38941. get name(): string;
  38942. private _zoomStopsAnimation;
  38943. private _idleRotationSpeed;
  38944. private _idleRotationWaitTime;
  38945. private _idleRotationSpinupTime;
  38946. /**
  38947. * Sets the flag that indicates if user zooming should stop animation.
  38948. */
  38949. set zoomStopsAnimation(flag: boolean);
  38950. /**
  38951. * Gets the flag that indicates if user zooming should stop animation.
  38952. */
  38953. get zoomStopsAnimation(): boolean;
  38954. /**
  38955. * Sets the default speed at which the camera rotates around the model.
  38956. */
  38957. set idleRotationSpeed(speed: number);
  38958. /**
  38959. * Gets the default speed at which the camera rotates around the model.
  38960. */
  38961. get idleRotationSpeed(): number;
  38962. /**
  38963. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38964. */
  38965. set idleRotationWaitTime(time: number);
  38966. /**
  38967. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38968. */
  38969. get idleRotationWaitTime(): number;
  38970. /**
  38971. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38972. */
  38973. set idleRotationSpinupTime(time: number);
  38974. /**
  38975. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38976. */
  38977. get idleRotationSpinupTime(): number;
  38978. /**
  38979. * Gets a value indicating if the camera is currently rotating because of this behavior
  38980. */
  38981. get rotationInProgress(): boolean;
  38982. private _onPrePointerObservableObserver;
  38983. private _onAfterCheckInputsObserver;
  38984. private _attachedCamera;
  38985. private _isPointerDown;
  38986. private _lastFrameTime;
  38987. private _lastInteractionTime;
  38988. private _cameraRotationSpeed;
  38989. /**
  38990. * Initializes the behavior.
  38991. */
  38992. init(): void;
  38993. /**
  38994. * Attaches the behavior to its arc rotate camera.
  38995. * @param camera Defines the camera to attach the behavior to
  38996. */
  38997. attach(camera: ArcRotateCamera): void;
  38998. /**
  38999. * Detaches the behavior from its current arc rotate camera.
  39000. */
  39001. detach(): void;
  39002. /**
  39003. * Returns true if user is scrolling.
  39004. * @return true if user is scrolling.
  39005. */
  39006. private _userIsZooming;
  39007. private _lastFrameRadius;
  39008. private _shouldAnimationStopForInteraction;
  39009. /**
  39010. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39011. */
  39012. private _applyUserInteraction;
  39013. private _userIsMoving;
  39014. }
  39015. }
  39016. declare module BABYLON {
  39017. /**
  39018. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39019. */
  39020. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39021. private ui;
  39022. /**
  39023. * The name of the behavior
  39024. */
  39025. name: string;
  39026. /**
  39027. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39028. */
  39029. distanceAwayFromFace: number;
  39030. /**
  39031. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39032. */
  39033. distanceAwayFromBottomOfFace: number;
  39034. private _faceVectors;
  39035. private _target;
  39036. private _scene;
  39037. private _onRenderObserver;
  39038. private _tmpMatrix;
  39039. private _tmpVector;
  39040. /**
  39041. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39042. * @param ui The transform node that should be attched to the mesh
  39043. */
  39044. constructor(ui: TransformNode);
  39045. /**
  39046. * Initializes the behavior
  39047. */
  39048. init(): void;
  39049. private _closestFace;
  39050. private _zeroVector;
  39051. private _lookAtTmpMatrix;
  39052. private _lookAtToRef;
  39053. /**
  39054. * Attaches the AttachToBoxBehavior to the passed in mesh
  39055. * @param target The mesh that the specified node will be attached to
  39056. */
  39057. attach(target: Mesh): void;
  39058. /**
  39059. * Detaches the behavior from the mesh
  39060. */
  39061. detach(): void;
  39062. }
  39063. }
  39064. declare module BABYLON {
  39065. /**
  39066. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39067. */
  39068. export class FadeInOutBehavior implements Behavior<Mesh> {
  39069. /**
  39070. * Time in milliseconds to delay before fading in (Default: 0)
  39071. */
  39072. delay: number;
  39073. /**
  39074. * Time in milliseconds for the mesh to fade in (Default: 300)
  39075. */
  39076. fadeInTime: number;
  39077. private _millisecondsPerFrame;
  39078. private _hovered;
  39079. private _hoverValue;
  39080. private _ownerNode;
  39081. /**
  39082. * Instatiates the FadeInOutBehavior
  39083. */
  39084. constructor();
  39085. /**
  39086. * The name of the behavior
  39087. */
  39088. get name(): string;
  39089. /**
  39090. * Initializes the behavior
  39091. */
  39092. init(): void;
  39093. /**
  39094. * Attaches the fade behavior on the passed in mesh
  39095. * @param ownerNode The mesh that will be faded in/out once attached
  39096. */
  39097. attach(ownerNode: Mesh): void;
  39098. /**
  39099. * Detaches the behavior from the mesh
  39100. */
  39101. detach(): void;
  39102. /**
  39103. * Triggers the mesh to begin fading in or out
  39104. * @param value if the object should fade in or out (true to fade in)
  39105. */
  39106. fadeIn(value: boolean): void;
  39107. private _update;
  39108. private _setAllVisibility;
  39109. }
  39110. }
  39111. declare module BABYLON {
  39112. /**
  39113. * Class containing a set of static utilities functions for managing Pivots
  39114. * @hidden
  39115. */
  39116. export class PivotTools {
  39117. private static _PivotCached;
  39118. private static _OldPivotPoint;
  39119. private static _PivotTranslation;
  39120. private static _PivotTmpVector;
  39121. /** @hidden */
  39122. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39123. /** @hidden */
  39124. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39125. }
  39126. }
  39127. declare module BABYLON {
  39128. /**
  39129. * Class containing static functions to help procedurally build meshes
  39130. */
  39131. export class PlaneBuilder {
  39132. /**
  39133. * Creates a plane mesh
  39134. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39135. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39136. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39138. * * 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
  39139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39140. * @param name defines the name of the mesh
  39141. * @param options defines the options used to create the mesh
  39142. * @param scene defines the hosting scene
  39143. * @returns the plane mesh
  39144. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39145. */
  39146. static CreatePlane(name: string, options: {
  39147. size?: number;
  39148. width?: number;
  39149. height?: number;
  39150. sideOrientation?: number;
  39151. frontUVs?: Vector4;
  39152. backUVs?: Vector4;
  39153. updatable?: boolean;
  39154. sourcePlane?: Plane;
  39155. }, scene?: Nullable<Scene>): Mesh;
  39156. }
  39157. }
  39158. declare module BABYLON {
  39159. /**
  39160. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39161. */
  39162. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39163. private static _AnyMouseID;
  39164. /**
  39165. * Abstract mesh the behavior is set on
  39166. */
  39167. attachedNode: AbstractMesh;
  39168. private _dragPlane;
  39169. private _scene;
  39170. private _pointerObserver;
  39171. private _beforeRenderObserver;
  39172. private static _planeScene;
  39173. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39174. /**
  39175. * 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)
  39176. */
  39177. maxDragAngle: number;
  39178. /**
  39179. * @hidden
  39180. */
  39181. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39182. /**
  39183. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39184. */
  39185. currentDraggingPointerID: number;
  39186. /**
  39187. * The last position where the pointer hit the drag plane in world space
  39188. */
  39189. lastDragPosition: Vector3;
  39190. /**
  39191. * If the behavior is currently in a dragging state
  39192. */
  39193. dragging: boolean;
  39194. /**
  39195. * 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)
  39196. */
  39197. dragDeltaRatio: number;
  39198. /**
  39199. * If the drag plane orientation should be updated during the dragging (Default: true)
  39200. */
  39201. updateDragPlane: boolean;
  39202. private _debugMode;
  39203. private _moving;
  39204. /**
  39205. * Fires each time the attached mesh is dragged with the pointer
  39206. * * delta between last drag position and current drag position in world space
  39207. * * dragDistance along the drag axis
  39208. * * dragPlaneNormal normal of the current drag plane used during the drag
  39209. * * dragPlanePoint in world space where the drag intersects the drag plane
  39210. */
  39211. onDragObservable: Observable<{
  39212. delta: Vector3;
  39213. dragPlanePoint: Vector3;
  39214. dragPlaneNormal: Vector3;
  39215. dragDistance: number;
  39216. pointerId: number;
  39217. }>;
  39218. /**
  39219. * Fires each time a drag begins (eg. mouse down on mesh)
  39220. */
  39221. onDragStartObservable: Observable<{
  39222. dragPlanePoint: Vector3;
  39223. pointerId: number;
  39224. }>;
  39225. /**
  39226. * Fires each time a drag ends (eg. mouse release after drag)
  39227. */
  39228. onDragEndObservable: Observable<{
  39229. dragPlanePoint: Vector3;
  39230. pointerId: number;
  39231. }>;
  39232. /**
  39233. * If the attached mesh should be moved when dragged
  39234. */
  39235. moveAttached: boolean;
  39236. /**
  39237. * If the drag behavior will react to drag events (Default: true)
  39238. */
  39239. enabled: boolean;
  39240. /**
  39241. * If pointer events should start and release the drag (Default: true)
  39242. */
  39243. startAndReleaseDragOnPointerEvents: boolean;
  39244. /**
  39245. * If camera controls should be detached during the drag
  39246. */
  39247. detachCameraControls: boolean;
  39248. /**
  39249. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39250. */
  39251. useObjectOrientationForDragging: boolean;
  39252. private _options;
  39253. /**
  39254. * Gets the options used by the behavior
  39255. */
  39256. get options(): {
  39257. dragAxis?: Vector3;
  39258. dragPlaneNormal?: Vector3;
  39259. };
  39260. /**
  39261. * Sets the options used by the behavior
  39262. */
  39263. set options(options: {
  39264. dragAxis?: Vector3;
  39265. dragPlaneNormal?: Vector3;
  39266. });
  39267. /**
  39268. * Creates a pointer drag behavior that can be attached to a mesh
  39269. * @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)
  39270. */
  39271. constructor(options?: {
  39272. dragAxis?: Vector3;
  39273. dragPlaneNormal?: Vector3;
  39274. });
  39275. /**
  39276. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39277. */
  39278. validateDrag: (targetPosition: Vector3) => boolean;
  39279. /**
  39280. * The name of the behavior
  39281. */
  39282. get name(): string;
  39283. /**
  39284. * Initializes the behavior
  39285. */
  39286. init(): void;
  39287. private _tmpVector;
  39288. private _alternatePickedPoint;
  39289. private _worldDragAxis;
  39290. private _targetPosition;
  39291. private _attachedElement;
  39292. /**
  39293. * Attaches the drag behavior the passed in mesh
  39294. * @param ownerNode The mesh that will be dragged around once attached
  39295. * @param predicate Predicate to use for pick filtering
  39296. */
  39297. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39298. /**
  39299. * Force relase the drag action by code.
  39300. */
  39301. releaseDrag(): void;
  39302. private _startDragRay;
  39303. private _lastPointerRay;
  39304. /**
  39305. * Simulates the start of a pointer drag event on the behavior
  39306. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39307. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39308. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39309. */
  39310. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39311. private _startDrag;
  39312. private _dragDelta;
  39313. private _moveDrag;
  39314. private _pickWithRayOnDragPlane;
  39315. private _pointA;
  39316. private _pointB;
  39317. private _pointC;
  39318. private _lineA;
  39319. private _lineB;
  39320. private _localAxis;
  39321. private _lookAt;
  39322. private _updateDragPlanePosition;
  39323. /**
  39324. * Detaches the behavior from the mesh
  39325. */
  39326. detach(): void;
  39327. }
  39328. }
  39329. declare module BABYLON {
  39330. /**
  39331. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39332. */
  39333. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39334. private _dragBehaviorA;
  39335. private _dragBehaviorB;
  39336. private _startDistance;
  39337. private _initialScale;
  39338. private _targetScale;
  39339. private _ownerNode;
  39340. private _sceneRenderObserver;
  39341. /**
  39342. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39343. */
  39344. constructor();
  39345. /**
  39346. * The name of the behavior
  39347. */
  39348. get name(): string;
  39349. /**
  39350. * Initializes the behavior
  39351. */
  39352. init(): void;
  39353. private _getCurrentDistance;
  39354. /**
  39355. * Attaches the scale behavior the passed in mesh
  39356. * @param ownerNode The mesh that will be scaled around once attached
  39357. */
  39358. attach(ownerNode: Mesh): void;
  39359. /**
  39360. * Detaches the behavior from the mesh
  39361. */
  39362. detach(): void;
  39363. }
  39364. }
  39365. declare module BABYLON {
  39366. /**
  39367. * 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
  39368. */
  39369. export class SixDofDragBehavior implements Behavior<Mesh> {
  39370. private static _virtualScene;
  39371. private _ownerNode;
  39372. private _sceneRenderObserver;
  39373. private _scene;
  39374. private _targetPosition;
  39375. private _virtualOriginMesh;
  39376. private _virtualDragMesh;
  39377. private _pointerObserver;
  39378. private _moving;
  39379. private _startingOrientation;
  39380. /**
  39381. * 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)
  39382. */
  39383. private zDragFactor;
  39384. /**
  39385. * If the object should rotate to face the drag origin
  39386. */
  39387. rotateDraggedObject: boolean;
  39388. /**
  39389. * If the behavior is currently in a dragging state
  39390. */
  39391. dragging: boolean;
  39392. /**
  39393. * 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)
  39394. */
  39395. dragDeltaRatio: number;
  39396. /**
  39397. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39398. */
  39399. currentDraggingPointerID: number;
  39400. /**
  39401. * If camera controls should be detached during the drag
  39402. */
  39403. detachCameraControls: boolean;
  39404. /**
  39405. * Fires each time a drag starts
  39406. */
  39407. onDragStartObservable: Observable<{}>;
  39408. /**
  39409. * Fires each time a drag ends (eg. mouse release after drag)
  39410. */
  39411. onDragEndObservable: Observable<{}>;
  39412. /**
  39413. * 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
  39414. */
  39415. constructor();
  39416. /**
  39417. * The name of the behavior
  39418. */
  39419. get name(): string;
  39420. /**
  39421. * Initializes the behavior
  39422. */
  39423. init(): void;
  39424. /**
  39425. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39426. */
  39427. private get _pointerCamera();
  39428. /**
  39429. * Attaches the scale behavior the passed in mesh
  39430. * @param ownerNode The mesh that will be scaled around once attached
  39431. */
  39432. attach(ownerNode: Mesh): void;
  39433. /**
  39434. * Detaches the behavior from the mesh
  39435. */
  39436. detach(): void;
  39437. }
  39438. }
  39439. declare module BABYLON {
  39440. /**
  39441. * Class used to apply inverse kinematics to bones
  39442. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39443. */
  39444. export class BoneIKController {
  39445. private static _tmpVecs;
  39446. private static _tmpQuat;
  39447. private static _tmpMats;
  39448. /**
  39449. * Gets or sets the target mesh
  39450. */
  39451. targetMesh: AbstractMesh;
  39452. /** Gets or sets the mesh used as pole */
  39453. poleTargetMesh: AbstractMesh;
  39454. /**
  39455. * Gets or sets the bone used as pole
  39456. */
  39457. poleTargetBone: Nullable<Bone>;
  39458. /**
  39459. * Gets or sets the target position
  39460. */
  39461. targetPosition: Vector3;
  39462. /**
  39463. * Gets or sets the pole target position
  39464. */
  39465. poleTargetPosition: Vector3;
  39466. /**
  39467. * Gets or sets the pole target local offset
  39468. */
  39469. poleTargetLocalOffset: Vector3;
  39470. /**
  39471. * Gets or sets the pole angle
  39472. */
  39473. poleAngle: number;
  39474. /**
  39475. * Gets or sets the mesh associated with the controller
  39476. */
  39477. mesh: AbstractMesh;
  39478. /**
  39479. * 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)
  39480. */
  39481. slerpAmount: number;
  39482. private _bone1Quat;
  39483. private _bone1Mat;
  39484. private _bone2Ang;
  39485. private _bone1;
  39486. private _bone2;
  39487. private _bone1Length;
  39488. private _bone2Length;
  39489. private _maxAngle;
  39490. private _maxReach;
  39491. private _rightHandedSystem;
  39492. private _bendAxis;
  39493. private _slerping;
  39494. private _adjustRoll;
  39495. /**
  39496. * Gets or sets maximum allowed angle
  39497. */
  39498. get maxAngle(): number;
  39499. set maxAngle(value: number);
  39500. /**
  39501. * Creates a new BoneIKController
  39502. * @param mesh defines the mesh to control
  39503. * @param bone defines the bone to control
  39504. * @param options defines options to set up the controller
  39505. */
  39506. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39507. targetMesh?: AbstractMesh;
  39508. poleTargetMesh?: AbstractMesh;
  39509. poleTargetBone?: Bone;
  39510. poleTargetLocalOffset?: Vector3;
  39511. poleAngle?: number;
  39512. bendAxis?: Vector3;
  39513. maxAngle?: number;
  39514. slerpAmount?: number;
  39515. });
  39516. private _setMaxAngle;
  39517. /**
  39518. * Force the controller to update the bones
  39519. */
  39520. update(): void;
  39521. }
  39522. }
  39523. declare module BABYLON {
  39524. /**
  39525. * Class used to make a bone look toward a point in space
  39526. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39527. */
  39528. export class BoneLookController {
  39529. private static _tmpVecs;
  39530. private static _tmpQuat;
  39531. private static _tmpMats;
  39532. /**
  39533. * The target Vector3 that the bone will look at
  39534. */
  39535. target: Vector3;
  39536. /**
  39537. * The mesh that the bone is attached to
  39538. */
  39539. mesh: AbstractMesh;
  39540. /**
  39541. * The bone that will be looking to the target
  39542. */
  39543. bone: Bone;
  39544. /**
  39545. * The up axis of the coordinate system that is used when the bone is rotated
  39546. */
  39547. upAxis: Vector3;
  39548. /**
  39549. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39550. */
  39551. upAxisSpace: Space;
  39552. /**
  39553. * Used to make an adjustment to the yaw of the bone
  39554. */
  39555. adjustYaw: number;
  39556. /**
  39557. * Used to make an adjustment to the pitch of the bone
  39558. */
  39559. adjustPitch: number;
  39560. /**
  39561. * Used to make an adjustment to the roll of the bone
  39562. */
  39563. adjustRoll: number;
  39564. /**
  39565. * 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)
  39566. */
  39567. slerpAmount: number;
  39568. private _minYaw;
  39569. private _maxYaw;
  39570. private _minPitch;
  39571. private _maxPitch;
  39572. private _minYawSin;
  39573. private _minYawCos;
  39574. private _maxYawSin;
  39575. private _maxYawCos;
  39576. private _midYawConstraint;
  39577. private _minPitchTan;
  39578. private _maxPitchTan;
  39579. private _boneQuat;
  39580. private _slerping;
  39581. private _transformYawPitch;
  39582. private _transformYawPitchInv;
  39583. private _firstFrameSkipped;
  39584. private _yawRange;
  39585. private _fowardAxis;
  39586. /**
  39587. * Gets or sets the minimum yaw angle that the bone can look to
  39588. */
  39589. get minYaw(): number;
  39590. set minYaw(value: number);
  39591. /**
  39592. * Gets or sets the maximum yaw angle that the bone can look to
  39593. */
  39594. get maxYaw(): number;
  39595. set maxYaw(value: number);
  39596. /**
  39597. * Gets or sets the minimum pitch angle that the bone can look to
  39598. */
  39599. get minPitch(): number;
  39600. set minPitch(value: number);
  39601. /**
  39602. * Gets or sets the maximum pitch angle that the bone can look to
  39603. */
  39604. get maxPitch(): number;
  39605. set maxPitch(value: number);
  39606. /**
  39607. * Create a BoneLookController
  39608. * @param mesh the mesh that the bone belongs to
  39609. * @param bone the bone that will be looking to the target
  39610. * @param target the target Vector3 to look at
  39611. * @param options optional settings:
  39612. * * maxYaw: the maximum angle the bone will yaw to
  39613. * * minYaw: the minimum angle the bone will yaw to
  39614. * * maxPitch: the maximum angle the bone will pitch to
  39615. * * minPitch: the minimum angle the bone will yaw to
  39616. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39617. * * upAxis: the up axis of the coordinate system
  39618. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39619. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39620. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39621. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39622. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39623. * * adjustRoll: used to make an adjustment to the roll of the bone
  39624. **/
  39625. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39626. maxYaw?: number;
  39627. minYaw?: number;
  39628. maxPitch?: number;
  39629. minPitch?: number;
  39630. slerpAmount?: number;
  39631. upAxis?: Vector3;
  39632. upAxisSpace?: Space;
  39633. yawAxis?: Vector3;
  39634. pitchAxis?: Vector3;
  39635. adjustYaw?: number;
  39636. adjustPitch?: number;
  39637. adjustRoll?: number;
  39638. });
  39639. /**
  39640. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39641. */
  39642. update(): void;
  39643. private _getAngleDiff;
  39644. private _getAngleBetween;
  39645. private _isAngleBetween;
  39646. }
  39647. }
  39648. declare module BABYLON {
  39649. /**
  39650. * Manage the gamepad inputs to control an arc rotate camera.
  39651. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39652. */
  39653. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39654. /**
  39655. * Defines the camera the input is attached to.
  39656. */
  39657. camera: ArcRotateCamera;
  39658. /**
  39659. * Defines the gamepad the input is gathering event from.
  39660. */
  39661. gamepad: Nullable<Gamepad>;
  39662. /**
  39663. * Defines the gamepad rotation sensiblity.
  39664. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39665. */
  39666. gamepadRotationSensibility: number;
  39667. /**
  39668. * Defines the gamepad move sensiblity.
  39669. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39670. */
  39671. gamepadMoveSensibility: number;
  39672. private _yAxisScale;
  39673. /**
  39674. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39675. */
  39676. get invertYAxis(): boolean;
  39677. set invertYAxis(value: boolean);
  39678. private _onGamepadConnectedObserver;
  39679. private _onGamepadDisconnectedObserver;
  39680. /**
  39681. * Attach the input controls to a specific dom element to get the input from.
  39682. * @param element Defines the element the controls should be listened from
  39683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39684. */
  39685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39686. /**
  39687. * Detach the current controls from the specified dom element.
  39688. * @param element Defines the element to stop listening the inputs from
  39689. */
  39690. detachControl(element: Nullable<HTMLElement>): void;
  39691. /**
  39692. * Update the current camera state depending on the inputs that have been used this frame.
  39693. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39694. */
  39695. checkInputs(): void;
  39696. /**
  39697. * Gets the class name of the current intput.
  39698. * @returns the class name
  39699. */
  39700. getClassName(): string;
  39701. /**
  39702. * Get the friendly name associated with the input class.
  39703. * @returns the input friendly name
  39704. */
  39705. getSimpleName(): string;
  39706. }
  39707. }
  39708. declare module BABYLON {
  39709. interface ArcRotateCameraInputsManager {
  39710. /**
  39711. * Add orientation input support to the input manager.
  39712. * @returns the current input manager
  39713. */
  39714. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39715. }
  39716. /**
  39717. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39719. */
  39720. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39721. /**
  39722. * Defines the camera the input is attached to.
  39723. */
  39724. camera: ArcRotateCamera;
  39725. /**
  39726. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39727. */
  39728. alphaCorrection: number;
  39729. /**
  39730. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39731. */
  39732. gammaCorrection: number;
  39733. private _alpha;
  39734. private _gamma;
  39735. private _dirty;
  39736. private _deviceOrientationHandler;
  39737. /**
  39738. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39739. */
  39740. constructor();
  39741. /**
  39742. * Attach the input controls to a specific dom element to get the input from.
  39743. * @param element Defines the element the controls should be listened from
  39744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39745. */
  39746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39747. /** @hidden */
  39748. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39749. /**
  39750. * Update the current camera state depending on the inputs that have been used this frame.
  39751. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39752. */
  39753. checkInputs(): void;
  39754. /**
  39755. * Detach the current controls from the specified dom element.
  39756. * @param element Defines the element to stop listening the inputs from
  39757. */
  39758. detachControl(element: Nullable<HTMLElement>): void;
  39759. /**
  39760. * Gets the class name of the current intput.
  39761. * @returns the class name
  39762. */
  39763. getClassName(): string;
  39764. /**
  39765. * Get the friendly name associated with the input class.
  39766. * @returns the input friendly name
  39767. */
  39768. getSimpleName(): string;
  39769. }
  39770. }
  39771. declare module BABYLON {
  39772. /**
  39773. * Listen to mouse events to control the camera.
  39774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39775. */
  39776. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39777. /**
  39778. * Defines the camera the input is attached to.
  39779. */
  39780. camera: FlyCamera;
  39781. /**
  39782. * Defines if touch is enabled. (Default is true.)
  39783. */
  39784. touchEnabled: boolean;
  39785. /**
  39786. * Defines the buttons associated with the input to handle camera rotation.
  39787. */
  39788. buttons: number[];
  39789. /**
  39790. * Assign buttons for Yaw control.
  39791. */
  39792. buttonsYaw: number[];
  39793. /**
  39794. * Assign buttons for Pitch control.
  39795. */
  39796. buttonsPitch: number[];
  39797. /**
  39798. * Assign buttons for Roll control.
  39799. */
  39800. buttonsRoll: number[];
  39801. /**
  39802. * Detect if any button is being pressed while mouse is moved.
  39803. * -1 = Mouse locked.
  39804. * 0 = Left button.
  39805. * 1 = Middle Button.
  39806. * 2 = Right Button.
  39807. */
  39808. activeButton: number;
  39809. /**
  39810. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39811. * Higher values reduce its sensitivity.
  39812. */
  39813. angularSensibility: number;
  39814. private _mousemoveCallback;
  39815. private _observer;
  39816. private _rollObserver;
  39817. private previousPosition;
  39818. private noPreventDefault;
  39819. private element;
  39820. /**
  39821. * Listen to mouse events to control the camera.
  39822. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39823. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39824. */
  39825. constructor(touchEnabled?: boolean);
  39826. /**
  39827. * Attach the mouse control to the HTML DOM element.
  39828. * @param element Defines the element that listens to the input events.
  39829. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39830. */
  39831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39832. /**
  39833. * Detach the current controls from the specified dom element.
  39834. * @param element Defines the element to stop listening the inputs from
  39835. */
  39836. detachControl(element: Nullable<HTMLElement>): void;
  39837. /**
  39838. * Gets the class name of the current input.
  39839. * @returns the class name.
  39840. */
  39841. getClassName(): string;
  39842. /**
  39843. * Get the friendly name associated with the input class.
  39844. * @returns the input's friendly name.
  39845. */
  39846. getSimpleName(): string;
  39847. private _pointerInput;
  39848. private _onMouseMove;
  39849. /**
  39850. * Rotate camera by mouse offset.
  39851. */
  39852. private rotateCamera;
  39853. }
  39854. }
  39855. declare module BABYLON {
  39856. /**
  39857. * Default Inputs manager for the FlyCamera.
  39858. * It groups all the default supported inputs for ease of use.
  39859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39860. */
  39861. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39862. /**
  39863. * Instantiates a new FlyCameraInputsManager.
  39864. * @param camera Defines the camera the inputs belong to.
  39865. */
  39866. constructor(camera: FlyCamera);
  39867. /**
  39868. * Add keyboard input support to the input manager.
  39869. * @returns the new FlyCameraKeyboardMoveInput().
  39870. */
  39871. addKeyboard(): FlyCameraInputsManager;
  39872. /**
  39873. * Add mouse input support to the input manager.
  39874. * @param touchEnabled Enable touch screen support.
  39875. * @returns the new FlyCameraMouseInput().
  39876. */
  39877. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39878. }
  39879. }
  39880. declare module BABYLON {
  39881. /**
  39882. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39883. * such as in a 3D Space Shooter or a Flight Simulator.
  39884. */
  39885. export class FlyCamera extends TargetCamera {
  39886. /**
  39887. * Define the collision ellipsoid of the camera.
  39888. * This is helpful for simulating a camera body, like a player's body.
  39889. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39890. */
  39891. ellipsoid: Vector3;
  39892. /**
  39893. * Define an offset for the position of the ellipsoid around the camera.
  39894. * This can be helpful if the camera is attached away from the player's body center,
  39895. * such as at its head.
  39896. */
  39897. ellipsoidOffset: Vector3;
  39898. /**
  39899. * Enable or disable collisions of the camera with the rest of the scene objects.
  39900. */
  39901. checkCollisions: boolean;
  39902. /**
  39903. * Enable or disable gravity on the camera.
  39904. */
  39905. applyGravity: boolean;
  39906. /**
  39907. * Define the current direction the camera is moving to.
  39908. */
  39909. cameraDirection: Vector3;
  39910. /**
  39911. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39912. * This overrides and empties cameraRotation.
  39913. */
  39914. rotationQuaternion: Quaternion;
  39915. /**
  39916. * Track Roll to maintain the wanted Rolling when looking around.
  39917. */
  39918. _trackRoll: number;
  39919. /**
  39920. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39921. */
  39922. rollCorrect: number;
  39923. /**
  39924. * Mimic a banked turn, Rolling the camera when Yawing.
  39925. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39926. */
  39927. bankedTurn: boolean;
  39928. /**
  39929. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39930. */
  39931. bankedTurnLimit: number;
  39932. /**
  39933. * Value of 0 disables the banked Roll.
  39934. * Value of 1 is equal to the Yaw angle in radians.
  39935. */
  39936. bankedTurnMultiplier: number;
  39937. /**
  39938. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39939. */
  39940. inputs: FlyCameraInputsManager;
  39941. /**
  39942. * Gets the input sensibility for mouse input.
  39943. * Higher values reduce sensitivity.
  39944. */
  39945. get angularSensibility(): number;
  39946. /**
  39947. * Sets the input sensibility for a mouse input.
  39948. * Higher values reduce sensitivity.
  39949. */
  39950. set angularSensibility(value: number);
  39951. /**
  39952. * Get the keys for camera movement forward.
  39953. */
  39954. get keysForward(): number[];
  39955. /**
  39956. * Set the keys for camera movement forward.
  39957. */
  39958. set keysForward(value: number[]);
  39959. /**
  39960. * Get the keys for camera movement backward.
  39961. */
  39962. get keysBackward(): number[];
  39963. set keysBackward(value: number[]);
  39964. /**
  39965. * Get the keys for camera movement up.
  39966. */
  39967. get keysUp(): number[];
  39968. /**
  39969. * Set the keys for camera movement up.
  39970. */
  39971. set keysUp(value: number[]);
  39972. /**
  39973. * Get the keys for camera movement down.
  39974. */
  39975. get keysDown(): number[];
  39976. /**
  39977. * Set the keys for camera movement down.
  39978. */
  39979. set keysDown(value: number[]);
  39980. /**
  39981. * Get the keys for camera movement left.
  39982. */
  39983. get keysLeft(): number[];
  39984. /**
  39985. * Set the keys for camera movement left.
  39986. */
  39987. set keysLeft(value: number[]);
  39988. /**
  39989. * Set the keys for camera movement right.
  39990. */
  39991. get keysRight(): number[];
  39992. /**
  39993. * Set the keys for camera movement right.
  39994. */
  39995. set keysRight(value: number[]);
  39996. /**
  39997. * Event raised when the camera collides with a mesh in the scene.
  39998. */
  39999. onCollide: (collidedMesh: AbstractMesh) => void;
  40000. private _collider;
  40001. private _needMoveForGravity;
  40002. private _oldPosition;
  40003. private _diffPosition;
  40004. private _newPosition;
  40005. /** @hidden */
  40006. _localDirection: Vector3;
  40007. /** @hidden */
  40008. _transformedDirection: Vector3;
  40009. /**
  40010. * Instantiates a FlyCamera.
  40011. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40012. * such as in a 3D Space Shooter or a Flight Simulator.
  40013. * @param name Define the name of the camera in the scene.
  40014. * @param position Define the starting position of the camera in the scene.
  40015. * @param scene Define the scene the camera belongs to.
  40016. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40017. */
  40018. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40019. /**
  40020. * Attach a control to the HTML DOM element.
  40021. * @param element Defines the element that listens to the input events.
  40022. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40023. */
  40024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40025. /**
  40026. * Detach a control from the HTML DOM element.
  40027. * The camera will stop reacting to that input.
  40028. * @param element Defines the element that listens to the input events.
  40029. */
  40030. detachControl(element: HTMLElement): void;
  40031. private _collisionMask;
  40032. /**
  40033. * Get the mask that the camera ignores in collision events.
  40034. */
  40035. get collisionMask(): number;
  40036. /**
  40037. * Set the mask that the camera ignores in collision events.
  40038. */
  40039. set collisionMask(mask: number);
  40040. /** @hidden */
  40041. _collideWithWorld(displacement: Vector3): void;
  40042. /** @hidden */
  40043. private _onCollisionPositionChange;
  40044. /** @hidden */
  40045. _checkInputs(): void;
  40046. /** @hidden */
  40047. _decideIfNeedsToMove(): boolean;
  40048. /** @hidden */
  40049. _updatePosition(): void;
  40050. /**
  40051. * Restore the Roll to its target value at the rate specified.
  40052. * @param rate - Higher means slower restoring.
  40053. * @hidden
  40054. */
  40055. restoreRoll(rate: number): void;
  40056. /**
  40057. * Destroy the camera and release the current resources held by it.
  40058. */
  40059. dispose(): void;
  40060. /**
  40061. * Get the current object class name.
  40062. * @returns the class name.
  40063. */
  40064. getClassName(): string;
  40065. }
  40066. }
  40067. declare module BABYLON {
  40068. /**
  40069. * Listen to keyboard events to control the camera.
  40070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40071. */
  40072. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40073. /**
  40074. * Defines the camera the input is attached to.
  40075. */
  40076. camera: FlyCamera;
  40077. /**
  40078. * The list of keyboard keys used to control the forward move of the camera.
  40079. */
  40080. keysForward: number[];
  40081. /**
  40082. * The list of keyboard keys used to control the backward move of the camera.
  40083. */
  40084. keysBackward: number[];
  40085. /**
  40086. * The list of keyboard keys used to control the forward move of the camera.
  40087. */
  40088. keysUp: number[];
  40089. /**
  40090. * The list of keyboard keys used to control the backward move of the camera.
  40091. */
  40092. keysDown: number[];
  40093. /**
  40094. * The list of keyboard keys used to control the right strafe move of the camera.
  40095. */
  40096. keysRight: number[];
  40097. /**
  40098. * The list of keyboard keys used to control the left strafe move of the camera.
  40099. */
  40100. keysLeft: number[];
  40101. private _keys;
  40102. private _onCanvasBlurObserver;
  40103. private _onKeyboardObserver;
  40104. private _engine;
  40105. private _scene;
  40106. /**
  40107. * Attach the input controls to a specific dom element to get the input from.
  40108. * @param element Defines the element the controls should be listened from
  40109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40110. */
  40111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40112. /**
  40113. * Detach the current controls from the specified dom element.
  40114. * @param element Defines the element to stop listening the inputs from
  40115. */
  40116. detachControl(element: Nullable<HTMLElement>): void;
  40117. /**
  40118. * Gets the class name of the current intput.
  40119. * @returns the class name
  40120. */
  40121. getClassName(): string;
  40122. /** @hidden */
  40123. _onLostFocus(e: FocusEvent): void;
  40124. /**
  40125. * Get the friendly name associated with the input class.
  40126. * @returns the input friendly name
  40127. */
  40128. getSimpleName(): string;
  40129. /**
  40130. * Update the current camera state depending on the inputs that have been used this frame.
  40131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40132. */
  40133. checkInputs(): void;
  40134. }
  40135. }
  40136. declare module BABYLON {
  40137. /**
  40138. * Manage the mouse wheel inputs to control a follow camera.
  40139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40140. */
  40141. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40142. /**
  40143. * Defines the camera the input is attached to.
  40144. */
  40145. camera: FollowCamera;
  40146. /**
  40147. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40148. */
  40149. axisControlRadius: boolean;
  40150. /**
  40151. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40152. */
  40153. axisControlHeight: boolean;
  40154. /**
  40155. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40156. */
  40157. axisControlRotation: boolean;
  40158. /**
  40159. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40160. * relation to mouseWheel events.
  40161. */
  40162. wheelPrecision: number;
  40163. /**
  40164. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40165. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40166. */
  40167. wheelDeltaPercentage: number;
  40168. private _wheel;
  40169. private _observer;
  40170. /**
  40171. * Attach the input controls to a specific dom element to get the input from.
  40172. * @param element Defines the element the controls should be listened from
  40173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40174. */
  40175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40176. /**
  40177. * Detach the current controls from the specified dom element.
  40178. * @param element Defines the element to stop listening the inputs from
  40179. */
  40180. detachControl(element: Nullable<HTMLElement>): void;
  40181. /**
  40182. * Gets the class name of the current intput.
  40183. * @returns the class name
  40184. */
  40185. getClassName(): string;
  40186. /**
  40187. * Get the friendly name associated with the input class.
  40188. * @returns the input friendly name
  40189. */
  40190. getSimpleName(): string;
  40191. }
  40192. }
  40193. declare module BABYLON {
  40194. /**
  40195. * Manage the pointers inputs to control an follow camera.
  40196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40197. */
  40198. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40199. /**
  40200. * Defines the camera the input is attached to.
  40201. */
  40202. camera: FollowCamera;
  40203. /**
  40204. * Gets the class name of the current input.
  40205. * @returns the class name
  40206. */
  40207. getClassName(): string;
  40208. /**
  40209. * Defines the pointer angular sensibility along the X axis or how fast is
  40210. * the camera rotating.
  40211. * A negative number will reverse the axis direction.
  40212. */
  40213. angularSensibilityX: number;
  40214. /**
  40215. * Defines the pointer angular sensibility along the Y axis or how fast is
  40216. * the camera rotating.
  40217. * A negative number will reverse the axis direction.
  40218. */
  40219. angularSensibilityY: number;
  40220. /**
  40221. * Defines the pointer pinch precision or how fast is the camera zooming.
  40222. * A negative number will reverse the axis direction.
  40223. */
  40224. pinchPrecision: number;
  40225. /**
  40226. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40227. * from 0.
  40228. * It defines the percentage of current camera.radius to use as delta when
  40229. * pinch zoom is used.
  40230. */
  40231. pinchDeltaPercentage: number;
  40232. /**
  40233. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40234. */
  40235. axisXControlRadius: boolean;
  40236. /**
  40237. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40238. */
  40239. axisXControlHeight: boolean;
  40240. /**
  40241. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40242. */
  40243. axisXControlRotation: boolean;
  40244. /**
  40245. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40246. */
  40247. axisYControlRadius: boolean;
  40248. /**
  40249. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40250. */
  40251. axisYControlHeight: boolean;
  40252. /**
  40253. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40254. */
  40255. axisYControlRotation: boolean;
  40256. /**
  40257. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40258. */
  40259. axisPinchControlRadius: boolean;
  40260. /**
  40261. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40262. */
  40263. axisPinchControlHeight: boolean;
  40264. /**
  40265. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40266. */
  40267. axisPinchControlRotation: boolean;
  40268. /**
  40269. * Log error messages if basic misconfiguration has occurred.
  40270. */
  40271. warningEnable: boolean;
  40272. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40273. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40274. private _warningCounter;
  40275. private _warning;
  40276. }
  40277. }
  40278. declare module BABYLON {
  40279. /**
  40280. * Default Inputs manager for the FollowCamera.
  40281. * It groups all the default supported inputs for ease of use.
  40282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40283. */
  40284. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40285. /**
  40286. * Instantiates a new FollowCameraInputsManager.
  40287. * @param camera Defines the camera the inputs belong to
  40288. */
  40289. constructor(camera: FollowCamera);
  40290. /**
  40291. * Add keyboard input support to the input manager.
  40292. * @returns the current input manager
  40293. */
  40294. addKeyboard(): FollowCameraInputsManager;
  40295. /**
  40296. * Add mouse wheel input support to the input manager.
  40297. * @returns the current input manager
  40298. */
  40299. addMouseWheel(): FollowCameraInputsManager;
  40300. /**
  40301. * Add pointers input support to the input manager.
  40302. * @returns the current input manager
  40303. */
  40304. addPointers(): FollowCameraInputsManager;
  40305. /**
  40306. * Add orientation input support to the input manager.
  40307. * @returns the current input manager
  40308. */
  40309. addVRDeviceOrientation(): FollowCameraInputsManager;
  40310. }
  40311. }
  40312. declare module BABYLON {
  40313. /**
  40314. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40315. * an arc rotate version arcFollowCamera are available.
  40316. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40317. */
  40318. export class FollowCamera extends TargetCamera {
  40319. /**
  40320. * Distance the follow camera should follow an object at
  40321. */
  40322. radius: number;
  40323. /**
  40324. * Minimum allowed distance of the camera to the axis of rotation
  40325. * (The camera can not get closer).
  40326. * This can help limiting how the Camera is able to move in the scene.
  40327. */
  40328. lowerRadiusLimit: Nullable<number>;
  40329. /**
  40330. * Maximum allowed distance of the camera to the axis of rotation
  40331. * (The camera can not get further).
  40332. * This can help limiting how the Camera is able to move in the scene.
  40333. */
  40334. upperRadiusLimit: Nullable<number>;
  40335. /**
  40336. * Define a rotation offset between the camera and the object it follows
  40337. */
  40338. rotationOffset: number;
  40339. /**
  40340. * Minimum allowed angle to camera position relative to target object.
  40341. * This can help limiting how the Camera is able to move in the scene.
  40342. */
  40343. lowerRotationOffsetLimit: Nullable<number>;
  40344. /**
  40345. * Maximum allowed angle to camera position relative to target object.
  40346. * This can help limiting how the Camera is able to move in the scene.
  40347. */
  40348. upperRotationOffsetLimit: Nullable<number>;
  40349. /**
  40350. * Define a height offset between the camera and the object it follows.
  40351. * It can help following an object from the top (like a car chaing a plane)
  40352. */
  40353. heightOffset: number;
  40354. /**
  40355. * Minimum allowed height of camera position relative to target object.
  40356. * This can help limiting how the Camera is able to move in the scene.
  40357. */
  40358. lowerHeightOffsetLimit: Nullable<number>;
  40359. /**
  40360. * Maximum allowed height of camera position relative to target object.
  40361. * This can help limiting how the Camera is able to move in the scene.
  40362. */
  40363. upperHeightOffsetLimit: Nullable<number>;
  40364. /**
  40365. * Define how fast the camera can accelerate to follow it s target.
  40366. */
  40367. cameraAcceleration: number;
  40368. /**
  40369. * Define the speed limit of the camera following an object.
  40370. */
  40371. maxCameraSpeed: number;
  40372. /**
  40373. * Define the target of the camera.
  40374. */
  40375. lockedTarget: Nullable<AbstractMesh>;
  40376. /**
  40377. * Defines the input associated with the camera.
  40378. */
  40379. inputs: FollowCameraInputsManager;
  40380. /**
  40381. * Instantiates the follow camera.
  40382. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40383. * @param name Define the name of the camera in the scene
  40384. * @param position Define the position of the camera
  40385. * @param scene Define the scene the camera belong to
  40386. * @param lockedTarget Define the target of the camera
  40387. */
  40388. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40389. private _follow;
  40390. /**
  40391. * Attached controls to the current camera.
  40392. * @param element Defines the element the controls should be listened from
  40393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40394. */
  40395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40396. /**
  40397. * Detach the current controls from the camera.
  40398. * The camera will stop reacting to inputs.
  40399. * @param element Defines the element to stop listening the inputs from
  40400. */
  40401. detachControl(element: HTMLElement): void;
  40402. /** @hidden */
  40403. _checkInputs(): void;
  40404. private _checkLimits;
  40405. /**
  40406. * Gets the camera class name.
  40407. * @returns the class name
  40408. */
  40409. getClassName(): string;
  40410. }
  40411. /**
  40412. * Arc Rotate version of the follow camera.
  40413. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40414. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40415. */
  40416. export class ArcFollowCamera extends TargetCamera {
  40417. /** The longitudinal angle of the camera */
  40418. alpha: number;
  40419. /** The latitudinal angle of the camera */
  40420. beta: number;
  40421. /** The radius of the camera from its target */
  40422. radius: number;
  40423. /** Define the camera target (the messh it should follow) */
  40424. target: Nullable<AbstractMesh>;
  40425. private _cartesianCoordinates;
  40426. /**
  40427. * Instantiates a new ArcFollowCamera
  40428. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40429. * @param name Define the name of the camera
  40430. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40431. * @param beta Define the rotation angle of the camera around the elevation axis
  40432. * @param radius Define the radius of the camera from its target point
  40433. * @param target Define the target of the camera
  40434. * @param scene Define the scene the camera belongs to
  40435. */
  40436. constructor(name: string,
  40437. /** The longitudinal angle of the camera */
  40438. alpha: number,
  40439. /** The latitudinal angle of the camera */
  40440. beta: number,
  40441. /** The radius of the camera from its target */
  40442. radius: number,
  40443. /** Define the camera target (the messh it should follow) */
  40444. target: Nullable<AbstractMesh>, scene: Scene);
  40445. private _follow;
  40446. /** @hidden */
  40447. _checkInputs(): void;
  40448. /**
  40449. * Returns the class name of the object.
  40450. * It is mostly used internally for serialization purposes.
  40451. */
  40452. getClassName(): string;
  40453. }
  40454. }
  40455. declare module BABYLON {
  40456. /**
  40457. * Manage the keyboard inputs to control the movement of a follow camera.
  40458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40459. */
  40460. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40461. /**
  40462. * Defines the camera the input is attached to.
  40463. */
  40464. camera: FollowCamera;
  40465. /**
  40466. * Defines the list of key codes associated with the up action (increase heightOffset)
  40467. */
  40468. keysHeightOffsetIncr: number[];
  40469. /**
  40470. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40471. */
  40472. keysHeightOffsetDecr: number[];
  40473. /**
  40474. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40475. */
  40476. keysHeightOffsetModifierAlt: boolean;
  40477. /**
  40478. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40479. */
  40480. keysHeightOffsetModifierCtrl: boolean;
  40481. /**
  40482. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40483. */
  40484. keysHeightOffsetModifierShift: boolean;
  40485. /**
  40486. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40487. */
  40488. keysRotationOffsetIncr: number[];
  40489. /**
  40490. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40491. */
  40492. keysRotationOffsetDecr: number[];
  40493. /**
  40494. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40495. */
  40496. keysRotationOffsetModifierAlt: boolean;
  40497. /**
  40498. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40499. */
  40500. keysRotationOffsetModifierCtrl: boolean;
  40501. /**
  40502. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40503. */
  40504. keysRotationOffsetModifierShift: boolean;
  40505. /**
  40506. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40507. */
  40508. keysRadiusIncr: number[];
  40509. /**
  40510. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40511. */
  40512. keysRadiusDecr: number[];
  40513. /**
  40514. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40515. */
  40516. keysRadiusModifierAlt: boolean;
  40517. /**
  40518. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40519. */
  40520. keysRadiusModifierCtrl: boolean;
  40521. /**
  40522. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40523. */
  40524. keysRadiusModifierShift: boolean;
  40525. /**
  40526. * Defines the rate of change of heightOffset.
  40527. */
  40528. heightSensibility: number;
  40529. /**
  40530. * Defines the rate of change of rotationOffset.
  40531. */
  40532. rotationSensibility: number;
  40533. /**
  40534. * Defines the rate of change of radius.
  40535. */
  40536. radiusSensibility: number;
  40537. private _keys;
  40538. private _ctrlPressed;
  40539. private _altPressed;
  40540. private _shiftPressed;
  40541. private _onCanvasBlurObserver;
  40542. private _onKeyboardObserver;
  40543. private _engine;
  40544. private _scene;
  40545. /**
  40546. * Attach the input controls to a specific dom element to get the input from.
  40547. * @param element Defines the element the controls should be listened from
  40548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40549. */
  40550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40551. /**
  40552. * Detach the current controls from the specified dom element.
  40553. * @param element Defines the element to stop listening the inputs from
  40554. */
  40555. detachControl(element: Nullable<HTMLElement>): void;
  40556. /**
  40557. * Update the current camera state depending on the inputs that have been used this frame.
  40558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40559. */
  40560. checkInputs(): void;
  40561. /**
  40562. * Gets the class name of the current input.
  40563. * @returns the class name
  40564. */
  40565. getClassName(): string;
  40566. /**
  40567. * Get the friendly name associated with the input class.
  40568. * @returns the input friendly name
  40569. */
  40570. getSimpleName(): string;
  40571. /**
  40572. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40573. * allow modification of the heightOffset value.
  40574. */
  40575. private _modifierHeightOffset;
  40576. /**
  40577. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40578. * allow modification of the rotationOffset value.
  40579. */
  40580. private _modifierRotationOffset;
  40581. /**
  40582. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40583. * allow modification of the radius value.
  40584. */
  40585. private _modifierRadius;
  40586. }
  40587. }
  40588. declare module BABYLON {
  40589. interface FreeCameraInputsManager {
  40590. /**
  40591. * @hidden
  40592. */
  40593. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40594. /**
  40595. * Add orientation input support to the input manager.
  40596. * @returns the current input manager
  40597. */
  40598. addDeviceOrientation(): FreeCameraInputsManager;
  40599. }
  40600. /**
  40601. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40602. * Screen rotation is taken into account.
  40603. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40604. */
  40605. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40606. private _camera;
  40607. private _screenOrientationAngle;
  40608. private _constantTranform;
  40609. private _screenQuaternion;
  40610. private _alpha;
  40611. private _beta;
  40612. private _gamma;
  40613. /**
  40614. * Can be used to detect if a device orientation sensor is available on a device
  40615. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40616. * @returns a promise that will resolve on orientation change
  40617. */
  40618. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40619. /**
  40620. * @hidden
  40621. */
  40622. _onDeviceOrientationChangedObservable: Observable<void>;
  40623. /**
  40624. * Instantiates a new input
  40625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40626. */
  40627. constructor();
  40628. /**
  40629. * Define the camera controlled by the input.
  40630. */
  40631. get camera(): FreeCamera;
  40632. set camera(camera: FreeCamera);
  40633. /**
  40634. * Attach the input controls to a specific dom element to get the input from.
  40635. * @param element Defines the element the controls should be listened from
  40636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40637. */
  40638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40639. private _orientationChanged;
  40640. private _deviceOrientation;
  40641. /**
  40642. * Detach the current controls from the specified dom element.
  40643. * @param element Defines the element to stop listening the inputs from
  40644. */
  40645. detachControl(element: Nullable<HTMLElement>): void;
  40646. /**
  40647. * Update the current camera state depending on the inputs that have been used this frame.
  40648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40649. */
  40650. checkInputs(): void;
  40651. /**
  40652. * Gets the class name of the current intput.
  40653. * @returns the class name
  40654. */
  40655. getClassName(): string;
  40656. /**
  40657. * Get the friendly name associated with the input class.
  40658. * @returns the input friendly name
  40659. */
  40660. getSimpleName(): string;
  40661. }
  40662. }
  40663. declare module BABYLON {
  40664. /**
  40665. * Manage the gamepad inputs to control a free camera.
  40666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40667. */
  40668. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40669. /**
  40670. * Define the camera the input is attached to.
  40671. */
  40672. camera: FreeCamera;
  40673. /**
  40674. * Define the Gamepad controlling the input
  40675. */
  40676. gamepad: Nullable<Gamepad>;
  40677. /**
  40678. * Defines the gamepad rotation sensiblity.
  40679. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40680. */
  40681. gamepadAngularSensibility: number;
  40682. /**
  40683. * Defines the gamepad move sensiblity.
  40684. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40685. */
  40686. gamepadMoveSensibility: number;
  40687. private _yAxisScale;
  40688. /**
  40689. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40690. */
  40691. get invertYAxis(): boolean;
  40692. set invertYAxis(value: boolean);
  40693. private _onGamepadConnectedObserver;
  40694. private _onGamepadDisconnectedObserver;
  40695. private _cameraTransform;
  40696. private _deltaTransform;
  40697. private _vector3;
  40698. private _vector2;
  40699. /**
  40700. * Attach the input controls to a specific dom element to get the input from.
  40701. * @param element Defines the element the controls should be listened from
  40702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40703. */
  40704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40705. /**
  40706. * Detach the current controls from the specified dom element.
  40707. * @param element Defines the element to stop listening the inputs from
  40708. */
  40709. detachControl(element: Nullable<HTMLElement>): void;
  40710. /**
  40711. * Update the current camera state depending on the inputs that have been used this frame.
  40712. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40713. */
  40714. checkInputs(): void;
  40715. /**
  40716. * Gets the class name of the current intput.
  40717. * @returns the class name
  40718. */
  40719. getClassName(): string;
  40720. /**
  40721. * Get the friendly name associated with the input class.
  40722. * @returns the input friendly name
  40723. */
  40724. getSimpleName(): string;
  40725. }
  40726. }
  40727. declare module BABYLON {
  40728. /**
  40729. * Defines the potential axis of a Joystick
  40730. */
  40731. export enum JoystickAxis {
  40732. /** X axis */
  40733. X = 0,
  40734. /** Y axis */
  40735. Y = 1,
  40736. /** Z axis */
  40737. Z = 2
  40738. }
  40739. /**
  40740. * Class used to define virtual joystick (used in touch mode)
  40741. */
  40742. export class VirtualJoystick {
  40743. /**
  40744. * Gets or sets a boolean indicating that left and right values must be inverted
  40745. */
  40746. reverseLeftRight: boolean;
  40747. /**
  40748. * Gets or sets a boolean indicating that up and down values must be inverted
  40749. */
  40750. reverseUpDown: boolean;
  40751. /**
  40752. * Gets the offset value for the position (ie. the change of the position value)
  40753. */
  40754. deltaPosition: Vector3;
  40755. /**
  40756. * Gets a boolean indicating if the virtual joystick was pressed
  40757. */
  40758. pressed: boolean;
  40759. /**
  40760. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40761. */
  40762. static Canvas: Nullable<HTMLCanvasElement>;
  40763. private static _globalJoystickIndex;
  40764. private static vjCanvasContext;
  40765. private static vjCanvasWidth;
  40766. private static vjCanvasHeight;
  40767. private static halfWidth;
  40768. private _action;
  40769. private _axisTargetedByLeftAndRight;
  40770. private _axisTargetedByUpAndDown;
  40771. private _joystickSensibility;
  40772. private _inversedSensibility;
  40773. private _joystickPointerID;
  40774. private _joystickColor;
  40775. private _joystickPointerPos;
  40776. private _joystickPreviousPointerPos;
  40777. private _joystickPointerStartPos;
  40778. private _deltaJoystickVector;
  40779. private _leftJoystick;
  40780. private _touches;
  40781. private _onPointerDownHandlerRef;
  40782. private _onPointerMoveHandlerRef;
  40783. private _onPointerUpHandlerRef;
  40784. private _onResize;
  40785. /**
  40786. * Creates a new virtual joystick
  40787. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40788. */
  40789. constructor(leftJoystick?: boolean);
  40790. /**
  40791. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40792. * @param newJoystickSensibility defines the new sensibility
  40793. */
  40794. setJoystickSensibility(newJoystickSensibility: number): void;
  40795. private _onPointerDown;
  40796. private _onPointerMove;
  40797. private _onPointerUp;
  40798. /**
  40799. * Change the color of the virtual joystick
  40800. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40801. */
  40802. setJoystickColor(newColor: string): void;
  40803. /**
  40804. * Defines a callback to call when the joystick is touched
  40805. * @param action defines the callback
  40806. */
  40807. setActionOnTouch(action: () => any): void;
  40808. /**
  40809. * Defines which axis you'd like to control for left & right
  40810. * @param axis defines the axis to use
  40811. */
  40812. setAxisForLeftRight(axis: JoystickAxis): void;
  40813. /**
  40814. * Defines which axis you'd like to control for up & down
  40815. * @param axis defines the axis to use
  40816. */
  40817. setAxisForUpDown(axis: JoystickAxis): void;
  40818. private _drawVirtualJoystick;
  40819. /**
  40820. * Release internal HTML canvas
  40821. */
  40822. releaseCanvas(): void;
  40823. }
  40824. }
  40825. declare module BABYLON {
  40826. interface FreeCameraInputsManager {
  40827. /**
  40828. * Add virtual joystick input support to the input manager.
  40829. * @returns the current input manager
  40830. */
  40831. addVirtualJoystick(): FreeCameraInputsManager;
  40832. }
  40833. /**
  40834. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40835. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40836. */
  40837. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40838. /**
  40839. * Defines the camera the input is attached to.
  40840. */
  40841. camera: FreeCamera;
  40842. private _leftjoystick;
  40843. private _rightjoystick;
  40844. /**
  40845. * Gets the left stick of the virtual joystick.
  40846. * @returns The virtual Joystick
  40847. */
  40848. getLeftJoystick(): VirtualJoystick;
  40849. /**
  40850. * Gets the right stick of the virtual joystick.
  40851. * @returns The virtual Joystick
  40852. */
  40853. getRightJoystick(): VirtualJoystick;
  40854. /**
  40855. * Update the current camera state depending on the inputs that have been used this frame.
  40856. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40857. */
  40858. checkInputs(): void;
  40859. /**
  40860. * Attach the input controls to a specific dom element to get the input from.
  40861. * @param element Defines the element the controls should be listened from
  40862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40863. */
  40864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40865. /**
  40866. * Detach the current controls from the specified dom element.
  40867. * @param element Defines the element to stop listening the inputs from
  40868. */
  40869. detachControl(element: Nullable<HTMLElement>): void;
  40870. /**
  40871. * Gets the class name of the current intput.
  40872. * @returns the class name
  40873. */
  40874. getClassName(): string;
  40875. /**
  40876. * Get the friendly name associated with the input class.
  40877. * @returns the input friendly name
  40878. */
  40879. getSimpleName(): string;
  40880. }
  40881. }
  40882. declare module BABYLON {
  40883. /**
  40884. * This represents a FPS type of camera controlled by touch.
  40885. * This is like a universal camera minus the Gamepad controls.
  40886. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40887. */
  40888. export class TouchCamera extends FreeCamera {
  40889. /**
  40890. * Defines the touch sensibility for rotation.
  40891. * The higher the faster.
  40892. */
  40893. get touchAngularSensibility(): number;
  40894. set touchAngularSensibility(value: number);
  40895. /**
  40896. * Defines the touch sensibility for move.
  40897. * The higher the faster.
  40898. */
  40899. get touchMoveSensibility(): number;
  40900. set touchMoveSensibility(value: number);
  40901. /**
  40902. * Instantiates a new touch camera.
  40903. * This represents a FPS type of camera controlled by touch.
  40904. * This is like a universal camera minus the Gamepad controls.
  40905. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40906. * @param name Define the name of the camera in the scene
  40907. * @param position Define the start position of the camera in the scene
  40908. * @param scene Define the scene the camera belongs to
  40909. */
  40910. constructor(name: string, position: Vector3, scene: Scene);
  40911. /**
  40912. * Gets the current object class name.
  40913. * @return the class name
  40914. */
  40915. getClassName(): string;
  40916. /** @hidden */
  40917. _setupInputs(): void;
  40918. }
  40919. }
  40920. declare module BABYLON {
  40921. /**
  40922. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40923. * being tilted forward or back and left or right.
  40924. */
  40925. export class DeviceOrientationCamera extends FreeCamera {
  40926. private _initialQuaternion;
  40927. private _quaternionCache;
  40928. private _tmpDragQuaternion;
  40929. private _disablePointerInputWhenUsingDeviceOrientation;
  40930. /**
  40931. * Creates a new device orientation camera
  40932. * @param name The name of the camera
  40933. * @param position The start position camera
  40934. * @param scene The scene the camera belongs to
  40935. */
  40936. constructor(name: string, position: Vector3, scene: Scene);
  40937. /**
  40938. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40939. */
  40940. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40941. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40942. private _dragFactor;
  40943. /**
  40944. * Enabled turning on the y axis when the orientation sensor is active
  40945. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40946. */
  40947. enableHorizontalDragging(dragFactor?: number): void;
  40948. /**
  40949. * Gets the current instance class name ("DeviceOrientationCamera").
  40950. * This helps avoiding instanceof at run time.
  40951. * @returns the class name
  40952. */
  40953. getClassName(): string;
  40954. /**
  40955. * @hidden
  40956. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40957. */
  40958. _checkInputs(): void;
  40959. /**
  40960. * Reset the camera to its default orientation on the specified axis only.
  40961. * @param axis The axis to reset
  40962. */
  40963. resetToCurrentRotation(axis?: Axis): void;
  40964. }
  40965. }
  40966. declare module BABYLON {
  40967. /**
  40968. * Defines supported buttons for XBox360 compatible gamepads
  40969. */
  40970. export enum Xbox360Button {
  40971. /** A */
  40972. A = 0,
  40973. /** B */
  40974. B = 1,
  40975. /** X */
  40976. X = 2,
  40977. /** Y */
  40978. Y = 3,
  40979. /** Left button */
  40980. LB = 4,
  40981. /** Right button */
  40982. RB = 5,
  40983. /** Back */
  40984. Back = 8,
  40985. /** Start */
  40986. Start = 9,
  40987. /** Left stick */
  40988. LeftStick = 10,
  40989. /** Right stick */
  40990. RightStick = 11
  40991. }
  40992. /** Defines values for XBox360 DPad */
  40993. export enum Xbox360Dpad {
  40994. /** Up */
  40995. Up = 12,
  40996. /** Down */
  40997. Down = 13,
  40998. /** Left */
  40999. Left = 14,
  41000. /** Right */
  41001. Right = 15
  41002. }
  41003. /**
  41004. * Defines a XBox360 gamepad
  41005. */
  41006. export class Xbox360Pad extends Gamepad {
  41007. private _leftTrigger;
  41008. private _rightTrigger;
  41009. private _onlefttriggerchanged;
  41010. private _onrighttriggerchanged;
  41011. private _onbuttondown;
  41012. private _onbuttonup;
  41013. private _ondpaddown;
  41014. private _ondpadup;
  41015. /** Observable raised when a button is pressed */
  41016. onButtonDownObservable: Observable<Xbox360Button>;
  41017. /** Observable raised when a button is released */
  41018. onButtonUpObservable: Observable<Xbox360Button>;
  41019. /** Observable raised when a pad is pressed */
  41020. onPadDownObservable: Observable<Xbox360Dpad>;
  41021. /** Observable raised when a pad is released */
  41022. onPadUpObservable: Observable<Xbox360Dpad>;
  41023. private _buttonA;
  41024. private _buttonB;
  41025. private _buttonX;
  41026. private _buttonY;
  41027. private _buttonBack;
  41028. private _buttonStart;
  41029. private _buttonLB;
  41030. private _buttonRB;
  41031. private _buttonLeftStick;
  41032. private _buttonRightStick;
  41033. private _dPadUp;
  41034. private _dPadDown;
  41035. private _dPadLeft;
  41036. private _dPadRight;
  41037. private _isXboxOnePad;
  41038. /**
  41039. * Creates a new XBox360 gamepad object
  41040. * @param id defines the id of this gamepad
  41041. * @param index defines its index
  41042. * @param gamepad defines the internal HTML gamepad object
  41043. * @param xboxOne defines if it is a XBox One gamepad
  41044. */
  41045. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41046. /**
  41047. * Defines the callback to call when left trigger is pressed
  41048. * @param callback defines the callback to use
  41049. */
  41050. onlefttriggerchanged(callback: (value: number) => void): void;
  41051. /**
  41052. * Defines the callback to call when right trigger is pressed
  41053. * @param callback defines the callback to use
  41054. */
  41055. onrighttriggerchanged(callback: (value: number) => void): void;
  41056. /**
  41057. * Gets the left trigger value
  41058. */
  41059. get leftTrigger(): number;
  41060. /**
  41061. * Sets the left trigger value
  41062. */
  41063. set leftTrigger(newValue: number);
  41064. /**
  41065. * Gets the right trigger value
  41066. */
  41067. get rightTrigger(): number;
  41068. /**
  41069. * Sets the right trigger value
  41070. */
  41071. set rightTrigger(newValue: number);
  41072. /**
  41073. * Defines the callback to call when a button is pressed
  41074. * @param callback defines the callback to use
  41075. */
  41076. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41077. /**
  41078. * Defines the callback to call when a button is released
  41079. * @param callback defines the callback to use
  41080. */
  41081. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41082. /**
  41083. * Defines the callback to call when a pad is pressed
  41084. * @param callback defines the callback to use
  41085. */
  41086. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41087. /**
  41088. * Defines the callback to call when a pad is released
  41089. * @param callback defines the callback to use
  41090. */
  41091. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41092. private _setButtonValue;
  41093. private _setDPadValue;
  41094. /**
  41095. * Gets the value of the `A` button
  41096. */
  41097. get buttonA(): number;
  41098. /**
  41099. * Sets the value of the `A` button
  41100. */
  41101. set buttonA(value: number);
  41102. /**
  41103. * Gets the value of the `B` button
  41104. */
  41105. get buttonB(): number;
  41106. /**
  41107. * Sets the value of the `B` button
  41108. */
  41109. set buttonB(value: number);
  41110. /**
  41111. * Gets the value of the `X` button
  41112. */
  41113. get buttonX(): number;
  41114. /**
  41115. * Sets the value of the `X` button
  41116. */
  41117. set buttonX(value: number);
  41118. /**
  41119. * Gets the value of the `Y` button
  41120. */
  41121. get buttonY(): number;
  41122. /**
  41123. * Sets the value of the `Y` button
  41124. */
  41125. set buttonY(value: number);
  41126. /**
  41127. * Gets the value of the `Start` button
  41128. */
  41129. get buttonStart(): number;
  41130. /**
  41131. * Sets the value of the `Start` button
  41132. */
  41133. set buttonStart(value: number);
  41134. /**
  41135. * Gets the value of the `Back` button
  41136. */
  41137. get buttonBack(): number;
  41138. /**
  41139. * Sets the value of the `Back` button
  41140. */
  41141. set buttonBack(value: number);
  41142. /**
  41143. * Gets the value of the `Left` button
  41144. */
  41145. get buttonLB(): number;
  41146. /**
  41147. * Sets the value of the `Left` button
  41148. */
  41149. set buttonLB(value: number);
  41150. /**
  41151. * Gets the value of the `Right` button
  41152. */
  41153. get buttonRB(): number;
  41154. /**
  41155. * Sets the value of the `Right` button
  41156. */
  41157. set buttonRB(value: number);
  41158. /**
  41159. * Gets the value of the Left joystick
  41160. */
  41161. get buttonLeftStick(): number;
  41162. /**
  41163. * Sets the value of the Left joystick
  41164. */
  41165. set buttonLeftStick(value: number);
  41166. /**
  41167. * Gets the value of the Right joystick
  41168. */
  41169. get buttonRightStick(): number;
  41170. /**
  41171. * Sets the value of the Right joystick
  41172. */
  41173. set buttonRightStick(value: number);
  41174. /**
  41175. * Gets the value of D-pad up
  41176. */
  41177. get dPadUp(): number;
  41178. /**
  41179. * Sets the value of D-pad up
  41180. */
  41181. set dPadUp(value: number);
  41182. /**
  41183. * Gets the value of D-pad down
  41184. */
  41185. get dPadDown(): number;
  41186. /**
  41187. * Sets the value of D-pad down
  41188. */
  41189. set dPadDown(value: number);
  41190. /**
  41191. * Gets the value of D-pad left
  41192. */
  41193. get dPadLeft(): number;
  41194. /**
  41195. * Sets the value of D-pad left
  41196. */
  41197. set dPadLeft(value: number);
  41198. /**
  41199. * Gets the value of D-pad right
  41200. */
  41201. get dPadRight(): number;
  41202. /**
  41203. * Sets the value of D-pad right
  41204. */
  41205. set dPadRight(value: number);
  41206. /**
  41207. * Force the gamepad to synchronize with device values
  41208. */
  41209. update(): void;
  41210. /**
  41211. * Disposes the gamepad
  41212. */
  41213. dispose(): void;
  41214. }
  41215. }
  41216. declare module BABYLON {
  41217. /**
  41218. * Defines supported buttons for DualShock compatible gamepads
  41219. */
  41220. export enum DualShockButton {
  41221. /** Cross */
  41222. Cross = 0,
  41223. /** Circle */
  41224. Circle = 1,
  41225. /** Square */
  41226. Square = 2,
  41227. /** Triangle */
  41228. Triangle = 3,
  41229. /** L1 */
  41230. L1 = 4,
  41231. /** R1 */
  41232. R1 = 5,
  41233. /** Share */
  41234. Share = 8,
  41235. /** Options */
  41236. Options = 9,
  41237. /** Left stick */
  41238. LeftStick = 10,
  41239. /** Right stick */
  41240. RightStick = 11
  41241. }
  41242. /** Defines values for DualShock DPad */
  41243. export enum DualShockDpad {
  41244. /** Up */
  41245. Up = 12,
  41246. /** Down */
  41247. Down = 13,
  41248. /** Left */
  41249. Left = 14,
  41250. /** Right */
  41251. Right = 15
  41252. }
  41253. /**
  41254. * Defines a DualShock gamepad
  41255. */
  41256. export class DualShockPad extends Gamepad {
  41257. private _leftTrigger;
  41258. private _rightTrigger;
  41259. private _onlefttriggerchanged;
  41260. private _onrighttriggerchanged;
  41261. private _onbuttondown;
  41262. private _onbuttonup;
  41263. private _ondpaddown;
  41264. private _ondpadup;
  41265. /** Observable raised when a button is pressed */
  41266. onButtonDownObservable: Observable<DualShockButton>;
  41267. /** Observable raised when a button is released */
  41268. onButtonUpObservable: Observable<DualShockButton>;
  41269. /** Observable raised when a pad is pressed */
  41270. onPadDownObservable: Observable<DualShockDpad>;
  41271. /** Observable raised when a pad is released */
  41272. onPadUpObservable: Observable<DualShockDpad>;
  41273. private _buttonCross;
  41274. private _buttonCircle;
  41275. private _buttonSquare;
  41276. private _buttonTriangle;
  41277. private _buttonShare;
  41278. private _buttonOptions;
  41279. private _buttonL1;
  41280. private _buttonR1;
  41281. private _buttonLeftStick;
  41282. private _buttonRightStick;
  41283. private _dPadUp;
  41284. private _dPadDown;
  41285. private _dPadLeft;
  41286. private _dPadRight;
  41287. /**
  41288. * Creates a new DualShock gamepad object
  41289. * @param id defines the id of this gamepad
  41290. * @param index defines its index
  41291. * @param gamepad defines the internal HTML gamepad object
  41292. */
  41293. constructor(id: string, index: number, gamepad: any);
  41294. /**
  41295. * Defines the callback to call when left trigger is pressed
  41296. * @param callback defines the callback to use
  41297. */
  41298. onlefttriggerchanged(callback: (value: number) => void): void;
  41299. /**
  41300. * Defines the callback to call when right trigger is pressed
  41301. * @param callback defines the callback to use
  41302. */
  41303. onrighttriggerchanged(callback: (value: number) => void): void;
  41304. /**
  41305. * Gets the left trigger value
  41306. */
  41307. get leftTrigger(): number;
  41308. /**
  41309. * Sets the left trigger value
  41310. */
  41311. set leftTrigger(newValue: number);
  41312. /**
  41313. * Gets the right trigger value
  41314. */
  41315. get rightTrigger(): number;
  41316. /**
  41317. * Sets the right trigger value
  41318. */
  41319. set rightTrigger(newValue: number);
  41320. /**
  41321. * Defines the callback to call when a button is pressed
  41322. * @param callback defines the callback to use
  41323. */
  41324. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41325. /**
  41326. * Defines the callback to call when a button is released
  41327. * @param callback defines the callback to use
  41328. */
  41329. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41330. /**
  41331. * Defines the callback to call when a pad is pressed
  41332. * @param callback defines the callback to use
  41333. */
  41334. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41335. /**
  41336. * Defines the callback to call when a pad is released
  41337. * @param callback defines the callback to use
  41338. */
  41339. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41340. private _setButtonValue;
  41341. private _setDPadValue;
  41342. /**
  41343. * Gets the value of the `Cross` button
  41344. */
  41345. get buttonCross(): number;
  41346. /**
  41347. * Sets the value of the `Cross` button
  41348. */
  41349. set buttonCross(value: number);
  41350. /**
  41351. * Gets the value of the `Circle` button
  41352. */
  41353. get buttonCircle(): number;
  41354. /**
  41355. * Sets the value of the `Circle` button
  41356. */
  41357. set buttonCircle(value: number);
  41358. /**
  41359. * Gets the value of the `Square` button
  41360. */
  41361. get buttonSquare(): number;
  41362. /**
  41363. * Sets the value of the `Square` button
  41364. */
  41365. set buttonSquare(value: number);
  41366. /**
  41367. * Gets the value of the `Triangle` button
  41368. */
  41369. get buttonTriangle(): number;
  41370. /**
  41371. * Sets the value of the `Triangle` button
  41372. */
  41373. set buttonTriangle(value: number);
  41374. /**
  41375. * Gets the value of the `Options` button
  41376. */
  41377. get buttonOptions(): number;
  41378. /**
  41379. * Sets the value of the `Options` button
  41380. */
  41381. set buttonOptions(value: number);
  41382. /**
  41383. * Gets the value of the `Share` button
  41384. */
  41385. get buttonShare(): number;
  41386. /**
  41387. * Sets the value of the `Share` button
  41388. */
  41389. set buttonShare(value: number);
  41390. /**
  41391. * Gets the value of the `L1` button
  41392. */
  41393. get buttonL1(): number;
  41394. /**
  41395. * Sets the value of the `L1` button
  41396. */
  41397. set buttonL1(value: number);
  41398. /**
  41399. * Gets the value of the `R1` button
  41400. */
  41401. get buttonR1(): number;
  41402. /**
  41403. * Sets the value of the `R1` button
  41404. */
  41405. set buttonR1(value: number);
  41406. /**
  41407. * Gets the value of the Left joystick
  41408. */
  41409. get buttonLeftStick(): number;
  41410. /**
  41411. * Sets the value of the Left joystick
  41412. */
  41413. set buttonLeftStick(value: number);
  41414. /**
  41415. * Gets the value of the Right joystick
  41416. */
  41417. get buttonRightStick(): number;
  41418. /**
  41419. * Sets the value of the Right joystick
  41420. */
  41421. set buttonRightStick(value: number);
  41422. /**
  41423. * Gets the value of D-pad up
  41424. */
  41425. get dPadUp(): number;
  41426. /**
  41427. * Sets the value of D-pad up
  41428. */
  41429. set dPadUp(value: number);
  41430. /**
  41431. * Gets the value of D-pad down
  41432. */
  41433. get dPadDown(): number;
  41434. /**
  41435. * Sets the value of D-pad down
  41436. */
  41437. set dPadDown(value: number);
  41438. /**
  41439. * Gets the value of D-pad left
  41440. */
  41441. get dPadLeft(): number;
  41442. /**
  41443. * Sets the value of D-pad left
  41444. */
  41445. set dPadLeft(value: number);
  41446. /**
  41447. * Gets the value of D-pad right
  41448. */
  41449. get dPadRight(): number;
  41450. /**
  41451. * Sets the value of D-pad right
  41452. */
  41453. set dPadRight(value: number);
  41454. /**
  41455. * Force the gamepad to synchronize with device values
  41456. */
  41457. update(): void;
  41458. /**
  41459. * Disposes the gamepad
  41460. */
  41461. dispose(): void;
  41462. }
  41463. }
  41464. declare module BABYLON {
  41465. /**
  41466. * Manager for handling gamepads
  41467. */
  41468. export class GamepadManager {
  41469. private _scene?;
  41470. private _babylonGamepads;
  41471. private _oneGamepadConnected;
  41472. /** @hidden */
  41473. _isMonitoring: boolean;
  41474. private _gamepadEventSupported;
  41475. private _gamepadSupport?;
  41476. /**
  41477. * observable to be triggered when the gamepad controller has been connected
  41478. */
  41479. onGamepadConnectedObservable: Observable<Gamepad>;
  41480. /**
  41481. * observable to be triggered when the gamepad controller has been disconnected
  41482. */
  41483. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41484. private _onGamepadConnectedEvent;
  41485. private _onGamepadDisconnectedEvent;
  41486. /**
  41487. * Initializes the gamepad manager
  41488. * @param _scene BabylonJS scene
  41489. */
  41490. constructor(_scene?: Scene | undefined);
  41491. /**
  41492. * The gamepads in the game pad manager
  41493. */
  41494. get gamepads(): Gamepad[];
  41495. /**
  41496. * Get the gamepad controllers based on type
  41497. * @param type The type of gamepad controller
  41498. * @returns Nullable gamepad
  41499. */
  41500. getGamepadByType(type?: number): Nullable<Gamepad>;
  41501. /**
  41502. * Disposes the gamepad manager
  41503. */
  41504. dispose(): void;
  41505. private _addNewGamepad;
  41506. private _startMonitoringGamepads;
  41507. private _stopMonitoringGamepads;
  41508. /** @hidden */
  41509. _checkGamepadsStatus(): void;
  41510. private _updateGamepadObjects;
  41511. }
  41512. }
  41513. declare module BABYLON {
  41514. interface Scene {
  41515. /** @hidden */
  41516. _gamepadManager: Nullable<GamepadManager>;
  41517. /**
  41518. * Gets the gamepad manager associated with the scene
  41519. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41520. */
  41521. gamepadManager: GamepadManager;
  41522. }
  41523. /**
  41524. * Interface representing a free camera inputs manager
  41525. */
  41526. interface FreeCameraInputsManager {
  41527. /**
  41528. * Adds gamepad input support to the FreeCameraInputsManager.
  41529. * @returns the FreeCameraInputsManager
  41530. */
  41531. addGamepad(): FreeCameraInputsManager;
  41532. }
  41533. /**
  41534. * Interface representing an arc rotate camera inputs manager
  41535. */
  41536. interface ArcRotateCameraInputsManager {
  41537. /**
  41538. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41539. * @returns the camera inputs manager
  41540. */
  41541. addGamepad(): ArcRotateCameraInputsManager;
  41542. }
  41543. /**
  41544. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41545. */
  41546. export class GamepadSystemSceneComponent implements ISceneComponent {
  41547. /**
  41548. * The component name helpfull to identify the component in the list of scene components.
  41549. */
  41550. readonly name: string;
  41551. /**
  41552. * The scene the component belongs to.
  41553. */
  41554. scene: Scene;
  41555. /**
  41556. * Creates a new instance of the component for the given scene
  41557. * @param scene Defines the scene to register the component in
  41558. */
  41559. constructor(scene: Scene);
  41560. /**
  41561. * Registers the component in a given scene
  41562. */
  41563. register(): void;
  41564. /**
  41565. * Rebuilds the elements related to this component in case of
  41566. * context lost for instance.
  41567. */
  41568. rebuild(): void;
  41569. /**
  41570. * Disposes the component and the associated ressources
  41571. */
  41572. dispose(): void;
  41573. private _beforeCameraUpdate;
  41574. }
  41575. }
  41576. declare module BABYLON {
  41577. /**
  41578. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  41579. * which still works and will still be found in many Playgrounds.
  41580. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41581. */
  41582. export class UniversalCamera extends TouchCamera {
  41583. /**
  41584. * Defines the gamepad rotation sensiblity.
  41585. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41586. */
  41587. get gamepadAngularSensibility(): number;
  41588. set gamepadAngularSensibility(value: number);
  41589. /**
  41590. * Defines the gamepad move sensiblity.
  41591. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41592. */
  41593. get gamepadMoveSensibility(): number;
  41594. set gamepadMoveSensibility(value: number);
  41595. /**
  41596. * 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,
  41597. * which still works and will still be found in many Playgrounds.
  41598. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41599. * @param name Define the name of the camera in the scene
  41600. * @param position Define the start position of the camera in the scene
  41601. * @param scene Define the scene the camera belongs to
  41602. */
  41603. constructor(name: string, position: Vector3, scene: Scene);
  41604. /**
  41605. * Gets the current object class name.
  41606. * @return the class name
  41607. */
  41608. getClassName(): string;
  41609. }
  41610. }
  41611. declare module BABYLON {
  41612. /**
  41613. * This represents a FPS type of camera. This is only here for back compat purpose.
  41614. * Please use the UniversalCamera instead as both are identical.
  41615. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41616. */
  41617. export class GamepadCamera extends UniversalCamera {
  41618. /**
  41619. * Instantiates a new Gamepad Camera
  41620. * This represents a FPS type of camera. This is only here for back compat purpose.
  41621. * Please use the UniversalCamera instead as both are identical.
  41622. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41623. * @param name Define the name of the camera in the scene
  41624. * @param position Define the start position of the camera in the scene
  41625. * @param scene Define the scene the camera belongs to
  41626. */
  41627. constructor(name: string, position: Vector3, scene: Scene);
  41628. /**
  41629. * Gets the current object class name.
  41630. * @return the class name
  41631. */
  41632. getClassName(): string;
  41633. }
  41634. }
  41635. declare module BABYLON {
  41636. /** @hidden */
  41637. export var passPixelShader: {
  41638. name: string;
  41639. shader: string;
  41640. };
  41641. }
  41642. declare module BABYLON {
  41643. /** @hidden */
  41644. export var passCubePixelShader: {
  41645. name: string;
  41646. shader: string;
  41647. };
  41648. }
  41649. declare module BABYLON {
  41650. /**
  41651. * PassPostProcess which produces an output the same as it's input
  41652. */
  41653. export class PassPostProcess extends PostProcess {
  41654. /**
  41655. * Creates the PassPostProcess
  41656. * @param name The name of the effect.
  41657. * @param options The required width/height ratio to downsize to before computing the render pass.
  41658. * @param camera The camera to apply the render pass to.
  41659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41660. * @param engine The engine which the post process will be applied. (default: current engine)
  41661. * @param reusable If the post process can be reused on the same frame. (default: false)
  41662. * @param textureType The type of texture to be used when performing the post processing.
  41663. * @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)
  41664. */
  41665. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41666. }
  41667. /**
  41668. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41669. */
  41670. export class PassCubePostProcess extends PostProcess {
  41671. private _face;
  41672. /**
  41673. * Gets or sets the cube face to display.
  41674. * * 0 is +X
  41675. * * 1 is -X
  41676. * * 2 is +Y
  41677. * * 3 is -Y
  41678. * * 4 is +Z
  41679. * * 5 is -Z
  41680. */
  41681. get face(): number;
  41682. set face(value: number);
  41683. /**
  41684. * Creates the PassCubePostProcess
  41685. * @param name The name of the effect.
  41686. * @param options The required width/height ratio to downsize to before computing the render pass.
  41687. * @param camera The camera to apply the render pass to.
  41688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41689. * @param engine The engine which the post process will be applied. (default: current engine)
  41690. * @param reusable If the post process can be reused on the same frame. (default: false)
  41691. * @param textureType The type of texture to be used when performing the post processing.
  41692. * @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)
  41693. */
  41694. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41695. }
  41696. }
  41697. declare module BABYLON {
  41698. /** @hidden */
  41699. export var anaglyphPixelShader: {
  41700. name: string;
  41701. shader: string;
  41702. };
  41703. }
  41704. declare module BABYLON {
  41705. /**
  41706. * Postprocess used to generate anaglyphic rendering
  41707. */
  41708. export class AnaglyphPostProcess extends PostProcess {
  41709. private _passedProcess;
  41710. /**
  41711. * Creates a new AnaglyphPostProcess
  41712. * @param name defines postprocess name
  41713. * @param options defines creation options or target ratio scale
  41714. * @param rigCameras defines cameras using this postprocess
  41715. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41716. * @param engine defines hosting engine
  41717. * @param reusable defines if the postprocess will be reused multiple times per frame
  41718. */
  41719. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41720. }
  41721. }
  41722. declare module BABYLON {
  41723. /**
  41724. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41725. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41726. */
  41727. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41728. /**
  41729. * Creates a new AnaglyphArcRotateCamera
  41730. * @param name defines camera name
  41731. * @param alpha defines alpha angle (in radians)
  41732. * @param beta defines beta angle (in radians)
  41733. * @param radius defines radius
  41734. * @param target defines camera target
  41735. * @param interaxialDistance defines distance between each color axis
  41736. * @param scene defines the hosting scene
  41737. */
  41738. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41739. /**
  41740. * Gets camera class name
  41741. * @returns AnaglyphArcRotateCamera
  41742. */
  41743. getClassName(): string;
  41744. }
  41745. }
  41746. declare module BABYLON {
  41747. /**
  41748. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41749. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41750. */
  41751. export class AnaglyphFreeCamera extends FreeCamera {
  41752. /**
  41753. * Creates a new AnaglyphFreeCamera
  41754. * @param name defines camera name
  41755. * @param position defines initial position
  41756. * @param interaxialDistance defines distance between each color axis
  41757. * @param scene defines the hosting scene
  41758. */
  41759. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41760. /**
  41761. * Gets camera class name
  41762. * @returns AnaglyphFreeCamera
  41763. */
  41764. getClassName(): string;
  41765. }
  41766. }
  41767. declare module BABYLON {
  41768. /**
  41769. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41770. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41771. */
  41772. export class AnaglyphGamepadCamera extends GamepadCamera {
  41773. /**
  41774. * Creates a new AnaglyphGamepadCamera
  41775. * @param name defines camera name
  41776. * @param position defines initial position
  41777. * @param interaxialDistance defines distance between each color axis
  41778. * @param scene defines the hosting scene
  41779. */
  41780. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41781. /**
  41782. * Gets camera class name
  41783. * @returns AnaglyphGamepadCamera
  41784. */
  41785. getClassName(): string;
  41786. }
  41787. }
  41788. declare module BABYLON {
  41789. /**
  41790. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41791. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41792. */
  41793. export class AnaglyphUniversalCamera extends UniversalCamera {
  41794. /**
  41795. * Creates a new AnaglyphUniversalCamera
  41796. * @param name defines camera name
  41797. * @param position defines initial position
  41798. * @param interaxialDistance defines distance between each color axis
  41799. * @param scene defines the hosting scene
  41800. */
  41801. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41802. /**
  41803. * Gets camera class name
  41804. * @returns AnaglyphUniversalCamera
  41805. */
  41806. getClassName(): string;
  41807. }
  41808. }
  41809. declare module BABYLON {
  41810. /** @hidden */
  41811. export var stereoscopicInterlacePixelShader: {
  41812. name: string;
  41813. shader: string;
  41814. };
  41815. }
  41816. declare module BABYLON {
  41817. /**
  41818. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41819. */
  41820. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41821. private _stepSize;
  41822. private _passedProcess;
  41823. /**
  41824. * Initializes a StereoscopicInterlacePostProcessI
  41825. * @param name The name of the effect.
  41826. * @param rigCameras The rig cameras to be appled to the post process
  41827. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41828. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41830. * @param engine The engine which the post process will be applied. (default: current engine)
  41831. * @param reusable If the post process can be reused on the same frame. (default: false)
  41832. */
  41833. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41834. }
  41835. /**
  41836. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41837. */
  41838. export class StereoscopicInterlacePostProcess extends PostProcess {
  41839. private _stepSize;
  41840. private _passedProcess;
  41841. /**
  41842. * Initializes a StereoscopicInterlacePostProcess
  41843. * @param name The name of the effect.
  41844. * @param rigCameras The rig cameras to be appled to the post process
  41845. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41847. * @param engine The engine which the post process will be applied. (default: current engine)
  41848. * @param reusable If the post process can be reused on the same frame. (default: false)
  41849. */
  41850. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41851. }
  41852. }
  41853. declare module BABYLON {
  41854. /**
  41855. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41856. * @see http://doc.babylonjs.com/features/cameras
  41857. */
  41858. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41859. /**
  41860. * Creates a new StereoscopicArcRotateCamera
  41861. * @param name defines camera name
  41862. * @param alpha defines alpha angle (in radians)
  41863. * @param beta defines beta angle (in radians)
  41864. * @param radius defines radius
  41865. * @param target defines camera target
  41866. * @param interaxialDistance defines distance between each color axis
  41867. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41868. * @param scene defines the hosting scene
  41869. */
  41870. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41871. /**
  41872. * Gets camera class name
  41873. * @returns StereoscopicArcRotateCamera
  41874. */
  41875. getClassName(): string;
  41876. }
  41877. }
  41878. declare module BABYLON {
  41879. /**
  41880. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41881. * @see http://doc.babylonjs.com/features/cameras
  41882. */
  41883. export class StereoscopicFreeCamera extends FreeCamera {
  41884. /**
  41885. * Creates a new StereoscopicFreeCamera
  41886. * @param name defines camera name
  41887. * @param position defines initial position
  41888. * @param interaxialDistance defines distance between each color axis
  41889. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41890. * @param scene defines the hosting scene
  41891. */
  41892. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41893. /**
  41894. * Gets camera class name
  41895. * @returns StereoscopicFreeCamera
  41896. */
  41897. getClassName(): string;
  41898. }
  41899. }
  41900. declare module BABYLON {
  41901. /**
  41902. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41903. * @see http://doc.babylonjs.com/features/cameras
  41904. */
  41905. export class StereoscopicGamepadCamera extends GamepadCamera {
  41906. /**
  41907. * Creates a new StereoscopicGamepadCamera
  41908. * @param name defines camera name
  41909. * @param position defines initial position
  41910. * @param interaxialDistance defines distance between each color axis
  41911. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41912. * @param scene defines the hosting scene
  41913. */
  41914. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41915. /**
  41916. * Gets camera class name
  41917. * @returns StereoscopicGamepadCamera
  41918. */
  41919. getClassName(): string;
  41920. }
  41921. }
  41922. declare module BABYLON {
  41923. /**
  41924. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41925. * @see http://doc.babylonjs.com/features/cameras
  41926. */
  41927. export class StereoscopicUniversalCamera extends UniversalCamera {
  41928. /**
  41929. * Creates a new StereoscopicUniversalCamera
  41930. * @param name defines camera name
  41931. * @param position defines initial position
  41932. * @param interaxialDistance defines distance between each color axis
  41933. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41934. * @param scene defines the hosting scene
  41935. */
  41936. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41937. /**
  41938. * Gets camera class name
  41939. * @returns StereoscopicUniversalCamera
  41940. */
  41941. getClassName(): string;
  41942. }
  41943. }
  41944. declare module BABYLON {
  41945. /**
  41946. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41947. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41948. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41949. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41950. */
  41951. export class VirtualJoysticksCamera extends FreeCamera {
  41952. /**
  41953. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41954. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41955. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41956. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41957. * @param name Define the name of the camera in the scene
  41958. * @param position Define the start position of the camera in the scene
  41959. * @param scene Define the scene the camera belongs to
  41960. */
  41961. constructor(name: string, position: Vector3, scene: Scene);
  41962. /**
  41963. * Gets the current object class name.
  41964. * @return the class name
  41965. */
  41966. getClassName(): string;
  41967. }
  41968. }
  41969. declare module BABYLON {
  41970. /**
  41971. * This represents all the required metrics to create a VR camera.
  41972. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41973. */
  41974. export class VRCameraMetrics {
  41975. /**
  41976. * Define the horizontal resolution off the screen.
  41977. */
  41978. hResolution: number;
  41979. /**
  41980. * Define the vertical resolution off the screen.
  41981. */
  41982. vResolution: number;
  41983. /**
  41984. * Define the horizontal screen size.
  41985. */
  41986. hScreenSize: number;
  41987. /**
  41988. * Define the vertical screen size.
  41989. */
  41990. vScreenSize: number;
  41991. /**
  41992. * Define the vertical screen center position.
  41993. */
  41994. vScreenCenter: number;
  41995. /**
  41996. * Define the distance of the eyes to the screen.
  41997. */
  41998. eyeToScreenDistance: number;
  41999. /**
  42000. * Define the distance between both lenses
  42001. */
  42002. lensSeparationDistance: number;
  42003. /**
  42004. * Define the distance between both viewer's eyes.
  42005. */
  42006. interpupillaryDistance: number;
  42007. /**
  42008. * Define the distortion factor of the VR postprocess.
  42009. * Please, touch with care.
  42010. */
  42011. distortionK: number[];
  42012. /**
  42013. * Define the chromatic aberration correction factors for the VR post process.
  42014. */
  42015. chromaAbCorrection: number[];
  42016. /**
  42017. * Define the scale factor of the post process.
  42018. * The smaller the better but the slower.
  42019. */
  42020. postProcessScaleFactor: number;
  42021. /**
  42022. * Define an offset for the lens center.
  42023. */
  42024. lensCenterOffset: number;
  42025. /**
  42026. * Define if the current vr camera should compensate the distortion of the lense or not.
  42027. */
  42028. compensateDistortion: boolean;
  42029. /**
  42030. * Defines if multiview should be enabled when rendering (Default: false)
  42031. */
  42032. multiviewEnabled: boolean;
  42033. /**
  42034. * Gets the rendering aspect ratio based on the provided resolutions.
  42035. */
  42036. get aspectRatio(): number;
  42037. /**
  42038. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42039. */
  42040. get aspectRatioFov(): number;
  42041. /**
  42042. * @hidden
  42043. */
  42044. get leftHMatrix(): Matrix;
  42045. /**
  42046. * @hidden
  42047. */
  42048. get rightHMatrix(): Matrix;
  42049. /**
  42050. * @hidden
  42051. */
  42052. get leftPreViewMatrix(): Matrix;
  42053. /**
  42054. * @hidden
  42055. */
  42056. get rightPreViewMatrix(): Matrix;
  42057. /**
  42058. * Get the default VRMetrics based on the most generic setup.
  42059. * @returns the default vr metrics
  42060. */
  42061. static GetDefault(): VRCameraMetrics;
  42062. }
  42063. }
  42064. declare module BABYLON {
  42065. /** @hidden */
  42066. export var vrDistortionCorrectionPixelShader: {
  42067. name: string;
  42068. shader: string;
  42069. };
  42070. }
  42071. declare module BABYLON {
  42072. /**
  42073. * VRDistortionCorrectionPostProcess used for mobile VR
  42074. */
  42075. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42076. private _isRightEye;
  42077. private _distortionFactors;
  42078. private _postProcessScaleFactor;
  42079. private _lensCenterOffset;
  42080. private _scaleIn;
  42081. private _scaleFactor;
  42082. private _lensCenter;
  42083. /**
  42084. * Initializes the VRDistortionCorrectionPostProcess
  42085. * @param name The name of the effect.
  42086. * @param camera The camera to apply the render pass to.
  42087. * @param isRightEye If this is for the right eye distortion
  42088. * @param vrMetrics All the required metrics for the VR camera
  42089. */
  42090. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42091. }
  42092. }
  42093. declare module BABYLON {
  42094. /**
  42095. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42096. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42097. */
  42098. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42099. /**
  42100. * Creates a new VRDeviceOrientationArcRotateCamera
  42101. * @param name defines camera name
  42102. * @param alpha defines the camera rotation along the logitudinal axis
  42103. * @param beta defines the camera rotation along the latitudinal axis
  42104. * @param radius defines the camera distance from its target
  42105. * @param target defines the camera target
  42106. * @param scene defines the scene the camera belongs to
  42107. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42108. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42109. */
  42110. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42111. /**
  42112. * Gets camera class name
  42113. * @returns VRDeviceOrientationArcRotateCamera
  42114. */
  42115. getClassName(): string;
  42116. }
  42117. }
  42118. declare module BABYLON {
  42119. /**
  42120. * Camera used to simulate VR rendering (based on FreeCamera)
  42121. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42122. */
  42123. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42124. /**
  42125. * Creates a new VRDeviceOrientationFreeCamera
  42126. * @param name defines camera name
  42127. * @param position defines the start position of the camera
  42128. * @param scene defines the scene the camera belongs to
  42129. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42130. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42131. */
  42132. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42133. /**
  42134. * Gets camera class name
  42135. * @returns VRDeviceOrientationFreeCamera
  42136. */
  42137. getClassName(): string;
  42138. }
  42139. }
  42140. declare module BABYLON {
  42141. /**
  42142. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42143. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42144. */
  42145. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42146. /**
  42147. * Creates a new VRDeviceOrientationGamepadCamera
  42148. * @param name defines camera name
  42149. * @param position defines the start position of the camera
  42150. * @param scene defines the scene the camera belongs to
  42151. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42152. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42153. */
  42154. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42155. /**
  42156. * Gets camera class name
  42157. * @returns VRDeviceOrientationGamepadCamera
  42158. */
  42159. getClassName(): string;
  42160. }
  42161. }
  42162. declare module BABYLON {
  42163. /** @hidden */
  42164. export var imageProcessingPixelShader: {
  42165. name: string;
  42166. shader: string;
  42167. };
  42168. }
  42169. declare module BABYLON {
  42170. /**
  42171. * ImageProcessingPostProcess
  42172. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42173. */
  42174. export class ImageProcessingPostProcess extends PostProcess {
  42175. /**
  42176. * Default configuration related to image processing available in the PBR Material.
  42177. */
  42178. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42179. /**
  42180. * Gets the image processing configuration used either in this material.
  42181. */
  42182. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42183. /**
  42184. * Sets the Default image processing configuration used either in the this material.
  42185. *
  42186. * If sets to null, the scene one is in use.
  42187. */
  42188. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42189. /**
  42190. * Keep track of the image processing observer to allow dispose and replace.
  42191. */
  42192. private _imageProcessingObserver;
  42193. /**
  42194. * Attaches a new image processing configuration to the PBR Material.
  42195. * @param configuration
  42196. */
  42197. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42198. /**
  42199. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42200. */
  42201. get colorCurves(): Nullable<ColorCurves>;
  42202. /**
  42203. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42204. */
  42205. set colorCurves(value: Nullable<ColorCurves>);
  42206. /**
  42207. * Gets wether the color curves effect is enabled.
  42208. */
  42209. get colorCurvesEnabled(): boolean;
  42210. /**
  42211. * Sets wether the color curves effect is enabled.
  42212. */
  42213. set colorCurvesEnabled(value: boolean);
  42214. /**
  42215. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42216. */
  42217. get colorGradingTexture(): Nullable<BaseTexture>;
  42218. /**
  42219. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42220. */
  42221. set colorGradingTexture(value: Nullable<BaseTexture>);
  42222. /**
  42223. * Gets wether the color grading effect is enabled.
  42224. */
  42225. get colorGradingEnabled(): boolean;
  42226. /**
  42227. * Gets wether the color grading effect is enabled.
  42228. */
  42229. set colorGradingEnabled(value: boolean);
  42230. /**
  42231. * Gets exposure used in the effect.
  42232. */
  42233. get exposure(): number;
  42234. /**
  42235. * Sets exposure used in the effect.
  42236. */
  42237. set exposure(value: number);
  42238. /**
  42239. * Gets wether tonemapping is enabled or not.
  42240. */
  42241. get toneMappingEnabled(): boolean;
  42242. /**
  42243. * Sets wether tonemapping is enabled or not
  42244. */
  42245. set toneMappingEnabled(value: boolean);
  42246. /**
  42247. * Gets the type of tone mapping effect.
  42248. */
  42249. get toneMappingType(): number;
  42250. /**
  42251. * Sets the type of tone mapping effect.
  42252. */
  42253. set toneMappingType(value: number);
  42254. /**
  42255. * Gets contrast used in the effect.
  42256. */
  42257. get contrast(): number;
  42258. /**
  42259. * Sets contrast used in the effect.
  42260. */
  42261. set contrast(value: number);
  42262. /**
  42263. * Gets Vignette stretch size.
  42264. */
  42265. get vignetteStretch(): number;
  42266. /**
  42267. * Sets Vignette stretch size.
  42268. */
  42269. set vignetteStretch(value: number);
  42270. /**
  42271. * Gets Vignette centre X Offset.
  42272. */
  42273. get vignetteCentreX(): number;
  42274. /**
  42275. * Sets Vignette centre X Offset.
  42276. */
  42277. set vignetteCentreX(value: number);
  42278. /**
  42279. * Gets Vignette centre Y Offset.
  42280. */
  42281. get vignetteCentreY(): number;
  42282. /**
  42283. * Sets Vignette centre Y Offset.
  42284. */
  42285. set vignetteCentreY(value: number);
  42286. /**
  42287. * Gets Vignette weight or intensity of the vignette effect.
  42288. */
  42289. get vignetteWeight(): number;
  42290. /**
  42291. * Sets Vignette weight or intensity of the vignette effect.
  42292. */
  42293. set vignetteWeight(value: number);
  42294. /**
  42295. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42296. * if vignetteEnabled is set to true.
  42297. */
  42298. get vignetteColor(): Color4;
  42299. /**
  42300. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42301. * if vignetteEnabled is set to true.
  42302. */
  42303. set vignetteColor(value: Color4);
  42304. /**
  42305. * Gets Camera field of view used by the Vignette effect.
  42306. */
  42307. get vignetteCameraFov(): number;
  42308. /**
  42309. * Sets Camera field of view used by the Vignette effect.
  42310. */
  42311. set vignetteCameraFov(value: number);
  42312. /**
  42313. * Gets the vignette blend mode allowing different kind of effect.
  42314. */
  42315. get vignetteBlendMode(): number;
  42316. /**
  42317. * Sets the vignette blend mode allowing different kind of effect.
  42318. */
  42319. set vignetteBlendMode(value: number);
  42320. /**
  42321. * Gets wether the vignette effect is enabled.
  42322. */
  42323. get vignetteEnabled(): boolean;
  42324. /**
  42325. * Sets wether the vignette effect is enabled.
  42326. */
  42327. set vignetteEnabled(value: boolean);
  42328. private _fromLinearSpace;
  42329. /**
  42330. * Gets wether the input of the processing is in Gamma or Linear Space.
  42331. */
  42332. get fromLinearSpace(): boolean;
  42333. /**
  42334. * Sets wether the input of the processing is in Gamma or Linear Space.
  42335. */
  42336. set fromLinearSpace(value: boolean);
  42337. /**
  42338. * Defines cache preventing GC.
  42339. */
  42340. private _defines;
  42341. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42342. /**
  42343. * "ImageProcessingPostProcess"
  42344. * @returns "ImageProcessingPostProcess"
  42345. */
  42346. getClassName(): string;
  42347. protected _updateParameters(): void;
  42348. dispose(camera?: Camera): void;
  42349. }
  42350. }
  42351. declare module BABYLON {
  42352. /**
  42353. * Class containing static functions to help procedurally build meshes
  42354. */
  42355. export class GroundBuilder {
  42356. /**
  42357. * Creates a ground mesh
  42358. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42359. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42361. * @param name defines the name of the mesh
  42362. * @param options defines the options used to create the mesh
  42363. * @param scene defines the hosting scene
  42364. * @returns the ground mesh
  42365. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42366. */
  42367. static CreateGround(name: string, options: {
  42368. width?: number;
  42369. height?: number;
  42370. subdivisions?: number;
  42371. subdivisionsX?: number;
  42372. subdivisionsY?: number;
  42373. updatable?: boolean;
  42374. }, scene: any): Mesh;
  42375. /**
  42376. * Creates a tiled ground mesh
  42377. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42378. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42379. * * 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
  42380. * * 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
  42381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42382. * @param name defines the name of the mesh
  42383. * @param options defines the options used to create the mesh
  42384. * @param scene defines the hosting scene
  42385. * @returns the tiled ground mesh
  42386. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42387. */
  42388. static CreateTiledGround(name: string, options: {
  42389. xmin: number;
  42390. zmin: number;
  42391. xmax: number;
  42392. zmax: number;
  42393. subdivisions?: {
  42394. w: number;
  42395. h: number;
  42396. };
  42397. precision?: {
  42398. w: number;
  42399. h: number;
  42400. };
  42401. updatable?: boolean;
  42402. }, scene?: Nullable<Scene>): Mesh;
  42403. /**
  42404. * Creates a ground mesh from a height map
  42405. * * The parameter `url` sets the URL of the height map image resource.
  42406. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42407. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42408. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42409. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42410. * * 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.
  42411. * * 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).
  42412. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42414. * @param name defines the name of the mesh
  42415. * @param url defines the url to the height map
  42416. * @param options defines the options used to create the mesh
  42417. * @param scene defines the hosting scene
  42418. * @returns the ground mesh
  42419. * @see https://doc.babylonjs.com/babylon101/height_map
  42420. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42421. */
  42422. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42423. width?: number;
  42424. height?: number;
  42425. subdivisions?: number;
  42426. minHeight?: number;
  42427. maxHeight?: number;
  42428. colorFilter?: Color3;
  42429. alphaFilter?: number;
  42430. updatable?: boolean;
  42431. onReady?: (mesh: GroundMesh) => void;
  42432. }, scene?: Nullable<Scene>): GroundMesh;
  42433. }
  42434. }
  42435. declare module BABYLON {
  42436. /**
  42437. * Class containing static functions to help procedurally build meshes
  42438. */
  42439. export class TorusBuilder {
  42440. /**
  42441. * Creates a torus mesh
  42442. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42443. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42444. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42446. * * 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
  42447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42448. * @param name defines the name of the mesh
  42449. * @param options defines the options used to create the mesh
  42450. * @param scene defines the hosting scene
  42451. * @returns the torus mesh
  42452. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42453. */
  42454. static CreateTorus(name: string, options: {
  42455. diameter?: number;
  42456. thickness?: number;
  42457. tessellation?: number;
  42458. updatable?: boolean;
  42459. sideOrientation?: number;
  42460. frontUVs?: Vector4;
  42461. backUVs?: Vector4;
  42462. }, scene: any): Mesh;
  42463. }
  42464. }
  42465. declare module BABYLON {
  42466. /**
  42467. * Class containing static functions to help procedurally build meshes
  42468. */
  42469. export class CylinderBuilder {
  42470. /**
  42471. * Creates a cylinder or a cone mesh
  42472. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42473. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42474. * * 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.
  42475. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42476. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42477. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42478. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42479. * * 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).
  42480. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42481. * * 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).
  42482. * * 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
  42483. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42484. * * 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
  42485. * * 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.
  42486. * * If `enclose` is false, a ring surface is one element.
  42487. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42488. * * 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
  42489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42490. * * 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
  42491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42492. * @param name defines the name of the mesh
  42493. * @param options defines the options used to create the mesh
  42494. * @param scene defines the hosting scene
  42495. * @returns the cylinder mesh
  42496. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42497. */
  42498. static CreateCylinder(name: string, options: {
  42499. height?: number;
  42500. diameterTop?: number;
  42501. diameterBottom?: number;
  42502. diameter?: number;
  42503. tessellation?: number;
  42504. subdivisions?: number;
  42505. arc?: number;
  42506. faceColors?: Color4[];
  42507. faceUV?: Vector4[];
  42508. updatable?: boolean;
  42509. hasRings?: boolean;
  42510. enclose?: boolean;
  42511. cap?: number;
  42512. sideOrientation?: number;
  42513. frontUVs?: Vector4;
  42514. backUVs?: Vector4;
  42515. }, scene: any): Mesh;
  42516. }
  42517. }
  42518. declare module BABYLON {
  42519. /**
  42520. * States of the webXR experience
  42521. */
  42522. export enum WebXRState {
  42523. /**
  42524. * Transitioning to being in XR mode
  42525. */
  42526. ENTERING_XR = 0,
  42527. /**
  42528. * Transitioning to non XR mode
  42529. */
  42530. EXITING_XR = 1,
  42531. /**
  42532. * In XR mode and presenting
  42533. */
  42534. IN_XR = 2,
  42535. /**
  42536. * Not entered XR mode
  42537. */
  42538. NOT_IN_XR = 3
  42539. }
  42540. /**
  42541. * Abstraction of the XR render target
  42542. */
  42543. export interface WebXRRenderTarget extends IDisposable {
  42544. /**
  42545. * xrpresent context of the canvas which can be used to display/mirror xr content
  42546. */
  42547. canvasContext: WebGLRenderingContext;
  42548. /**
  42549. * xr layer for the canvas
  42550. */
  42551. xrLayer: Nullable<XRWebGLLayer>;
  42552. /**
  42553. * Initializes the xr layer for the session
  42554. * @param xrSession xr session
  42555. * @returns a promise that will resolve once the XR Layer has been created
  42556. */
  42557. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42558. }
  42559. }
  42560. declare module BABYLON {
  42561. /**
  42562. * COnfiguration object for WebXR output canvas
  42563. */
  42564. export class WebXRManagedOutputCanvasOptions {
  42565. /**
  42566. * An optional canvas in case you wish to create it yourself and provide it here.
  42567. * If not provided, a new canvas will be created
  42568. */
  42569. canvasElement?: HTMLCanvasElement;
  42570. /**
  42571. * Options for this XR Layer output
  42572. */
  42573. canvasOptions?: XRWebGLLayerOptions;
  42574. /**
  42575. * CSS styling for a newly created canvas (if not provided)
  42576. */
  42577. newCanvasCssStyle?: string;
  42578. /**
  42579. * Get the default values of the configuration object
  42580. * @returns default values of this configuration object
  42581. */
  42582. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42583. }
  42584. /**
  42585. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42586. */
  42587. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42588. private _options;
  42589. private _canvas;
  42590. private _engine;
  42591. /**
  42592. * Rendering context of the canvas which can be used to display/mirror xr content
  42593. */
  42594. canvasContext: WebGLRenderingContext;
  42595. /**
  42596. * xr layer for the canvas
  42597. */
  42598. xrLayer: Nullable<XRWebGLLayer>;
  42599. /**
  42600. * Initializes the canvas to be added/removed upon entering/exiting xr
  42601. * @param _xrSessionManager The XR Session manager
  42602. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42603. */
  42604. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42605. /**
  42606. * Disposes of the object
  42607. */
  42608. dispose(): void;
  42609. /**
  42610. * Initializes the xr layer for the session
  42611. * @param xrSession xr session
  42612. * @returns a promise that will resolve once the XR Layer has been created
  42613. */
  42614. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42615. private _addCanvas;
  42616. private _removeCanvas;
  42617. private _setManagedOutputCanvas;
  42618. }
  42619. }
  42620. declare module BABYLON {
  42621. /**
  42622. * Manages an XRSession to work with Babylon's engine
  42623. * @see https://doc.babylonjs.com/how_to/webxr
  42624. */
  42625. export class WebXRSessionManager implements IDisposable {
  42626. /** The scene which the session should be created for */
  42627. scene: Scene;
  42628. private _referenceSpace;
  42629. private _rttProvider;
  42630. private _sessionEnded;
  42631. private _xrNavigator;
  42632. private baseLayer;
  42633. /**
  42634. * The base reference space from which the session started. good if you want to reset your
  42635. * reference space
  42636. */
  42637. baseReferenceSpace: XRReferenceSpace;
  42638. /**
  42639. * Current XR frame
  42640. */
  42641. currentFrame: Nullable<XRFrame>;
  42642. /** WebXR timestamp updated every frame */
  42643. currentTimestamp: number;
  42644. /**
  42645. * Used just in case of a failure to initialize an immersive session.
  42646. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42647. */
  42648. defaultHeightCompensation: number;
  42649. /**
  42650. * Fires every time a new xrFrame arrives which can be used to update the camera
  42651. */
  42652. onXRFrameObservable: Observable<XRFrame>;
  42653. /**
  42654. * Fires when the reference space changed
  42655. */
  42656. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42657. /**
  42658. * Fires when the xr session is ended either by the device or manually done
  42659. */
  42660. onXRSessionEnded: Observable<any>;
  42661. /**
  42662. * Fires when the xr session is ended either by the device or manually done
  42663. */
  42664. onXRSessionInit: Observable<XRSession>;
  42665. /**
  42666. * Underlying xr session
  42667. */
  42668. session: XRSession;
  42669. /**
  42670. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42671. * or get the offset the player is currently at.
  42672. */
  42673. viewerReferenceSpace: XRReferenceSpace;
  42674. /**
  42675. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42676. * @param scene The scene which the session should be created for
  42677. */
  42678. constructor(
  42679. /** The scene which the session should be created for */
  42680. scene: Scene);
  42681. /**
  42682. * The current reference space used in this session. This reference space can constantly change!
  42683. * It is mainly used to offset the camera's position.
  42684. */
  42685. get referenceSpace(): XRReferenceSpace;
  42686. /**
  42687. * Set a new reference space and triggers the observable
  42688. */
  42689. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42690. /**
  42691. * Disposes of the session manager
  42692. */
  42693. dispose(): void;
  42694. /**
  42695. * Stops the xrSession and restores the render loop
  42696. * @returns Promise which resolves after it exits XR
  42697. */
  42698. exitXRAsync(): Promise<void>;
  42699. /**
  42700. * Gets the correct render target texture to be rendered this frame for this eye
  42701. * @param eye the eye for which to get the render target
  42702. * @returns the render target for the specified eye
  42703. */
  42704. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42705. /**
  42706. * Creates a WebXRRenderTarget object for the XR session
  42707. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42708. * @param options optional options to provide when creating a new render target
  42709. * @returns a WebXR render target to which the session can render
  42710. */
  42711. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42712. /**
  42713. * Initializes the manager
  42714. * After initialization enterXR can be called to start an XR session
  42715. * @returns Promise which resolves after it is initialized
  42716. */
  42717. initializeAsync(): Promise<void>;
  42718. /**
  42719. * Initializes an xr session
  42720. * @param xrSessionMode mode to initialize
  42721. * @param xrSessionInit defines optional and required values to pass to the session builder
  42722. * @returns a promise which will resolve once the session has been initialized
  42723. */
  42724. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42725. /**
  42726. * Checks if a session would be supported for the creation options specified
  42727. * @param sessionMode session mode to check if supported eg. immersive-vr
  42728. * @returns A Promise that resolves to true if supported and false if not
  42729. */
  42730. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42731. /**
  42732. * Resets the reference space to the one started the session
  42733. */
  42734. resetReferenceSpace(): void;
  42735. /**
  42736. * Starts rendering to the xr layer
  42737. */
  42738. runXRRenderLoop(): void;
  42739. /**
  42740. * Sets the reference space on the xr session
  42741. * @param referenceSpaceType space to set
  42742. * @returns a promise that will resolve once the reference space has been set
  42743. */
  42744. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42745. /**
  42746. * Updates the render state of the session
  42747. * @param state state to set
  42748. * @returns a promise that resolves once the render state has been updated
  42749. */
  42750. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42751. /**
  42752. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42753. * @param sessionMode defines the session to test
  42754. * @returns a promise with boolean as final value
  42755. */
  42756. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42757. private _createRenderTargetTexture;
  42758. }
  42759. }
  42760. declare module BABYLON {
  42761. /**
  42762. * WebXR Camera which holds the views for the xrSession
  42763. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42764. */
  42765. export class WebXRCamera extends FreeCamera {
  42766. private _xrSessionManager;
  42767. private _firstFrame;
  42768. private _referenceQuaternion;
  42769. private _referencedPosition;
  42770. private _xrInvPositionCache;
  42771. private _xrInvQuaternionCache;
  42772. /**
  42773. * Should position compensation execute on first frame.
  42774. * This is used when copying the position from a native (non XR) camera
  42775. */
  42776. compensateOnFirstFrame: boolean;
  42777. /**
  42778. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42779. * @param name the name of the camera
  42780. * @param scene the scene to add the camera to
  42781. * @param _xrSessionManager a constructed xr session manager
  42782. */
  42783. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42784. /**
  42785. * Return the user's height, unrelated to the current ground.
  42786. * This will be the y position of this camera, when ground level is 0.
  42787. */
  42788. get realWorldHeight(): number;
  42789. /** @hidden */
  42790. _updateForDualEyeDebugging(): void;
  42791. /**
  42792. * Sets this camera's transformation based on a non-vr camera
  42793. * @param otherCamera the non-vr camera to copy the transformation from
  42794. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42795. */
  42796. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42797. /**
  42798. * Gets the current instance class name ("WebXRCamera").
  42799. * @returns the class name
  42800. */
  42801. getClassName(): string;
  42802. private _updateFromXRSession;
  42803. private _updateNumberOfRigCameras;
  42804. private _updateReferenceSpace;
  42805. private _updateReferenceSpaceOffset;
  42806. }
  42807. }
  42808. declare module BABYLON {
  42809. /**
  42810. * Defining the interface required for a (webxr) feature
  42811. */
  42812. export interface IWebXRFeature extends IDisposable {
  42813. /**
  42814. * Is this feature attached
  42815. */
  42816. attached: boolean;
  42817. /**
  42818. * Should auto-attach be disabled?
  42819. */
  42820. disableAutoAttach: boolean;
  42821. /**
  42822. * Attach the feature to the session
  42823. * Will usually be called by the features manager
  42824. *
  42825. * @param force should attachment be forced (even when already attached)
  42826. * @returns true if successful.
  42827. */
  42828. attach(force?: boolean): boolean;
  42829. /**
  42830. * Detach the feature from the session
  42831. * Will usually be called by the features manager
  42832. *
  42833. * @returns true if successful.
  42834. */
  42835. detach(): boolean;
  42836. }
  42837. /**
  42838. * A list of the currently available features without referencing them
  42839. */
  42840. export class WebXRFeatureName {
  42841. /**
  42842. * The name of the anchor system feature
  42843. */
  42844. static ANCHOR_SYSTEM: string;
  42845. /**
  42846. * The name of the background remover feature
  42847. */
  42848. static BACKGROUND_REMOVER: string;
  42849. /**
  42850. * The name of the hit test feature
  42851. */
  42852. static HIT_TEST: string;
  42853. /**
  42854. * physics impostors for xr controllers feature
  42855. */
  42856. static PHYSICS_CONTROLLERS: string;
  42857. /**
  42858. * The name of the plane detection feature
  42859. */
  42860. static PLANE_DETECTION: string;
  42861. /**
  42862. * The name of the pointer selection feature
  42863. */
  42864. static POINTER_SELECTION: string;
  42865. /**
  42866. * The name of the teleportation feature
  42867. */
  42868. static TELEPORTATION: string;
  42869. }
  42870. /**
  42871. * Defining the constructor of a feature. Used to register the modules.
  42872. */
  42873. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42874. /**
  42875. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42876. * It is mainly used in AR sessions.
  42877. *
  42878. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42879. */
  42880. export class WebXRFeaturesManager implements IDisposable {
  42881. private _xrSessionManager;
  42882. private static readonly _AvailableFeatures;
  42883. private _features;
  42884. /**
  42885. * constructs a new features manages.
  42886. *
  42887. * @param _xrSessionManager an instance of WebXRSessionManager
  42888. */
  42889. constructor(_xrSessionManager: WebXRSessionManager);
  42890. /**
  42891. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42892. * Mainly used internally.
  42893. *
  42894. * @param featureName the name of the feature to register
  42895. * @param constructorFunction the function used to construct the module
  42896. * @param version the (babylon) version of the module
  42897. * @param stable is that a stable version of this module
  42898. */
  42899. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42900. /**
  42901. * Returns a constructor of a specific feature.
  42902. *
  42903. * @param featureName the name of the feature to construct
  42904. * @param version the version of the feature to load
  42905. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42906. * @param options optional options provided to the module.
  42907. * @returns a function that, when called, will return a new instance of this feature
  42908. */
  42909. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42910. /**
  42911. * Can be used to return the list of features currently registered
  42912. *
  42913. * @returns an Array of available features
  42914. */
  42915. static GetAvailableFeatures(): string[];
  42916. /**
  42917. * Gets the versions available for a specific feature
  42918. * @param featureName the name of the feature
  42919. * @returns an array with the available versions
  42920. */
  42921. static GetAvailableVersions(featureName: string): string[];
  42922. /**
  42923. * Return the latest unstable version of this feature
  42924. * @param featureName the name of the feature to search
  42925. * @returns the version number. if not found will return -1
  42926. */
  42927. static GetLatestVersionOfFeature(featureName: string): number;
  42928. /**
  42929. * Return the latest stable version of this feature
  42930. * @param featureName the name of the feature to search
  42931. * @returns the version number. if not found will return -1
  42932. */
  42933. static GetStableVersionOfFeature(featureName: string): number;
  42934. /**
  42935. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42936. * Can be used during a session to start a feature
  42937. * @param featureName the name of feature to attach
  42938. */
  42939. attachFeature(featureName: string): void;
  42940. /**
  42941. * Can be used inside a session or when the session ends to detach a specific feature
  42942. * @param featureName the name of the feature to detach
  42943. */
  42944. detachFeature(featureName: string): void;
  42945. /**
  42946. * Used to disable an already-enabled feature
  42947. * The feature will be disposed and will be recreated once enabled.
  42948. * @param featureName the feature to disable
  42949. * @returns true if disable was successful
  42950. */
  42951. disableFeature(featureName: string | {
  42952. Name: string;
  42953. }): boolean;
  42954. /**
  42955. * dispose this features manager
  42956. */
  42957. dispose(): void;
  42958. /**
  42959. * 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.
  42960. * 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.
  42961. *
  42962. * @param featureName the name of the feature to load or the class of the feature
  42963. * @param version optional version to load. if not provided the latest version will be enabled
  42964. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42965. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42966. * @returns a new constructed feature or throws an error if feature not found.
  42967. */
  42968. enableFeature(featureName: string | {
  42969. Name: string;
  42970. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42971. /**
  42972. * get the implementation of an enabled feature.
  42973. * @param featureName the name of the feature to load
  42974. * @returns the feature class, if found
  42975. */
  42976. getEnabledFeature(featureName: string): IWebXRFeature;
  42977. /**
  42978. * Get the list of enabled features
  42979. * @returns an array of enabled features
  42980. */
  42981. getEnabledFeatures(): string[];
  42982. }
  42983. }
  42984. declare module BABYLON {
  42985. /**
  42986. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  42987. * @see https://doc.babylonjs.com/how_to/webxr
  42988. */
  42989. export class WebXRExperienceHelper implements IDisposable {
  42990. private scene;
  42991. private _nonVRCamera;
  42992. private _originalSceneAutoClear;
  42993. private _supported;
  42994. /**
  42995. * Camera used to render xr content
  42996. */
  42997. camera: WebXRCamera;
  42998. /** A features manager for this xr session */
  42999. featuresManager: WebXRFeaturesManager;
  43000. /**
  43001. * Observers registered here will be triggered after the camera's initial transformation is set
  43002. * This can be used to set a different ground level or an extra rotation.
  43003. *
  43004. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43005. * to the position set after this observable is done executing.
  43006. */
  43007. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43008. /**
  43009. * Fires when the state of the experience helper has changed
  43010. */
  43011. onStateChangedObservable: Observable<WebXRState>;
  43012. /** Session manager used to keep track of xr session */
  43013. sessionManager: WebXRSessionManager;
  43014. /**
  43015. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43016. */
  43017. state: WebXRState;
  43018. /**
  43019. * Creates a WebXRExperienceHelper
  43020. * @param scene The scene the helper should be created in
  43021. */
  43022. private constructor();
  43023. /**
  43024. * Creates the experience helper
  43025. * @param scene the scene to attach the experience helper to
  43026. * @returns a promise for the experience helper
  43027. */
  43028. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43029. /**
  43030. * Disposes of the experience helper
  43031. */
  43032. dispose(): void;
  43033. /**
  43034. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43035. * @param sessionMode options for the XR session
  43036. * @param referenceSpaceType frame of reference of the XR session
  43037. * @param renderTarget the output canvas that will be used to enter XR mode
  43038. * @returns promise that resolves after xr mode has entered
  43039. */
  43040. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43041. /**
  43042. * Exits XR mode and returns the scene to its original state
  43043. * @returns promise that resolves after xr mode has exited
  43044. */
  43045. exitXRAsync(): Promise<void>;
  43046. private _nonXRToXRCamera;
  43047. private _setState;
  43048. }
  43049. }
  43050. declare module BABYLON {
  43051. /**
  43052. * X-Y values for axes in WebXR
  43053. */
  43054. export interface IWebXRMotionControllerAxesValue {
  43055. /**
  43056. * The value of the x axis
  43057. */
  43058. x: number;
  43059. /**
  43060. * The value of the y-axis
  43061. */
  43062. y: number;
  43063. }
  43064. /**
  43065. * changed / previous values for the values of this component
  43066. */
  43067. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43068. /**
  43069. * current (this frame) value
  43070. */
  43071. current: T;
  43072. /**
  43073. * previous (last change) value
  43074. */
  43075. previous: T;
  43076. }
  43077. /**
  43078. * Represents changes in the component between current frame and last values recorded
  43079. */
  43080. export interface IWebXRMotionControllerComponentChanges {
  43081. /**
  43082. * will be populated with previous and current values if axes changed
  43083. */
  43084. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43085. /**
  43086. * will be populated with previous and current values if pressed changed
  43087. */
  43088. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43089. /**
  43090. * will be populated with previous and current values if touched changed
  43091. */
  43092. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43093. /**
  43094. * will be populated with previous and current values if value changed
  43095. */
  43096. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43097. }
  43098. /**
  43099. * This class represents a single component (for example button or thumbstick) of a motion controller
  43100. */
  43101. export class WebXRControllerComponent implements IDisposable {
  43102. /**
  43103. * the id of this component
  43104. */
  43105. id: string;
  43106. /**
  43107. * the type of the component
  43108. */
  43109. type: MotionControllerComponentType;
  43110. private _buttonIndex;
  43111. private _axesIndices;
  43112. private _axes;
  43113. private _changes;
  43114. private _currentValue;
  43115. private _hasChanges;
  43116. private _pressed;
  43117. private _touched;
  43118. /**
  43119. * button component type
  43120. */
  43121. static BUTTON_TYPE: MotionControllerComponentType;
  43122. /**
  43123. * squeeze component type
  43124. */
  43125. static SQUEEZE_TYPE: MotionControllerComponentType;
  43126. /**
  43127. * Thumbstick component type
  43128. */
  43129. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43130. /**
  43131. * Touchpad component type
  43132. */
  43133. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43134. /**
  43135. * trigger component type
  43136. */
  43137. static TRIGGER_TYPE: MotionControllerComponentType;
  43138. /**
  43139. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43140. * the axes data changes
  43141. */
  43142. onAxisValueChangedObservable: Observable<{
  43143. x: number;
  43144. y: number;
  43145. }>;
  43146. /**
  43147. * Observers registered here will be triggered when the state of a button changes
  43148. * State change is either pressed / touched / value
  43149. */
  43150. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43151. /**
  43152. * Creates a new component for a motion controller.
  43153. * It is created by the motion controller itself
  43154. *
  43155. * @param id the id of this component
  43156. * @param type the type of the component
  43157. * @param _buttonIndex index in the buttons array of the gamepad
  43158. * @param _axesIndices indices of the values in the axes array of the gamepad
  43159. */
  43160. constructor(
  43161. /**
  43162. * the id of this component
  43163. */
  43164. id: string,
  43165. /**
  43166. * the type of the component
  43167. */
  43168. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43169. /**
  43170. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43171. */
  43172. get axes(): IWebXRMotionControllerAxesValue;
  43173. /**
  43174. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43175. */
  43176. get changes(): IWebXRMotionControllerComponentChanges;
  43177. /**
  43178. * Return whether or not the component changed the last frame
  43179. */
  43180. get hasChanges(): boolean;
  43181. /**
  43182. * is the button currently pressed
  43183. */
  43184. get pressed(): boolean;
  43185. /**
  43186. * is the button currently touched
  43187. */
  43188. get touched(): boolean;
  43189. /**
  43190. * Get the current value of this component
  43191. */
  43192. get value(): number;
  43193. /**
  43194. * Dispose this component
  43195. */
  43196. dispose(): void;
  43197. /**
  43198. * Are there axes correlating to this component
  43199. * @return true is axes data is available
  43200. */
  43201. isAxes(): boolean;
  43202. /**
  43203. * Is this component a button (hence - pressable)
  43204. * @returns true if can be pressed
  43205. */
  43206. isButton(): boolean;
  43207. /**
  43208. * update this component using the gamepad object it is in. Called on every frame
  43209. * @param nativeController the native gamepad controller object
  43210. */
  43211. update(nativeController: IMinimalMotionControllerObject): void;
  43212. }
  43213. }
  43214. declare module BABYLON {
  43215. /**
  43216. * Class used to represent data loading progression
  43217. */
  43218. export class SceneLoaderProgressEvent {
  43219. /** defines if data length to load can be evaluated */
  43220. readonly lengthComputable: boolean;
  43221. /** defines the loaded data length */
  43222. readonly loaded: number;
  43223. /** defines the data length to load */
  43224. readonly total: number;
  43225. /**
  43226. * Create a new progress event
  43227. * @param lengthComputable defines if data length to load can be evaluated
  43228. * @param loaded defines the loaded data length
  43229. * @param total defines the data length to load
  43230. */
  43231. constructor(
  43232. /** defines if data length to load can be evaluated */
  43233. lengthComputable: boolean,
  43234. /** defines the loaded data length */
  43235. loaded: number,
  43236. /** defines the data length to load */
  43237. total: number);
  43238. /**
  43239. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43240. * @param event defines the source event
  43241. * @returns a new SceneLoaderProgressEvent
  43242. */
  43243. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43244. }
  43245. /**
  43246. * Interface used by SceneLoader plugins to define supported file extensions
  43247. */
  43248. export interface ISceneLoaderPluginExtensions {
  43249. /**
  43250. * Defines the list of supported extensions
  43251. */
  43252. [extension: string]: {
  43253. isBinary: boolean;
  43254. };
  43255. }
  43256. /**
  43257. * Interface used by SceneLoader plugin factory
  43258. */
  43259. export interface ISceneLoaderPluginFactory {
  43260. /**
  43261. * Defines the name of the factory
  43262. */
  43263. name: string;
  43264. /**
  43265. * Function called to create a new plugin
  43266. * @return the new plugin
  43267. */
  43268. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43269. /**
  43270. * The callback that returns true if the data can be directly loaded.
  43271. * @param data string containing the file data
  43272. * @returns if the data can be loaded directly
  43273. */
  43274. canDirectLoad?(data: string): boolean;
  43275. }
  43276. /**
  43277. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43278. */
  43279. export interface ISceneLoaderPluginBase {
  43280. /**
  43281. * The friendly name of this plugin.
  43282. */
  43283. name: string;
  43284. /**
  43285. * The file extensions supported by this plugin.
  43286. */
  43287. extensions: string | ISceneLoaderPluginExtensions;
  43288. /**
  43289. * The callback called when loading from a url.
  43290. * @param scene scene loading this url
  43291. * @param url url to load
  43292. * @param onSuccess callback called when the file successfully loads
  43293. * @param onProgress callback called while file is loading (if the server supports this mode)
  43294. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43295. * @param onError callback called when the file fails to load
  43296. * @returns a file request object
  43297. */
  43298. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43299. /**
  43300. * The callback called when loading from a file object.
  43301. * @param scene scene loading this file
  43302. * @param file defines the file to load
  43303. * @param onSuccess defines the callback to call when data is loaded
  43304. * @param onProgress defines the callback to call during loading process
  43305. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43306. * @param onError defines the callback to call when an error occurs
  43307. * @returns a file request object
  43308. */
  43309. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43310. /**
  43311. * The callback that returns true if the data can be directly loaded.
  43312. * @param data string containing the file data
  43313. * @returns if the data can be loaded directly
  43314. */
  43315. canDirectLoad?(data: string): boolean;
  43316. /**
  43317. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43318. * @param scene scene loading this data
  43319. * @param data string containing the data
  43320. * @returns data to pass to the plugin
  43321. */
  43322. directLoad?(scene: Scene, data: string): any;
  43323. /**
  43324. * The callback that allows custom handling of the root url based on the response url.
  43325. * @param rootUrl the original root url
  43326. * @param responseURL the response url if available
  43327. * @returns the new root url
  43328. */
  43329. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43330. }
  43331. /**
  43332. * Interface used to define a SceneLoader plugin
  43333. */
  43334. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43335. /**
  43336. * Import meshes into a scene.
  43337. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43338. * @param scene The scene to import into
  43339. * @param data The data to import
  43340. * @param rootUrl The root url for scene and resources
  43341. * @param meshes The meshes array to import into
  43342. * @param particleSystems The particle systems array to import into
  43343. * @param skeletons The skeletons array to import into
  43344. * @param onError The callback when import fails
  43345. * @returns True if successful or false otherwise
  43346. */
  43347. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43348. /**
  43349. * Load into a scene.
  43350. * @param scene The scene to load into
  43351. * @param data The data to import
  43352. * @param rootUrl The root url for scene and resources
  43353. * @param onError The callback when import fails
  43354. * @returns True if successful or false otherwise
  43355. */
  43356. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43357. /**
  43358. * Load into an asset container.
  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 onError The callback when import fails
  43363. * @returns The loaded asset container
  43364. */
  43365. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43366. }
  43367. /**
  43368. * Interface used to define an async SceneLoader plugin
  43369. */
  43370. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43371. /**
  43372. * Import meshes into a scene.
  43373. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43374. * @param scene The scene to import into
  43375. * @param data The data to import
  43376. * @param rootUrl The root url for scene and resources
  43377. * @param onProgress The callback when the load progresses
  43378. * @param fileName Defines the name of the file to load
  43379. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43380. */
  43381. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43382. meshes: AbstractMesh[];
  43383. particleSystems: IParticleSystem[];
  43384. skeletons: Skeleton[];
  43385. animationGroups: AnimationGroup[];
  43386. }>;
  43387. /**
  43388. * Load into a scene.
  43389. * @param scene The scene to load into
  43390. * @param data The data to import
  43391. * @param rootUrl The root url for scene and resources
  43392. * @param onProgress The callback when the load progresses
  43393. * @param fileName Defines the name of the file to load
  43394. * @returns Nothing
  43395. */
  43396. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43397. /**
  43398. * Load into an asset container.
  43399. * @param scene The scene to load into
  43400. * @param data The data to import
  43401. * @param rootUrl The root url for scene and resources
  43402. * @param onProgress The callback when the load progresses
  43403. * @param fileName Defines the name of the file to load
  43404. * @returns The loaded asset container
  43405. */
  43406. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43407. }
  43408. /**
  43409. * Mode that determines how to handle old animation groups before loading new ones.
  43410. */
  43411. export enum SceneLoaderAnimationGroupLoadingMode {
  43412. /**
  43413. * Reset all old animations to initial state then dispose them.
  43414. */
  43415. Clean = 0,
  43416. /**
  43417. * Stop all old animations.
  43418. */
  43419. Stop = 1,
  43420. /**
  43421. * Restart old animations from first frame.
  43422. */
  43423. Sync = 2,
  43424. /**
  43425. * Old animations remains untouched.
  43426. */
  43427. NoSync = 3
  43428. }
  43429. /**
  43430. * Class used to load scene from various file formats using registered plugins
  43431. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43432. */
  43433. export class SceneLoader {
  43434. /**
  43435. * No logging while loading
  43436. */
  43437. static readonly NO_LOGGING: number;
  43438. /**
  43439. * Minimal logging while loading
  43440. */
  43441. static readonly MINIMAL_LOGGING: number;
  43442. /**
  43443. * Summary logging while loading
  43444. */
  43445. static readonly SUMMARY_LOGGING: number;
  43446. /**
  43447. * Detailled logging while loading
  43448. */
  43449. static readonly DETAILED_LOGGING: number;
  43450. /**
  43451. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43452. */
  43453. static get ForceFullSceneLoadingForIncremental(): boolean;
  43454. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43455. /**
  43456. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43457. */
  43458. static get ShowLoadingScreen(): boolean;
  43459. static set ShowLoadingScreen(value: boolean);
  43460. /**
  43461. * Defines the current logging level (while loading the scene)
  43462. * @ignorenaming
  43463. */
  43464. static get loggingLevel(): number;
  43465. static set loggingLevel(value: number);
  43466. /**
  43467. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43468. */
  43469. static get CleanBoneMatrixWeights(): boolean;
  43470. static set CleanBoneMatrixWeights(value: boolean);
  43471. /**
  43472. * Event raised when a plugin is used to load a scene
  43473. */
  43474. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43475. private static _registeredPlugins;
  43476. private static _getDefaultPlugin;
  43477. private static _getPluginForExtension;
  43478. private static _getPluginForDirectLoad;
  43479. private static _getPluginForFilename;
  43480. private static _getDirectLoad;
  43481. private static _loadData;
  43482. private static _getFileInfo;
  43483. /**
  43484. * Gets a plugin that can load the given extension
  43485. * @param extension defines the extension to load
  43486. * @returns a plugin or null if none works
  43487. */
  43488. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43489. /**
  43490. * Gets a boolean indicating that the given extension can be loaded
  43491. * @param extension defines the extension to load
  43492. * @returns true if the extension is supported
  43493. */
  43494. static IsPluginForExtensionAvailable(extension: string): boolean;
  43495. /**
  43496. * Adds a new plugin to the list of registered plugins
  43497. * @param plugin defines the plugin to add
  43498. */
  43499. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43500. /**
  43501. * Import meshes into a scene
  43502. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43503. * @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)
  43504. * @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)
  43505. * @param scene the instance of BABYLON.Scene to append to
  43506. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43507. * @param onProgress a callback with a progress event for each file being loaded
  43508. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43509. * @param pluginExtension the extension used to determine the plugin
  43510. * @returns The loaded plugin
  43511. */
  43512. 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>;
  43513. /**
  43514. * Import meshes into a scene
  43515. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43516. * @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)
  43517. * @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)
  43518. * @param scene the instance of BABYLON.Scene to append to
  43519. * @param onProgress a callback with a progress event for each file being loaded
  43520. * @param pluginExtension the extension used to determine the plugin
  43521. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43522. */
  43523. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43524. meshes: AbstractMesh[];
  43525. particleSystems: IParticleSystem[];
  43526. skeletons: Skeleton[];
  43527. animationGroups: AnimationGroup[];
  43528. }>;
  43529. /**
  43530. * Load a scene
  43531. * @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)
  43532. * @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)
  43533. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43534. * @param onSuccess a callback with the scene when import succeeds
  43535. * @param onProgress a callback with a progress event for each file being loaded
  43536. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43537. * @param pluginExtension the extension used to determine the plugin
  43538. * @returns The loaded plugin
  43539. */
  43540. 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>;
  43541. /**
  43542. * Load a scene
  43543. * @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)
  43544. * @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)
  43545. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43546. * @param onProgress a callback with a progress event for each file being loaded
  43547. * @param pluginExtension the extension used to determine the plugin
  43548. * @returns The loaded scene
  43549. */
  43550. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43551. /**
  43552. * Append a scene
  43553. * @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)
  43554. * @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)
  43555. * @param scene is the instance of BABYLON.Scene to append to
  43556. * @param onSuccess a callback with the scene when import succeeds
  43557. * @param onProgress a callback with a progress event for each file being loaded
  43558. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43559. * @param pluginExtension the extension used to determine the plugin
  43560. * @returns The loaded plugin
  43561. */
  43562. 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>;
  43563. /**
  43564. * Append a scene
  43565. * @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)
  43566. * @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)
  43567. * @param scene is the instance of BABYLON.Scene to append to
  43568. * @param onProgress a callback with a progress event for each file being loaded
  43569. * @param pluginExtension the extension used to determine the plugin
  43570. * @returns The given scene
  43571. */
  43572. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43573. /**
  43574. * Load a scene into an asset container
  43575. * @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)
  43576. * @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)
  43577. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43578. * @param onSuccess a callback with the scene when import succeeds
  43579. * @param onProgress a callback with a progress event for each file being loaded
  43580. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43581. * @param pluginExtension the extension used to determine the plugin
  43582. * @returns The loaded plugin
  43583. */
  43584. 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>;
  43585. /**
  43586. * Load a scene into an asset container
  43587. * @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)
  43588. * @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)
  43589. * @param scene is the instance of Scene to append to
  43590. * @param onProgress a callback with a progress event for each file being loaded
  43591. * @param pluginExtension the extension used to determine the plugin
  43592. * @returns The loaded asset container
  43593. */
  43594. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43595. /**
  43596. * Import animations from a file into a scene
  43597. * @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)
  43598. * @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)
  43599. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43600. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43601. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43602. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43603. * @param onSuccess a callback with the scene when import succeeds
  43604. * @param onProgress a callback with a progress event for each file being loaded
  43605. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43606. */
  43607. 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;
  43608. /**
  43609. * Import animations from a file into a scene
  43610. * @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)
  43611. * @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)
  43612. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43613. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43614. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43615. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43616. * @param onSuccess a callback with the scene when import succeeds
  43617. * @param onProgress a callback with a progress event for each file being loaded
  43618. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43619. * @returns the updated scene with imported animations
  43620. */
  43621. 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>;
  43622. }
  43623. }
  43624. declare module BABYLON {
  43625. /**
  43626. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43627. */
  43628. export type MotionControllerHandness = "none" | "left" | "right";
  43629. /**
  43630. * The type of components available in motion controllers.
  43631. * This is not the name of the component.
  43632. */
  43633. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43634. /**
  43635. * The state of a controller component
  43636. */
  43637. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43638. /**
  43639. * The schema of motion controller layout.
  43640. * No object will be initialized using this interface
  43641. * This is used just to define the profile.
  43642. */
  43643. export interface IMotionControllerLayout {
  43644. /**
  43645. * Path to load the assets. Usually relative to the base path
  43646. */
  43647. assetPath: string;
  43648. /**
  43649. * Available components (unsorted)
  43650. */
  43651. components: {
  43652. /**
  43653. * A map of component Ids
  43654. */
  43655. [componentId: string]: {
  43656. /**
  43657. * The type of input the component outputs
  43658. */
  43659. type: MotionControllerComponentType;
  43660. /**
  43661. * The indices of this component in the gamepad object
  43662. */
  43663. gamepadIndices: {
  43664. /**
  43665. * Index of button
  43666. */
  43667. button?: number;
  43668. /**
  43669. * If available, index of x-axis
  43670. */
  43671. xAxis?: number;
  43672. /**
  43673. * If available, index of y-axis
  43674. */
  43675. yAxis?: number;
  43676. };
  43677. /**
  43678. * The mesh's root node name
  43679. */
  43680. rootNodeName: string;
  43681. /**
  43682. * Animation definitions for this model
  43683. */
  43684. visualResponses: {
  43685. [stateKey: string]: {
  43686. /**
  43687. * What property will be animated
  43688. */
  43689. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43690. /**
  43691. * What states influence this visual response
  43692. */
  43693. states: MotionControllerComponentStateType[];
  43694. /**
  43695. * Type of animation - movement or visibility
  43696. */
  43697. valueNodeProperty: "transform" | "visibility";
  43698. /**
  43699. * Base node name to move. Its position will be calculated according to the min and max nodes
  43700. */
  43701. valueNodeName?: string;
  43702. /**
  43703. * Minimum movement node
  43704. */
  43705. minNodeName?: string;
  43706. /**
  43707. * Max movement node
  43708. */
  43709. maxNodeName?: string;
  43710. };
  43711. };
  43712. /**
  43713. * If touch enabled, what is the name of node to display user feedback
  43714. */
  43715. touchPointNodeName?: string;
  43716. };
  43717. };
  43718. /**
  43719. * Is it xr standard mapping or not
  43720. */
  43721. gamepadMapping: "" | "xr-standard";
  43722. /**
  43723. * Base root node of this entire model
  43724. */
  43725. rootNodeName: string;
  43726. /**
  43727. * Defines the main button component id
  43728. */
  43729. selectComponentId: string;
  43730. }
  43731. /**
  43732. * A definition for the layout map in the input profile
  43733. */
  43734. export interface IMotionControllerLayoutMap {
  43735. /**
  43736. * Layouts with handness type as a key
  43737. */
  43738. [handness: string]: IMotionControllerLayout;
  43739. }
  43740. /**
  43741. * The XR Input profile schema
  43742. * Profiles can be found here:
  43743. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43744. */
  43745. export interface IMotionControllerProfile {
  43746. /**
  43747. * fallback profiles for this profileId
  43748. */
  43749. fallbackProfileIds: string[];
  43750. /**
  43751. * The layout map, with handness as key
  43752. */
  43753. layouts: IMotionControllerLayoutMap;
  43754. /**
  43755. * The id of this profile
  43756. * correlates to the profile(s) in the xrInput.profiles array
  43757. */
  43758. profileId: string;
  43759. }
  43760. /**
  43761. * A helper-interface for the 3 meshes needed for controller button animation
  43762. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43763. */
  43764. export interface IMotionControllerButtonMeshMap {
  43765. /**
  43766. * the mesh that defines the pressed value mesh position.
  43767. * This is used to find the max-position of this button
  43768. */
  43769. pressedMesh: AbstractMesh;
  43770. /**
  43771. * the mesh that defines the unpressed value mesh position.
  43772. * This is used to find the min (or initial) position of this button
  43773. */
  43774. unpressedMesh: AbstractMesh;
  43775. /**
  43776. * The mesh that will be changed when value changes
  43777. */
  43778. valueMesh: AbstractMesh;
  43779. }
  43780. /**
  43781. * A helper-interface for the 3 meshes needed for controller axis animation.
  43782. * This will be expanded when touchpad animations are fully supported
  43783. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43784. */
  43785. export interface IMotionControllerMeshMap {
  43786. /**
  43787. * the mesh that defines the maximum value mesh position.
  43788. */
  43789. maxMesh?: AbstractMesh;
  43790. /**
  43791. * the mesh that defines the minimum value mesh position.
  43792. */
  43793. minMesh?: AbstractMesh;
  43794. /**
  43795. * The mesh that will be changed when axis value changes
  43796. */
  43797. valueMesh: AbstractMesh;
  43798. }
  43799. /**
  43800. * The elements needed for change-detection of the gamepad objects in motion controllers
  43801. */
  43802. export interface IMinimalMotionControllerObject {
  43803. /**
  43804. * Available axes of this controller
  43805. */
  43806. axes: number[];
  43807. /**
  43808. * An array of available buttons
  43809. */
  43810. buttons: Array<{
  43811. /**
  43812. * Value of the button/trigger
  43813. */
  43814. value: number;
  43815. /**
  43816. * If the button/trigger is currently touched
  43817. */
  43818. touched: boolean;
  43819. /**
  43820. * If the button/trigger is currently pressed
  43821. */
  43822. pressed: boolean;
  43823. }>;
  43824. }
  43825. /**
  43826. * An Abstract Motion controller
  43827. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43828. * Each component has an observable to check for changes in value and state
  43829. */
  43830. export abstract class WebXRAbstractMotionController implements IDisposable {
  43831. protected scene: Scene;
  43832. protected layout: IMotionControllerLayout;
  43833. /**
  43834. * The gamepad object correlating to this controller
  43835. */
  43836. gamepadObject: IMinimalMotionControllerObject;
  43837. /**
  43838. * handness (left/right/none) of this controller
  43839. */
  43840. handness: MotionControllerHandness;
  43841. private _initComponent;
  43842. private _modelReady;
  43843. /**
  43844. * A map of components (WebXRControllerComponent) in this motion controller
  43845. * Components have a ComponentType and can also have both button and axis definitions
  43846. */
  43847. readonly components: {
  43848. [id: string]: WebXRControllerComponent;
  43849. };
  43850. /**
  43851. * Disable the model's animation. Can be set at any time.
  43852. */
  43853. disableAnimation: boolean;
  43854. /**
  43855. * Observers registered here will be triggered when the model of this controller is done loading
  43856. */
  43857. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43858. /**
  43859. * The profile id of this motion controller
  43860. */
  43861. abstract profileId: string;
  43862. /**
  43863. * The root mesh of the model. It is null if the model was not yet initialized
  43864. */
  43865. rootMesh: Nullable<AbstractMesh>;
  43866. /**
  43867. * constructs a new abstract motion controller
  43868. * @param scene the scene to which the model of the controller will be added
  43869. * @param layout The profile layout to load
  43870. * @param gamepadObject The gamepad object correlating to this controller
  43871. * @param handness handness (left/right/none) of this controller
  43872. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43873. */
  43874. constructor(scene: Scene, layout: IMotionControllerLayout,
  43875. /**
  43876. * The gamepad object correlating to this controller
  43877. */
  43878. gamepadObject: IMinimalMotionControllerObject,
  43879. /**
  43880. * handness (left/right/none) of this controller
  43881. */
  43882. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43883. /**
  43884. * Dispose this controller, the model mesh and all its components
  43885. */
  43886. dispose(): void;
  43887. /**
  43888. * Returns all components of specific type
  43889. * @param type the type to search for
  43890. * @return an array of components with this type
  43891. */
  43892. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43893. /**
  43894. * get a component based an its component id as defined in layout.components
  43895. * @param id the id of the component
  43896. * @returns the component correlates to the id or undefined if not found
  43897. */
  43898. getComponent(id: string): WebXRControllerComponent;
  43899. /**
  43900. * Get the list of components available in this motion controller
  43901. * @returns an array of strings correlating to available components
  43902. */
  43903. getComponentIds(): string[];
  43904. /**
  43905. * Get the first component of specific type
  43906. * @param type type of component to find
  43907. * @return a controller component or null if not found
  43908. */
  43909. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43910. /**
  43911. * Get the main (Select) component of this controller as defined in the layout
  43912. * @returns the main component of this controller
  43913. */
  43914. getMainComponent(): WebXRControllerComponent;
  43915. /**
  43916. * Loads the model correlating to this controller
  43917. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43918. * @returns A promise fulfilled with the result of the model loading
  43919. */
  43920. loadModel(): Promise<boolean>;
  43921. /**
  43922. * Update this model using the current XRFrame
  43923. * @param xrFrame the current xr frame to use and update the model
  43924. */
  43925. updateFromXRFrame(xrFrame: XRFrame): void;
  43926. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43927. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43928. /**
  43929. * Moves the axis on the controller mesh based on its current state
  43930. * @param axis the index of the axis
  43931. * @param axisValue the value of the axis which determines the meshes new position
  43932. * @hidden
  43933. */
  43934. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43935. /**
  43936. * Update the model itself with the current frame data
  43937. * @param xrFrame the frame to use for updating the model mesh
  43938. */
  43939. protected updateModel(xrFrame: XRFrame): void;
  43940. /**
  43941. * Get the filename and path for this controller's model
  43942. * @returns a map of filename and path
  43943. */
  43944. protected abstract _getFilenameAndPath(): {
  43945. filename: string;
  43946. path: string;
  43947. };
  43948. /**
  43949. * This function is called before the mesh is loaded. It checks for loading constraints.
  43950. * For example, this function can check if the GLB loader is available
  43951. * If this function returns false, the generic controller will be loaded instead
  43952. * @returns Is the client ready to load the mesh
  43953. */
  43954. protected abstract _getModelLoadingConstraints(): boolean;
  43955. /**
  43956. * This function will be called after the model was successfully loaded and can be used
  43957. * for mesh transformations before it is available for the user
  43958. * @param meshes the loaded meshes
  43959. */
  43960. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43961. /**
  43962. * Set the root mesh for this controller. Important for the WebXR controller class
  43963. * @param meshes the loaded meshes
  43964. */
  43965. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43966. /**
  43967. * A function executed each frame that updates the mesh (if needed)
  43968. * @param xrFrame the current xrFrame
  43969. */
  43970. protected abstract _updateModel(xrFrame: XRFrame): void;
  43971. private _getGenericFilenameAndPath;
  43972. private _getGenericParentMesh;
  43973. }
  43974. }
  43975. declare module BABYLON {
  43976. /**
  43977. * A generic trigger-only motion controller for WebXR
  43978. */
  43979. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43980. /**
  43981. * Static version of the profile id of this controller
  43982. */
  43983. static ProfileId: string;
  43984. profileId: string;
  43985. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43986. protected _getFilenameAndPath(): {
  43987. filename: string;
  43988. path: string;
  43989. };
  43990. protected _getModelLoadingConstraints(): boolean;
  43991. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43992. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43993. protected _updateModel(): void;
  43994. }
  43995. }
  43996. declare module BABYLON {
  43997. /**
  43998. * Class containing static functions to help procedurally build meshes
  43999. */
  44000. export class SphereBuilder {
  44001. /**
  44002. * Creates a sphere mesh
  44003. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44004. * * 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`)
  44005. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44006. * * 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
  44007. * * 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)
  44008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44009. * * 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
  44010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44011. * @param name defines the name of the mesh
  44012. * @param options defines the options used to create the mesh
  44013. * @param scene defines the hosting scene
  44014. * @returns the sphere mesh
  44015. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44016. */
  44017. static CreateSphere(name: string, options: {
  44018. segments?: number;
  44019. diameter?: number;
  44020. diameterX?: number;
  44021. diameterY?: number;
  44022. diameterZ?: number;
  44023. arc?: number;
  44024. slice?: number;
  44025. sideOrientation?: number;
  44026. frontUVs?: Vector4;
  44027. backUVs?: Vector4;
  44028. updatable?: boolean;
  44029. }, scene?: Nullable<Scene>): Mesh;
  44030. }
  44031. }
  44032. declare module BABYLON {
  44033. /**
  44034. * A profiled motion controller has its profile loaded from an online repository.
  44035. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44036. */
  44037. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44038. private _repositoryUrl;
  44039. private _buttonMeshMapping;
  44040. private _touchDots;
  44041. /**
  44042. * The profile ID of this controller. Will be populated when the controller initializes.
  44043. */
  44044. profileId: string;
  44045. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44046. dispose(): void;
  44047. protected _getFilenameAndPath(): {
  44048. filename: string;
  44049. path: string;
  44050. };
  44051. protected _getModelLoadingConstraints(): boolean;
  44052. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44053. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44054. protected _updateModel(_xrFrame: XRFrame): void;
  44055. }
  44056. }
  44057. declare module BABYLON {
  44058. /**
  44059. * A construction function type to create a new controller based on an xrInput object
  44060. */
  44061. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44062. /**
  44063. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44064. *
  44065. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44066. * it should be replaced with auto-loaded controllers.
  44067. *
  44068. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44069. */
  44070. export class WebXRMotionControllerManager {
  44071. private static _AvailableControllers;
  44072. private static _Fallbacks;
  44073. private static _ProfileLoadingPromises;
  44074. private static _ProfilesList;
  44075. /**
  44076. * The base URL of the online controller repository. Can be changed at any time.
  44077. */
  44078. static BaseRepositoryUrl: string;
  44079. /**
  44080. * Which repository gets priority - local or online
  44081. */
  44082. static PrioritizeOnlineRepository: boolean;
  44083. /**
  44084. * Use the online repository, or use only locally-defined controllers
  44085. */
  44086. static UseOnlineRepository: boolean;
  44087. /**
  44088. * Clear the cache used for profile loading and reload when requested again
  44089. */
  44090. static ClearProfilesCache(): void;
  44091. /**
  44092. * Register the default fallbacks.
  44093. * This function is called automatically when this file is imported.
  44094. */
  44095. static DefaultFallbacks(): void;
  44096. /**
  44097. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44098. * @param profileId the profile to which a fallback needs to be found
  44099. * @return an array with corresponding fallback profiles
  44100. */
  44101. static FindFallbackWithProfileId(profileId: string): string[];
  44102. /**
  44103. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44104. * The order of search:
  44105. *
  44106. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44107. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44108. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44109. * 4) return the generic trigger controller if none were found
  44110. *
  44111. * @param xrInput the xrInput to which a new controller is initialized
  44112. * @param scene the scene to which the model will be added
  44113. * @param forceProfile force a certain profile for this controller
  44114. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44115. */
  44116. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44117. /**
  44118. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44119. *
  44120. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44121. *
  44122. * @param type the profile type to register
  44123. * @param constructFunction the function to be called when loading this profile
  44124. */
  44125. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44126. /**
  44127. * Register a fallback to a specific profile.
  44128. * @param profileId the profileId that will receive the fallbacks
  44129. * @param fallbacks A list of fallback profiles
  44130. */
  44131. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44132. /**
  44133. * Will update the list of profiles available in the repository
  44134. * @return a promise that resolves to a map of profiles available online
  44135. */
  44136. static UpdateProfilesList(): Promise<{
  44137. [profile: string]: string;
  44138. }>;
  44139. private static _LoadProfileFromRepository;
  44140. private static _LoadProfilesFromAvailableControllers;
  44141. }
  44142. }
  44143. declare module BABYLON {
  44144. /**
  44145. * Configuration options for the WebXR controller creation
  44146. */
  44147. export interface IWebXRControllerOptions {
  44148. /**
  44149. * Should the controller mesh be animated when a user interacts with it
  44150. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44151. */
  44152. disableMotionControllerAnimation?: boolean;
  44153. /**
  44154. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44155. */
  44156. doNotLoadControllerMesh?: boolean;
  44157. /**
  44158. * Force a specific controller type for this controller.
  44159. * This can be used when creating your own profile or when testing different controllers
  44160. */
  44161. forceControllerProfile?: string;
  44162. }
  44163. /**
  44164. * Represents an XR controller
  44165. */
  44166. export class WebXRInputSource {
  44167. private _scene;
  44168. /** The underlying input source for the controller */
  44169. inputSource: XRInputSource;
  44170. private _options;
  44171. private _tmpQuaternion;
  44172. private _tmpVector;
  44173. private _uniqueId;
  44174. /**
  44175. * 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
  44176. */
  44177. grip?: AbstractMesh;
  44178. /**
  44179. * If available, this is the gamepad object related to this controller.
  44180. * Using this object it is possible to get click events and trackpad changes of the
  44181. * webxr controller that is currently being used.
  44182. */
  44183. motionController?: WebXRAbstractMotionController;
  44184. /**
  44185. * Event that fires when the controller is removed/disposed.
  44186. * The object provided as event data is this controller, after associated assets were disposed.
  44187. * uniqueId is still available.
  44188. */
  44189. onDisposeObservable: Observable<WebXRInputSource>;
  44190. /**
  44191. * Will be triggered when the mesh associated with the motion controller is done loading.
  44192. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44193. * A shortened version of controller -> motion controller -> on mesh loaded.
  44194. */
  44195. onMeshLoadedObservable: Observable<AbstractMesh>;
  44196. /**
  44197. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44198. */
  44199. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44200. /**
  44201. * Pointer which can be used to select objects or attach a visible laser to
  44202. */
  44203. pointer: AbstractMesh;
  44204. /**
  44205. * Creates the controller
  44206. * @see https://doc.babylonjs.com/how_to/webxr
  44207. * @param _scene the scene which the controller should be associated to
  44208. * @param inputSource the underlying input source for the controller
  44209. * @param _options options for this controller creation
  44210. */
  44211. constructor(_scene: Scene,
  44212. /** The underlying input source for the controller */
  44213. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44214. /**
  44215. * Get this controllers unique id
  44216. */
  44217. get uniqueId(): string;
  44218. /**
  44219. * Disposes of the object
  44220. */
  44221. dispose(): void;
  44222. /**
  44223. * Gets a world space ray coming from the pointer or grip
  44224. * @param result the resulting ray
  44225. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44226. */
  44227. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44228. /**
  44229. * Updates the controller pose based on the given XRFrame
  44230. * @param xrFrame xr frame to update the pose with
  44231. * @param referenceSpace reference space to use
  44232. */
  44233. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44234. }
  44235. }
  44236. declare module BABYLON {
  44237. /**
  44238. * The schema for initialization options of the XR Input class
  44239. */
  44240. export interface IWebXRInputOptions {
  44241. /**
  44242. * If set to true no model will be automatically loaded
  44243. */
  44244. doNotLoadControllerMeshes?: boolean;
  44245. /**
  44246. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44247. * If not found, the xr input profile data will be used.
  44248. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44249. */
  44250. forceInputProfile?: string;
  44251. /**
  44252. * Do not send a request to the controller repository to load the profile.
  44253. *
  44254. * Instead, use the controllers available in babylon itself.
  44255. */
  44256. disableOnlineControllerRepository?: boolean;
  44257. /**
  44258. * A custom URL for the controllers repository
  44259. */
  44260. customControllersRepositoryURL?: string;
  44261. /**
  44262. * Should the controller model's components not move according to the user input
  44263. */
  44264. disableControllerAnimation?: boolean;
  44265. }
  44266. /**
  44267. * XR input used to track XR inputs such as controllers/rays
  44268. */
  44269. export class WebXRInput implements IDisposable {
  44270. /**
  44271. * the xr session manager for this session
  44272. */
  44273. xrSessionManager: WebXRSessionManager;
  44274. /**
  44275. * the WebXR camera for this session. Mainly used for teleportation
  44276. */
  44277. xrCamera: WebXRCamera;
  44278. private readonly options;
  44279. /**
  44280. * XR controllers being tracked
  44281. */
  44282. controllers: Array<WebXRInputSource>;
  44283. private _frameObserver;
  44284. private _sessionEndedObserver;
  44285. private _sessionInitObserver;
  44286. /**
  44287. * Event when a controller has been connected/added
  44288. */
  44289. onControllerAddedObservable: Observable<WebXRInputSource>;
  44290. /**
  44291. * Event when a controller has been removed/disconnected
  44292. */
  44293. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44294. /**
  44295. * Initializes the WebXRInput
  44296. * @param xrSessionManager the xr session manager for this session
  44297. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44298. * @param options = initialization options for this xr input
  44299. */
  44300. constructor(
  44301. /**
  44302. * the xr session manager for this session
  44303. */
  44304. xrSessionManager: WebXRSessionManager,
  44305. /**
  44306. * the WebXR camera for this session. Mainly used for teleportation
  44307. */
  44308. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44309. private _onInputSourcesChange;
  44310. private _addAndRemoveControllers;
  44311. /**
  44312. * Disposes of the object
  44313. */
  44314. dispose(): void;
  44315. }
  44316. }
  44317. declare module BABYLON {
  44318. /**
  44319. * This is the base class for all WebXR features.
  44320. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44321. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44322. */
  44323. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44324. protected _xrSessionManager: WebXRSessionManager;
  44325. private _attached;
  44326. private _removeOnDetach;
  44327. /**
  44328. * Should auto-attach be disabled?
  44329. */
  44330. disableAutoAttach: boolean;
  44331. /**
  44332. * Construct a new (abstract) WebXR feature
  44333. * @param _xrSessionManager the xr session manager for this feature
  44334. */
  44335. constructor(_xrSessionManager: WebXRSessionManager);
  44336. /**
  44337. * Is this feature attached
  44338. */
  44339. get attached(): boolean;
  44340. /**
  44341. * attach this feature
  44342. *
  44343. * @param force should attachment be forced (even when already attached)
  44344. * @returns true if successful, false is failed or already attached
  44345. */
  44346. attach(force?: boolean): boolean;
  44347. /**
  44348. * detach this feature.
  44349. *
  44350. * @returns true if successful, false if failed or already detached
  44351. */
  44352. detach(): boolean;
  44353. /**
  44354. * Dispose this feature and all of the resources attached
  44355. */
  44356. dispose(): void;
  44357. /**
  44358. * This is used to register callbacks that will automatically be removed when detach is called.
  44359. * @param observable the observable to which the observer will be attached
  44360. * @param callback the callback to register
  44361. */
  44362. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44363. /**
  44364. * Code in this function will be executed on each xrFrame received from the browser.
  44365. * This function will not execute after the feature is detached.
  44366. * @param _xrFrame the current frame
  44367. */
  44368. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44369. }
  44370. }
  44371. declare module BABYLON {
  44372. /**
  44373. * Renders a layer on top of an existing scene
  44374. */
  44375. export class UtilityLayerRenderer implements IDisposable {
  44376. /** the original scene that will be rendered on top of */
  44377. originalScene: Scene;
  44378. private _pointerCaptures;
  44379. private _lastPointerEvents;
  44380. private static _DefaultUtilityLayer;
  44381. private static _DefaultKeepDepthUtilityLayer;
  44382. private _sharedGizmoLight;
  44383. private _renderCamera;
  44384. /**
  44385. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44386. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44387. * @returns the camera that is used when rendering the utility layer
  44388. */
  44389. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44390. /**
  44391. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44392. * @param cam the camera that should be used when rendering the utility layer
  44393. */
  44394. setRenderCamera(cam: Nullable<Camera>): void;
  44395. /**
  44396. * @hidden
  44397. * Light which used by gizmos to get light shading
  44398. */
  44399. _getSharedGizmoLight(): HemisphericLight;
  44400. /**
  44401. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44402. */
  44403. pickUtilitySceneFirst: boolean;
  44404. /**
  44405. * 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)
  44406. */
  44407. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44408. /**
  44409. * 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)
  44410. */
  44411. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44412. /**
  44413. * The scene that is rendered on top of the original scene
  44414. */
  44415. utilityLayerScene: Scene;
  44416. /**
  44417. * If the utility layer should automatically be rendered on top of existing scene
  44418. */
  44419. shouldRender: boolean;
  44420. /**
  44421. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44422. */
  44423. onlyCheckPointerDownEvents: boolean;
  44424. /**
  44425. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44426. */
  44427. processAllEvents: boolean;
  44428. /**
  44429. * Observable raised when the pointer move from the utility layer scene to the main scene
  44430. */
  44431. onPointerOutObservable: Observable<number>;
  44432. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44433. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44434. private _afterRenderObserver;
  44435. private _sceneDisposeObserver;
  44436. private _originalPointerObserver;
  44437. /**
  44438. * Instantiates a UtilityLayerRenderer
  44439. * @param originalScene the original scene that will be rendered on top of
  44440. * @param handleEvents boolean indicating if the utility layer should handle events
  44441. */
  44442. constructor(
  44443. /** the original scene that will be rendered on top of */
  44444. originalScene: Scene, handleEvents?: boolean);
  44445. private _notifyObservers;
  44446. /**
  44447. * Renders the utility layers scene on top of the original scene
  44448. */
  44449. render(): void;
  44450. /**
  44451. * Disposes of the renderer
  44452. */
  44453. dispose(): void;
  44454. private _updateCamera;
  44455. }
  44456. }
  44457. declare module BABYLON {
  44458. /**
  44459. * Options interface for the pointer selection module
  44460. */
  44461. export interface IWebXRControllerPointerSelectionOptions {
  44462. /**
  44463. * if provided, this scene will be used to render meshes.
  44464. */
  44465. customUtilityLayerScene?: Scene;
  44466. /**
  44467. * 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)
  44468. * If not disabled, the last picked point will be used to execute a pointer up event
  44469. * If disabled, pointer up event will be triggered right after the pointer down event.
  44470. * Used in screen and gaze target ray mode only
  44471. */
  44472. disablePointerUpOnTouchOut: boolean;
  44473. /**
  44474. * For gaze mode (time to select instead of press)
  44475. */
  44476. forceGazeMode: boolean;
  44477. /**
  44478. * 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
  44479. * to start a new countdown to the pointer down event.
  44480. * Defaults to 1.
  44481. */
  44482. gazeModePointerMovedFactor?: number;
  44483. /**
  44484. * Different button type to use instead of the main component
  44485. */
  44486. overrideButtonId?: string;
  44487. /**
  44488. * use this rendering group id for the meshes (optional)
  44489. */
  44490. renderingGroupId?: number;
  44491. /**
  44492. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44493. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44494. * 3000 means 3 seconds between pointing at something and selecting it
  44495. */
  44496. timeToSelect?: number;
  44497. /**
  44498. * Should meshes created here be added to a utility layer or the main scene
  44499. */
  44500. useUtilityLayer?: boolean;
  44501. /**
  44502. * the xr input to use with this pointer selection
  44503. */
  44504. xrInput: WebXRInput;
  44505. }
  44506. /**
  44507. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44508. */
  44509. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44510. private readonly _options;
  44511. private static _idCounter;
  44512. private _attachController;
  44513. private _controllers;
  44514. private _scene;
  44515. private _tmpVectorForPickCompare;
  44516. /**
  44517. * The module's name
  44518. */
  44519. static readonly Name: string;
  44520. /**
  44521. * The (Babylon) version of this module.
  44522. * This is an integer representing the implementation version.
  44523. * This number does not correspond to the WebXR specs version
  44524. */
  44525. static readonly Version: number;
  44526. /**
  44527. * Disable lighting on the laser pointer (so it will always be visible)
  44528. */
  44529. disablePointerLighting: boolean;
  44530. /**
  44531. * Disable lighting on the selection mesh (so it will always be visible)
  44532. */
  44533. disableSelectionMeshLighting: boolean;
  44534. /**
  44535. * Should the laser pointer be displayed
  44536. */
  44537. displayLaserPointer: boolean;
  44538. /**
  44539. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44540. */
  44541. displaySelectionMesh: boolean;
  44542. /**
  44543. * This color will be set to the laser pointer when selection is triggered
  44544. */
  44545. laserPointerPickedColor: Color3;
  44546. /**
  44547. * Default color of the laser pointer
  44548. */
  44549. lasterPointerDefaultColor: Color3;
  44550. /**
  44551. * default color of the selection ring
  44552. */
  44553. selectionMeshDefaultColor: Color3;
  44554. /**
  44555. * This color will be applied to the selection ring when selection is triggered
  44556. */
  44557. selectionMeshPickedColor: Color3;
  44558. /**
  44559. * constructs a new background remover module
  44560. * @param _xrSessionManager the session manager for this module
  44561. * @param _options read-only options to be used in this module
  44562. */
  44563. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44564. /**
  44565. * attach this feature
  44566. * Will usually be called by the features manager
  44567. *
  44568. * @returns true if successful.
  44569. */
  44570. attach(): boolean;
  44571. /**
  44572. * detach this feature.
  44573. * Will usually be called by the features manager
  44574. *
  44575. * @returns true if successful.
  44576. */
  44577. detach(): boolean;
  44578. /**
  44579. * Will get the mesh under a specific pointer.
  44580. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44581. * @param controllerId the controllerId to check
  44582. * @returns The mesh under pointer or null if no mesh is under the pointer
  44583. */
  44584. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44585. /**
  44586. * Get the xr controller that correlates to the pointer id in the pointer event
  44587. *
  44588. * @param id the pointer id to search for
  44589. * @returns the controller that correlates to this id or null if not found
  44590. */
  44591. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44592. protected _onXRFrame(_xrFrame: XRFrame): void;
  44593. private _attachGazeMode;
  44594. private _attachScreenRayMode;
  44595. private _attachTrackedPointerRayMode;
  44596. private _convertNormalToDirectionOfRay;
  44597. private _detachController;
  44598. private _generateNewMeshPair;
  44599. private _pickingMoved;
  44600. private _updatePointerDistance;
  44601. }
  44602. }
  44603. declare module BABYLON {
  44604. /**
  44605. * Button which can be used to enter a different mode of XR
  44606. */
  44607. export class WebXREnterExitUIButton {
  44608. /** button element */
  44609. element: HTMLElement;
  44610. /** XR initialization options for the button */
  44611. sessionMode: XRSessionMode;
  44612. /** Reference space type */
  44613. referenceSpaceType: XRReferenceSpaceType;
  44614. /**
  44615. * Creates a WebXREnterExitUIButton
  44616. * @param element button element
  44617. * @param sessionMode XR initialization session mode
  44618. * @param referenceSpaceType the type of reference space to be used
  44619. */
  44620. constructor(
  44621. /** button element */
  44622. element: HTMLElement,
  44623. /** XR initialization options for the button */
  44624. sessionMode: XRSessionMode,
  44625. /** Reference space type */
  44626. referenceSpaceType: XRReferenceSpaceType);
  44627. /**
  44628. * Extendable function which can be used to update the button's visuals when the state changes
  44629. * @param activeButton the current active button in the UI
  44630. */
  44631. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44632. }
  44633. /**
  44634. * Options to create the webXR UI
  44635. */
  44636. export class WebXREnterExitUIOptions {
  44637. /**
  44638. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44639. */
  44640. customButtons?: Array<WebXREnterExitUIButton>;
  44641. /**
  44642. * A reference space type to use when creating the default button.
  44643. * Default is local-floor
  44644. */
  44645. referenceSpaceType?: XRReferenceSpaceType;
  44646. /**
  44647. * Context to enter xr with
  44648. */
  44649. renderTarget?: Nullable<WebXRRenderTarget>;
  44650. /**
  44651. * A session mode to use when creating the default button.
  44652. * Default is immersive-vr
  44653. */
  44654. sessionMode?: XRSessionMode;
  44655. }
  44656. /**
  44657. * UI to allow the user to enter/exit XR mode
  44658. */
  44659. export class WebXREnterExitUI implements IDisposable {
  44660. private scene;
  44661. /** version of the options passed to this UI */
  44662. options: WebXREnterExitUIOptions;
  44663. private _activeButton;
  44664. private _buttons;
  44665. private _overlay;
  44666. /**
  44667. * Fired every time the active button is changed.
  44668. *
  44669. * When xr is entered via a button that launches xr that button will be the callback parameter
  44670. *
  44671. * When exiting xr the callback parameter will be null)
  44672. */
  44673. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44674. /**
  44675. *
  44676. * @param scene babylon scene object to use
  44677. * @param options (read-only) version of the options passed to this UI
  44678. */
  44679. private constructor();
  44680. /**
  44681. * Creates UI to allow the user to enter/exit XR mode
  44682. * @param scene the scene to add the ui to
  44683. * @param helper the xr experience helper to enter/exit xr with
  44684. * @param options options to configure the UI
  44685. * @returns the created ui
  44686. */
  44687. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44688. /**
  44689. * Disposes of the XR UI component
  44690. */
  44691. dispose(): void;
  44692. private _updateButtons;
  44693. }
  44694. }
  44695. declare module BABYLON {
  44696. /**
  44697. * Class containing static functions to help procedurally build meshes
  44698. */
  44699. export class LinesBuilder {
  44700. /**
  44701. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44702. * * 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
  44703. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44704. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44705. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44706. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44707. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44708. * * 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
  44709. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44711. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44712. * @param name defines the name of the new line system
  44713. * @param options defines the options used to create the line system
  44714. * @param scene defines the hosting scene
  44715. * @returns a new line system mesh
  44716. */
  44717. static CreateLineSystem(name: string, options: {
  44718. lines: Vector3[][];
  44719. updatable?: boolean;
  44720. instance?: Nullable<LinesMesh>;
  44721. colors?: Nullable<Color4[][]>;
  44722. useVertexAlpha?: boolean;
  44723. }, scene: Nullable<Scene>): LinesMesh;
  44724. /**
  44725. * Creates a line mesh
  44726. * 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
  44727. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44728. * * The parameter `points` is an array successive Vector3
  44729. * * 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
  44730. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44731. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44732. * * When updating an instance, remember that only point positions can change, not the number of points
  44733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44735. * @param name defines the name of the new line system
  44736. * @param options defines the options used to create the line system
  44737. * @param scene defines the hosting scene
  44738. * @returns a new line mesh
  44739. */
  44740. static CreateLines(name: string, options: {
  44741. points: Vector3[];
  44742. updatable?: boolean;
  44743. instance?: Nullable<LinesMesh>;
  44744. colors?: Color4[];
  44745. useVertexAlpha?: boolean;
  44746. }, scene?: Nullable<Scene>): LinesMesh;
  44747. /**
  44748. * Creates a dashed line mesh
  44749. * * 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
  44750. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44751. * * The parameter `points` is an array successive Vector3
  44752. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44753. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44754. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44755. * * 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
  44756. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44757. * * When updating an instance, remember that only point positions can change, not the number of points
  44758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44759. * @param name defines the name of the mesh
  44760. * @param options defines the options used to create the mesh
  44761. * @param scene defines the hosting scene
  44762. * @returns the dashed line mesh
  44763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44764. */
  44765. static CreateDashedLines(name: string, options: {
  44766. points: Vector3[];
  44767. dashSize?: number;
  44768. gapSize?: number;
  44769. dashNb?: number;
  44770. updatable?: boolean;
  44771. instance?: LinesMesh;
  44772. useVertexAlpha?: boolean;
  44773. }, scene?: Nullable<Scene>): LinesMesh;
  44774. }
  44775. }
  44776. declare module BABYLON {
  44777. /**
  44778. * The options container for the teleportation module
  44779. */
  44780. export interface IWebXRTeleportationOptions {
  44781. /**
  44782. * if provided, this scene will be used to render meshes.
  44783. */
  44784. customUtilityLayerScene?: Scene;
  44785. /**
  44786. * Values to configure the default target mesh
  44787. */
  44788. defaultTargetMeshOptions?: {
  44789. /**
  44790. * Fill color of the teleportation area
  44791. */
  44792. teleportationFillColor?: string;
  44793. /**
  44794. * Border color for the teleportation area
  44795. */
  44796. teleportationBorderColor?: string;
  44797. /**
  44798. * Disable the mesh's animation sequence
  44799. */
  44800. disableAnimation?: boolean;
  44801. /**
  44802. * Disable lighting on the material or the ring and arrow
  44803. */
  44804. disableLighting?: boolean;
  44805. /**
  44806. * Override the default material of the torus and arrow
  44807. */
  44808. torusArrowMaterial?: Material;
  44809. };
  44810. /**
  44811. * A list of meshes to use as floor meshes.
  44812. * Meshes can be added and removed after initializing the feature using the
  44813. * addFloorMesh and removeFloorMesh functions
  44814. * If empty, rotation will still work
  44815. */
  44816. floorMeshes?: AbstractMesh[];
  44817. /**
  44818. * use this rendering group id for the meshes (optional)
  44819. */
  44820. renderingGroupId?: number;
  44821. /**
  44822. * Should teleportation move only to snap points
  44823. */
  44824. snapPointsOnly?: boolean;
  44825. /**
  44826. * An array of points to which the teleportation will snap to.
  44827. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  44828. */
  44829. snapPositions?: Vector3[];
  44830. /**
  44831. * How close should the teleportation ray be in order to snap to position.
  44832. * Default to 0.8 units (meters)
  44833. */
  44834. snapToPositionRadius?: number;
  44835. /**
  44836. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44837. * If you want to support rotation, make sure your mesh has a direction indicator.
  44838. *
  44839. * When left untouched, the default mesh will be initialized.
  44840. */
  44841. teleportationTargetMesh?: AbstractMesh;
  44842. /**
  44843. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  44844. */
  44845. timeToTeleport?: number;
  44846. /**
  44847. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  44848. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  44849. */
  44850. useMainComponentOnly?: boolean;
  44851. /**
  44852. * Should meshes created here be added to a utility layer or the main scene
  44853. */
  44854. useUtilityLayer?: boolean;
  44855. /**
  44856. * Babylon XR Input class for controller
  44857. */
  44858. xrInput: WebXRInput;
  44859. }
  44860. /**
  44861. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  44862. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  44863. * the input of the attached controllers.
  44864. */
  44865. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44866. private _options;
  44867. private _controllers;
  44868. private _currentTeleportationControllerId;
  44869. private _floorMeshes;
  44870. private _quadraticBezierCurve;
  44871. private _selectionFeature;
  44872. private _snapToPositions;
  44873. private _snappedToPoint;
  44874. private _teleportationRingMaterial?;
  44875. private _tmpRay;
  44876. private _tmpVector;
  44877. /**
  44878. * The module's name
  44879. */
  44880. static readonly Name: string;
  44881. /**
  44882. * The (Babylon) version of this module.
  44883. * This is an integer representing the implementation version.
  44884. * This number does not correspond to the webxr specs version
  44885. */
  44886. static readonly Version: number;
  44887. /**
  44888. * Is movement backwards enabled
  44889. */
  44890. backwardsMovementEnabled: boolean;
  44891. /**
  44892. * Distance to travel when moving backwards
  44893. */
  44894. backwardsTeleportationDistance: number;
  44895. /**
  44896. * The distance from the user to the inspection point in the direction of the controller
  44897. * A higher number will allow the user to move further
  44898. * defaults to 5 (meters, in xr units)
  44899. */
  44900. parabolicCheckRadius: number;
  44901. /**
  44902. * Should the module support parabolic ray on top of direct ray
  44903. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44904. * Very helpful when moving between floors / different heights
  44905. */
  44906. parabolicRayEnabled: boolean;
  44907. /**
  44908. * How much rotation should be applied when rotating right and left
  44909. */
  44910. rotationAngle: number;
  44911. /**
  44912. * Is rotation enabled when moving forward?
  44913. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44914. */
  44915. rotationEnabled: boolean;
  44916. /**
  44917. * constructs a new anchor system
  44918. * @param _xrSessionManager an instance of WebXRSessionManager
  44919. * @param _options configuration object for this feature
  44920. */
  44921. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44922. /**
  44923. * Get the snapPointsOnly flag
  44924. */
  44925. get snapPointsOnly(): boolean;
  44926. /**
  44927. * Sets the snapPointsOnly flag
  44928. * @param snapToPoints should teleportation be exclusively to snap points
  44929. */
  44930. set snapPointsOnly(snapToPoints: boolean);
  44931. /**
  44932. * Add a new mesh to the floor meshes array
  44933. * @param mesh the mesh to use as floor mesh
  44934. */
  44935. addFloorMesh(mesh: AbstractMesh): void;
  44936. /**
  44937. * Add a new snap-to point to fix teleportation to this position
  44938. * @param newSnapPoint The new Snap-To point
  44939. */
  44940. addSnapPoint(newSnapPoint: Vector3): void;
  44941. attach(): boolean;
  44942. detach(): boolean;
  44943. dispose(): void;
  44944. /**
  44945. * Remove a mesh from the floor meshes array
  44946. * @param mesh the mesh to remove
  44947. */
  44948. removeFloorMesh(mesh: AbstractMesh): void;
  44949. /**
  44950. * Remove a mesh from the floor meshes array using its name
  44951. * @param name the mesh name to remove
  44952. */
  44953. removeFloorMeshByName(name: string): void;
  44954. /**
  44955. * 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
  44956. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  44957. * @returns was the point found and removed or not
  44958. */
  44959. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  44960. /**
  44961. * This function sets a selection feature that will be disabled when
  44962. * the forward ray is shown and will be reattached when hidden.
  44963. * This is used to remove the selection rays when moving.
  44964. * @param selectionFeature the feature to disable when forward movement is enabled
  44965. */
  44966. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44967. protected _onXRFrame(_xrFrame: XRFrame): void;
  44968. private _attachController;
  44969. private _createDefaultTargetMesh;
  44970. private _detachController;
  44971. private _findClosestSnapPointWithRadius;
  44972. private _setTargetMeshPosition;
  44973. private _setTargetMeshVisibility;
  44974. private _showParabolicPath;
  44975. private _teleportForward;
  44976. }
  44977. }
  44978. declare module BABYLON {
  44979. /**
  44980. * Options for the default xr helper
  44981. */
  44982. export class WebXRDefaultExperienceOptions {
  44983. /**
  44984. * Enable or disable default UI to enter XR
  44985. */
  44986. disableDefaultUI?: boolean;
  44987. /**
  44988. * Should teleportation not initialize. defaults to false.
  44989. */
  44990. disableTeleportation?: boolean;
  44991. /**
  44992. * Floor meshes that will be used for teleport
  44993. */
  44994. floorMeshes?: Array<AbstractMesh>;
  44995. /**
  44996. * If set to true, the first frame will not be used to reset position
  44997. * The first frame is mainly used when copying transformation from the old camera
  44998. * Mainly used in AR
  44999. */
  45000. ignoreNativeCameraTransformation?: boolean;
  45001. /**
  45002. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45003. */
  45004. inputOptions?: IWebXRInputOptions;
  45005. /**
  45006. * optional configuration for the output canvas
  45007. */
  45008. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45009. /**
  45010. * optional UI options. This can be used among other to change session mode and reference space type
  45011. */
  45012. uiOptions?: WebXREnterExitUIOptions;
  45013. /**
  45014. * When loading teleportation and pointer select, use stable versions instead of latest.
  45015. */
  45016. useStablePlugins?: boolean;
  45017. }
  45018. /**
  45019. * Default experience which provides a similar setup to the previous webVRExperience
  45020. */
  45021. export class WebXRDefaultExperience {
  45022. /**
  45023. * Base experience
  45024. */
  45025. baseExperience: WebXRExperienceHelper;
  45026. /**
  45027. * Enables ui for entering/exiting xr
  45028. */
  45029. enterExitUI: WebXREnterExitUI;
  45030. /**
  45031. * Input experience extension
  45032. */
  45033. input: WebXRInput;
  45034. /**
  45035. * Enables laser pointer and selection
  45036. */
  45037. pointerSelection: WebXRControllerPointerSelection;
  45038. /**
  45039. * Default target xr should render to
  45040. */
  45041. renderTarget: WebXRRenderTarget;
  45042. /**
  45043. * Enables teleportation
  45044. */
  45045. teleportation: WebXRMotionControllerTeleportation;
  45046. private constructor();
  45047. /**
  45048. * Creates the default xr experience
  45049. * @param scene scene
  45050. * @param options options for basic configuration
  45051. * @returns resulting WebXRDefaultExperience
  45052. */
  45053. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45054. /**
  45055. * DIsposes of the experience helper
  45056. */
  45057. dispose(): void;
  45058. }
  45059. }
  45060. declare module BABYLON {
  45061. /**
  45062. * Options to modify the vr teleportation behavior.
  45063. */
  45064. export interface VRTeleportationOptions {
  45065. /**
  45066. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45067. */
  45068. floorMeshName?: string;
  45069. /**
  45070. * A list of meshes to be used as the teleportation floor. (default: empty)
  45071. */
  45072. floorMeshes?: Mesh[];
  45073. /**
  45074. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45075. */
  45076. teleportationMode?: number;
  45077. /**
  45078. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45079. */
  45080. teleportationTime?: number;
  45081. /**
  45082. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45083. */
  45084. teleportationSpeed?: number;
  45085. /**
  45086. * The easing function used in the animation or null for Linear. (default CircleEase)
  45087. */
  45088. easingFunction?: EasingFunction;
  45089. }
  45090. /**
  45091. * Options to modify the vr experience helper's behavior.
  45092. */
  45093. export interface VRExperienceHelperOptions extends WebVROptions {
  45094. /**
  45095. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45096. */
  45097. createDeviceOrientationCamera?: boolean;
  45098. /**
  45099. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45100. */
  45101. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45102. /**
  45103. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45104. */
  45105. laserToggle?: boolean;
  45106. /**
  45107. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45108. */
  45109. floorMeshes?: Mesh[];
  45110. /**
  45111. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45112. */
  45113. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45114. /**
  45115. * Defines if WebXR should be used instead of WebVR (if available)
  45116. */
  45117. useXR?: boolean;
  45118. }
  45119. /**
  45120. * Event containing information after VR has been entered
  45121. */
  45122. export class OnAfterEnteringVRObservableEvent {
  45123. /**
  45124. * If entering vr was successful
  45125. */
  45126. success: boolean;
  45127. }
  45128. /**
  45129. * Helps to quickly add VR support to an existing scene.
  45130. * See http://doc.babylonjs.com/how_to/webvr_helper
  45131. */
  45132. export class VRExperienceHelper {
  45133. /** Options to modify the vr experience helper's behavior. */
  45134. webVROptions: VRExperienceHelperOptions;
  45135. private _scene;
  45136. private _position;
  45137. private _btnVR;
  45138. private _btnVRDisplayed;
  45139. private _webVRsupported;
  45140. private _webVRready;
  45141. private _webVRrequesting;
  45142. private _webVRpresenting;
  45143. private _hasEnteredVR;
  45144. private _fullscreenVRpresenting;
  45145. private _inputElement;
  45146. private _webVRCamera;
  45147. private _vrDeviceOrientationCamera;
  45148. private _deviceOrientationCamera;
  45149. private _existingCamera;
  45150. private _onKeyDown;
  45151. private _onVrDisplayPresentChange;
  45152. private _onVRDisplayChanged;
  45153. private _onVRRequestPresentStart;
  45154. private _onVRRequestPresentComplete;
  45155. /**
  45156. * 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)
  45157. */
  45158. enableGazeEvenWhenNoPointerLock: boolean;
  45159. /**
  45160. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45161. */
  45162. exitVROnDoubleTap: boolean;
  45163. /**
  45164. * Observable raised right before entering VR.
  45165. */
  45166. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45167. /**
  45168. * Observable raised when entering VR has completed.
  45169. */
  45170. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45171. /**
  45172. * Observable raised when exiting VR.
  45173. */
  45174. onExitingVRObservable: Observable<VRExperienceHelper>;
  45175. /**
  45176. * Observable raised when controller mesh is loaded.
  45177. */
  45178. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45179. /** Return this.onEnteringVRObservable
  45180. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45181. */
  45182. get onEnteringVR(): Observable<VRExperienceHelper>;
  45183. /** Return this.onExitingVRObservable
  45184. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45185. */
  45186. get onExitingVR(): Observable<VRExperienceHelper>;
  45187. /** Return this.onControllerMeshLoadedObservable
  45188. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45189. */
  45190. get onControllerMeshLoaded(): Observable<WebVRController>;
  45191. private _rayLength;
  45192. private _useCustomVRButton;
  45193. private _teleportationRequested;
  45194. private _teleportActive;
  45195. private _floorMeshName;
  45196. private _floorMeshesCollection;
  45197. private _teleportationMode;
  45198. private _teleportationTime;
  45199. private _teleportationSpeed;
  45200. private _teleportationEasing;
  45201. private _rotationAllowed;
  45202. private _teleportBackwardsVector;
  45203. private _teleportationTarget;
  45204. private _isDefaultTeleportationTarget;
  45205. private _postProcessMove;
  45206. private _teleportationFillColor;
  45207. private _teleportationBorderColor;
  45208. private _rotationAngle;
  45209. private _haloCenter;
  45210. private _cameraGazer;
  45211. private _padSensibilityUp;
  45212. private _padSensibilityDown;
  45213. private _leftController;
  45214. private _rightController;
  45215. private _gazeColor;
  45216. private _laserColor;
  45217. private _pickedLaserColor;
  45218. private _pickedGazeColor;
  45219. /**
  45220. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45221. */
  45222. onNewMeshSelected: Observable<AbstractMesh>;
  45223. /**
  45224. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45225. * This observable will provide the mesh and the controller used to select the mesh
  45226. */
  45227. onMeshSelectedWithController: Observable<{
  45228. mesh: AbstractMesh;
  45229. controller: WebVRController;
  45230. }>;
  45231. /**
  45232. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45233. */
  45234. onNewMeshPicked: Observable<PickingInfo>;
  45235. private _circleEase;
  45236. /**
  45237. * Observable raised before camera teleportation
  45238. */
  45239. onBeforeCameraTeleport: Observable<Vector3>;
  45240. /**
  45241. * Observable raised after camera teleportation
  45242. */
  45243. onAfterCameraTeleport: Observable<Vector3>;
  45244. /**
  45245. * Observable raised when current selected mesh gets unselected
  45246. */
  45247. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45248. private _raySelectionPredicate;
  45249. /**
  45250. * To be optionaly changed by user to define custom ray selection
  45251. */
  45252. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45253. /**
  45254. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45255. */
  45256. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45257. /**
  45258. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45259. */
  45260. teleportationEnabled: boolean;
  45261. private _defaultHeight;
  45262. private _teleportationInitialized;
  45263. private _interactionsEnabled;
  45264. private _interactionsRequested;
  45265. private _displayGaze;
  45266. private _displayLaserPointer;
  45267. /**
  45268. * The mesh used to display where the user is going to teleport.
  45269. */
  45270. get teleportationTarget(): Mesh;
  45271. /**
  45272. * Sets the mesh to be used to display where the user is going to teleport.
  45273. */
  45274. set teleportationTarget(value: Mesh);
  45275. /**
  45276. * 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
  45277. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45278. * See http://doc.babylonjs.com/resources/baking_transformations
  45279. */
  45280. get gazeTrackerMesh(): Mesh;
  45281. set gazeTrackerMesh(value: Mesh);
  45282. /**
  45283. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45284. */
  45285. updateGazeTrackerScale: boolean;
  45286. /**
  45287. * If the gaze trackers color should be updated when selecting meshes
  45288. */
  45289. updateGazeTrackerColor: boolean;
  45290. /**
  45291. * If the controller laser color should be updated when selecting meshes
  45292. */
  45293. updateControllerLaserColor: boolean;
  45294. /**
  45295. * The gaze tracking mesh corresponding to the left controller
  45296. */
  45297. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45298. /**
  45299. * The gaze tracking mesh corresponding to the right controller
  45300. */
  45301. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45302. /**
  45303. * If the ray of the gaze should be displayed.
  45304. */
  45305. get displayGaze(): boolean;
  45306. /**
  45307. * Sets if the ray of the gaze should be displayed.
  45308. */
  45309. set displayGaze(value: boolean);
  45310. /**
  45311. * If the ray of the LaserPointer should be displayed.
  45312. */
  45313. get displayLaserPointer(): boolean;
  45314. /**
  45315. * Sets if the ray of the LaserPointer should be displayed.
  45316. */
  45317. set displayLaserPointer(value: boolean);
  45318. /**
  45319. * The deviceOrientationCamera used as the camera when not in VR.
  45320. */
  45321. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45322. /**
  45323. * Based on the current WebVR support, returns the current VR camera used.
  45324. */
  45325. get currentVRCamera(): Nullable<Camera>;
  45326. /**
  45327. * The webVRCamera which is used when in VR.
  45328. */
  45329. get webVRCamera(): WebVRFreeCamera;
  45330. /**
  45331. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45332. */
  45333. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45334. /**
  45335. * The html button that is used to trigger entering into VR.
  45336. */
  45337. get vrButton(): Nullable<HTMLButtonElement>;
  45338. private get _teleportationRequestInitiated();
  45339. /**
  45340. * Defines whether or not Pointer lock should be requested when switching to
  45341. * full screen.
  45342. */
  45343. requestPointerLockOnFullScreen: boolean;
  45344. /**
  45345. * If asking to force XR, this will be populated with the default xr experience
  45346. */
  45347. xr: WebXRDefaultExperience;
  45348. /**
  45349. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45350. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45351. */
  45352. xrTestDone: boolean;
  45353. /**
  45354. * Instantiates a VRExperienceHelper.
  45355. * Helps to quickly add VR support to an existing scene.
  45356. * @param scene The scene the VRExperienceHelper belongs to.
  45357. * @param webVROptions Options to modify the vr experience helper's behavior.
  45358. */
  45359. constructor(scene: Scene,
  45360. /** Options to modify the vr experience helper's behavior. */
  45361. webVROptions?: VRExperienceHelperOptions);
  45362. private completeVRInit;
  45363. private _onDefaultMeshLoaded;
  45364. private _onResize;
  45365. private _onFullscreenChange;
  45366. /**
  45367. * Gets a value indicating if we are currently in VR mode.
  45368. */
  45369. get isInVRMode(): boolean;
  45370. private onVrDisplayPresentChange;
  45371. private onVRDisplayChanged;
  45372. private moveButtonToBottomRight;
  45373. private displayVRButton;
  45374. private updateButtonVisibility;
  45375. private _cachedAngularSensibility;
  45376. /**
  45377. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45378. * Otherwise, will use the fullscreen API.
  45379. */
  45380. enterVR(): void;
  45381. /**
  45382. * Attempt to exit VR, or fullscreen.
  45383. */
  45384. exitVR(): void;
  45385. /**
  45386. * The position of the vr experience helper.
  45387. */
  45388. get position(): Vector3;
  45389. /**
  45390. * Sets the position of the vr experience helper.
  45391. */
  45392. set position(value: Vector3);
  45393. /**
  45394. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45395. */
  45396. enableInteractions(): void;
  45397. private get _noControllerIsActive();
  45398. private beforeRender;
  45399. private _isTeleportationFloor;
  45400. /**
  45401. * Adds a floor mesh to be used for teleportation.
  45402. * @param floorMesh the mesh to be used for teleportation.
  45403. */
  45404. addFloorMesh(floorMesh: Mesh): void;
  45405. /**
  45406. * Removes a floor mesh from being used for teleportation.
  45407. * @param floorMesh the mesh to be removed.
  45408. */
  45409. removeFloorMesh(floorMesh: Mesh): void;
  45410. /**
  45411. * Enables interactions and teleportation using the VR controllers and gaze.
  45412. * @param vrTeleportationOptions options to modify teleportation behavior.
  45413. */
  45414. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45415. private _onNewGamepadConnected;
  45416. private _tryEnableInteractionOnController;
  45417. private _onNewGamepadDisconnected;
  45418. private _enableInteractionOnController;
  45419. private _checkTeleportWithRay;
  45420. private _checkRotate;
  45421. private _checkTeleportBackwards;
  45422. private _enableTeleportationOnController;
  45423. private _createTeleportationCircles;
  45424. private _displayTeleportationTarget;
  45425. private _hideTeleportationTarget;
  45426. private _rotateCamera;
  45427. private _moveTeleportationSelectorTo;
  45428. private _workingVector;
  45429. private _workingQuaternion;
  45430. private _workingMatrix;
  45431. /**
  45432. * Time Constant Teleportation Mode
  45433. */
  45434. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45435. /**
  45436. * Speed Constant Teleportation Mode
  45437. */
  45438. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45439. /**
  45440. * Teleports the users feet to the desired location
  45441. * @param location The location where the user's feet should be placed
  45442. */
  45443. teleportCamera(location: Vector3): void;
  45444. private _convertNormalToDirectionOfRay;
  45445. private _castRayAndSelectObject;
  45446. private _notifySelectedMeshUnselected;
  45447. /**
  45448. * Permanently set new colors for the laser pointer
  45449. * @param color the new laser color
  45450. * @param pickedColor the new laser color when picked mesh detected
  45451. */
  45452. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45453. /**
  45454. * Set lighting enabled / disabled on the laser pointer of both controllers
  45455. * @param enabled should the lighting be enabled on the laser pointer
  45456. */
  45457. setLaserLightingState(enabled?: boolean): void;
  45458. /**
  45459. * Permanently set new colors for the gaze pointer
  45460. * @param color the new gaze color
  45461. * @param pickedColor the new gaze color when picked mesh detected
  45462. */
  45463. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45464. /**
  45465. * Sets the color of the laser ray from the vr controllers.
  45466. * @param color new color for the ray.
  45467. */
  45468. changeLaserColor(color: Color3): void;
  45469. /**
  45470. * Sets the color of the ray from the vr headsets gaze.
  45471. * @param color new color for the ray.
  45472. */
  45473. changeGazeColor(color: Color3): void;
  45474. /**
  45475. * Exits VR and disposes of the vr experience helper
  45476. */
  45477. dispose(): void;
  45478. /**
  45479. * Gets the name of the VRExperienceHelper class
  45480. * @returns "VRExperienceHelper"
  45481. */
  45482. getClassName(): string;
  45483. }
  45484. }
  45485. declare module BABYLON {
  45486. /**
  45487. * Contains an array of blocks representing the octree
  45488. */
  45489. export interface IOctreeContainer<T> {
  45490. /**
  45491. * Blocks within the octree
  45492. */
  45493. blocks: Array<OctreeBlock<T>>;
  45494. }
  45495. /**
  45496. * Class used to store a cell in an octree
  45497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45498. */
  45499. export class OctreeBlock<T> {
  45500. /**
  45501. * Gets the content of the current block
  45502. */
  45503. entries: T[];
  45504. /**
  45505. * Gets the list of block children
  45506. */
  45507. blocks: Array<OctreeBlock<T>>;
  45508. private _depth;
  45509. private _maxDepth;
  45510. private _capacity;
  45511. private _minPoint;
  45512. private _maxPoint;
  45513. private _boundingVectors;
  45514. private _creationFunc;
  45515. /**
  45516. * Creates a new block
  45517. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45518. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45519. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45520. * @param depth defines the current depth of this block in the octree
  45521. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45522. * @param creationFunc defines a callback to call when an element is added to the block
  45523. */
  45524. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45525. /**
  45526. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45527. */
  45528. get capacity(): number;
  45529. /**
  45530. * Gets the minimum vector (in world space) of the block's bounding box
  45531. */
  45532. get minPoint(): Vector3;
  45533. /**
  45534. * Gets the maximum vector (in world space) of the block's bounding box
  45535. */
  45536. get maxPoint(): Vector3;
  45537. /**
  45538. * Add a new element to this block
  45539. * @param entry defines the element to add
  45540. */
  45541. addEntry(entry: T): void;
  45542. /**
  45543. * Remove an element from this block
  45544. * @param entry defines the element to remove
  45545. */
  45546. removeEntry(entry: T): void;
  45547. /**
  45548. * Add an array of elements to this block
  45549. * @param entries defines the array of elements to add
  45550. */
  45551. addEntries(entries: T[]): void;
  45552. /**
  45553. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45554. * @param frustumPlanes defines the frustum planes to test
  45555. * @param selection defines the array to store current content if selection is positive
  45556. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45557. */
  45558. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45559. /**
  45560. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45561. * @param sphereCenter defines the bounding sphere center
  45562. * @param sphereRadius defines the bounding sphere radius
  45563. * @param selection defines the array to store current content if selection is positive
  45564. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45565. */
  45566. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45567. /**
  45568. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45569. * @param ray defines the ray to test with
  45570. * @param selection defines the array to store current content if selection is positive
  45571. */
  45572. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45573. /**
  45574. * Subdivide the content into child blocks (this block will then be empty)
  45575. */
  45576. createInnerBlocks(): void;
  45577. /**
  45578. * @hidden
  45579. */
  45580. 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;
  45581. }
  45582. }
  45583. declare module BABYLON {
  45584. /**
  45585. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45586. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45587. */
  45588. export class Octree<T> {
  45589. /** 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.) */
  45590. maxDepth: number;
  45591. /**
  45592. * Blocks within the octree containing objects
  45593. */
  45594. blocks: Array<OctreeBlock<T>>;
  45595. /**
  45596. * Content stored in the octree
  45597. */
  45598. dynamicContent: T[];
  45599. private _maxBlockCapacity;
  45600. private _selectionContent;
  45601. private _creationFunc;
  45602. /**
  45603. * Creates a octree
  45604. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45605. * @param creationFunc function to be used to instatiate the octree
  45606. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45607. * @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.)
  45608. */
  45609. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45610. /** 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.) */
  45611. maxDepth?: number);
  45612. /**
  45613. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45614. * @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);
  45615. * @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);
  45616. * @param entries meshes to be added to the octree blocks
  45617. */
  45618. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45619. /**
  45620. * Adds a mesh to the octree
  45621. * @param entry Mesh to add to the octree
  45622. */
  45623. addMesh(entry: T): void;
  45624. /**
  45625. * Remove an element from the octree
  45626. * @param entry defines the element to remove
  45627. */
  45628. removeMesh(entry: T): void;
  45629. /**
  45630. * Selects an array of meshes within the frustum
  45631. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45632. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45633. * @returns array of meshes within the frustum
  45634. */
  45635. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45636. /**
  45637. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45638. * @param sphereCenter defines the bounding sphere center
  45639. * @param sphereRadius defines the bounding sphere radius
  45640. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45641. * @returns an array of objects that intersect the sphere
  45642. */
  45643. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45644. /**
  45645. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45646. * @param ray defines the ray to test with
  45647. * @returns array of intersected objects
  45648. */
  45649. intersectsRay(ray: Ray): SmartArray<T>;
  45650. /**
  45651. * Adds a mesh into the octree block if it intersects the block
  45652. */
  45653. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45654. /**
  45655. * Adds a submesh into the octree block if it intersects the block
  45656. */
  45657. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45658. }
  45659. }
  45660. declare module BABYLON {
  45661. interface Scene {
  45662. /**
  45663. * @hidden
  45664. * Backing Filed
  45665. */
  45666. _selectionOctree: Octree<AbstractMesh>;
  45667. /**
  45668. * Gets the octree used to boost mesh selection (picking)
  45669. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45670. */
  45671. selectionOctree: Octree<AbstractMesh>;
  45672. /**
  45673. * Creates or updates the octree used to boost selection (picking)
  45674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45675. * @param maxCapacity defines the maximum capacity per leaf
  45676. * @param maxDepth defines the maximum depth of the octree
  45677. * @returns an octree of AbstractMesh
  45678. */
  45679. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45680. }
  45681. interface AbstractMesh {
  45682. /**
  45683. * @hidden
  45684. * Backing Field
  45685. */
  45686. _submeshesOctree: Octree<SubMesh>;
  45687. /**
  45688. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45689. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45690. * @param maxCapacity defines the maximum size of each block (64 by default)
  45691. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45692. * @returns the new octree
  45693. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45694. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45695. */
  45696. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45697. }
  45698. /**
  45699. * Defines the octree scene component responsible to manage any octrees
  45700. * in a given scene.
  45701. */
  45702. export class OctreeSceneComponent {
  45703. /**
  45704. * The component name help to identify the component in the list of scene components.
  45705. */
  45706. readonly name: string;
  45707. /**
  45708. * The scene the component belongs to.
  45709. */
  45710. scene: Scene;
  45711. /**
  45712. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45713. */
  45714. readonly checksIsEnabled: boolean;
  45715. /**
  45716. * Creates a new instance of the component for the given scene
  45717. * @param scene Defines the scene to register the component in
  45718. */
  45719. constructor(scene: Scene);
  45720. /**
  45721. * Registers the component in a given scene
  45722. */
  45723. register(): void;
  45724. /**
  45725. * Return the list of active meshes
  45726. * @returns the list of active meshes
  45727. */
  45728. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45729. /**
  45730. * Return the list of active sub meshes
  45731. * @param mesh The mesh to get the candidates sub meshes from
  45732. * @returns the list of active sub meshes
  45733. */
  45734. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45735. private _tempRay;
  45736. /**
  45737. * Return the list of sub meshes intersecting with a given local ray
  45738. * @param mesh defines the mesh to find the submesh for
  45739. * @param localRay defines the ray in local space
  45740. * @returns the list of intersecting sub meshes
  45741. */
  45742. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45743. /**
  45744. * Return the list of sub meshes colliding with a collider
  45745. * @param mesh defines the mesh to find the submesh for
  45746. * @param collider defines the collider to evaluate the collision against
  45747. * @returns the list of colliding sub meshes
  45748. */
  45749. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45750. /**
  45751. * Rebuilds the elements related to this component in case of
  45752. * context lost for instance.
  45753. */
  45754. rebuild(): void;
  45755. /**
  45756. * Disposes the component and the associated ressources.
  45757. */
  45758. dispose(): void;
  45759. }
  45760. }
  45761. declare module BABYLON {
  45762. /**
  45763. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45764. */
  45765. export class Gizmo implements IDisposable {
  45766. /** The utility layer the gizmo will be added to */
  45767. gizmoLayer: UtilityLayerRenderer;
  45768. /**
  45769. * The root mesh of the gizmo
  45770. */
  45771. _rootMesh: Mesh;
  45772. private _attachedMesh;
  45773. /**
  45774. * Ratio for the scale of the gizmo (Default: 1)
  45775. */
  45776. scaleRatio: number;
  45777. /**
  45778. * If a custom mesh has been set (Default: false)
  45779. */
  45780. protected _customMeshSet: boolean;
  45781. /**
  45782. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45783. * * When set, interactions will be enabled
  45784. */
  45785. get attachedMesh(): Nullable<AbstractMesh>;
  45786. set attachedMesh(value: Nullable<AbstractMesh>);
  45787. /**
  45788. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45789. * @param mesh The mesh to replace the default mesh of the gizmo
  45790. */
  45791. setCustomMesh(mesh: Mesh): void;
  45792. /**
  45793. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45794. */
  45795. updateGizmoRotationToMatchAttachedMesh: boolean;
  45796. /**
  45797. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45798. */
  45799. updateGizmoPositionToMatchAttachedMesh: boolean;
  45800. /**
  45801. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45802. */
  45803. updateScale: boolean;
  45804. protected _interactionsEnabled: boolean;
  45805. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45806. private _beforeRenderObserver;
  45807. private _tempVector;
  45808. /**
  45809. * Creates a gizmo
  45810. * @param gizmoLayer The utility layer the gizmo will be added to
  45811. */
  45812. constructor(
  45813. /** The utility layer the gizmo will be added to */
  45814. gizmoLayer?: UtilityLayerRenderer);
  45815. /**
  45816. * Updates the gizmo to match the attached mesh's position/rotation
  45817. */
  45818. protected _update(): void;
  45819. /**
  45820. * Disposes of the gizmo
  45821. */
  45822. dispose(): void;
  45823. }
  45824. }
  45825. declare module BABYLON {
  45826. /**
  45827. * Single plane drag gizmo
  45828. */
  45829. export class PlaneDragGizmo extends Gizmo {
  45830. /**
  45831. * Drag behavior responsible for the gizmos dragging interactions
  45832. */
  45833. dragBehavior: PointerDragBehavior;
  45834. private _pointerObserver;
  45835. /**
  45836. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45837. */
  45838. snapDistance: number;
  45839. /**
  45840. * Event that fires each time the gizmo snaps to a new location.
  45841. * * snapDistance is the the change in distance
  45842. */
  45843. onSnapObservable: Observable<{
  45844. snapDistance: number;
  45845. }>;
  45846. private _plane;
  45847. private _coloredMaterial;
  45848. private _hoverMaterial;
  45849. private _isEnabled;
  45850. private _parent;
  45851. /** @hidden */
  45852. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45853. /** @hidden */
  45854. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45855. /**
  45856. * Creates a PlaneDragGizmo
  45857. * @param gizmoLayer The utility layer the gizmo will be added to
  45858. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45859. * @param color The color of the gizmo
  45860. */
  45861. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45862. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45863. /**
  45864. * If the gizmo is enabled
  45865. */
  45866. set isEnabled(value: boolean);
  45867. get isEnabled(): boolean;
  45868. /**
  45869. * Disposes of the gizmo
  45870. */
  45871. dispose(): void;
  45872. }
  45873. }
  45874. declare module BABYLON {
  45875. /**
  45876. * Gizmo that enables dragging a mesh along 3 axis
  45877. */
  45878. export class PositionGizmo extends Gizmo {
  45879. /**
  45880. * Internal gizmo used for interactions on the x axis
  45881. */
  45882. xGizmo: AxisDragGizmo;
  45883. /**
  45884. * Internal gizmo used for interactions on the y axis
  45885. */
  45886. yGizmo: AxisDragGizmo;
  45887. /**
  45888. * Internal gizmo used for interactions on the z axis
  45889. */
  45890. zGizmo: AxisDragGizmo;
  45891. /**
  45892. * Internal gizmo used for interactions on the yz plane
  45893. */
  45894. xPlaneGizmo: PlaneDragGizmo;
  45895. /**
  45896. * Internal gizmo used for interactions on the xz plane
  45897. */
  45898. yPlaneGizmo: PlaneDragGizmo;
  45899. /**
  45900. * Internal gizmo used for interactions on the xy plane
  45901. */
  45902. zPlaneGizmo: PlaneDragGizmo;
  45903. /**
  45904. * private variables
  45905. */
  45906. private _meshAttached;
  45907. private _updateGizmoRotationToMatchAttachedMesh;
  45908. private _snapDistance;
  45909. private _scaleRatio;
  45910. /** Fires an event when any of it's sub gizmos are dragged */
  45911. onDragStartObservable: Observable<unknown>;
  45912. /** Fires an event when any of it's sub gizmos are released from dragging */
  45913. onDragEndObservable: Observable<unknown>;
  45914. /**
  45915. * If set to true, planar drag is enabled
  45916. */
  45917. private _planarGizmoEnabled;
  45918. get attachedMesh(): Nullable<AbstractMesh>;
  45919. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45920. /**
  45921. * Creates a PositionGizmo
  45922. * @param gizmoLayer The utility layer the gizmo will be added to
  45923. */
  45924. constructor(gizmoLayer?: UtilityLayerRenderer);
  45925. /**
  45926. * If the planar drag gizmo is enabled
  45927. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45928. */
  45929. set planarGizmoEnabled(value: boolean);
  45930. get planarGizmoEnabled(): boolean;
  45931. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45932. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45933. /**
  45934. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45935. */
  45936. set snapDistance(value: number);
  45937. get snapDistance(): number;
  45938. /**
  45939. * Ratio for the scale of the gizmo (Default: 1)
  45940. */
  45941. set scaleRatio(value: number);
  45942. get scaleRatio(): number;
  45943. /**
  45944. * Disposes of the gizmo
  45945. */
  45946. dispose(): void;
  45947. /**
  45948. * CustomMeshes are not supported by this gizmo
  45949. * @param mesh The mesh to replace the default mesh of the gizmo
  45950. */
  45951. setCustomMesh(mesh: Mesh): void;
  45952. }
  45953. }
  45954. declare module BABYLON {
  45955. /**
  45956. * Single axis drag gizmo
  45957. */
  45958. export class AxisDragGizmo extends Gizmo {
  45959. /**
  45960. * Drag behavior responsible for the gizmos dragging interactions
  45961. */
  45962. dragBehavior: PointerDragBehavior;
  45963. private _pointerObserver;
  45964. /**
  45965. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45966. */
  45967. snapDistance: number;
  45968. /**
  45969. * Event that fires each time the gizmo snaps to a new location.
  45970. * * snapDistance is the the change in distance
  45971. */
  45972. onSnapObservable: Observable<{
  45973. snapDistance: number;
  45974. }>;
  45975. private _isEnabled;
  45976. private _parent;
  45977. private _arrow;
  45978. private _coloredMaterial;
  45979. private _hoverMaterial;
  45980. /** @hidden */
  45981. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45982. /** @hidden */
  45983. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45984. /**
  45985. * Creates an AxisDragGizmo
  45986. * @param gizmoLayer The utility layer the gizmo will be added to
  45987. * @param dragAxis The axis which the gizmo will be able to drag on
  45988. * @param color The color of the gizmo
  45989. */
  45990. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45991. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45992. /**
  45993. * If the gizmo is enabled
  45994. */
  45995. set isEnabled(value: boolean);
  45996. get isEnabled(): boolean;
  45997. /**
  45998. * Disposes of the gizmo
  45999. */
  46000. dispose(): void;
  46001. }
  46002. }
  46003. declare module BABYLON.Debug {
  46004. /**
  46005. * The Axes viewer will show 3 axes in a specific point in space
  46006. */
  46007. export class AxesViewer {
  46008. private _xAxis;
  46009. private _yAxis;
  46010. private _zAxis;
  46011. private _scaleLinesFactor;
  46012. private _instanced;
  46013. /**
  46014. * Gets the hosting scene
  46015. */
  46016. scene: Scene;
  46017. /**
  46018. * Gets or sets a number used to scale line length
  46019. */
  46020. scaleLines: number;
  46021. /** Gets the node hierarchy used to render x-axis */
  46022. get xAxis(): TransformNode;
  46023. /** Gets the node hierarchy used to render y-axis */
  46024. get yAxis(): TransformNode;
  46025. /** Gets the node hierarchy used to render z-axis */
  46026. get zAxis(): TransformNode;
  46027. /**
  46028. * Creates a new AxesViewer
  46029. * @param scene defines the hosting scene
  46030. * @param scaleLines defines a number used to scale line length (1 by default)
  46031. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46032. * @param xAxis defines the node hierarchy used to render the x-axis
  46033. * @param yAxis defines the node hierarchy used to render the y-axis
  46034. * @param zAxis defines the node hierarchy used to render the z-axis
  46035. */
  46036. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46037. /**
  46038. * Force the viewer to update
  46039. * @param position defines the position of the viewer
  46040. * @param xaxis defines the x axis of the viewer
  46041. * @param yaxis defines the y axis of the viewer
  46042. * @param zaxis defines the z axis of the viewer
  46043. */
  46044. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46045. /**
  46046. * Creates an instance of this axes viewer.
  46047. * @returns a new axes viewer with instanced meshes
  46048. */
  46049. createInstance(): AxesViewer;
  46050. /** Releases resources */
  46051. dispose(): void;
  46052. private static _SetRenderingGroupId;
  46053. }
  46054. }
  46055. declare module BABYLON.Debug {
  46056. /**
  46057. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46058. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46059. */
  46060. export class BoneAxesViewer extends AxesViewer {
  46061. /**
  46062. * Gets or sets the target mesh where to display the axes viewer
  46063. */
  46064. mesh: Nullable<Mesh>;
  46065. /**
  46066. * Gets or sets the target bone where to display the axes viewer
  46067. */
  46068. bone: Nullable<Bone>;
  46069. /** Gets current position */
  46070. pos: Vector3;
  46071. /** Gets direction of X axis */
  46072. xaxis: Vector3;
  46073. /** Gets direction of Y axis */
  46074. yaxis: Vector3;
  46075. /** Gets direction of Z axis */
  46076. zaxis: Vector3;
  46077. /**
  46078. * Creates a new BoneAxesViewer
  46079. * @param scene defines the hosting scene
  46080. * @param bone defines the target bone
  46081. * @param mesh defines the target mesh
  46082. * @param scaleLines defines a scaling factor for line length (1 by default)
  46083. */
  46084. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46085. /**
  46086. * Force the viewer to update
  46087. */
  46088. update(): void;
  46089. /** Releases resources */
  46090. dispose(): void;
  46091. }
  46092. }
  46093. declare module BABYLON {
  46094. /**
  46095. * Interface used to define scene explorer extensibility option
  46096. */
  46097. export interface IExplorerExtensibilityOption {
  46098. /**
  46099. * Define the option label
  46100. */
  46101. label: string;
  46102. /**
  46103. * Defines the action to execute on click
  46104. */
  46105. action: (entity: any) => void;
  46106. }
  46107. /**
  46108. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46109. */
  46110. export interface IExplorerExtensibilityGroup {
  46111. /**
  46112. * Defines a predicate to test if a given type mut be extended
  46113. */
  46114. predicate: (entity: any) => boolean;
  46115. /**
  46116. * Gets the list of options added to a type
  46117. */
  46118. entries: IExplorerExtensibilityOption[];
  46119. }
  46120. /**
  46121. * Interface used to define the options to use to create the Inspector
  46122. */
  46123. export interface IInspectorOptions {
  46124. /**
  46125. * Display in overlay mode (default: false)
  46126. */
  46127. overlay?: boolean;
  46128. /**
  46129. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46130. */
  46131. globalRoot?: HTMLElement;
  46132. /**
  46133. * Display the Scene explorer
  46134. */
  46135. showExplorer?: boolean;
  46136. /**
  46137. * Display the property inspector
  46138. */
  46139. showInspector?: boolean;
  46140. /**
  46141. * Display in embed mode (both panes on the right)
  46142. */
  46143. embedMode?: boolean;
  46144. /**
  46145. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46146. */
  46147. handleResize?: boolean;
  46148. /**
  46149. * Allow the panes to popup (default: true)
  46150. */
  46151. enablePopup?: boolean;
  46152. /**
  46153. * Allow the panes to be closed by users (default: true)
  46154. */
  46155. enableClose?: boolean;
  46156. /**
  46157. * Optional list of extensibility entries
  46158. */
  46159. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46160. /**
  46161. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46162. */
  46163. inspectorURL?: string;
  46164. /**
  46165. * Optional initial tab (default to DebugLayerTab.Properties)
  46166. */
  46167. initialTab?: DebugLayerTab;
  46168. }
  46169. interface Scene {
  46170. /**
  46171. * @hidden
  46172. * Backing field
  46173. */
  46174. _debugLayer: DebugLayer;
  46175. /**
  46176. * Gets the debug layer (aka Inspector) associated with the scene
  46177. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46178. */
  46179. debugLayer: DebugLayer;
  46180. }
  46181. /**
  46182. * Enum of inspector action tab
  46183. */
  46184. export enum DebugLayerTab {
  46185. /**
  46186. * Properties tag (default)
  46187. */
  46188. Properties = 0,
  46189. /**
  46190. * Debug tab
  46191. */
  46192. Debug = 1,
  46193. /**
  46194. * Statistics tab
  46195. */
  46196. Statistics = 2,
  46197. /**
  46198. * Tools tab
  46199. */
  46200. Tools = 3,
  46201. /**
  46202. * Settings tab
  46203. */
  46204. Settings = 4
  46205. }
  46206. /**
  46207. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46208. * what is happening in your scene
  46209. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46210. */
  46211. export class DebugLayer {
  46212. /**
  46213. * Define the url to get the inspector script from.
  46214. * By default it uses the babylonjs CDN.
  46215. * @ignoreNaming
  46216. */
  46217. static InspectorURL: string;
  46218. private _scene;
  46219. private BJSINSPECTOR;
  46220. private _onPropertyChangedObservable?;
  46221. /**
  46222. * Observable triggered when a property is changed through the inspector.
  46223. */
  46224. get onPropertyChangedObservable(): any;
  46225. /**
  46226. * Instantiates a new debug layer.
  46227. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46228. * what is happening in your scene
  46229. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46230. * @param scene Defines the scene to inspect
  46231. */
  46232. constructor(scene: Scene);
  46233. /** Creates the inspector window. */
  46234. private _createInspector;
  46235. /**
  46236. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46237. * @param entity defines the entity to select
  46238. * @param lineContainerTitle defines the specific block to highlight
  46239. */
  46240. select(entity: any, lineContainerTitle?: string): void;
  46241. /** Get the inspector from bundle or global */
  46242. private _getGlobalInspector;
  46243. /**
  46244. * Get if the inspector is visible or not.
  46245. * @returns true if visible otherwise, false
  46246. */
  46247. isVisible(): boolean;
  46248. /**
  46249. * Hide the inspector and close its window.
  46250. */
  46251. hide(): void;
  46252. /**
  46253. * Launch the debugLayer.
  46254. * @param config Define the configuration of the inspector
  46255. * @return a promise fulfilled when the debug layer is visible
  46256. */
  46257. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46258. }
  46259. }
  46260. declare module BABYLON {
  46261. /**
  46262. * Class containing static functions to help procedurally build meshes
  46263. */
  46264. export class BoxBuilder {
  46265. /**
  46266. * Creates a box mesh
  46267. * * The parameter `size` sets the size (float) of each box side (default 1)
  46268. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46269. * * 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)
  46270. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46272. * * 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
  46273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46274. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46275. * @param name defines the name of the mesh
  46276. * @param options defines the options used to create the mesh
  46277. * @param scene defines the hosting scene
  46278. * @returns the box mesh
  46279. */
  46280. static CreateBox(name: string, options: {
  46281. size?: number;
  46282. width?: number;
  46283. height?: number;
  46284. depth?: number;
  46285. faceUV?: Vector4[];
  46286. faceColors?: Color4[];
  46287. sideOrientation?: number;
  46288. frontUVs?: Vector4;
  46289. backUVs?: Vector4;
  46290. wrap?: boolean;
  46291. topBaseAt?: number;
  46292. bottomBaseAt?: number;
  46293. updatable?: boolean;
  46294. }, scene?: Nullable<Scene>): Mesh;
  46295. }
  46296. }
  46297. declare module BABYLON.Debug {
  46298. /**
  46299. * Used to show the physics impostor around the specific mesh
  46300. */
  46301. export class PhysicsViewer {
  46302. /** @hidden */
  46303. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46304. /** @hidden */
  46305. protected _meshes: Array<Nullable<AbstractMesh>>;
  46306. /** @hidden */
  46307. protected _scene: Nullable<Scene>;
  46308. /** @hidden */
  46309. protected _numMeshes: number;
  46310. /** @hidden */
  46311. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46312. private _renderFunction;
  46313. private _utilityLayer;
  46314. private _debugBoxMesh;
  46315. private _debugSphereMesh;
  46316. private _debugCylinderMesh;
  46317. private _debugMaterial;
  46318. private _debugMeshMeshes;
  46319. /**
  46320. * Creates a new PhysicsViewer
  46321. * @param scene defines the hosting scene
  46322. */
  46323. constructor(scene: Scene);
  46324. /** @hidden */
  46325. protected _updateDebugMeshes(): void;
  46326. /**
  46327. * Renders a specified physic impostor
  46328. * @param impostor defines the impostor to render
  46329. * @param targetMesh defines the mesh represented by the impostor
  46330. * @returns the new debug mesh used to render the impostor
  46331. */
  46332. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46333. /**
  46334. * Hides a specified physic impostor
  46335. * @param impostor defines the impostor to hide
  46336. */
  46337. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46338. private _getDebugMaterial;
  46339. private _getDebugBoxMesh;
  46340. private _getDebugSphereMesh;
  46341. private _getDebugCylinderMesh;
  46342. private _getDebugMeshMesh;
  46343. private _getDebugMesh;
  46344. /** Releases all resources */
  46345. dispose(): void;
  46346. }
  46347. }
  46348. declare module BABYLON {
  46349. /**
  46350. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46351. * in order to better appreciate the issue one might have.
  46352. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46353. */
  46354. export class RayHelper {
  46355. /**
  46356. * Defines the ray we are currently tryin to visualize.
  46357. */
  46358. ray: Nullable<Ray>;
  46359. private _renderPoints;
  46360. private _renderLine;
  46361. private _renderFunction;
  46362. private _scene;
  46363. private _updateToMeshFunction;
  46364. private _attachedToMesh;
  46365. private _meshSpaceDirection;
  46366. private _meshSpaceOrigin;
  46367. /**
  46368. * Helper function to create a colored helper in a scene in one line.
  46369. * @param ray Defines the ray we are currently tryin to visualize
  46370. * @param scene Defines the scene the ray is used in
  46371. * @param color Defines the color we want to see the ray in
  46372. * @returns The newly created ray helper.
  46373. */
  46374. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46375. /**
  46376. * Instantiate a new ray helper.
  46377. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46378. * in order to better appreciate the issue one might have.
  46379. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46380. * @param ray Defines the ray we are currently tryin to visualize
  46381. */
  46382. constructor(ray: Ray);
  46383. /**
  46384. * Shows the ray we are willing to debug.
  46385. * @param scene Defines the scene the ray needs to be rendered in
  46386. * @param color Defines the color the ray needs to be rendered in
  46387. */
  46388. show(scene: Scene, color?: Color3): void;
  46389. /**
  46390. * Hides the ray we are debugging.
  46391. */
  46392. hide(): void;
  46393. private _render;
  46394. /**
  46395. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46396. * @param mesh Defines the mesh we want the helper attached to
  46397. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46398. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46399. * @param length Defines the length of the ray
  46400. */
  46401. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46402. /**
  46403. * Detach the ray helper from the mesh it has previously been attached to.
  46404. */
  46405. detachFromMesh(): void;
  46406. private _updateToMesh;
  46407. /**
  46408. * Dispose the helper and release its associated resources.
  46409. */
  46410. dispose(): void;
  46411. }
  46412. }
  46413. declare module BABYLON.Debug {
  46414. /**
  46415. * Class used to render a debug view of a given skeleton
  46416. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46417. */
  46418. export class SkeletonViewer {
  46419. /** defines the skeleton to render */
  46420. skeleton: Skeleton;
  46421. /** defines the mesh attached to the skeleton */
  46422. mesh: AbstractMesh;
  46423. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46424. autoUpdateBonesMatrices: boolean;
  46425. /** defines the rendering group id to use with the viewer */
  46426. renderingGroupId: number;
  46427. /** Gets or sets the color used to render the skeleton */
  46428. color: Color3;
  46429. private _scene;
  46430. private _debugLines;
  46431. private _debugMesh;
  46432. private _isEnabled;
  46433. private _renderFunction;
  46434. private _utilityLayer;
  46435. /**
  46436. * Returns the mesh used to render the bones
  46437. */
  46438. get debugMesh(): Nullable<LinesMesh>;
  46439. /**
  46440. * Creates a new SkeletonViewer
  46441. * @param skeleton defines the skeleton to render
  46442. * @param mesh defines the mesh attached to the skeleton
  46443. * @param scene defines the hosting scene
  46444. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46445. * @param renderingGroupId defines the rendering group id to use with the viewer
  46446. */
  46447. constructor(
  46448. /** defines the skeleton to render */
  46449. skeleton: Skeleton,
  46450. /** defines the mesh attached to the skeleton */
  46451. mesh: AbstractMesh, scene: Scene,
  46452. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46453. autoUpdateBonesMatrices?: boolean,
  46454. /** defines the rendering group id to use with the viewer */
  46455. renderingGroupId?: number);
  46456. /** Gets or sets a boolean indicating if the viewer is enabled */
  46457. set isEnabled(value: boolean);
  46458. get isEnabled(): boolean;
  46459. private _getBonePosition;
  46460. private _getLinesForBonesWithLength;
  46461. private _getLinesForBonesNoLength;
  46462. /** Update the viewer to sync with current skeleton state */
  46463. update(): void;
  46464. /** Release associated resources */
  46465. dispose(): void;
  46466. }
  46467. }
  46468. declare module BABYLON {
  46469. /**
  46470. * Options to create the null engine
  46471. */
  46472. export class NullEngineOptions {
  46473. /**
  46474. * Render width (Default: 512)
  46475. */
  46476. renderWidth: number;
  46477. /**
  46478. * Render height (Default: 256)
  46479. */
  46480. renderHeight: number;
  46481. /**
  46482. * Texture size (Default: 512)
  46483. */
  46484. textureSize: number;
  46485. /**
  46486. * If delta time between frames should be constant
  46487. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46488. */
  46489. deterministicLockstep: boolean;
  46490. /**
  46491. * Maximum about of steps between frames (Default: 4)
  46492. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46493. */
  46494. lockstepMaxSteps: number;
  46495. }
  46496. /**
  46497. * The null engine class provides support for headless version of babylon.js.
  46498. * This can be used in server side scenario or for testing purposes
  46499. */
  46500. export class NullEngine extends Engine {
  46501. private _options;
  46502. /**
  46503. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46504. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46505. * @returns true if engine is in deterministic lock step mode
  46506. */
  46507. isDeterministicLockStep(): boolean;
  46508. /**
  46509. * Gets the max steps when engine is running in deterministic lock step
  46510. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46511. * @returns the max steps
  46512. */
  46513. getLockstepMaxSteps(): number;
  46514. /**
  46515. * Gets the current hardware scaling level.
  46516. * By default the hardware scaling level is computed from the window device ratio.
  46517. * 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.
  46518. * @returns a number indicating the current hardware scaling level
  46519. */
  46520. getHardwareScalingLevel(): number;
  46521. constructor(options?: NullEngineOptions);
  46522. /**
  46523. * Creates a vertex buffer
  46524. * @param vertices the data for the vertex buffer
  46525. * @returns the new WebGL static buffer
  46526. */
  46527. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46528. /**
  46529. * Creates a new index buffer
  46530. * @param indices defines the content of the index buffer
  46531. * @param updatable defines if the index buffer must be updatable
  46532. * @returns a new webGL buffer
  46533. */
  46534. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46535. /**
  46536. * Clear the current render buffer or the current render target (if any is set up)
  46537. * @param color defines the color to use
  46538. * @param backBuffer defines if the back buffer must be cleared
  46539. * @param depth defines if the depth buffer must be cleared
  46540. * @param stencil defines if the stencil buffer must be cleared
  46541. */
  46542. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46543. /**
  46544. * Gets the current render width
  46545. * @param useScreen defines if screen size must be used (or the current render target if any)
  46546. * @returns a number defining the current render width
  46547. */
  46548. getRenderWidth(useScreen?: boolean): number;
  46549. /**
  46550. * Gets the current render height
  46551. * @param useScreen defines if screen size must be used (or the current render target if any)
  46552. * @returns a number defining the current render height
  46553. */
  46554. getRenderHeight(useScreen?: boolean): number;
  46555. /**
  46556. * Set the WebGL's viewport
  46557. * @param viewport defines the viewport element to be used
  46558. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46559. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46560. */
  46561. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46562. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46563. /**
  46564. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46565. * @param pipelineContext defines the pipeline context to use
  46566. * @param uniformsNames defines the list of uniform names
  46567. * @returns an array of webGL uniform locations
  46568. */
  46569. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46570. /**
  46571. * Gets the lsit of active attributes for a given webGL program
  46572. * @param pipelineContext defines the pipeline context to use
  46573. * @param attributesNames defines the list of attribute names to get
  46574. * @returns an array of indices indicating the offset of each attribute
  46575. */
  46576. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46577. /**
  46578. * Binds an effect to the webGL context
  46579. * @param effect defines the effect to bind
  46580. */
  46581. bindSamplers(effect: Effect): void;
  46582. /**
  46583. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46584. * @param effect defines the effect to activate
  46585. */
  46586. enableEffect(effect: Effect): void;
  46587. /**
  46588. * Set various states to the webGL context
  46589. * @param culling defines backface culling state
  46590. * @param zOffset defines the value to apply to zOffset (0 by default)
  46591. * @param force defines if states must be applied even if cache is up to date
  46592. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46593. */
  46594. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46595. /**
  46596. * Set the value of an uniform to an array of int32
  46597. * @param uniform defines the webGL uniform location where to store the value
  46598. * @param array defines the array of int32 to store
  46599. */
  46600. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46601. /**
  46602. * Set the value of an uniform to an array of int32 (stored as vec2)
  46603. * @param uniform defines the webGL uniform location where to store the value
  46604. * @param array defines the array of int32 to store
  46605. */
  46606. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46607. /**
  46608. * Set the value of an uniform to an array of int32 (stored as vec3)
  46609. * @param uniform defines the webGL uniform location where to store the value
  46610. * @param array defines the array of int32 to store
  46611. */
  46612. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46613. /**
  46614. * Set the value of an uniform to an array of int32 (stored as vec4)
  46615. * @param uniform defines the webGL uniform location where to store the value
  46616. * @param array defines the array of int32 to store
  46617. */
  46618. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46619. /**
  46620. * Set the value of an uniform to an array of float32
  46621. * @param uniform defines the webGL uniform location where to store the value
  46622. * @param array defines the array of float32 to store
  46623. */
  46624. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46625. /**
  46626. * Set the value of an uniform to an array of float32 (stored as vec2)
  46627. * @param uniform defines the webGL uniform location where to store the value
  46628. * @param array defines the array of float32 to store
  46629. */
  46630. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46631. /**
  46632. * Set the value of an uniform to an array of float32 (stored as vec3)
  46633. * @param uniform defines the webGL uniform location where to store the value
  46634. * @param array defines the array of float32 to store
  46635. */
  46636. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46637. /**
  46638. * Set the value of an uniform to an array of float32 (stored as vec4)
  46639. * @param uniform defines the webGL uniform location where to store the value
  46640. * @param array defines the array of float32 to store
  46641. */
  46642. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46643. /**
  46644. * Set the value of an uniform to an array of number
  46645. * @param uniform defines the webGL uniform location where to store the value
  46646. * @param array defines the array of number to store
  46647. */
  46648. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46649. /**
  46650. * Set the value of an uniform to an array of number (stored as vec2)
  46651. * @param uniform defines the webGL uniform location where to store the value
  46652. * @param array defines the array of number to store
  46653. */
  46654. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46655. /**
  46656. * Set the value of an uniform to an array of number (stored as vec3)
  46657. * @param uniform defines the webGL uniform location where to store the value
  46658. * @param array defines the array of number to store
  46659. */
  46660. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46661. /**
  46662. * Set the value of an uniform to an array of number (stored as vec4)
  46663. * @param uniform defines the webGL uniform location where to store the value
  46664. * @param array defines the array of number to store
  46665. */
  46666. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46667. /**
  46668. * Set the value of an uniform to an array of float32 (stored as matrices)
  46669. * @param uniform defines the webGL uniform location where to store the value
  46670. * @param matrices defines the array of float32 to store
  46671. */
  46672. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46673. /**
  46674. * Set the value of an uniform to a matrix (3x3)
  46675. * @param uniform defines the webGL uniform location where to store the value
  46676. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46677. */
  46678. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46679. /**
  46680. * Set the value of an uniform to a matrix (2x2)
  46681. * @param uniform defines the webGL uniform location where to store the value
  46682. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46683. */
  46684. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46685. /**
  46686. * Set the value of an uniform to a number (float)
  46687. * @param uniform defines the webGL uniform location where to store the value
  46688. * @param value defines the float number to store
  46689. */
  46690. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46691. /**
  46692. * Set the value of an uniform to a vec2
  46693. * @param uniform defines the webGL uniform location where to store the value
  46694. * @param x defines the 1st component of the value
  46695. * @param y defines the 2nd component of the value
  46696. */
  46697. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46698. /**
  46699. * Set the value of an uniform to a vec3
  46700. * @param uniform defines the webGL uniform location where to store the value
  46701. * @param x defines the 1st component of the value
  46702. * @param y defines the 2nd component of the value
  46703. * @param z defines the 3rd component of the value
  46704. */
  46705. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46706. /**
  46707. * Set the value of an uniform to a boolean
  46708. * @param uniform defines the webGL uniform location where to store the value
  46709. * @param bool defines the boolean to store
  46710. */
  46711. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46712. /**
  46713. * Set the value of an uniform to a vec4
  46714. * @param uniform defines the webGL uniform location where to store the value
  46715. * @param x defines the 1st component of the value
  46716. * @param y defines the 2nd component of the value
  46717. * @param z defines the 3rd component of the value
  46718. * @param w defines the 4th component of the value
  46719. */
  46720. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46721. /**
  46722. * Sets the current alpha mode
  46723. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46724. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46725. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46726. */
  46727. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46728. /**
  46729. * Bind webGl buffers directly to the webGL context
  46730. * @param vertexBuffers defines the vertex buffer to bind
  46731. * @param indexBuffer defines the index buffer to bind
  46732. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46733. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46734. * @param effect defines the effect associated with the vertex buffer
  46735. */
  46736. bindBuffers(vertexBuffers: {
  46737. [key: string]: VertexBuffer;
  46738. }, indexBuffer: DataBuffer, effect: Effect): void;
  46739. /**
  46740. * Force the entire cache to be cleared
  46741. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46742. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46743. */
  46744. wipeCaches(bruteForce?: boolean): void;
  46745. /**
  46746. * Send a draw order
  46747. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46748. * @param indexStart defines the starting index
  46749. * @param indexCount defines the number of index to draw
  46750. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46751. */
  46752. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46753. /**
  46754. * Draw a list of indexed primitives
  46755. * @param fillMode defines the primitive to use
  46756. * @param indexStart defines the starting index
  46757. * @param indexCount defines the number of index to draw
  46758. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46759. */
  46760. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46761. /**
  46762. * Draw a list of unindexed primitives
  46763. * @param fillMode defines the primitive to use
  46764. * @param verticesStart defines the index of first vertex to draw
  46765. * @param verticesCount defines the count of vertices to draw
  46766. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46767. */
  46768. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46769. /** @hidden */
  46770. _createTexture(): WebGLTexture;
  46771. /** @hidden */
  46772. _releaseTexture(texture: InternalTexture): void;
  46773. /**
  46774. * Usually called from Texture.ts.
  46775. * Passed information to create a WebGLTexture
  46776. * @param urlArg defines a value which contains one of the following:
  46777. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46778. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46779. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46780. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46781. * @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)
  46782. * @param scene needed for loading to the correct scene
  46783. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46784. * @param onLoad optional callback to be called upon successful completion
  46785. * @param onError optional callback to be called upon failure
  46786. * @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
  46787. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46788. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46789. * @param forcedExtension defines the extension to use to pick the right loader
  46790. * @param mimeType defines an optional mime type
  46791. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46792. */
  46793. 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;
  46794. /**
  46795. * Creates a new render target texture
  46796. * @param size defines the size of the texture
  46797. * @param options defines the options used to create the texture
  46798. * @returns a new render target texture stored in an InternalTexture
  46799. */
  46800. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46801. /**
  46802. * Update the sampling mode of a given texture
  46803. * @param samplingMode defines the required sampling mode
  46804. * @param texture defines the texture to update
  46805. */
  46806. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46807. /**
  46808. * Binds the frame buffer to the specified texture.
  46809. * @param texture The texture to render to or null for the default canvas
  46810. * @param faceIndex The face of the texture to render to in case of cube texture
  46811. * @param requiredWidth The width of the target to render to
  46812. * @param requiredHeight The height of the target to render to
  46813. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46814. * @param lodLevel defines le lod level to bind to the frame buffer
  46815. */
  46816. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46817. /**
  46818. * Unbind the current render target texture from the webGL context
  46819. * @param texture defines the render target texture to unbind
  46820. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46821. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46822. */
  46823. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46824. /**
  46825. * Creates a dynamic vertex buffer
  46826. * @param vertices the data for the dynamic vertex buffer
  46827. * @returns the new WebGL dynamic buffer
  46828. */
  46829. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46830. /**
  46831. * Update the content of a dynamic texture
  46832. * @param texture defines the texture to update
  46833. * @param canvas defines the canvas containing the source
  46834. * @param invertY defines if data must be stored with Y axis inverted
  46835. * @param premulAlpha defines if alpha is stored as premultiplied
  46836. * @param format defines the format of the data
  46837. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46838. */
  46839. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46840. /**
  46841. * Gets a boolean indicating if all created effects are ready
  46842. * @returns true if all effects are ready
  46843. */
  46844. areAllEffectsReady(): boolean;
  46845. /**
  46846. * @hidden
  46847. * Get the current error code of the webGL context
  46848. * @returns the error code
  46849. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46850. */
  46851. getError(): number;
  46852. /** @hidden */
  46853. _getUnpackAlignement(): number;
  46854. /** @hidden */
  46855. _unpackFlipY(value: boolean): void;
  46856. /**
  46857. * Update a dynamic index buffer
  46858. * @param indexBuffer defines the target index buffer
  46859. * @param indices defines the data to update
  46860. * @param offset defines the offset in the target index buffer where update should start
  46861. */
  46862. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46863. /**
  46864. * Updates a dynamic vertex buffer.
  46865. * @param vertexBuffer the vertex buffer to update
  46866. * @param vertices the data used to update the vertex buffer
  46867. * @param byteOffset the byte offset of the data (optional)
  46868. * @param byteLength the byte length of the data (optional)
  46869. */
  46870. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46871. /** @hidden */
  46872. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46873. /** @hidden */
  46874. _bindTexture(channel: number, texture: InternalTexture): void;
  46875. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46876. /**
  46877. * 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
  46878. */
  46879. releaseEffects(): void;
  46880. displayLoadingUI(): void;
  46881. hideLoadingUI(): void;
  46882. /** @hidden */
  46883. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46884. /** @hidden */
  46885. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46886. /** @hidden */
  46887. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46888. /** @hidden */
  46889. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46890. }
  46891. }
  46892. declare module BABYLON {
  46893. /**
  46894. * @hidden
  46895. **/
  46896. export class _TimeToken {
  46897. _startTimeQuery: Nullable<WebGLQuery>;
  46898. _endTimeQuery: Nullable<WebGLQuery>;
  46899. _timeElapsedQuery: Nullable<WebGLQuery>;
  46900. _timeElapsedQueryEnded: boolean;
  46901. }
  46902. }
  46903. declare module BABYLON {
  46904. /** @hidden */
  46905. export class _OcclusionDataStorage {
  46906. /** @hidden */
  46907. occlusionInternalRetryCounter: number;
  46908. /** @hidden */
  46909. isOcclusionQueryInProgress: boolean;
  46910. /** @hidden */
  46911. isOccluded: boolean;
  46912. /** @hidden */
  46913. occlusionRetryCount: number;
  46914. /** @hidden */
  46915. occlusionType: number;
  46916. /** @hidden */
  46917. occlusionQueryAlgorithmType: number;
  46918. }
  46919. interface Engine {
  46920. /**
  46921. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46922. * @return the new query
  46923. */
  46924. createQuery(): WebGLQuery;
  46925. /**
  46926. * Delete and release a webGL query
  46927. * @param query defines the query to delete
  46928. * @return the current engine
  46929. */
  46930. deleteQuery(query: WebGLQuery): Engine;
  46931. /**
  46932. * Check if a given query has resolved and got its value
  46933. * @param query defines the query to check
  46934. * @returns true if the query got its value
  46935. */
  46936. isQueryResultAvailable(query: WebGLQuery): boolean;
  46937. /**
  46938. * Gets the value of a given query
  46939. * @param query defines the query to check
  46940. * @returns the value of the query
  46941. */
  46942. getQueryResult(query: WebGLQuery): number;
  46943. /**
  46944. * Initiates an occlusion query
  46945. * @param algorithmType defines the algorithm to use
  46946. * @param query defines the query to use
  46947. * @returns the current engine
  46948. * @see http://doc.babylonjs.com/features/occlusionquery
  46949. */
  46950. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46951. /**
  46952. * Ends an occlusion query
  46953. * @see http://doc.babylonjs.com/features/occlusionquery
  46954. * @param algorithmType defines the algorithm to use
  46955. * @returns the current engine
  46956. */
  46957. endOcclusionQuery(algorithmType: number): Engine;
  46958. /**
  46959. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46960. * Please note that only one query can be issued at a time
  46961. * @returns a time token used to track the time span
  46962. */
  46963. startTimeQuery(): Nullable<_TimeToken>;
  46964. /**
  46965. * Ends a time query
  46966. * @param token defines the token used to measure the time span
  46967. * @returns the time spent (in ns)
  46968. */
  46969. endTimeQuery(token: _TimeToken): int;
  46970. /** @hidden */
  46971. _currentNonTimestampToken: Nullable<_TimeToken>;
  46972. /** @hidden */
  46973. _createTimeQuery(): WebGLQuery;
  46974. /** @hidden */
  46975. _deleteTimeQuery(query: WebGLQuery): void;
  46976. /** @hidden */
  46977. _getGlAlgorithmType(algorithmType: number): number;
  46978. /** @hidden */
  46979. _getTimeQueryResult(query: WebGLQuery): any;
  46980. /** @hidden */
  46981. _getTimeQueryAvailability(query: WebGLQuery): any;
  46982. }
  46983. interface AbstractMesh {
  46984. /**
  46985. * Backing filed
  46986. * @hidden
  46987. */
  46988. __occlusionDataStorage: _OcclusionDataStorage;
  46989. /**
  46990. * Access property
  46991. * @hidden
  46992. */
  46993. _occlusionDataStorage: _OcclusionDataStorage;
  46994. /**
  46995. * 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.
  46996. * The default value is -1 which means don't break the query and wait till the result
  46997. * @see http://doc.babylonjs.com/features/occlusionquery
  46998. */
  46999. occlusionRetryCount: number;
  47000. /**
  47001. * 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:
  47002. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47003. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47004. * * 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.
  47005. * @see http://doc.babylonjs.com/features/occlusionquery
  47006. */
  47007. occlusionType: number;
  47008. /**
  47009. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47010. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47011. * * 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.
  47012. * @see http://doc.babylonjs.com/features/occlusionquery
  47013. */
  47014. occlusionQueryAlgorithmType: number;
  47015. /**
  47016. * 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
  47017. * @see http://doc.babylonjs.com/features/occlusionquery
  47018. */
  47019. isOccluded: boolean;
  47020. /**
  47021. * Flag to check the progress status of the query
  47022. * @see http://doc.babylonjs.com/features/occlusionquery
  47023. */
  47024. isOcclusionQueryInProgress: boolean;
  47025. }
  47026. }
  47027. declare module BABYLON {
  47028. /** @hidden */
  47029. export var _forceTransformFeedbackToBundle: boolean;
  47030. interface Engine {
  47031. /**
  47032. * Creates a webGL transform feedback object
  47033. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47034. * @returns the webGL transform feedback object
  47035. */
  47036. createTransformFeedback(): WebGLTransformFeedback;
  47037. /**
  47038. * Delete a webGL transform feedback object
  47039. * @param value defines the webGL transform feedback object to delete
  47040. */
  47041. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47042. /**
  47043. * Bind a webGL transform feedback object to the webgl context
  47044. * @param value defines the webGL transform feedback object to bind
  47045. */
  47046. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47047. /**
  47048. * Begins a transform feedback operation
  47049. * @param usePoints defines if points or triangles must be used
  47050. */
  47051. beginTransformFeedback(usePoints: boolean): void;
  47052. /**
  47053. * Ends a transform feedback operation
  47054. */
  47055. endTransformFeedback(): void;
  47056. /**
  47057. * Specify the varyings to use with transform feedback
  47058. * @param program defines the associated webGL program
  47059. * @param value defines the list of strings representing the varying names
  47060. */
  47061. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47062. /**
  47063. * Bind a webGL buffer for a transform feedback operation
  47064. * @param value defines the webGL buffer to bind
  47065. */
  47066. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47067. }
  47068. }
  47069. declare module BABYLON {
  47070. /**
  47071. * Creation options of the multi render target texture.
  47072. */
  47073. export interface IMultiRenderTargetOptions {
  47074. /**
  47075. * Define if the texture needs to create mip maps after render.
  47076. */
  47077. generateMipMaps?: boolean;
  47078. /**
  47079. * Define the types of all the draw buffers we want to create
  47080. */
  47081. types?: number[];
  47082. /**
  47083. * Define the sampling modes of all the draw buffers we want to create
  47084. */
  47085. samplingModes?: number[];
  47086. /**
  47087. * Define if a depth buffer is required
  47088. */
  47089. generateDepthBuffer?: boolean;
  47090. /**
  47091. * Define if a stencil buffer is required
  47092. */
  47093. generateStencilBuffer?: boolean;
  47094. /**
  47095. * Define if a depth texture is required instead of a depth buffer
  47096. */
  47097. generateDepthTexture?: boolean;
  47098. /**
  47099. * Define the number of desired draw buffers
  47100. */
  47101. textureCount?: number;
  47102. /**
  47103. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47104. */
  47105. doNotChangeAspectRatio?: boolean;
  47106. /**
  47107. * Define the default type of the buffers we are creating
  47108. */
  47109. defaultType?: number;
  47110. }
  47111. /**
  47112. * A multi render target, like a render target provides the ability to render to a texture.
  47113. * Unlike the render target, it can render to several draw buffers in one draw.
  47114. * This is specially interesting in deferred rendering or for any effects requiring more than
  47115. * just one color from a single pass.
  47116. */
  47117. export class MultiRenderTarget extends RenderTargetTexture {
  47118. private _internalTextures;
  47119. private _textures;
  47120. private _multiRenderTargetOptions;
  47121. /**
  47122. * Get if draw buffers are currently supported by the used hardware and browser.
  47123. */
  47124. get isSupported(): boolean;
  47125. /**
  47126. * Get the list of textures generated by the multi render target.
  47127. */
  47128. get textures(): Texture[];
  47129. /**
  47130. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47131. */
  47132. get depthTexture(): Texture;
  47133. /**
  47134. * Set the wrapping mode on U of all the textures we are rendering to.
  47135. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47136. */
  47137. set wrapU(wrap: number);
  47138. /**
  47139. * Set the wrapping mode on V of all the textures we are rendering to.
  47140. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47141. */
  47142. set wrapV(wrap: number);
  47143. /**
  47144. * Instantiate a new multi render target texture.
  47145. * A multi render target, like a render target provides the ability to render to a texture.
  47146. * Unlike the render target, it can render to several draw buffers in one draw.
  47147. * This is specially interesting in deferred rendering or for any effects requiring more than
  47148. * just one color from a single pass.
  47149. * @param name Define the name of the texture
  47150. * @param size Define the size of the buffers to render to
  47151. * @param count Define the number of target we are rendering into
  47152. * @param scene Define the scene the texture belongs to
  47153. * @param options Define the options used to create the multi render target
  47154. */
  47155. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47156. /** @hidden */
  47157. _rebuild(): void;
  47158. private _createInternalTextures;
  47159. private _createTextures;
  47160. /**
  47161. * Define the number of samples used if MSAA is enabled.
  47162. */
  47163. get samples(): number;
  47164. set samples(value: number);
  47165. /**
  47166. * Resize all the textures in the multi render target.
  47167. * Be carrefull as it will recreate all the data in the new texture.
  47168. * @param size Define the new size
  47169. */
  47170. resize(size: any): void;
  47171. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47172. /**
  47173. * Dispose the render targets and their associated resources
  47174. */
  47175. dispose(): void;
  47176. /**
  47177. * Release all the underlying texture used as draw buffers.
  47178. */
  47179. releaseInternalTextures(): void;
  47180. }
  47181. }
  47182. declare module BABYLON {
  47183. interface ThinEngine {
  47184. /**
  47185. * Unbind a list of render target textures from the webGL context
  47186. * This is used only when drawBuffer extension or webGL2 are active
  47187. * @param textures defines the render target textures to unbind
  47188. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47189. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47190. */
  47191. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47192. /**
  47193. * Create a multi render target texture
  47194. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47195. * @param size defines the size of the texture
  47196. * @param options defines the creation options
  47197. * @returns the cube texture as an InternalTexture
  47198. */
  47199. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47200. /**
  47201. * Update the sample count for a given multiple render target texture
  47202. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47203. * @param textures defines the textures to update
  47204. * @param samples defines the sample count to set
  47205. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47206. */
  47207. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47208. }
  47209. }
  47210. declare module BABYLON {
  47211. /**
  47212. * Class used to define an additional view for the engine
  47213. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47214. */
  47215. export class EngineView {
  47216. /** Defines the canvas where to render the view */
  47217. target: HTMLCanvasElement;
  47218. /** Defines an optional camera used to render the view (will use active camera else) */
  47219. camera?: Camera;
  47220. }
  47221. interface Engine {
  47222. /**
  47223. * Gets or sets the HTML element to use for attaching events
  47224. */
  47225. inputElement: Nullable<HTMLElement>;
  47226. /**
  47227. * Gets the current engine view
  47228. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47229. */
  47230. activeView: Nullable<EngineView>;
  47231. /** Gets or sets the list of views */
  47232. views: EngineView[];
  47233. /**
  47234. * Register a new child canvas
  47235. * @param canvas defines the canvas to register
  47236. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47237. * @returns the associated view
  47238. */
  47239. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47240. /**
  47241. * Remove a registered child canvas
  47242. * @param canvas defines the canvas to remove
  47243. * @returns the current engine
  47244. */
  47245. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47246. }
  47247. }
  47248. declare module BABYLON {
  47249. /**
  47250. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47251. */
  47252. export interface CubeMapInfo {
  47253. /**
  47254. * The pixel array for the front face.
  47255. * This is stored in format, left to right, up to down format.
  47256. */
  47257. front: Nullable<ArrayBufferView>;
  47258. /**
  47259. * The pixel array for the back face.
  47260. * This is stored in format, left to right, up to down format.
  47261. */
  47262. back: Nullable<ArrayBufferView>;
  47263. /**
  47264. * The pixel array for the left face.
  47265. * This is stored in format, left to right, up to down format.
  47266. */
  47267. left: Nullable<ArrayBufferView>;
  47268. /**
  47269. * The pixel array for the right face.
  47270. * This is stored in format, left to right, up to down format.
  47271. */
  47272. right: Nullable<ArrayBufferView>;
  47273. /**
  47274. * The pixel array for the up face.
  47275. * This is stored in format, left to right, up to down format.
  47276. */
  47277. up: Nullable<ArrayBufferView>;
  47278. /**
  47279. * The pixel array for the down face.
  47280. * This is stored in format, left to right, up to down format.
  47281. */
  47282. down: Nullable<ArrayBufferView>;
  47283. /**
  47284. * The size of the cubemap stored.
  47285. *
  47286. * Each faces will be size * size pixels.
  47287. */
  47288. size: number;
  47289. /**
  47290. * The format of the texture.
  47291. *
  47292. * RGBA, RGB.
  47293. */
  47294. format: number;
  47295. /**
  47296. * The type of the texture data.
  47297. *
  47298. * UNSIGNED_INT, FLOAT.
  47299. */
  47300. type: number;
  47301. /**
  47302. * Specifies whether the texture is in gamma space.
  47303. */
  47304. gammaSpace: boolean;
  47305. }
  47306. /**
  47307. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47308. */
  47309. export class PanoramaToCubeMapTools {
  47310. private static FACE_FRONT;
  47311. private static FACE_BACK;
  47312. private static FACE_RIGHT;
  47313. private static FACE_LEFT;
  47314. private static FACE_DOWN;
  47315. private static FACE_UP;
  47316. /**
  47317. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47318. *
  47319. * @param float32Array The source data.
  47320. * @param inputWidth The width of the input panorama.
  47321. * @param inputHeight The height of the input panorama.
  47322. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47323. * @return The cubemap data
  47324. */
  47325. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47326. private static CreateCubemapTexture;
  47327. private static CalcProjectionSpherical;
  47328. }
  47329. }
  47330. declare module BABYLON {
  47331. /**
  47332. * Helper class dealing with the extraction of spherical polynomial dataArray
  47333. * from a cube map.
  47334. */
  47335. export class CubeMapToSphericalPolynomialTools {
  47336. private static FileFaces;
  47337. /**
  47338. * Converts a texture to the according Spherical Polynomial data.
  47339. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47340. *
  47341. * @param texture The texture to extract the information from.
  47342. * @return The Spherical Polynomial data.
  47343. */
  47344. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47345. /**
  47346. * Converts a cubemap to the according Spherical Polynomial data.
  47347. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47348. *
  47349. * @param cubeInfo The Cube map to extract the information from.
  47350. * @return The Spherical Polynomial data.
  47351. */
  47352. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47353. }
  47354. }
  47355. declare module BABYLON {
  47356. interface BaseTexture {
  47357. /**
  47358. * Get the polynomial representation of the texture data.
  47359. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47360. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47361. */
  47362. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47363. }
  47364. }
  47365. declare module BABYLON {
  47366. /** @hidden */
  47367. export var rgbdEncodePixelShader: {
  47368. name: string;
  47369. shader: string;
  47370. };
  47371. }
  47372. declare module BABYLON {
  47373. /** @hidden */
  47374. export var rgbdDecodePixelShader: {
  47375. name: string;
  47376. shader: string;
  47377. };
  47378. }
  47379. declare module BABYLON {
  47380. /**
  47381. * Raw texture data and descriptor sufficient for WebGL texture upload
  47382. */
  47383. export interface EnvironmentTextureInfo {
  47384. /**
  47385. * Version of the environment map
  47386. */
  47387. version: number;
  47388. /**
  47389. * Width of image
  47390. */
  47391. width: number;
  47392. /**
  47393. * Irradiance information stored in the file.
  47394. */
  47395. irradiance: any;
  47396. /**
  47397. * Specular information stored in the file.
  47398. */
  47399. specular: any;
  47400. }
  47401. /**
  47402. * Defines One Image in the file. It requires only the position in the file
  47403. * as well as the length.
  47404. */
  47405. interface BufferImageData {
  47406. /**
  47407. * Length of the image data.
  47408. */
  47409. length: number;
  47410. /**
  47411. * Position of the data from the null terminator delimiting the end of the JSON.
  47412. */
  47413. position: number;
  47414. }
  47415. /**
  47416. * Defines the specular data enclosed in the file.
  47417. * This corresponds to the version 1 of the data.
  47418. */
  47419. export interface EnvironmentTextureSpecularInfoV1 {
  47420. /**
  47421. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47422. */
  47423. specularDataPosition?: number;
  47424. /**
  47425. * This contains all the images data needed to reconstruct the cubemap.
  47426. */
  47427. mipmaps: Array<BufferImageData>;
  47428. /**
  47429. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47430. */
  47431. lodGenerationScale: number;
  47432. }
  47433. /**
  47434. * Sets of helpers addressing the serialization and deserialization of environment texture
  47435. * stored in a BabylonJS env file.
  47436. * Those files are usually stored as .env files.
  47437. */
  47438. export class EnvironmentTextureTools {
  47439. /**
  47440. * Magic number identifying the env file.
  47441. */
  47442. private static _MagicBytes;
  47443. /**
  47444. * Gets the environment info from an env file.
  47445. * @param data The array buffer containing the .env bytes.
  47446. * @returns the environment file info (the json header) if successfully parsed.
  47447. */
  47448. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47449. /**
  47450. * Creates an environment texture from a loaded cube texture.
  47451. * @param texture defines the cube texture to convert in env file
  47452. * @return a promise containing the environment data if succesfull.
  47453. */
  47454. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47455. /**
  47456. * Creates a JSON representation of the spherical data.
  47457. * @param texture defines the texture containing the polynomials
  47458. * @return the JSON representation of the spherical info
  47459. */
  47460. private static _CreateEnvTextureIrradiance;
  47461. /**
  47462. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47463. * @param data the image data
  47464. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47465. * @return the views described by info providing access to the underlying buffer
  47466. */
  47467. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47468. /**
  47469. * Uploads the texture info contained in the env file to the GPU.
  47470. * @param texture defines the internal texture to upload to
  47471. * @param data defines the data to load
  47472. * @param info defines the texture info retrieved through the GetEnvInfo method
  47473. * @returns a promise
  47474. */
  47475. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47476. private static _OnImageReadyAsync;
  47477. /**
  47478. * Uploads the levels of image data to the GPU.
  47479. * @param texture defines the internal texture to upload to
  47480. * @param imageData defines the array buffer views of image data [mipmap][face]
  47481. * @returns a promise
  47482. */
  47483. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47484. /**
  47485. * Uploads spherical polynomials information to the texture.
  47486. * @param texture defines the texture we are trying to upload the information to
  47487. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47488. */
  47489. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47490. /** @hidden */
  47491. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47492. }
  47493. }
  47494. declare module BABYLON {
  47495. /**
  47496. * Contains position and normal vectors for a vertex
  47497. */
  47498. export class PositionNormalVertex {
  47499. /** the position of the vertex (defaut: 0,0,0) */
  47500. position: Vector3;
  47501. /** the normal of the vertex (defaut: 0,1,0) */
  47502. normal: Vector3;
  47503. /**
  47504. * Creates a PositionNormalVertex
  47505. * @param position the position of the vertex (defaut: 0,0,0)
  47506. * @param normal the normal of the vertex (defaut: 0,1,0)
  47507. */
  47508. constructor(
  47509. /** the position of the vertex (defaut: 0,0,0) */
  47510. position?: Vector3,
  47511. /** the normal of the vertex (defaut: 0,1,0) */
  47512. normal?: Vector3);
  47513. /**
  47514. * Clones the PositionNormalVertex
  47515. * @returns the cloned PositionNormalVertex
  47516. */
  47517. clone(): PositionNormalVertex;
  47518. }
  47519. /**
  47520. * Contains position, normal and uv vectors for a vertex
  47521. */
  47522. export class PositionNormalTextureVertex {
  47523. /** the position of the vertex (defaut: 0,0,0) */
  47524. position: Vector3;
  47525. /** the normal of the vertex (defaut: 0,1,0) */
  47526. normal: Vector3;
  47527. /** the uv of the vertex (default: 0,0) */
  47528. uv: Vector2;
  47529. /**
  47530. * Creates a PositionNormalTextureVertex
  47531. * @param position the position of the vertex (defaut: 0,0,0)
  47532. * @param normal the normal of the vertex (defaut: 0,1,0)
  47533. * @param uv the uv of the vertex (default: 0,0)
  47534. */
  47535. constructor(
  47536. /** the position of the vertex (defaut: 0,0,0) */
  47537. position?: Vector3,
  47538. /** the normal of the vertex (defaut: 0,1,0) */
  47539. normal?: Vector3,
  47540. /** the uv of the vertex (default: 0,0) */
  47541. uv?: Vector2);
  47542. /**
  47543. * Clones the PositionNormalTextureVertex
  47544. * @returns the cloned PositionNormalTextureVertex
  47545. */
  47546. clone(): PositionNormalTextureVertex;
  47547. }
  47548. }
  47549. declare module BABYLON {
  47550. /** @hidden */
  47551. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47552. private _genericAttributeLocation;
  47553. private _varyingLocationCount;
  47554. private _varyingLocationMap;
  47555. private _replacements;
  47556. private _textureCount;
  47557. private _uniforms;
  47558. lineProcessor(line: string): string;
  47559. attributeProcessor(attribute: string): string;
  47560. varyingProcessor(varying: string, isFragment: boolean): string;
  47561. uniformProcessor(uniform: string): string;
  47562. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47563. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47564. }
  47565. }
  47566. declare module BABYLON {
  47567. /**
  47568. * Container for accessors for natively-stored mesh data buffers.
  47569. */
  47570. class NativeDataBuffer extends DataBuffer {
  47571. /**
  47572. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47573. */
  47574. nativeIndexBuffer?: any;
  47575. /**
  47576. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47577. */
  47578. nativeVertexBuffer?: any;
  47579. }
  47580. /** @hidden */
  47581. class NativeTexture extends InternalTexture {
  47582. getInternalTexture(): InternalTexture;
  47583. getViewCount(): number;
  47584. }
  47585. /** @hidden */
  47586. export class NativeEngine extends Engine {
  47587. private readonly _native;
  47588. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47589. private readonly INVALID_HANDLE;
  47590. getHardwareScalingLevel(): number;
  47591. constructor();
  47592. /**
  47593. * Can be used to override the current requestAnimationFrame requester.
  47594. * @hidden
  47595. */
  47596. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47597. /**
  47598. * Override default engine behavior.
  47599. * @param color
  47600. * @param backBuffer
  47601. * @param depth
  47602. * @param stencil
  47603. */
  47604. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47605. /**
  47606. * Gets host document
  47607. * @returns the host document object
  47608. */
  47609. getHostDocument(): Nullable<Document>;
  47610. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47611. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47612. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47613. recordVertexArrayObject(vertexBuffers: {
  47614. [key: string]: VertexBuffer;
  47615. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47616. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47617. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47618. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47619. /**
  47620. * Draw a list of indexed primitives
  47621. * @param fillMode defines the primitive to use
  47622. * @param indexStart defines the starting index
  47623. * @param indexCount defines the number of index to draw
  47624. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47625. */
  47626. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47627. /**
  47628. * Draw a list of unindexed primitives
  47629. * @param fillMode defines the primitive to use
  47630. * @param verticesStart defines the index of first vertex to draw
  47631. * @param verticesCount defines the count of vertices to draw
  47632. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47633. */
  47634. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47635. createPipelineContext(): IPipelineContext;
  47636. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47637. /** @hidden */
  47638. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47639. /** @hidden */
  47640. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47641. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47642. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47643. protected _setProgram(program: WebGLProgram): void;
  47644. _releaseEffect(effect: Effect): void;
  47645. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47646. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47647. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47648. bindSamplers(effect: Effect): void;
  47649. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47650. getRenderWidth(useScreen?: boolean): number;
  47651. getRenderHeight(useScreen?: boolean): number;
  47652. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47653. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47654. /**
  47655. * Set the z offset to apply to current rendering
  47656. * @param value defines the offset to apply
  47657. */
  47658. setZOffset(value: number): void;
  47659. /**
  47660. * Gets the current value of the zOffset
  47661. * @returns the current zOffset state
  47662. */
  47663. getZOffset(): number;
  47664. /**
  47665. * Enable or disable depth buffering
  47666. * @param enable defines the state to set
  47667. */
  47668. setDepthBuffer(enable: boolean): void;
  47669. /**
  47670. * Gets a boolean indicating if depth writing is enabled
  47671. * @returns the current depth writing state
  47672. */
  47673. getDepthWrite(): boolean;
  47674. /**
  47675. * Enable or disable depth writing
  47676. * @param enable defines the state to set
  47677. */
  47678. setDepthWrite(enable: boolean): void;
  47679. /**
  47680. * Enable or disable color writing
  47681. * @param enable defines the state to set
  47682. */
  47683. setColorWrite(enable: boolean): void;
  47684. /**
  47685. * Gets a boolean indicating if color writing is enabled
  47686. * @returns the current color writing state
  47687. */
  47688. getColorWrite(): boolean;
  47689. /**
  47690. * Sets alpha constants used by some alpha blending modes
  47691. * @param r defines the red component
  47692. * @param g defines the green component
  47693. * @param b defines the blue component
  47694. * @param a defines the alpha component
  47695. */
  47696. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47697. /**
  47698. * Sets the current alpha mode
  47699. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47700. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47701. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47702. */
  47703. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47704. /**
  47705. * Gets the current alpha mode
  47706. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47707. * @returns the current alpha mode
  47708. */
  47709. getAlphaMode(): number;
  47710. setInt(uniform: WebGLUniformLocation, int: number): void;
  47711. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47712. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47713. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47714. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47715. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47716. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47717. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47718. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47719. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47720. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47721. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47722. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47723. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47724. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47725. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47726. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47727. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47728. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47729. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47730. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47731. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47732. wipeCaches(bruteForce?: boolean): void;
  47733. _createTexture(): WebGLTexture;
  47734. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47735. /**
  47736. * Usually called from Texture.ts.
  47737. * Passed information to create a WebGLTexture
  47738. * @param urlArg defines a value which contains one of the following:
  47739. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47740. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47741. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47742. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47743. * @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)
  47744. * @param scene needed for loading to the correct scene
  47745. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47746. * @param onLoad optional callback to be called upon successful completion
  47747. * @param onError optional callback to be called upon failure
  47748. * @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
  47749. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47750. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47751. * @param forcedExtension defines the extension to use to pick the right loader
  47752. * @param mimeType defines an optional mime type
  47753. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47754. */
  47755. 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;
  47756. /**
  47757. * Creates a cube texture
  47758. * @param rootUrl defines the url where the files to load is located
  47759. * @param scene defines the current scene
  47760. * @param files defines the list of files to load (1 per face)
  47761. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47762. * @param onLoad defines an optional callback raised when the texture is loaded
  47763. * @param onError defines an optional callback raised if there is an issue to load the texture
  47764. * @param format defines the format of the data
  47765. * @param forcedExtension defines the extension to use to pick the right loader
  47766. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47767. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47768. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47769. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47770. * @returns the cube texture as an InternalTexture
  47771. */
  47772. 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;
  47773. private _getSamplingFilter;
  47774. private static _GetNativeTextureFormat;
  47775. createRenderTargetTexture(size: number | {
  47776. width: number;
  47777. height: number;
  47778. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47779. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47780. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47781. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47782. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47783. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47784. /**
  47785. * Updates a dynamic vertex buffer.
  47786. * @param vertexBuffer the vertex buffer to update
  47787. * @param data the data used to update the vertex buffer
  47788. * @param byteOffset the byte offset of the data (optional)
  47789. * @param byteLength the byte length of the data (optional)
  47790. */
  47791. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47792. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47793. private _updateAnisotropicLevel;
  47794. private _getAddressMode;
  47795. /** @hidden */
  47796. _bindTexture(channel: number, texture: InternalTexture): void;
  47797. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47798. releaseEffects(): void;
  47799. /** @hidden */
  47800. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47801. /** @hidden */
  47802. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47803. /** @hidden */
  47804. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47805. /** @hidden */
  47806. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47807. }
  47808. }
  47809. declare module BABYLON {
  47810. /**
  47811. * Gather the list of clipboard event types as constants.
  47812. */
  47813. export class ClipboardEventTypes {
  47814. /**
  47815. * The clipboard event is fired when a copy command is active (pressed).
  47816. */
  47817. static readonly COPY: number;
  47818. /**
  47819. * The clipboard event is fired when a cut command is active (pressed).
  47820. */
  47821. static readonly CUT: number;
  47822. /**
  47823. * The clipboard event is fired when a paste command is active (pressed).
  47824. */
  47825. static readonly PASTE: number;
  47826. }
  47827. /**
  47828. * This class is used to store clipboard related info for the onClipboardObservable event.
  47829. */
  47830. export class ClipboardInfo {
  47831. /**
  47832. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47833. */
  47834. type: number;
  47835. /**
  47836. * Defines the related dom event
  47837. */
  47838. event: ClipboardEvent;
  47839. /**
  47840. *Creates an instance of ClipboardInfo.
  47841. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47842. * @param event Defines the related dom event
  47843. */
  47844. constructor(
  47845. /**
  47846. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47847. */
  47848. type: number,
  47849. /**
  47850. * Defines the related dom event
  47851. */
  47852. event: ClipboardEvent);
  47853. /**
  47854. * Get the clipboard event's type from the keycode.
  47855. * @param keyCode Defines the keyCode for the current keyboard event.
  47856. * @return {number}
  47857. */
  47858. static GetTypeFromCharacter(keyCode: number): number;
  47859. }
  47860. }
  47861. declare module BABYLON {
  47862. /**
  47863. * Google Daydream controller
  47864. */
  47865. export class DaydreamController extends WebVRController {
  47866. /**
  47867. * Base Url for the controller model.
  47868. */
  47869. static MODEL_BASE_URL: string;
  47870. /**
  47871. * File name for the controller model.
  47872. */
  47873. static MODEL_FILENAME: string;
  47874. /**
  47875. * Gamepad Id prefix used to identify Daydream Controller.
  47876. */
  47877. static readonly GAMEPAD_ID_PREFIX: string;
  47878. /**
  47879. * Creates a new DaydreamController from a gamepad
  47880. * @param vrGamepad the gamepad that the controller should be created from
  47881. */
  47882. constructor(vrGamepad: any);
  47883. /**
  47884. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47885. * @param scene scene in which to add meshes
  47886. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47887. */
  47888. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47889. /**
  47890. * Called once for each button that changed state since the last frame
  47891. * @param buttonIdx Which button index changed
  47892. * @param state New state of the button
  47893. * @param changes Which properties on the state changed since last frame
  47894. */
  47895. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47896. }
  47897. }
  47898. declare module BABYLON {
  47899. /**
  47900. * Gear VR Controller
  47901. */
  47902. export class GearVRController extends WebVRController {
  47903. /**
  47904. * Base Url for the controller model.
  47905. */
  47906. static MODEL_BASE_URL: string;
  47907. /**
  47908. * File name for the controller model.
  47909. */
  47910. static MODEL_FILENAME: string;
  47911. /**
  47912. * Gamepad Id prefix used to identify this controller.
  47913. */
  47914. static readonly GAMEPAD_ID_PREFIX: string;
  47915. private readonly _buttonIndexToObservableNameMap;
  47916. /**
  47917. * Creates a new GearVRController from a gamepad
  47918. * @param vrGamepad the gamepad that the controller should be created from
  47919. */
  47920. constructor(vrGamepad: any);
  47921. /**
  47922. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47923. * @param scene scene in which to add meshes
  47924. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47925. */
  47926. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47927. /**
  47928. * Called once for each button that changed state since the last frame
  47929. * @param buttonIdx Which button index changed
  47930. * @param state New state of the button
  47931. * @param changes Which properties on the state changed since last frame
  47932. */
  47933. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47934. }
  47935. }
  47936. declare module BABYLON {
  47937. /**
  47938. * Generic Controller
  47939. */
  47940. export class GenericController extends WebVRController {
  47941. /**
  47942. * Base Url for the controller model.
  47943. */
  47944. static readonly MODEL_BASE_URL: string;
  47945. /**
  47946. * File name for the controller model.
  47947. */
  47948. static readonly MODEL_FILENAME: string;
  47949. /**
  47950. * Creates a new GenericController from a gamepad
  47951. * @param vrGamepad the gamepad that the controller should be created from
  47952. */
  47953. constructor(vrGamepad: any);
  47954. /**
  47955. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47956. * @param scene scene in which to add meshes
  47957. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47958. */
  47959. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47960. /**
  47961. * Called once for each button that changed state since the last frame
  47962. * @param buttonIdx Which button index changed
  47963. * @param state New state of the button
  47964. * @param changes Which properties on the state changed since last frame
  47965. */
  47966. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47967. }
  47968. }
  47969. declare module BABYLON {
  47970. /**
  47971. * Oculus Touch Controller
  47972. */
  47973. export class OculusTouchController extends WebVRController {
  47974. /**
  47975. * Base Url for the controller model.
  47976. */
  47977. static MODEL_BASE_URL: string;
  47978. /**
  47979. * File name for the left controller model.
  47980. */
  47981. static MODEL_LEFT_FILENAME: string;
  47982. /**
  47983. * File name for the right controller model.
  47984. */
  47985. static MODEL_RIGHT_FILENAME: string;
  47986. /**
  47987. * Base Url for the Quest controller model.
  47988. */
  47989. static QUEST_MODEL_BASE_URL: string;
  47990. /**
  47991. * @hidden
  47992. * If the controllers are running on a device that needs the updated Quest controller models
  47993. */
  47994. static _IsQuest: boolean;
  47995. /**
  47996. * Fired when the secondary trigger on this controller is modified
  47997. */
  47998. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  47999. /**
  48000. * Fired when the thumb rest on this controller is modified
  48001. */
  48002. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48003. /**
  48004. * Creates a new OculusTouchController from a gamepad
  48005. * @param vrGamepad the gamepad that the controller should be created from
  48006. */
  48007. constructor(vrGamepad: any);
  48008. /**
  48009. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48010. * @param scene scene in which to add meshes
  48011. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48012. */
  48013. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48014. /**
  48015. * Fired when the A button on this controller is modified
  48016. */
  48017. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48018. /**
  48019. * Fired when the B button on this controller is modified
  48020. */
  48021. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48022. /**
  48023. * Fired when the X button on this controller is modified
  48024. */
  48025. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48026. /**
  48027. * Fired when the Y button on this controller is modified
  48028. */
  48029. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48030. /**
  48031. * Called once for each button that changed state since the last frame
  48032. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48033. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48034. * 2) secondary trigger (same)
  48035. * 3) A (right) X (left), touch, pressed = value
  48036. * 4) B / Y
  48037. * 5) thumb rest
  48038. * @param buttonIdx Which button index changed
  48039. * @param state New state of the button
  48040. * @param changes Which properties on the state changed since last frame
  48041. */
  48042. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48043. }
  48044. }
  48045. declare module BABYLON {
  48046. /**
  48047. * Vive Controller
  48048. */
  48049. export class ViveController extends WebVRController {
  48050. /**
  48051. * Base Url for the controller model.
  48052. */
  48053. static MODEL_BASE_URL: string;
  48054. /**
  48055. * File name for the controller model.
  48056. */
  48057. static MODEL_FILENAME: string;
  48058. /**
  48059. * Creates a new ViveController from a gamepad
  48060. * @param vrGamepad the gamepad that the controller should be created from
  48061. */
  48062. constructor(vrGamepad: any);
  48063. /**
  48064. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48065. * @param scene scene in which to add meshes
  48066. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48067. */
  48068. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48069. /**
  48070. * Fired when the left button on this controller is modified
  48071. */
  48072. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48073. /**
  48074. * Fired when the right button on this controller is modified
  48075. */
  48076. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48077. /**
  48078. * Fired when the menu button on this controller is modified
  48079. */
  48080. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48081. /**
  48082. * Called once for each button that changed state since the last frame
  48083. * Vive mapping:
  48084. * 0: touchpad
  48085. * 1: trigger
  48086. * 2: left AND right buttons
  48087. * 3: menu button
  48088. * @param buttonIdx Which button index changed
  48089. * @param state New state of the button
  48090. * @param changes Which properties on the state changed since last frame
  48091. */
  48092. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48093. }
  48094. }
  48095. declare module BABYLON {
  48096. /**
  48097. * Defines the WindowsMotionController object that the state of the windows motion controller
  48098. */
  48099. export class WindowsMotionController extends WebVRController {
  48100. /**
  48101. * The base url used to load the left and right controller models
  48102. */
  48103. static MODEL_BASE_URL: string;
  48104. /**
  48105. * The name of the left controller model file
  48106. */
  48107. static MODEL_LEFT_FILENAME: string;
  48108. /**
  48109. * The name of the right controller model file
  48110. */
  48111. static MODEL_RIGHT_FILENAME: string;
  48112. /**
  48113. * The controller name prefix for this controller type
  48114. */
  48115. static readonly GAMEPAD_ID_PREFIX: string;
  48116. /**
  48117. * The controller id pattern for this controller type
  48118. */
  48119. private static readonly GAMEPAD_ID_PATTERN;
  48120. private _loadedMeshInfo;
  48121. protected readonly _mapping: {
  48122. buttons: string[];
  48123. buttonMeshNames: {
  48124. 'trigger': string;
  48125. 'menu': string;
  48126. 'grip': string;
  48127. 'thumbstick': string;
  48128. 'trackpad': string;
  48129. };
  48130. buttonObservableNames: {
  48131. 'trigger': string;
  48132. 'menu': string;
  48133. 'grip': string;
  48134. 'thumbstick': string;
  48135. 'trackpad': string;
  48136. };
  48137. axisMeshNames: string[];
  48138. pointingPoseMeshName: string;
  48139. };
  48140. /**
  48141. * Fired when the trackpad on this controller is clicked
  48142. */
  48143. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48144. /**
  48145. * Fired when the trackpad on this controller is modified
  48146. */
  48147. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48148. /**
  48149. * The current x and y values of this controller's trackpad
  48150. */
  48151. trackpad: StickValues;
  48152. /**
  48153. * Creates a new WindowsMotionController from a gamepad
  48154. * @param vrGamepad the gamepad that the controller should be created from
  48155. */
  48156. constructor(vrGamepad: any);
  48157. /**
  48158. * Fired when the trigger on this controller is modified
  48159. */
  48160. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48161. /**
  48162. * Fired when the menu button on this controller is modified
  48163. */
  48164. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48165. /**
  48166. * Fired when the grip button on this controller is modified
  48167. */
  48168. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48169. /**
  48170. * Fired when the thumbstick button on this controller is modified
  48171. */
  48172. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48173. /**
  48174. * Fired when the touchpad button on this controller is modified
  48175. */
  48176. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48177. /**
  48178. * Fired when the touchpad values on this controller are modified
  48179. */
  48180. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48181. protected _updateTrackpad(): void;
  48182. /**
  48183. * Called once per frame by the engine.
  48184. */
  48185. update(): void;
  48186. /**
  48187. * Called once for each button that changed state since the last frame
  48188. * @param buttonIdx Which button index changed
  48189. * @param state New state of the button
  48190. * @param changes Which properties on the state changed since last frame
  48191. */
  48192. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48193. /**
  48194. * Moves the buttons on the controller mesh based on their current state
  48195. * @param buttonName the name of the button to move
  48196. * @param buttonValue the value of the button which determines the buttons new position
  48197. */
  48198. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48199. /**
  48200. * Moves the axis on the controller mesh based on its current state
  48201. * @param axis the index of the axis
  48202. * @param axisValue the value of the axis which determines the meshes new position
  48203. * @hidden
  48204. */
  48205. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48206. /**
  48207. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48208. * @param scene scene in which to add meshes
  48209. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48210. */
  48211. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48212. /**
  48213. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48214. * can be transformed by button presses and axes values, based on this._mapping.
  48215. *
  48216. * @param scene scene in which the meshes exist
  48217. * @param meshes list of meshes that make up the controller model to process
  48218. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48219. */
  48220. private processModel;
  48221. private createMeshInfo;
  48222. /**
  48223. * Gets the ray of the controller in the direction the controller is pointing
  48224. * @param length the length the resulting ray should be
  48225. * @returns a ray in the direction the controller is pointing
  48226. */
  48227. getForwardRay(length?: number): Ray;
  48228. /**
  48229. * Disposes of the controller
  48230. */
  48231. dispose(): void;
  48232. }
  48233. /**
  48234. * This class represents a new windows motion controller in XR.
  48235. */
  48236. export class XRWindowsMotionController extends WindowsMotionController {
  48237. /**
  48238. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48239. */
  48240. protected readonly _mapping: {
  48241. buttons: string[];
  48242. buttonMeshNames: {
  48243. 'trigger': string;
  48244. 'menu': string;
  48245. 'grip': string;
  48246. 'thumbstick': string;
  48247. 'trackpad': string;
  48248. };
  48249. buttonObservableNames: {
  48250. 'trigger': string;
  48251. 'menu': string;
  48252. 'grip': string;
  48253. 'thumbstick': string;
  48254. 'trackpad': string;
  48255. };
  48256. axisMeshNames: string[];
  48257. pointingPoseMeshName: string;
  48258. };
  48259. /**
  48260. * Construct a new XR-Based windows motion controller
  48261. *
  48262. * @param gamepadInfo the gamepad object from the browser
  48263. */
  48264. constructor(gamepadInfo: any);
  48265. /**
  48266. * holds the thumbstick values (X,Y)
  48267. */
  48268. thumbstickValues: StickValues;
  48269. /**
  48270. * Fired when the thumbstick on this controller is clicked
  48271. */
  48272. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48273. /**
  48274. * Fired when the thumbstick on this controller is modified
  48275. */
  48276. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48277. /**
  48278. * Fired when the touchpad button on this controller is modified
  48279. */
  48280. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48281. /**
  48282. * Fired when the touchpad values on this controller are modified
  48283. */
  48284. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48285. /**
  48286. * Fired when the thumbstick button on this controller is modified
  48287. * here to prevent breaking changes
  48288. */
  48289. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48290. /**
  48291. * updating the thumbstick(!) and not the trackpad.
  48292. * This is named this way due to the difference between WebVR and XR and to avoid
  48293. * changing the parent class.
  48294. */
  48295. protected _updateTrackpad(): void;
  48296. /**
  48297. * Disposes the class with joy
  48298. */
  48299. dispose(): void;
  48300. }
  48301. }
  48302. declare module BABYLON {
  48303. /**
  48304. * Class containing static functions to help procedurally build meshes
  48305. */
  48306. export class PolyhedronBuilder {
  48307. /**
  48308. * Creates a polyhedron mesh
  48309. * * 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
  48310. * * The parameter `size` (positive float, default 1) sets the polygon size
  48311. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48312. * * 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`
  48313. * * 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
  48314. * * 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)`)
  48315. * * 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
  48316. * * 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
  48317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48318. * * 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
  48319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48320. * @param name defines the name of the mesh
  48321. * @param options defines the options used to create the mesh
  48322. * @param scene defines the hosting scene
  48323. * @returns the polyhedron mesh
  48324. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48325. */
  48326. static CreatePolyhedron(name: string, options: {
  48327. type?: number;
  48328. size?: number;
  48329. sizeX?: number;
  48330. sizeY?: number;
  48331. sizeZ?: number;
  48332. custom?: any;
  48333. faceUV?: Vector4[];
  48334. faceColors?: Color4[];
  48335. flat?: boolean;
  48336. updatable?: boolean;
  48337. sideOrientation?: number;
  48338. frontUVs?: Vector4;
  48339. backUVs?: Vector4;
  48340. }, scene?: Nullable<Scene>): Mesh;
  48341. }
  48342. }
  48343. declare module BABYLON {
  48344. /**
  48345. * Gizmo that enables scaling a mesh along 3 axis
  48346. */
  48347. export class ScaleGizmo extends Gizmo {
  48348. /**
  48349. * Internal gizmo used for interactions on the x axis
  48350. */
  48351. xGizmo: AxisScaleGizmo;
  48352. /**
  48353. * Internal gizmo used for interactions on the y axis
  48354. */
  48355. yGizmo: AxisScaleGizmo;
  48356. /**
  48357. * Internal gizmo used for interactions on the z axis
  48358. */
  48359. zGizmo: AxisScaleGizmo;
  48360. /**
  48361. * Internal gizmo used to scale all axis equally
  48362. */
  48363. uniformScaleGizmo: AxisScaleGizmo;
  48364. private _meshAttached;
  48365. private _updateGizmoRotationToMatchAttachedMesh;
  48366. private _snapDistance;
  48367. private _scaleRatio;
  48368. private _uniformScalingMesh;
  48369. private _octahedron;
  48370. private _sensitivity;
  48371. /** Fires an event when any of it's sub gizmos are dragged */
  48372. onDragStartObservable: Observable<unknown>;
  48373. /** Fires an event when any of it's sub gizmos are released from dragging */
  48374. onDragEndObservable: Observable<unknown>;
  48375. get attachedMesh(): Nullable<AbstractMesh>;
  48376. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48377. /**
  48378. * Creates a ScaleGizmo
  48379. * @param gizmoLayer The utility layer the gizmo will be added to
  48380. */
  48381. constructor(gizmoLayer?: UtilityLayerRenderer);
  48382. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48383. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48384. /**
  48385. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48386. */
  48387. set snapDistance(value: number);
  48388. get snapDistance(): number;
  48389. /**
  48390. * Ratio for the scale of the gizmo (Default: 1)
  48391. */
  48392. set scaleRatio(value: number);
  48393. get scaleRatio(): number;
  48394. /**
  48395. * Sensitivity factor for dragging (Default: 1)
  48396. */
  48397. set sensitivity(value: number);
  48398. get sensitivity(): number;
  48399. /**
  48400. * Disposes of the gizmo
  48401. */
  48402. dispose(): void;
  48403. }
  48404. }
  48405. declare module BABYLON {
  48406. /**
  48407. * Single axis scale gizmo
  48408. */
  48409. export class AxisScaleGizmo extends Gizmo {
  48410. /**
  48411. * Drag behavior responsible for the gizmos dragging interactions
  48412. */
  48413. dragBehavior: PointerDragBehavior;
  48414. private _pointerObserver;
  48415. /**
  48416. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48417. */
  48418. snapDistance: number;
  48419. /**
  48420. * Event that fires each time the gizmo snaps to a new location.
  48421. * * snapDistance is the the change in distance
  48422. */
  48423. onSnapObservable: Observable<{
  48424. snapDistance: number;
  48425. }>;
  48426. /**
  48427. * If the scaling operation should be done on all axis (default: false)
  48428. */
  48429. uniformScaling: boolean;
  48430. /**
  48431. * Custom sensitivity value for the drag strength
  48432. */
  48433. sensitivity: number;
  48434. private _isEnabled;
  48435. private _parent;
  48436. private _arrow;
  48437. private _coloredMaterial;
  48438. private _hoverMaterial;
  48439. /**
  48440. * Creates an AxisScaleGizmo
  48441. * @param gizmoLayer The utility layer the gizmo will be added to
  48442. * @param dragAxis The axis which the gizmo will be able to scale on
  48443. * @param color The color of the gizmo
  48444. */
  48445. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48446. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48447. /**
  48448. * If the gizmo is enabled
  48449. */
  48450. set isEnabled(value: boolean);
  48451. get isEnabled(): boolean;
  48452. /**
  48453. * Disposes of the gizmo
  48454. */
  48455. dispose(): void;
  48456. /**
  48457. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48458. * @param mesh The mesh to replace the default mesh of the gizmo
  48459. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48460. */
  48461. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48462. }
  48463. }
  48464. declare module BABYLON {
  48465. /**
  48466. * Bounding box gizmo
  48467. */
  48468. export class BoundingBoxGizmo extends Gizmo {
  48469. private _lineBoundingBox;
  48470. private _rotateSpheresParent;
  48471. private _scaleBoxesParent;
  48472. private _boundingDimensions;
  48473. private _renderObserver;
  48474. private _pointerObserver;
  48475. private _scaleDragSpeed;
  48476. private _tmpQuaternion;
  48477. private _tmpVector;
  48478. private _tmpRotationMatrix;
  48479. /**
  48480. * 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)
  48481. */
  48482. ignoreChildren: boolean;
  48483. /**
  48484. * 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)
  48485. */
  48486. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48487. /**
  48488. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48489. */
  48490. rotationSphereSize: number;
  48491. /**
  48492. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48493. */
  48494. scaleBoxSize: number;
  48495. /**
  48496. * 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)
  48497. */
  48498. fixedDragMeshScreenSize: boolean;
  48499. /**
  48500. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48501. */
  48502. fixedDragMeshScreenSizeDistanceFactor: number;
  48503. /**
  48504. * Fired when a rotation sphere or scale box is dragged
  48505. */
  48506. onDragStartObservable: Observable<{}>;
  48507. /**
  48508. * Fired when a scale box is dragged
  48509. */
  48510. onScaleBoxDragObservable: Observable<{}>;
  48511. /**
  48512. * Fired when a scale box drag is ended
  48513. */
  48514. onScaleBoxDragEndObservable: Observable<{}>;
  48515. /**
  48516. * Fired when a rotation sphere is dragged
  48517. */
  48518. onRotationSphereDragObservable: Observable<{}>;
  48519. /**
  48520. * Fired when a rotation sphere drag is ended
  48521. */
  48522. onRotationSphereDragEndObservable: Observable<{}>;
  48523. /**
  48524. * 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)
  48525. */
  48526. scalePivot: Nullable<Vector3>;
  48527. /**
  48528. * Mesh used as a pivot to rotate the attached mesh
  48529. */
  48530. private _anchorMesh;
  48531. private _existingMeshScale;
  48532. private _dragMesh;
  48533. private pointerDragBehavior;
  48534. private coloredMaterial;
  48535. private hoverColoredMaterial;
  48536. /**
  48537. * Sets the color of the bounding box gizmo
  48538. * @param color the color to set
  48539. */
  48540. setColor(color: Color3): void;
  48541. /**
  48542. * Creates an BoundingBoxGizmo
  48543. * @param gizmoLayer The utility layer the gizmo will be added to
  48544. * @param color The color of the gizmo
  48545. */
  48546. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48547. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48548. private _selectNode;
  48549. /**
  48550. * Updates the bounding box information for the Gizmo
  48551. */
  48552. updateBoundingBox(): void;
  48553. private _updateRotationSpheres;
  48554. private _updateScaleBoxes;
  48555. /**
  48556. * Enables rotation on the specified axis and disables rotation on the others
  48557. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48558. */
  48559. setEnabledRotationAxis(axis: string): void;
  48560. /**
  48561. * Enables/disables scaling
  48562. * @param enable if scaling should be enabled
  48563. */
  48564. setEnabledScaling(enable: boolean): void;
  48565. private _updateDummy;
  48566. /**
  48567. * Enables a pointer drag behavior on the bounding box of the gizmo
  48568. */
  48569. enableDragBehavior(): void;
  48570. /**
  48571. * Disposes of the gizmo
  48572. */
  48573. dispose(): void;
  48574. /**
  48575. * 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)
  48576. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48577. * @returns the bounding box mesh with the passed in mesh as a child
  48578. */
  48579. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48580. /**
  48581. * CustomMeshes are not supported by this gizmo
  48582. * @param mesh The mesh to replace the default mesh of the gizmo
  48583. */
  48584. setCustomMesh(mesh: Mesh): void;
  48585. }
  48586. }
  48587. declare module BABYLON {
  48588. /**
  48589. * Single plane rotation gizmo
  48590. */
  48591. export class PlaneRotationGizmo extends Gizmo {
  48592. /**
  48593. * Drag behavior responsible for the gizmos dragging interactions
  48594. */
  48595. dragBehavior: PointerDragBehavior;
  48596. private _pointerObserver;
  48597. /**
  48598. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48599. */
  48600. snapDistance: number;
  48601. /**
  48602. * Event that fires each time the gizmo snaps to a new location.
  48603. * * snapDistance is the the change in distance
  48604. */
  48605. onSnapObservable: Observable<{
  48606. snapDistance: number;
  48607. }>;
  48608. private _isEnabled;
  48609. private _parent;
  48610. /**
  48611. * Creates a PlaneRotationGizmo
  48612. * @param gizmoLayer The utility layer the gizmo will be added to
  48613. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48614. * @param color The color of the gizmo
  48615. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48616. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48617. */
  48618. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48619. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48620. /**
  48621. * If the gizmo is enabled
  48622. */
  48623. set isEnabled(value: boolean);
  48624. get isEnabled(): boolean;
  48625. /**
  48626. * Disposes of the gizmo
  48627. */
  48628. dispose(): void;
  48629. }
  48630. }
  48631. declare module BABYLON {
  48632. /**
  48633. * Gizmo that enables rotating a mesh along 3 axis
  48634. */
  48635. export class RotationGizmo extends Gizmo {
  48636. /**
  48637. * Internal gizmo used for interactions on the x axis
  48638. */
  48639. xGizmo: PlaneRotationGizmo;
  48640. /**
  48641. * Internal gizmo used for interactions on the y axis
  48642. */
  48643. yGizmo: PlaneRotationGizmo;
  48644. /**
  48645. * Internal gizmo used for interactions on the z axis
  48646. */
  48647. zGizmo: PlaneRotationGizmo;
  48648. /** Fires an event when any of it's sub gizmos are dragged */
  48649. onDragStartObservable: Observable<unknown>;
  48650. /** Fires an event when any of it's sub gizmos are released from dragging */
  48651. onDragEndObservable: Observable<unknown>;
  48652. private _meshAttached;
  48653. get attachedMesh(): Nullable<AbstractMesh>;
  48654. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48655. /**
  48656. * Creates a RotationGizmo
  48657. * @param gizmoLayer The utility layer the gizmo will be added to
  48658. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48659. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48660. */
  48661. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48662. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48663. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48664. /**
  48665. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48666. */
  48667. set snapDistance(value: number);
  48668. get snapDistance(): number;
  48669. /**
  48670. * Ratio for the scale of the gizmo (Default: 1)
  48671. */
  48672. set scaleRatio(value: number);
  48673. get scaleRatio(): number;
  48674. /**
  48675. * Disposes of the gizmo
  48676. */
  48677. dispose(): void;
  48678. /**
  48679. * CustomMeshes are not supported by this gizmo
  48680. * @param mesh The mesh to replace the default mesh of the gizmo
  48681. */
  48682. setCustomMesh(mesh: Mesh): void;
  48683. }
  48684. }
  48685. declare module BABYLON {
  48686. /**
  48687. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48688. */
  48689. export class GizmoManager implements IDisposable {
  48690. private scene;
  48691. /**
  48692. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48693. */
  48694. gizmos: {
  48695. positionGizmo: Nullable<PositionGizmo>;
  48696. rotationGizmo: Nullable<RotationGizmo>;
  48697. scaleGizmo: Nullable<ScaleGizmo>;
  48698. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48699. };
  48700. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48701. clearGizmoOnEmptyPointerEvent: boolean;
  48702. /** Fires an event when the manager is attached to a mesh */
  48703. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48704. private _gizmosEnabled;
  48705. private _pointerObserver;
  48706. private _attachedMesh;
  48707. private _boundingBoxColor;
  48708. private _defaultUtilityLayer;
  48709. private _defaultKeepDepthUtilityLayer;
  48710. /**
  48711. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48712. */
  48713. boundingBoxDragBehavior: SixDofDragBehavior;
  48714. /**
  48715. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48716. */
  48717. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48718. /**
  48719. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48720. */
  48721. usePointerToAttachGizmos: boolean;
  48722. /**
  48723. * Utility layer that the bounding box gizmo belongs to
  48724. */
  48725. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48726. /**
  48727. * Utility layer that all gizmos besides bounding box belong to
  48728. */
  48729. get utilityLayer(): UtilityLayerRenderer;
  48730. /**
  48731. * Instatiates a gizmo manager
  48732. * @param scene the scene to overlay the gizmos on top of
  48733. */
  48734. constructor(scene: Scene);
  48735. /**
  48736. * Attaches a set of gizmos to the specified mesh
  48737. * @param mesh The mesh the gizmo's should be attached to
  48738. */
  48739. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48740. /**
  48741. * If the position gizmo is enabled
  48742. */
  48743. set positionGizmoEnabled(value: boolean);
  48744. get positionGizmoEnabled(): boolean;
  48745. /**
  48746. * If the rotation gizmo is enabled
  48747. */
  48748. set rotationGizmoEnabled(value: boolean);
  48749. get rotationGizmoEnabled(): boolean;
  48750. /**
  48751. * If the scale gizmo is enabled
  48752. */
  48753. set scaleGizmoEnabled(value: boolean);
  48754. get scaleGizmoEnabled(): boolean;
  48755. /**
  48756. * If the boundingBox gizmo is enabled
  48757. */
  48758. set boundingBoxGizmoEnabled(value: boolean);
  48759. get boundingBoxGizmoEnabled(): boolean;
  48760. /**
  48761. * Disposes of the gizmo manager
  48762. */
  48763. dispose(): void;
  48764. }
  48765. }
  48766. declare module BABYLON {
  48767. /**
  48768. * A directional light is defined by a direction (what a surprise!).
  48769. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48770. * 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.
  48771. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48772. */
  48773. export class DirectionalLight extends ShadowLight {
  48774. private _shadowFrustumSize;
  48775. /**
  48776. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48777. */
  48778. get shadowFrustumSize(): number;
  48779. /**
  48780. * Specifies a fix frustum size for the shadow generation.
  48781. */
  48782. set shadowFrustumSize(value: number);
  48783. private _shadowOrthoScale;
  48784. /**
  48785. * Gets the shadow projection scale against the optimal computed one.
  48786. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48787. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48788. */
  48789. get shadowOrthoScale(): number;
  48790. /**
  48791. * Sets the shadow projection scale against the optimal computed one.
  48792. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48793. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48794. */
  48795. set shadowOrthoScale(value: number);
  48796. /**
  48797. * Automatically compute the projection matrix to best fit (including all the casters)
  48798. * on each frame.
  48799. */
  48800. autoUpdateExtends: boolean;
  48801. /**
  48802. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48803. * on each frame. autoUpdateExtends must be set to true for this to work
  48804. */
  48805. autoCalcShadowZBounds: boolean;
  48806. private _orthoLeft;
  48807. private _orthoRight;
  48808. private _orthoTop;
  48809. private _orthoBottom;
  48810. /**
  48811. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48812. * The directional light is emitted from everywhere in the given direction.
  48813. * It can cast shadows.
  48814. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48815. * @param name The friendly name of the light
  48816. * @param direction The direction of the light
  48817. * @param scene The scene the light belongs to
  48818. */
  48819. constructor(name: string, direction: Vector3, scene: Scene);
  48820. /**
  48821. * Returns the string "DirectionalLight".
  48822. * @return The class name
  48823. */
  48824. getClassName(): string;
  48825. /**
  48826. * Returns the integer 1.
  48827. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48828. */
  48829. getTypeID(): number;
  48830. /**
  48831. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48832. * Returns the DirectionalLight Shadow projection matrix.
  48833. */
  48834. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48835. /**
  48836. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48837. * Returns the DirectionalLight Shadow projection matrix.
  48838. */
  48839. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48840. /**
  48841. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48842. * Returns the DirectionalLight Shadow projection matrix.
  48843. */
  48844. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48845. protected _buildUniformLayout(): void;
  48846. /**
  48847. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48848. * @param effect The effect to update
  48849. * @param lightIndex The index of the light in the effect to update
  48850. * @returns The directional light
  48851. */
  48852. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48853. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48854. /**
  48855. * Gets the minZ used for shadow according to both the scene and the light.
  48856. *
  48857. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48858. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48859. * @param activeCamera The camera we are returning the min for
  48860. * @returns the depth min z
  48861. */
  48862. getDepthMinZ(activeCamera: Camera): number;
  48863. /**
  48864. * Gets the maxZ used for shadow according to both the scene and the light.
  48865. *
  48866. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48867. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48868. * @param activeCamera The camera we are returning the max for
  48869. * @returns the depth max z
  48870. */
  48871. getDepthMaxZ(activeCamera: Camera): number;
  48872. /**
  48873. * Prepares the list of defines specific to the light type.
  48874. * @param defines the list of defines
  48875. * @param lightIndex defines the index of the light for the effect
  48876. */
  48877. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48878. }
  48879. }
  48880. declare module BABYLON {
  48881. /**
  48882. * Class containing static functions to help procedurally build meshes
  48883. */
  48884. export class HemisphereBuilder {
  48885. /**
  48886. * Creates a hemisphere mesh
  48887. * @param name defines the name of the mesh
  48888. * @param options defines the options used to create the mesh
  48889. * @param scene defines the hosting scene
  48890. * @returns the hemisphere mesh
  48891. */
  48892. static CreateHemisphere(name: string, options: {
  48893. segments?: number;
  48894. diameter?: number;
  48895. sideOrientation?: number;
  48896. }, scene: any): Mesh;
  48897. }
  48898. }
  48899. declare module BABYLON {
  48900. /**
  48901. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48902. * These values define a cone of light starting from the position, emitting toward the direction.
  48903. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48904. * and the exponent defines the speed of the decay of the light with distance (reach).
  48905. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48906. */
  48907. export class SpotLight extends ShadowLight {
  48908. private _angle;
  48909. private _innerAngle;
  48910. private _cosHalfAngle;
  48911. private _lightAngleScale;
  48912. private _lightAngleOffset;
  48913. /**
  48914. * Gets the cone angle of the spot light in Radians.
  48915. */
  48916. get angle(): number;
  48917. /**
  48918. * Sets the cone angle of the spot light in Radians.
  48919. */
  48920. set angle(value: number);
  48921. /**
  48922. * Only used in gltf falloff mode, this defines the angle where
  48923. * the directional falloff will start before cutting at angle which could be seen
  48924. * as outer angle.
  48925. */
  48926. get innerAngle(): number;
  48927. /**
  48928. * Only used in gltf falloff mode, this defines the angle where
  48929. * the directional falloff will start before cutting at angle which could be seen
  48930. * as outer angle.
  48931. */
  48932. set innerAngle(value: number);
  48933. private _shadowAngleScale;
  48934. /**
  48935. * Allows scaling the angle of the light for shadow generation only.
  48936. */
  48937. get shadowAngleScale(): number;
  48938. /**
  48939. * Allows scaling the angle of the light for shadow generation only.
  48940. */
  48941. set shadowAngleScale(value: number);
  48942. /**
  48943. * The light decay speed with the distance from the emission spot.
  48944. */
  48945. exponent: number;
  48946. private _projectionTextureMatrix;
  48947. /**
  48948. * Allows reading the projecton texture
  48949. */
  48950. get projectionTextureMatrix(): Matrix;
  48951. protected _projectionTextureLightNear: number;
  48952. /**
  48953. * Gets the near clip of the Spotlight for texture projection.
  48954. */
  48955. get projectionTextureLightNear(): number;
  48956. /**
  48957. * Sets the near clip of the Spotlight for texture projection.
  48958. */
  48959. set projectionTextureLightNear(value: number);
  48960. protected _projectionTextureLightFar: number;
  48961. /**
  48962. * Gets the far clip of the Spotlight for texture projection.
  48963. */
  48964. get projectionTextureLightFar(): number;
  48965. /**
  48966. * Sets the far clip of the Spotlight for texture projection.
  48967. */
  48968. set projectionTextureLightFar(value: number);
  48969. protected _projectionTextureUpDirection: Vector3;
  48970. /**
  48971. * Gets the Up vector of the Spotlight for texture projection.
  48972. */
  48973. get projectionTextureUpDirection(): Vector3;
  48974. /**
  48975. * Sets the Up vector of the Spotlight for texture projection.
  48976. */
  48977. set projectionTextureUpDirection(value: Vector3);
  48978. private _projectionTexture;
  48979. /**
  48980. * Gets the projection texture of the light.
  48981. */
  48982. get projectionTexture(): Nullable<BaseTexture>;
  48983. /**
  48984. * Sets the projection texture of the light.
  48985. */
  48986. set projectionTexture(value: Nullable<BaseTexture>);
  48987. private _projectionTextureViewLightDirty;
  48988. private _projectionTextureProjectionLightDirty;
  48989. private _projectionTextureDirty;
  48990. private _projectionTextureViewTargetVector;
  48991. private _projectionTextureViewLightMatrix;
  48992. private _projectionTextureProjectionLightMatrix;
  48993. private _projectionTextureScalingMatrix;
  48994. /**
  48995. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48996. * It can cast shadows.
  48997. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48998. * @param name The light friendly name
  48999. * @param position The position of the spot light in the scene
  49000. * @param direction The direction of the light in the scene
  49001. * @param angle The cone angle of the light in Radians
  49002. * @param exponent The light decay speed with the distance from the emission spot
  49003. * @param scene The scene the lights belongs to
  49004. */
  49005. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49006. /**
  49007. * Returns the string "SpotLight".
  49008. * @returns the class name
  49009. */
  49010. getClassName(): string;
  49011. /**
  49012. * Returns the integer 2.
  49013. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49014. */
  49015. getTypeID(): number;
  49016. /**
  49017. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49018. */
  49019. protected _setDirection(value: Vector3): void;
  49020. /**
  49021. * Overrides the position setter to recompute the projection texture view light Matrix.
  49022. */
  49023. protected _setPosition(value: Vector3): void;
  49024. /**
  49025. * 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.
  49026. * Returns the SpotLight.
  49027. */
  49028. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49029. protected _computeProjectionTextureViewLightMatrix(): void;
  49030. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49031. /**
  49032. * Main function for light texture projection matrix computing.
  49033. */
  49034. protected _computeProjectionTextureMatrix(): void;
  49035. protected _buildUniformLayout(): void;
  49036. private _computeAngleValues;
  49037. /**
  49038. * Sets the passed Effect "effect" with the Light textures.
  49039. * @param effect The effect to update
  49040. * @param lightIndex The index of the light in the effect to update
  49041. * @returns The light
  49042. */
  49043. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49044. /**
  49045. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49046. * @param effect The effect to update
  49047. * @param lightIndex The index of the light in the effect to update
  49048. * @returns The spot light
  49049. */
  49050. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49051. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49052. /**
  49053. * Disposes the light and the associated resources.
  49054. */
  49055. dispose(): void;
  49056. /**
  49057. * Prepares the list of defines specific to the light type.
  49058. * @param defines the list of defines
  49059. * @param lightIndex defines the index of the light for the effect
  49060. */
  49061. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49062. }
  49063. }
  49064. declare module BABYLON {
  49065. /**
  49066. * Gizmo that enables viewing a light
  49067. */
  49068. export class LightGizmo extends Gizmo {
  49069. private _lightMesh;
  49070. private _material;
  49071. private _cachedPosition;
  49072. private _cachedForward;
  49073. private _attachedMeshParent;
  49074. /**
  49075. * Creates a LightGizmo
  49076. * @param gizmoLayer The utility layer the gizmo will be added to
  49077. */
  49078. constructor(gizmoLayer?: UtilityLayerRenderer);
  49079. private _light;
  49080. /**
  49081. * The light that the gizmo is attached to
  49082. */
  49083. set light(light: Nullable<Light>);
  49084. get light(): Nullable<Light>;
  49085. /**
  49086. * Gets the material used to render the light gizmo
  49087. */
  49088. get material(): StandardMaterial;
  49089. /**
  49090. * @hidden
  49091. * Updates the gizmo to match the attached mesh's position/rotation
  49092. */
  49093. protected _update(): void;
  49094. private static _Scale;
  49095. /**
  49096. * Creates the lines for a light mesh
  49097. */
  49098. private static _CreateLightLines;
  49099. /**
  49100. * Disposes of the light gizmo
  49101. */
  49102. dispose(): void;
  49103. private static _CreateHemisphericLightMesh;
  49104. private static _CreatePointLightMesh;
  49105. private static _CreateSpotLightMesh;
  49106. private static _CreateDirectionalLightMesh;
  49107. }
  49108. }
  49109. declare module BABYLON {
  49110. /** @hidden */
  49111. export var backgroundFragmentDeclaration: {
  49112. name: string;
  49113. shader: string;
  49114. };
  49115. }
  49116. declare module BABYLON {
  49117. /** @hidden */
  49118. export var backgroundUboDeclaration: {
  49119. name: string;
  49120. shader: string;
  49121. };
  49122. }
  49123. declare module BABYLON {
  49124. /** @hidden */
  49125. export var backgroundPixelShader: {
  49126. name: string;
  49127. shader: string;
  49128. };
  49129. }
  49130. declare module BABYLON {
  49131. /** @hidden */
  49132. export var backgroundVertexDeclaration: {
  49133. name: string;
  49134. shader: string;
  49135. };
  49136. }
  49137. declare module BABYLON {
  49138. /** @hidden */
  49139. export var backgroundVertexShader: {
  49140. name: string;
  49141. shader: string;
  49142. };
  49143. }
  49144. declare module BABYLON {
  49145. /**
  49146. * Background material used to create an efficient environement around your scene.
  49147. */
  49148. export class BackgroundMaterial extends PushMaterial {
  49149. /**
  49150. * Standard reflectance value at parallel view angle.
  49151. */
  49152. static StandardReflectance0: number;
  49153. /**
  49154. * Standard reflectance value at grazing angle.
  49155. */
  49156. static StandardReflectance90: number;
  49157. protected _primaryColor: Color3;
  49158. /**
  49159. * Key light Color (multiply against the environement texture)
  49160. */
  49161. primaryColor: Color3;
  49162. protected __perceptualColor: Nullable<Color3>;
  49163. /**
  49164. * Experimental Internal Use Only.
  49165. *
  49166. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49167. * This acts as a helper to set the primary color to a more "human friendly" value.
  49168. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49169. * output color as close as possible from the chosen value.
  49170. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49171. * part of lighting setup.)
  49172. */
  49173. get _perceptualColor(): Nullable<Color3>;
  49174. set _perceptualColor(value: Nullable<Color3>);
  49175. protected _primaryColorShadowLevel: float;
  49176. /**
  49177. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49178. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49179. */
  49180. get primaryColorShadowLevel(): float;
  49181. set primaryColorShadowLevel(value: float);
  49182. protected _primaryColorHighlightLevel: float;
  49183. /**
  49184. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49185. * The primary color is used at the level chosen to define what the white area would look.
  49186. */
  49187. get primaryColorHighlightLevel(): float;
  49188. set primaryColorHighlightLevel(value: float);
  49189. protected _reflectionTexture: Nullable<BaseTexture>;
  49190. /**
  49191. * Reflection Texture used in the material.
  49192. * Should be author in a specific way for the best result (refer to the documentation).
  49193. */
  49194. reflectionTexture: Nullable<BaseTexture>;
  49195. protected _reflectionBlur: float;
  49196. /**
  49197. * Reflection Texture level of blur.
  49198. *
  49199. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49200. * texture twice.
  49201. */
  49202. reflectionBlur: float;
  49203. protected _diffuseTexture: Nullable<BaseTexture>;
  49204. /**
  49205. * Diffuse Texture used in the material.
  49206. * Should be author in a specific way for the best result (refer to the documentation).
  49207. */
  49208. diffuseTexture: Nullable<BaseTexture>;
  49209. protected _shadowLights: Nullable<IShadowLight[]>;
  49210. /**
  49211. * Specify the list of lights casting shadow on the material.
  49212. * All scene shadow lights will be included if null.
  49213. */
  49214. shadowLights: Nullable<IShadowLight[]>;
  49215. protected _shadowLevel: float;
  49216. /**
  49217. * Helps adjusting the shadow to a softer level if required.
  49218. * 0 means black shadows and 1 means no shadows.
  49219. */
  49220. shadowLevel: float;
  49221. protected _sceneCenter: Vector3;
  49222. /**
  49223. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49224. * It is usually zero but might be interesting to modify according to your setup.
  49225. */
  49226. sceneCenter: Vector3;
  49227. protected _opacityFresnel: boolean;
  49228. /**
  49229. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49230. * This helps ensuring a nice transition when the camera goes under the ground.
  49231. */
  49232. opacityFresnel: boolean;
  49233. protected _reflectionFresnel: boolean;
  49234. /**
  49235. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49236. * This helps adding a mirror texture on the ground.
  49237. */
  49238. reflectionFresnel: boolean;
  49239. protected _reflectionFalloffDistance: number;
  49240. /**
  49241. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49242. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49243. */
  49244. reflectionFalloffDistance: number;
  49245. protected _reflectionAmount: number;
  49246. /**
  49247. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49248. */
  49249. reflectionAmount: number;
  49250. protected _reflectionReflectance0: number;
  49251. /**
  49252. * This specifies the weight of the reflection at grazing angle.
  49253. */
  49254. reflectionReflectance0: number;
  49255. protected _reflectionReflectance90: number;
  49256. /**
  49257. * This specifies the weight of the reflection at a perpendicular point of view.
  49258. */
  49259. reflectionReflectance90: number;
  49260. /**
  49261. * Sets the reflection reflectance fresnel values according to the default standard
  49262. * empirically know to work well :-)
  49263. */
  49264. set reflectionStandardFresnelWeight(value: number);
  49265. protected _useRGBColor: boolean;
  49266. /**
  49267. * Helps to directly use the maps channels instead of their level.
  49268. */
  49269. useRGBColor: boolean;
  49270. protected _enableNoise: boolean;
  49271. /**
  49272. * This helps reducing the banding effect that could occur on the background.
  49273. */
  49274. enableNoise: boolean;
  49275. /**
  49276. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49277. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49278. * Recommended to be keep at 1.0 except for special cases.
  49279. */
  49280. get fovMultiplier(): number;
  49281. set fovMultiplier(value: number);
  49282. private _fovMultiplier;
  49283. /**
  49284. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49285. */
  49286. useEquirectangularFOV: boolean;
  49287. private _maxSimultaneousLights;
  49288. /**
  49289. * Number of Simultaneous lights allowed on the material.
  49290. */
  49291. maxSimultaneousLights: int;
  49292. /**
  49293. * Default configuration related to image processing available in the Background Material.
  49294. */
  49295. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49296. /**
  49297. * Keep track of the image processing observer to allow dispose and replace.
  49298. */
  49299. private _imageProcessingObserver;
  49300. /**
  49301. * Attaches a new image processing configuration to the PBR Material.
  49302. * @param configuration (if null the scene configuration will be use)
  49303. */
  49304. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49305. /**
  49306. * Gets the image processing configuration used either in this material.
  49307. */
  49308. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49309. /**
  49310. * Sets the Default image processing configuration used either in the this material.
  49311. *
  49312. * If sets to null, the scene one is in use.
  49313. */
  49314. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49315. /**
  49316. * Gets wether the color curves effect is enabled.
  49317. */
  49318. get cameraColorCurvesEnabled(): boolean;
  49319. /**
  49320. * Sets wether the color curves effect is enabled.
  49321. */
  49322. set cameraColorCurvesEnabled(value: boolean);
  49323. /**
  49324. * Gets wether the color grading effect is enabled.
  49325. */
  49326. get cameraColorGradingEnabled(): boolean;
  49327. /**
  49328. * Gets wether the color grading effect is enabled.
  49329. */
  49330. set cameraColorGradingEnabled(value: boolean);
  49331. /**
  49332. * Gets wether tonemapping is enabled or not.
  49333. */
  49334. get cameraToneMappingEnabled(): boolean;
  49335. /**
  49336. * Sets wether tonemapping is enabled or not
  49337. */
  49338. set cameraToneMappingEnabled(value: boolean);
  49339. /**
  49340. * The camera exposure used on this material.
  49341. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49342. * This corresponds to a photographic exposure.
  49343. */
  49344. get cameraExposure(): float;
  49345. /**
  49346. * The camera exposure used on this material.
  49347. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49348. * This corresponds to a photographic exposure.
  49349. */
  49350. set cameraExposure(value: float);
  49351. /**
  49352. * Gets The camera contrast used on this material.
  49353. */
  49354. get cameraContrast(): float;
  49355. /**
  49356. * Sets The camera contrast used on this material.
  49357. */
  49358. set cameraContrast(value: float);
  49359. /**
  49360. * Gets the Color Grading 2D Lookup Texture.
  49361. */
  49362. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49363. /**
  49364. * Sets the Color Grading 2D Lookup Texture.
  49365. */
  49366. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49367. /**
  49368. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49369. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49370. * 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;
  49371. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49372. */
  49373. get cameraColorCurves(): Nullable<ColorCurves>;
  49374. /**
  49375. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49376. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49377. * 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;
  49378. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49379. */
  49380. set cameraColorCurves(value: Nullable<ColorCurves>);
  49381. /**
  49382. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49383. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49384. */
  49385. switchToBGR: boolean;
  49386. private _renderTargets;
  49387. private _reflectionControls;
  49388. private _white;
  49389. private _primaryShadowColor;
  49390. private _primaryHighlightColor;
  49391. /**
  49392. * Instantiates a Background Material in the given scene
  49393. * @param name The friendly name of the material
  49394. * @param scene The scene to add the material to
  49395. */
  49396. constructor(name: string, scene: Scene);
  49397. /**
  49398. * Gets a boolean indicating that current material needs to register RTT
  49399. */
  49400. get hasRenderTargetTextures(): boolean;
  49401. /**
  49402. * The entire material has been created in order to prevent overdraw.
  49403. * @returns false
  49404. */
  49405. needAlphaTesting(): boolean;
  49406. /**
  49407. * The entire material has been created in order to prevent overdraw.
  49408. * @returns true if blending is enable
  49409. */
  49410. needAlphaBlending(): boolean;
  49411. /**
  49412. * Checks wether the material is ready to be rendered for a given mesh.
  49413. * @param mesh The mesh to render
  49414. * @param subMesh The submesh to check against
  49415. * @param useInstances Specify wether or not the material is used with instances
  49416. * @returns true if all the dependencies are ready (Textures, Effects...)
  49417. */
  49418. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49419. /**
  49420. * Compute the primary color according to the chosen perceptual color.
  49421. */
  49422. private _computePrimaryColorFromPerceptualColor;
  49423. /**
  49424. * Compute the highlights and shadow colors according to their chosen levels.
  49425. */
  49426. private _computePrimaryColors;
  49427. /**
  49428. * Build the uniform buffer used in the material.
  49429. */
  49430. buildUniformLayout(): void;
  49431. /**
  49432. * Unbind the material.
  49433. */
  49434. unbind(): void;
  49435. /**
  49436. * Bind only the world matrix to the material.
  49437. * @param world The world matrix to bind.
  49438. */
  49439. bindOnlyWorldMatrix(world: Matrix): void;
  49440. /**
  49441. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49442. * @param world The world matrix to bind.
  49443. * @param subMesh The submesh to bind for.
  49444. */
  49445. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49446. /**
  49447. * Checks to see if a texture is used in the material.
  49448. * @param texture - Base texture to use.
  49449. * @returns - Boolean specifying if a texture is used in the material.
  49450. */
  49451. hasTexture(texture: BaseTexture): boolean;
  49452. /**
  49453. * Dispose the material.
  49454. * @param forceDisposeEffect Force disposal of the associated effect.
  49455. * @param forceDisposeTextures Force disposal of the associated textures.
  49456. */
  49457. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49458. /**
  49459. * Clones the material.
  49460. * @param name The cloned name.
  49461. * @returns The cloned material.
  49462. */
  49463. clone(name: string): BackgroundMaterial;
  49464. /**
  49465. * Serializes the current material to its JSON representation.
  49466. * @returns The JSON representation.
  49467. */
  49468. serialize(): any;
  49469. /**
  49470. * Gets the class name of the material
  49471. * @returns "BackgroundMaterial"
  49472. */
  49473. getClassName(): string;
  49474. /**
  49475. * Parse a JSON input to create back a background material.
  49476. * @param source The JSON data to parse
  49477. * @param scene The scene to create the parsed material in
  49478. * @param rootUrl The root url of the assets the material depends upon
  49479. * @returns the instantiated BackgroundMaterial.
  49480. */
  49481. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49482. }
  49483. }
  49484. declare module BABYLON {
  49485. /**
  49486. * Represents the different options available during the creation of
  49487. * a Environment helper.
  49488. *
  49489. * This can control the default ground, skybox and image processing setup of your scene.
  49490. */
  49491. export interface IEnvironmentHelperOptions {
  49492. /**
  49493. * Specifies whether or not to create a ground.
  49494. * True by default.
  49495. */
  49496. createGround: boolean;
  49497. /**
  49498. * Specifies the ground size.
  49499. * 15 by default.
  49500. */
  49501. groundSize: number;
  49502. /**
  49503. * The texture used on the ground for the main color.
  49504. * Comes from the BabylonJS CDN by default.
  49505. *
  49506. * Remarks: Can be either a texture or a url.
  49507. */
  49508. groundTexture: string | BaseTexture;
  49509. /**
  49510. * The color mixed in the ground texture by default.
  49511. * BabylonJS clearColor by default.
  49512. */
  49513. groundColor: Color3;
  49514. /**
  49515. * Specifies the ground opacity.
  49516. * 1 by default.
  49517. */
  49518. groundOpacity: number;
  49519. /**
  49520. * Enables the ground to receive shadows.
  49521. * True by default.
  49522. */
  49523. enableGroundShadow: boolean;
  49524. /**
  49525. * Helps preventing the shadow to be fully black on the ground.
  49526. * 0.5 by default.
  49527. */
  49528. groundShadowLevel: number;
  49529. /**
  49530. * Creates a mirror texture attach to the ground.
  49531. * false by default.
  49532. */
  49533. enableGroundMirror: boolean;
  49534. /**
  49535. * Specifies the ground mirror size ratio.
  49536. * 0.3 by default as the default kernel is 64.
  49537. */
  49538. groundMirrorSizeRatio: number;
  49539. /**
  49540. * Specifies the ground mirror blur kernel size.
  49541. * 64 by default.
  49542. */
  49543. groundMirrorBlurKernel: number;
  49544. /**
  49545. * Specifies the ground mirror visibility amount.
  49546. * 1 by default
  49547. */
  49548. groundMirrorAmount: number;
  49549. /**
  49550. * Specifies the ground mirror reflectance weight.
  49551. * This uses the standard weight of the background material to setup the fresnel effect
  49552. * of the mirror.
  49553. * 1 by default.
  49554. */
  49555. groundMirrorFresnelWeight: number;
  49556. /**
  49557. * Specifies the ground mirror Falloff distance.
  49558. * This can helps reducing the size of the reflection.
  49559. * 0 by Default.
  49560. */
  49561. groundMirrorFallOffDistance: number;
  49562. /**
  49563. * Specifies the ground mirror texture type.
  49564. * Unsigned Int by Default.
  49565. */
  49566. groundMirrorTextureType: number;
  49567. /**
  49568. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49569. * the shown objects.
  49570. */
  49571. groundYBias: number;
  49572. /**
  49573. * Specifies whether or not to create a skybox.
  49574. * True by default.
  49575. */
  49576. createSkybox: boolean;
  49577. /**
  49578. * Specifies the skybox size.
  49579. * 20 by default.
  49580. */
  49581. skyboxSize: number;
  49582. /**
  49583. * The texture used on the skybox for the main color.
  49584. * Comes from the BabylonJS CDN by default.
  49585. *
  49586. * Remarks: Can be either a texture or a url.
  49587. */
  49588. skyboxTexture: string | BaseTexture;
  49589. /**
  49590. * The color mixed in the skybox texture by default.
  49591. * BabylonJS clearColor by default.
  49592. */
  49593. skyboxColor: Color3;
  49594. /**
  49595. * The background rotation around the Y axis of the scene.
  49596. * This helps aligning the key lights of your scene with the background.
  49597. * 0 by default.
  49598. */
  49599. backgroundYRotation: number;
  49600. /**
  49601. * Compute automatically the size of the elements to best fit with the scene.
  49602. */
  49603. sizeAuto: boolean;
  49604. /**
  49605. * Default position of the rootMesh if autoSize is not true.
  49606. */
  49607. rootPosition: Vector3;
  49608. /**
  49609. * Sets up the image processing in the scene.
  49610. * true by default.
  49611. */
  49612. setupImageProcessing: boolean;
  49613. /**
  49614. * The texture used as your environment texture in the scene.
  49615. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49616. *
  49617. * Remarks: Can be either a texture or a url.
  49618. */
  49619. environmentTexture: string | BaseTexture;
  49620. /**
  49621. * The value of the exposure to apply to the scene.
  49622. * 0.6 by default if setupImageProcessing is true.
  49623. */
  49624. cameraExposure: number;
  49625. /**
  49626. * The value of the contrast to apply to the scene.
  49627. * 1.6 by default if setupImageProcessing is true.
  49628. */
  49629. cameraContrast: number;
  49630. /**
  49631. * Specifies whether or not tonemapping should be enabled in the scene.
  49632. * true by default if setupImageProcessing is true.
  49633. */
  49634. toneMappingEnabled: boolean;
  49635. }
  49636. /**
  49637. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49638. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49639. * It also helps with the default setup of your imageProcessing configuration.
  49640. */
  49641. export class EnvironmentHelper {
  49642. /**
  49643. * Default ground texture URL.
  49644. */
  49645. private static _groundTextureCDNUrl;
  49646. /**
  49647. * Default skybox texture URL.
  49648. */
  49649. private static _skyboxTextureCDNUrl;
  49650. /**
  49651. * Default environment texture URL.
  49652. */
  49653. private static _environmentTextureCDNUrl;
  49654. /**
  49655. * Creates the default options for the helper.
  49656. */
  49657. private static _getDefaultOptions;
  49658. private _rootMesh;
  49659. /**
  49660. * Gets the root mesh created by the helper.
  49661. */
  49662. get rootMesh(): Mesh;
  49663. private _skybox;
  49664. /**
  49665. * Gets the skybox created by the helper.
  49666. */
  49667. get skybox(): Nullable<Mesh>;
  49668. private _skyboxTexture;
  49669. /**
  49670. * Gets the skybox texture created by the helper.
  49671. */
  49672. get skyboxTexture(): Nullable<BaseTexture>;
  49673. private _skyboxMaterial;
  49674. /**
  49675. * Gets the skybox material created by the helper.
  49676. */
  49677. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49678. private _ground;
  49679. /**
  49680. * Gets the ground mesh created by the helper.
  49681. */
  49682. get ground(): Nullable<Mesh>;
  49683. private _groundTexture;
  49684. /**
  49685. * Gets the ground texture created by the helper.
  49686. */
  49687. get groundTexture(): Nullable<BaseTexture>;
  49688. private _groundMirror;
  49689. /**
  49690. * Gets the ground mirror created by the helper.
  49691. */
  49692. get groundMirror(): Nullable<MirrorTexture>;
  49693. /**
  49694. * Gets the ground mirror render list to helps pushing the meshes
  49695. * you wish in the ground reflection.
  49696. */
  49697. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49698. private _groundMaterial;
  49699. /**
  49700. * Gets the ground material created by the helper.
  49701. */
  49702. get groundMaterial(): Nullable<BackgroundMaterial>;
  49703. /**
  49704. * Stores the creation options.
  49705. */
  49706. private readonly _scene;
  49707. private _options;
  49708. /**
  49709. * This observable will be notified with any error during the creation of the environment,
  49710. * mainly texture creation errors.
  49711. */
  49712. onErrorObservable: Observable<{
  49713. message?: string;
  49714. exception?: any;
  49715. }>;
  49716. /**
  49717. * constructor
  49718. * @param options Defines the options we want to customize the helper
  49719. * @param scene The scene to add the material to
  49720. */
  49721. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49722. /**
  49723. * Updates the background according to the new options
  49724. * @param options
  49725. */
  49726. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49727. /**
  49728. * Sets the primary color of all the available elements.
  49729. * @param color the main color to affect to the ground and the background
  49730. */
  49731. setMainColor(color: Color3): void;
  49732. /**
  49733. * Setup the image processing according to the specified options.
  49734. */
  49735. private _setupImageProcessing;
  49736. /**
  49737. * Setup the environment texture according to the specified options.
  49738. */
  49739. private _setupEnvironmentTexture;
  49740. /**
  49741. * Setup the background according to the specified options.
  49742. */
  49743. private _setupBackground;
  49744. /**
  49745. * Get the scene sizes according to the setup.
  49746. */
  49747. private _getSceneSize;
  49748. /**
  49749. * Setup the ground according to the specified options.
  49750. */
  49751. private _setupGround;
  49752. /**
  49753. * Setup the ground material according to the specified options.
  49754. */
  49755. private _setupGroundMaterial;
  49756. /**
  49757. * Setup the ground diffuse texture according to the specified options.
  49758. */
  49759. private _setupGroundDiffuseTexture;
  49760. /**
  49761. * Setup the ground mirror texture according to the specified options.
  49762. */
  49763. private _setupGroundMirrorTexture;
  49764. /**
  49765. * Setup the ground to receive the mirror texture.
  49766. */
  49767. private _setupMirrorInGroundMaterial;
  49768. /**
  49769. * Setup the skybox according to the specified options.
  49770. */
  49771. private _setupSkybox;
  49772. /**
  49773. * Setup the skybox material according to the specified options.
  49774. */
  49775. private _setupSkyboxMaterial;
  49776. /**
  49777. * Setup the skybox reflection texture according to the specified options.
  49778. */
  49779. private _setupSkyboxReflectionTexture;
  49780. private _errorHandler;
  49781. /**
  49782. * Dispose all the elements created by the Helper.
  49783. */
  49784. dispose(): void;
  49785. }
  49786. }
  49787. declare module BABYLON {
  49788. /**
  49789. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49790. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49791. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49792. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49793. */
  49794. export class PhotoDome extends TransformNode {
  49795. /**
  49796. * Define the image as a Monoscopic panoramic 360 image.
  49797. */
  49798. static readonly MODE_MONOSCOPIC: number;
  49799. /**
  49800. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49801. */
  49802. static readonly MODE_TOPBOTTOM: number;
  49803. /**
  49804. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49805. */
  49806. static readonly MODE_SIDEBYSIDE: number;
  49807. private _useDirectMapping;
  49808. /**
  49809. * The texture being displayed on the sphere
  49810. */
  49811. protected _photoTexture: Texture;
  49812. /**
  49813. * Gets or sets the texture being displayed on the sphere
  49814. */
  49815. get photoTexture(): Texture;
  49816. set photoTexture(value: Texture);
  49817. /**
  49818. * Observable raised when an error occured while loading the 360 image
  49819. */
  49820. onLoadErrorObservable: Observable<string>;
  49821. /**
  49822. * The skybox material
  49823. */
  49824. protected _material: BackgroundMaterial;
  49825. /**
  49826. * The surface used for the skybox
  49827. */
  49828. protected _mesh: Mesh;
  49829. /**
  49830. * Gets the mesh used for the skybox.
  49831. */
  49832. get mesh(): Mesh;
  49833. /**
  49834. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49835. * Also see the options.resolution property.
  49836. */
  49837. get fovMultiplier(): number;
  49838. set fovMultiplier(value: number);
  49839. private _imageMode;
  49840. /**
  49841. * Gets or set the current video mode for the video. It can be:
  49842. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49843. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49844. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49845. */
  49846. get imageMode(): number;
  49847. set imageMode(value: number);
  49848. /**
  49849. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49850. * @param name Element's name, child elements will append suffixes for their own names.
  49851. * @param urlsOfPhoto defines the url of the photo to display
  49852. * @param options defines an object containing optional or exposed sub element properties
  49853. * @param onError defines a callback called when an error occured while loading the texture
  49854. */
  49855. constructor(name: string, urlOfPhoto: string, options: {
  49856. resolution?: number;
  49857. size?: number;
  49858. useDirectMapping?: boolean;
  49859. faceForward?: boolean;
  49860. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49861. private _onBeforeCameraRenderObserver;
  49862. private _changeImageMode;
  49863. /**
  49864. * Releases resources associated with this node.
  49865. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49866. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49867. */
  49868. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49869. }
  49870. }
  49871. declare module BABYLON {
  49872. /**
  49873. * Class used to host RGBD texture specific utilities
  49874. */
  49875. export class RGBDTextureTools {
  49876. /**
  49877. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49878. * @param texture the texture to expand.
  49879. */
  49880. static ExpandRGBDTexture(texture: Texture): void;
  49881. }
  49882. }
  49883. declare module BABYLON {
  49884. /**
  49885. * Class used to host texture specific utilities
  49886. */
  49887. export class BRDFTextureTools {
  49888. /**
  49889. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49890. * @param scene defines the hosting scene
  49891. * @returns the environment BRDF texture
  49892. */
  49893. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49894. private static _environmentBRDFBase64Texture;
  49895. }
  49896. }
  49897. declare module BABYLON {
  49898. /**
  49899. * @hidden
  49900. */
  49901. export interface IMaterialClearCoatDefines {
  49902. CLEARCOAT: boolean;
  49903. CLEARCOAT_DEFAULTIOR: boolean;
  49904. CLEARCOAT_TEXTURE: boolean;
  49905. CLEARCOAT_TEXTUREDIRECTUV: number;
  49906. CLEARCOAT_BUMP: boolean;
  49907. CLEARCOAT_BUMPDIRECTUV: number;
  49908. CLEARCOAT_TINT: boolean;
  49909. CLEARCOAT_TINT_TEXTURE: boolean;
  49910. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49911. /** @hidden */
  49912. _areTexturesDirty: boolean;
  49913. }
  49914. /**
  49915. * Define the code related to the clear coat parameters of the pbr material.
  49916. */
  49917. export class PBRClearCoatConfiguration {
  49918. /**
  49919. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49920. * The default fits with a polyurethane material.
  49921. */
  49922. private static readonly _DefaultIndexOfRefraction;
  49923. private _isEnabled;
  49924. /**
  49925. * Defines if the clear coat is enabled in the material.
  49926. */
  49927. isEnabled: boolean;
  49928. /**
  49929. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49930. */
  49931. intensity: number;
  49932. /**
  49933. * Defines the clear coat layer roughness.
  49934. */
  49935. roughness: number;
  49936. private _indexOfRefraction;
  49937. /**
  49938. * Defines the index of refraction of the clear coat.
  49939. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49940. * The default fits with a polyurethane material.
  49941. * Changing the default value is more performance intensive.
  49942. */
  49943. indexOfRefraction: number;
  49944. private _texture;
  49945. /**
  49946. * Stores the clear coat values in a texture.
  49947. */
  49948. texture: Nullable<BaseTexture>;
  49949. private _bumpTexture;
  49950. /**
  49951. * Define the clear coat specific bump texture.
  49952. */
  49953. bumpTexture: Nullable<BaseTexture>;
  49954. private _isTintEnabled;
  49955. /**
  49956. * Defines if the clear coat tint is enabled in the material.
  49957. */
  49958. isTintEnabled: boolean;
  49959. /**
  49960. * Defines the clear coat tint of the material.
  49961. * This is only use if tint is enabled
  49962. */
  49963. tintColor: Color3;
  49964. /**
  49965. * Defines the distance at which the tint color should be found in the
  49966. * clear coat media.
  49967. * This is only use if tint is enabled
  49968. */
  49969. tintColorAtDistance: number;
  49970. /**
  49971. * Defines the clear coat layer thickness.
  49972. * This is only use if tint is enabled
  49973. */
  49974. tintThickness: number;
  49975. private _tintTexture;
  49976. /**
  49977. * Stores the clear tint values in a texture.
  49978. * rgb is tint
  49979. * a is a thickness factor
  49980. */
  49981. tintTexture: Nullable<BaseTexture>;
  49982. /** @hidden */
  49983. private _internalMarkAllSubMeshesAsTexturesDirty;
  49984. /** @hidden */
  49985. _markAllSubMeshesAsTexturesDirty(): void;
  49986. /**
  49987. * Instantiate a new istance of clear coat configuration.
  49988. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49989. */
  49990. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49991. /**
  49992. * Gets wehter the submesh is ready to be used or not.
  49993. * @param defines the list of "defines" to update.
  49994. * @param scene defines the scene the material belongs to.
  49995. * @param engine defines the engine the material belongs to.
  49996. * @param disableBumpMap defines wether the material disables bump or not.
  49997. * @returns - boolean indicating that the submesh is ready or not.
  49998. */
  49999. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50000. /**
  50001. * Checks to see if a texture is used in the material.
  50002. * @param defines the list of "defines" to update.
  50003. * @param scene defines the scene to the material belongs to.
  50004. */
  50005. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50006. /**
  50007. * Binds the material data.
  50008. * @param uniformBuffer defines the Uniform buffer to fill in.
  50009. * @param scene defines the scene the material belongs to.
  50010. * @param engine defines the engine the material belongs to.
  50011. * @param disableBumpMap defines wether the material disables bump or not.
  50012. * @param isFrozen defines wether the material is frozen or not.
  50013. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50014. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50015. */
  50016. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50017. /**
  50018. * Checks to see if a texture is used in the material.
  50019. * @param texture - Base texture to use.
  50020. * @returns - Boolean specifying if a texture is used in the material.
  50021. */
  50022. hasTexture(texture: BaseTexture): boolean;
  50023. /**
  50024. * Returns an array of the actively used textures.
  50025. * @param activeTextures Array of BaseTextures
  50026. */
  50027. getActiveTextures(activeTextures: BaseTexture[]): void;
  50028. /**
  50029. * Returns the animatable textures.
  50030. * @param animatables Array of animatable textures.
  50031. */
  50032. getAnimatables(animatables: IAnimatable[]): void;
  50033. /**
  50034. * Disposes the resources of the material.
  50035. * @param forceDisposeTextures - Forces the disposal of all textures.
  50036. */
  50037. dispose(forceDisposeTextures?: boolean): void;
  50038. /**
  50039. * Get the current class name of the texture useful for serialization or dynamic coding.
  50040. * @returns "PBRClearCoatConfiguration"
  50041. */
  50042. getClassName(): string;
  50043. /**
  50044. * Add fallbacks to the effect fallbacks list.
  50045. * @param defines defines the Base texture to use.
  50046. * @param fallbacks defines the current fallback list.
  50047. * @param currentRank defines the current fallback rank.
  50048. * @returns the new fallback rank.
  50049. */
  50050. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50051. /**
  50052. * Add the required uniforms to the current list.
  50053. * @param uniforms defines the current uniform list.
  50054. */
  50055. static AddUniforms(uniforms: string[]): void;
  50056. /**
  50057. * Add the required samplers to the current list.
  50058. * @param samplers defines the current sampler list.
  50059. */
  50060. static AddSamplers(samplers: string[]): void;
  50061. /**
  50062. * Add the required uniforms to the current buffer.
  50063. * @param uniformBuffer defines the current uniform buffer.
  50064. */
  50065. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50066. /**
  50067. * Makes a duplicate of the current configuration into another one.
  50068. * @param clearCoatConfiguration define the config where to copy the info
  50069. */
  50070. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50071. /**
  50072. * Serializes this clear coat configuration.
  50073. * @returns - An object with the serialized config.
  50074. */
  50075. serialize(): any;
  50076. /**
  50077. * Parses a anisotropy Configuration from a serialized object.
  50078. * @param source - Serialized object.
  50079. * @param scene Defines the scene we are parsing for
  50080. * @param rootUrl Defines the rootUrl to load from
  50081. */
  50082. parse(source: any, scene: Scene, rootUrl: string): void;
  50083. }
  50084. }
  50085. declare module BABYLON {
  50086. /**
  50087. * @hidden
  50088. */
  50089. export interface IMaterialAnisotropicDefines {
  50090. ANISOTROPIC: boolean;
  50091. ANISOTROPIC_TEXTURE: boolean;
  50092. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50093. MAINUV1: boolean;
  50094. _areTexturesDirty: boolean;
  50095. _needUVs: boolean;
  50096. }
  50097. /**
  50098. * Define the code related to the anisotropic parameters of the pbr material.
  50099. */
  50100. export class PBRAnisotropicConfiguration {
  50101. private _isEnabled;
  50102. /**
  50103. * Defines if the anisotropy is enabled in the material.
  50104. */
  50105. isEnabled: boolean;
  50106. /**
  50107. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50108. */
  50109. intensity: number;
  50110. /**
  50111. * Defines if the effect is along the tangents, bitangents or in between.
  50112. * By default, the effect is "strectching" the highlights along the tangents.
  50113. */
  50114. direction: Vector2;
  50115. private _texture;
  50116. /**
  50117. * Stores the anisotropy values in a texture.
  50118. * rg is direction (like normal from -1 to 1)
  50119. * b is a intensity
  50120. */
  50121. texture: Nullable<BaseTexture>;
  50122. /** @hidden */
  50123. private _internalMarkAllSubMeshesAsTexturesDirty;
  50124. /** @hidden */
  50125. _markAllSubMeshesAsTexturesDirty(): void;
  50126. /**
  50127. * Instantiate a new istance of anisotropy configuration.
  50128. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50129. */
  50130. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50131. /**
  50132. * Specifies that the submesh is ready to be used.
  50133. * @param defines the list of "defines" to update.
  50134. * @param scene defines the scene the material belongs to.
  50135. * @returns - boolean indicating that the submesh is ready or not.
  50136. */
  50137. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50138. /**
  50139. * Checks to see if a texture is used in the material.
  50140. * @param defines the list of "defines" to update.
  50141. * @param mesh the mesh we are preparing the defines for.
  50142. * @param scene defines the scene the material belongs to.
  50143. */
  50144. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50145. /**
  50146. * Binds the material data.
  50147. * @param uniformBuffer defines the Uniform buffer to fill in.
  50148. * @param scene defines the scene the material belongs to.
  50149. * @param isFrozen defines wether the material is frozen or not.
  50150. */
  50151. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50152. /**
  50153. * Checks to see if a texture is used in the material.
  50154. * @param texture - Base texture to use.
  50155. * @returns - Boolean specifying if a texture is used in the material.
  50156. */
  50157. hasTexture(texture: BaseTexture): boolean;
  50158. /**
  50159. * Returns an array of the actively used textures.
  50160. * @param activeTextures Array of BaseTextures
  50161. */
  50162. getActiveTextures(activeTextures: BaseTexture[]): void;
  50163. /**
  50164. * Returns the animatable textures.
  50165. * @param animatables Array of animatable textures.
  50166. */
  50167. getAnimatables(animatables: IAnimatable[]): void;
  50168. /**
  50169. * Disposes the resources of the material.
  50170. * @param forceDisposeTextures - Forces the disposal of all textures.
  50171. */
  50172. dispose(forceDisposeTextures?: boolean): void;
  50173. /**
  50174. * Get the current class name of the texture useful for serialization or dynamic coding.
  50175. * @returns "PBRAnisotropicConfiguration"
  50176. */
  50177. getClassName(): string;
  50178. /**
  50179. * Add fallbacks to the effect fallbacks list.
  50180. * @param defines defines the Base texture to use.
  50181. * @param fallbacks defines the current fallback list.
  50182. * @param currentRank defines the current fallback rank.
  50183. * @returns the new fallback rank.
  50184. */
  50185. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50186. /**
  50187. * Add the required uniforms to the current list.
  50188. * @param uniforms defines the current uniform list.
  50189. */
  50190. static AddUniforms(uniforms: string[]): void;
  50191. /**
  50192. * Add the required uniforms to the current buffer.
  50193. * @param uniformBuffer defines the current uniform buffer.
  50194. */
  50195. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50196. /**
  50197. * Add the required samplers to the current list.
  50198. * @param samplers defines the current sampler list.
  50199. */
  50200. static AddSamplers(samplers: string[]): void;
  50201. /**
  50202. * Makes a duplicate of the current configuration into another one.
  50203. * @param anisotropicConfiguration define the config where to copy the info
  50204. */
  50205. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50206. /**
  50207. * Serializes this anisotropy configuration.
  50208. * @returns - An object with the serialized config.
  50209. */
  50210. serialize(): any;
  50211. /**
  50212. * Parses a anisotropy Configuration from a serialized object.
  50213. * @param source - Serialized object.
  50214. * @param scene Defines the scene we are parsing for
  50215. * @param rootUrl Defines the rootUrl to load from
  50216. */
  50217. parse(source: any, scene: Scene, rootUrl: string): void;
  50218. }
  50219. }
  50220. declare module BABYLON {
  50221. /**
  50222. * @hidden
  50223. */
  50224. export interface IMaterialBRDFDefines {
  50225. BRDF_V_HEIGHT_CORRELATED: boolean;
  50226. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50227. SPHERICAL_HARMONICS: boolean;
  50228. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50229. /** @hidden */
  50230. _areMiscDirty: boolean;
  50231. }
  50232. /**
  50233. * Define the code related to the BRDF parameters of the pbr material.
  50234. */
  50235. export class PBRBRDFConfiguration {
  50236. /**
  50237. * Default value used for the energy conservation.
  50238. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50239. */
  50240. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50241. /**
  50242. * Default value used for the Smith Visibility Height Correlated mode.
  50243. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50244. */
  50245. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50246. /**
  50247. * Default value used for the IBL diffuse part.
  50248. * This can help switching back to the polynomials mode globally which is a tiny bit
  50249. * less GPU intensive at the drawback of a lower quality.
  50250. */
  50251. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50252. /**
  50253. * Default value used for activating energy conservation for the specular workflow.
  50254. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50255. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50256. */
  50257. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50258. private _useEnergyConservation;
  50259. /**
  50260. * Defines if the material uses energy conservation.
  50261. */
  50262. useEnergyConservation: boolean;
  50263. private _useSmithVisibilityHeightCorrelated;
  50264. /**
  50265. * LEGACY Mode set to false
  50266. * Defines if the material uses height smith correlated visibility term.
  50267. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50268. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50269. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50270. * Not relying on height correlated will also disable energy conservation.
  50271. */
  50272. useSmithVisibilityHeightCorrelated: boolean;
  50273. private _useSphericalHarmonics;
  50274. /**
  50275. * LEGACY Mode set to false
  50276. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50277. * diffuse part of the IBL.
  50278. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50279. * to the ground truth.
  50280. */
  50281. useSphericalHarmonics: boolean;
  50282. private _useSpecularGlossinessInputEnergyConservation;
  50283. /**
  50284. * Defines if the material uses energy conservation, when the specular workflow is active.
  50285. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50286. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50287. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50288. */
  50289. useSpecularGlossinessInputEnergyConservation: boolean;
  50290. /** @hidden */
  50291. private _internalMarkAllSubMeshesAsMiscDirty;
  50292. /** @hidden */
  50293. _markAllSubMeshesAsMiscDirty(): void;
  50294. /**
  50295. * Instantiate a new istance of clear coat configuration.
  50296. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50297. */
  50298. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50299. /**
  50300. * Checks to see if a texture is used in the material.
  50301. * @param defines the list of "defines" to update.
  50302. */
  50303. prepareDefines(defines: IMaterialBRDFDefines): void;
  50304. /**
  50305. * Get the current class name of the texture useful for serialization or dynamic coding.
  50306. * @returns "PBRClearCoatConfiguration"
  50307. */
  50308. getClassName(): string;
  50309. /**
  50310. * Makes a duplicate of the current configuration into another one.
  50311. * @param brdfConfiguration define the config where to copy the info
  50312. */
  50313. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50314. /**
  50315. * Serializes this BRDF configuration.
  50316. * @returns - An object with the serialized config.
  50317. */
  50318. serialize(): any;
  50319. /**
  50320. * Parses a anisotropy Configuration from a serialized object.
  50321. * @param source - Serialized object.
  50322. * @param scene Defines the scene we are parsing for
  50323. * @param rootUrl Defines the rootUrl to load from
  50324. */
  50325. parse(source: any, scene: Scene, rootUrl: string): void;
  50326. }
  50327. }
  50328. declare module BABYLON {
  50329. /**
  50330. * @hidden
  50331. */
  50332. export interface IMaterialSheenDefines {
  50333. SHEEN: boolean;
  50334. SHEEN_TEXTURE: boolean;
  50335. SHEEN_TEXTUREDIRECTUV: number;
  50336. SHEEN_LINKWITHALBEDO: boolean;
  50337. /** @hidden */
  50338. _areTexturesDirty: boolean;
  50339. }
  50340. /**
  50341. * Define the code related to the Sheen parameters of the pbr material.
  50342. */
  50343. export class PBRSheenConfiguration {
  50344. private _isEnabled;
  50345. /**
  50346. * Defines if the material uses sheen.
  50347. */
  50348. isEnabled: boolean;
  50349. private _linkSheenWithAlbedo;
  50350. /**
  50351. * Defines if the sheen is linked to the sheen color.
  50352. */
  50353. linkSheenWithAlbedo: boolean;
  50354. /**
  50355. * Defines the sheen intensity.
  50356. */
  50357. intensity: number;
  50358. /**
  50359. * Defines the sheen color.
  50360. */
  50361. color: Color3;
  50362. private _texture;
  50363. /**
  50364. * Stores the sheen tint values in a texture.
  50365. * rgb is tint
  50366. * a is a intensity
  50367. */
  50368. texture: Nullable<BaseTexture>;
  50369. /** @hidden */
  50370. private _internalMarkAllSubMeshesAsTexturesDirty;
  50371. /** @hidden */
  50372. _markAllSubMeshesAsTexturesDirty(): void;
  50373. /**
  50374. * Instantiate a new istance of clear coat configuration.
  50375. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50376. */
  50377. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50378. /**
  50379. * Specifies that the submesh is ready to be used.
  50380. * @param defines the list of "defines" to update.
  50381. * @param scene defines the scene the material belongs to.
  50382. * @returns - boolean indicating that the submesh is ready or not.
  50383. */
  50384. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50385. /**
  50386. * Checks to see if a texture is used in the material.
  50387. * @param defines the list of "defines" to update.
  50388. * @param scene defines the scene the material belongs to.
  50389. */
  50390. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50391. /**
  50392. * Binds the material data.
  50393. * @param uniformBuffer defines the Uniform buffer to fill in.
  50394. * @param scene defines the scene the material belongs to.
  50395. * @param isFrozen defines wether the material is frozen or not.
  50396. */
  50397. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50398. /**
  50399. * Checks to see if a texture is used in the material.
  50400. * @param texture - Base texture to use.
  50401. * @returns - Boolean specifying if a texture is used in the material.
  50402. */
  50403. hasTexture(texture: BaseTexture): boolean;
  50404. /**
  50405. * Returns an array of the actively used textures.
  50406. * @param activeTextures Array of BaseTextures
  50407. */
  50408. getActiveTextures(activeTextures: BaseTexture[]): void;
  50409. /**
  50410. * Returns the animatable textures.
  50411. * @param animatables Array of animatable textures.
  50412. */
  50413. getAnimatables(animatables: IAnimatable[]): void;
  50414. /**
  50415. * Disposes the resources of the material.
  50416. * @param forceDisposeTextures - Forces the disposal of all textures.
  50417. */
  50418. dispose(forceDisposeTextures?: boolean): void;
  50419. /**
  50420. * Get the current class name of the texture useful for serialization or dynamic coding.
  50421. * @returns "PBRSheenConfiguration"
  50422. */
  50423. getClassName(): string;
  50424. /**
  50425. * Add fallbacks to the effect fallbacks list.
  50426. * @param defines defines the Base texture to use.
  50427. * @param fallbacks defines the current fallback list.
  50428. * @param currentRank defines the current fallback rank.
  50429. * @returns the new fallback rank.
  50430. */
  50431. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50432. /**
  50433. * Add the required uniforms to the current list.
  50434. * @param uniforms defines the current uniform list.
  50435. */
  50436. static AddUniforms(uniforms: string[]): void;
  50437. /**
  50438. * Add the required uniforms to the current buffer.
  50439. * @param uniformBuffer defines the current uniform buffer.
  50440. */
  50441. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50442. /**
  50443. * Add the required samplers to the current list.
  50444. * @param samplers defines the current sampler list.
  50445. */
  50446. static AddSamplers(samplers: string[]): void;
  50447. /**
  50448. * Makes a duplicate of the current configuration into another one.
  50449. * @param sheenConfiguration define the config where to copy the info
  50450. */
  50451. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50452. /**
  50453. * Serializes this BRDF configuration.
  50454. * @returns - An object with the serialized config.
  50455. */
  50456. serialize(): any;
  50457. /**
  50458. * Parses a anisotropy Configuration from a serialized object.
  50459. * @param source - Serialized object.
  50460. * @param scene Defines the scene we are parsing for
  50461. * @param rootUrl Defines the rootUrl to load from
  50462. */
  50463. parse(source: any, scene: Scene, rootUrl: string): void;
  50464. }
  50465. }
  50466. declare module BABYLON {
  50467. /**
  50468. * @hidden
  50469. */
  50470. export interface IMaterialSubSurfaceDefines {
  50471. SUBSURFACE: boolean;
  50472. SS_REFRACTION: boolean;
  50473. SS_TRANSLUCENCY: boolean;
  50474. SS_SCATERRING: boolean;
  50475. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50476. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50477. SS_REFRACTIONMAP_3D: boolean;
  50478. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50479. SS_LODINREFRACTIONALPHA: boolean;
  50480. SS_GAMMAREFRACTION: boolean;
  50481. SS_RGBDREFRACTION: boolean;
  50482. SS_LINEARSPECULARREFRACTION: boolean;
  50483. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50484. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50485. /** @hidden */
  50486. _areTexturesDirty: boolean;
  50487. }
  50488. /**
  50489. * Define the code related to the sub surface parameters of the pbr material.
  50490. */
  50491. export class PBRSubSurfaceConfiguration {
  50492. private _isRefractionEnabled;
  50493. /**
  50494. * Defines if the refraction is enabled in the material.
  50495. */
  50496. isRefractionEnabled: boolean;
  50497. private _isTranslucencyEnabled;
  50498. /**
  50499. * Defines if the translucency is enabled in the material.
  50500. */
  50501. isTranslucencyEnabled: boolean;
  50502. private _isScatteringEnabled;
  50503. /**
  50504. * Defines the refraction intensity of the material.
  50505. * The refraction when enabled replaces the Diffuse part of the material.
  50506. * The intensity helps transitionning between diffuse and refraction.
  50507. */
  50508. refractionIntensity: number;
  50509. /**
  50510. * Defines the translucency intensity of the material.
  50511. * When translucency has been enabled, this defines how much of the "translucency"
  50512. * is addded to the diffuse part of the material.
  50513. */
  50514. translucencyIntensity: number;
  50515. /**
  50516. * Defines the scattering intensity of the material.
  50517. * When scattering has been enabled, this defines how much of the "scattered light"
  50518. * is addded to the diffuse part of the material.
  50519. */
  50520. scatteringIntensity: number;
  50521. private _thicknessTexture;
  50522. /**
  50523. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50524. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50525. * 0 would mean minimumThickness
  50526. * 1 would mean maximumThickness
  50527. * The other channels might be use as a mask to vary the different effects intensity.
  50528. */
  50529. thicknessTexture: Nullable<BaseTexture>;
  50530. private _refractionTexture;
  50531. /**
  50532. * Defines the texture to use for refraction.
  50533. */
  50534. refractionTexture: Nullable<BaseTexture>;
  50535. private _indexOfRefraction;
  50536. /**
  50537. * Defines the index of refraction used in the material.
  50538. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50539. */
  50540. indexOfRefraction: number;
  50541. private _invertRefractionY;
  50542. /**
  50543. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50544. */
  50545. invertRefractionY: boolean;
  50546. private _linkRefractionWithTransparency;
  50547. /**
  50548. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50549. * Materials half opaque for instance using refraction could benefit from this control.
  50550. */
  50551. linkRefractionWithTransparency: boolean;
  50552. /**
  50553. * Defines the minimum thickness stored in the thickness map.
  50554. * If no thickness map is defined, this value will be used to simulate thickness.
  50555. */
  50556. minimumThickness: number;
  50557. /**
  50558. * Defines the maximum thickness stored in the thickness map.
  50559. */
  50560. maximumThickness: number;
  50561. /**
  50562. * Defines the volume tint of the material.
  50563. * This is used for both translucency and scattering.
  50564. */
  50565. tintColor: Color3;
  50566. /**
  50567. * Defines the distance at which the tint color should be found in the media.
  50568. * This is used for refraction only.
  50569. */
  50570. tintColorAtDistance: number;
  50571. /**
  50572. * Defines how far each channel transmit through the media.
  50573. * It is defined as a color to simplify it selection.
  50574. */
  50575. diffusionDistance: Color3;
  50576. private _useMaskFromThicknessTexture;
  50577. /**
  50578. * Stores the intensity of the different subsurface effects in the thickness texture.
  50579. * * the green channel is the translucency intensity.
  50580. * * the blue channel is the scattering intensity.
  50581. * * the alpha channel is the refraction intensity.
  50582. */
  50583. useMaskFromThicknessTexture: boolean;
  50584. /** @hidden */
  50585. private _internalMarkAllSubMeshesAsTexturesDirty;
  50586. /** @hidden */
  50587. _markAllSubMeshesAsTexturesDirty(): void;
  50588. /**
  50589. * Instantiate a new istance of sub surface configuration.
  50590. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50591. */
  50592. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50593. /**
  50594. * Gets wehter the submesh is ready to be used or not.
  50595. * @param defines the list of "defines" to update.
  50596. * @param scene defines the scene the material belongs to.
  50597. * @returns - boolean indicating that the submesh is ready or not.
  50598. */
  50599. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50600. /**
  50601. * Checks to see if a texture is used in the material.
  50602. * @param defines the list of "defines" to update.
  50603. * @param scene defines the scene to the material belongs to.
  50604. */
  50605. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50606. /**
  50607. * Binds the material data.
  50608. * @param uniformBuffer defines the Uniform buffer to fill in.
  50609. * @param scene defines the scene the material belongs to.
  50610. * @param engine defines the engine the material belongs to.
  50611. * @param isFrozen defines wether the material is frozen or not.
  50612. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50613. */
  50614. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50615. /**
  50616. * Unbinds the material from the mesh.
  50617. * @param activeEffect defines the effect that should be unbound from.
  50618. * @returns true if unbound, otherwise false
  50619. */
  50620. unbind(activeEffect: Effect): boolean;
  50621. /**
  50622. * Returns the texture used for refraction or null if none is used.
  50623. * @param scene defines the scene the material belongs to.
  50624. * @returns - Refraction texture if present. If no refraction texture and refraction
  50625. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50626. */
  50627. private _getRefractionTexture;
  50628. /**
  50629. * Returns true if alpha blending should be disabled.
  50630. */
  50631. get disableAlphaBlending(): boolean;
  50632. /**
  50633. * Fills the list of render target textures.
  50634. * @param renderTargets the list of render targets to update
  50635. */
  50636. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50637. /**
  50638. * Checks to see if a texture is used in the material.
  50639. * @param texture - Base texture to use.
  50640. * @returns - Boolean specifying if a texture is used in the material.
  50641. */
  50642. hasTexture(texture: BaseTexture): boolean;
  50643. /**
  50644. * Gets a boolean indicating that current material needs to register RTT
  50645. * @returns true if this uses a render target otherwise false.
  50646. */
  50647. hasRenderTargetTextures(): boolean;
  50648. /**
  50649. * Returns an array of the actively used textures.
  50650. * @param activeTextures Array of BaseTextures
  50651. */
  50652. getActiveTextures(activeTextures: BaseTexture[]): void;
  50653. /**
  50654. * Returns the animatable textures.
  50655. * @param animatables Array of animatable textures.
  50656. */
  50657. getAnimatables(animatables: IAnimatable[]): void;
  50658. /**
  50659. * Disposes the resources of the material.
  50660. * @param forceDisposeTextures - Forces the disposal of all textures.
  50661. */
  50662. dispose(forceDisposeTextures?: boolean): void;
  50663. /**
  50664. * Get the current class name of the texture useful for serialization or dynamic coding.
  50665. * @returns "PBRSubSurfaceConfiguration"
  50666. */
  50667. getClassName(): string;
  50668. /**
  50669. * Add fallbacks to the effect fallbacks list.
  50670. * @param defines defines the Base texture to use.
  50671. * @param fallbacks defines the current fallback list.
  50672. * @param currentRank defines the current fallback rank.
  50673. * @returns the new fallback rank.
  50674. */
  50675. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50676. /**
  50677. * Add the required uniforms to the current list.
  50678. * @param uniforms defines the current uniform list.
  50679. */
  50680. static AddUniforms(uniforms: string[]): void;
  50681. /**
  50682. * Add the required samplers to the current list.
  50683. * @param samplers defines the current sampler list.
  50684. */
  50685. static AddSamplers(samplers: string[]): void;
  50686. /**
  50687. * Add the required uniforms to the current buffer.
  50688. * @param uniformBuffer defines the current uniform buffer.
  50689. */
  50690. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50691. /**
  50692. * Makes a duplicate of the current configuration into another one.
  50693. * @param configuration define the config where to copy the info
  50694. */
  50695. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50696. /**
  50697. * Serializes this Sub Surface configuration.
  50698. * @returns - An object with the serialized config.
  50699. */
  50700. serialize(): any;
  50701. /**
  50702. * Parses a anisotropy Configuration from a serialized object.
  50703. * @param source - Serialized object.
  50704. * @param scene Defines the scene we are parsing for
  50705. * @param rootUrl Defines the rootUrl to load from
  50706. */
  50707. parse(source: any, scene: Scene, rootUrl: string): void;
  50708. }
  50709. }
  50710. declare module BABYLON {
  50711. /** @hidden */
  50712. export var pbrFragmentDeclaration: {
  50713. name: string;
  50714. shader: string;
  50715. };
  50716. }
  50717. declare module BABYLON {
  50718. /** @hidden */
  50719. export var pbrUboDeclaration: {
  50720. name: string;
  50721. shader: string;
  50722. };
  50723. }
  50724. declare module BABYLON {
  50725. /** @hidden */
  50726. export var pbrFragmentExtraDeclaration: {
  50727. name: string;
  50728. shader: string;
  50729. };
  50730. }
  50731. declare module BABYLON {
  50732. /** @hidden */
  50733. export var pbrFragmentSamplersDeclaration: {
  50734. name: string;
  50735. shader: string;
  50736. };
  50737. }
  50738. declare module BABYLON {
  50739. /** @hidden */
  50740. export var pbrHelperFunctions: {
  50741. name: string;
  50742. shader: string;
  50743. };
  50744. }
  50745. declare module BABYLON {
  50746. /** @hidden */
  50747. export var harmonicsFunctions: {
  50748. name: string;
  50749. shader: string;
  50750. };
  50751. }
  50752. declare module BABYLON {
  50753. /** @hidden */
  50754. export var pbrDirectLightingSetupFunctions: {
  50755. name: string;
  50756. shader: string;
  50757. };
  50758. }
  50759. declare module BABYLON {
  50760. /** @hidden */
  50761. export var pbrDirectLightingFalloffFunctions: {
  50762. name: string;
  50763. shader: string;
  50764. };
  50765. }
  50766. declare module BABYLON {
  50767. /** @hidden */
  50768. export var pbrBRDFFunctions: {
  50769. name: string;
  50770. shader: string;
  50771. };
  50772. }
  50773. declare module BABYLON {
  50774. /** @hidden */
  50775. export var pbrDirectLightingFunctions: {
  50776. name: string;
  50777. shader: string;
  50778. };
  50779. }
  50780. declare module BABYLON {
  50781. /** @hidden */
  50782. export var pbrIBLFunctions: {
  50783. name: string;
  50784. shader: string;
  50785. };
  50786. }
  50787. declare module BABYLON {
  50788. /** @hidden */
  50789. export var pbrDebug: {
  50790. name: string;
  50791. shader: string;
  50792. };
  50793. }
  50794. declare module BABYLON {
  50795. /** @hidden */
  50796. export var pbrPixelShader: {
  50797. name: string;
  50798. shader: string;
  50799. };
  50800. }
  50801. declare module BABYLON {
  50802. /** @hidden */
  50803. export var pbrVertexDeclaration: {
  50804. name: string;
  50805. shader: string;
  50806. };
  50807. }
  50808. declare module BABYLON {
  50809. /** @hidden */
  50810. export var pbrVertexShader: {
  50811. name: string;
  50812. shader: string;
  50813. };
  50814. }
  50815. declare module BABYLON {
  50816. /**
  50817. * Manages the defines for the PBR Material.
  50818. * @hidden
  50819. */
  50820. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50821. PBR: boolean;
  50822. MAINUV1: boolean;
  50823. MAINUV2: boolean;
  50824. UV1: boolean;
  50825. UV2: boolean;
  50826. ALBEDO: boolean;
  50827. GAMMAALBEDO: boolean;
  50828. ALBEDODIRECTUV: number;
  50829. VERTEXCOLOR: boolean;
  50830. AMBIENT: boolean;
  50831. AMBIENTDIRECTUV: number;
  50832. AMBIENTINGRAYSCALE: boolean;
  50833. OPACITY: boolean;
  50834. VERTEXALPHA: boolean;
  50835. OPACITYDIRECTUV: number;
  50836. OPACITYRGB: boolean;
  50837. ALPHATEST: boolean;
  50838. DEPTHPREPASS: boolean;
  50839. ALPHABLEND: boolean;
  50840. ALPHAFROMALBEDO: boolean;
  50841. ALPHATESTVALUE: string;
  50842. SPECULAROVERALPHA: boolean;
  50843. RADIANCEOVERALPHA: boolean;
  50844. ALPHAFRESNEL: boolean;
  50845. LINEARALPHAFRESNEL: boolean;
  50846. PREMULTIPLYALPHA: boolean;
  50847. EMISSIVE: boolean;
  50848. EMISSIVEDIRECTUV: number;
  50849. REFLECTIVITY: boolean;
  50850. REFLECTIVITYDIRECTUV: number;
  50851. SPECULARTERM: boolean;
  50852. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50853. MICROSURFACEAUTOMATIC: boolean;
  50854. LODBASEDMICROSFURACE: boolean;
  50855. MICROSURFACEMAP: boolean;
  50856. MICROSURFACEMAPDIRECTUV: number;
  50857. METALLICWORKFLOW: boolean;
  50858. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50859. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50860. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50861. AOSTOREINMETALMAPRED: boolean;
  50862. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50863. ENVIRONMENTBRDF: boolean;
  50864. ENVIRONMENTBRDF_RGBD: boolean;
  50865. NORMAL: boolean;
  50866. TANGENT: boolean;
  50867. BUMP: boolean;
  50868. BUMPDIRECTUV: number;
  50869. OBJECTSPACE_NORMALMAP: boolean;
  50870. PARALLAX: boolean;
  50871. PARALLAXOCCLUSION: boolean;
  50872. NORMALXYSCALE: boolean;
  50873. LIGHTMAP: boolean;
  50874. LIGHTMAPDIRECTUV: number;
  50875. USELIGHTMAPASSHADOWMAP: boolean;
  50876. GAMMALIGHTMAP: boolean;
  50877. RGBDLIGHTMAP: boolean;
  50878. REFLECTION: boolean;
  50879. REFLECTIONMAP_3D: boolean;
  50880. REFLECTIONMAP_SPHERICAL: boolean;
  50881. REFLECTIONMAP_PLANAR: boolean;
  50882. REFLECTIONMAP_CUBIC: boolean;
  50883. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50884. REFLECTIONMAP_PROJECTION: boolean;
  50885. REFLECTIONMAP_SKYBOX: boolean;
  50886. REFLECTIONMAP_EXPLICIT: boolean;
  50887. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50888. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50889. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50890. INVERTCUBICMAP: boolean;
  50891. USESPHERICALFROMREFLECTIONMAP: boolean;
  50892. USEIRRADIANCEMAP: boolean;
  50893. SPHERICAL_HARMONICS: boolean;
  50894. USESPHERICALINVERTEX: boolean;
  50895. REFLECTIONMAP_OPPOSITEZ: boolean;
  50896. LODINREFLECTIONALPHA: boolean;
  50897. GAMMAREFLECTION: boolean;
  50898. RGBDREFLECTION: boolean;
  50899. LINEARSPECULARREFLECTION: boolean;
  50900. RADIANCEOCCLUSION: boolean;
  50901. HORIZONOCCLUSION: boolean;
  50902. INSTANCES: boolean;
  50903. NUM_BONE_INFLUENCERS: number;
  50904. BonesPerMesh: number;
  50905. BONETEXTURE: boolean;
  50906. NONUNIFORMSCALING: boolean;
  50907. MORPHTARGETS: boolean;
  50908. MORPHTARGETS_NORMAL: boolean;
  50909. MORPHTARGETS_TANGENT: boolean;
  50910. MORPHTARGETS_UV: boolean;
  50911. NUM_MORPH_INFLUENCERS: number;
  50912. IMAGEPROCESSING: boolean;
  50913. VIGNETTE: boolean;
  50914. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50915. VIGNETTEBLENDMODEOPAQUE: boolean;
  50916. TONEMAPPING: boolean;
  50917. TONEMAPPING_ACES: boolean;
  50918. CONTRAST: boolean;
  50919. COLORCURVES: boolean;
  50920. COLORGRADING: boolean;
  50921. COLORGRADING3D: boolean;
  50922. SAMPLER3DGREENDEPTH: boolean;
  50923. SAMPLER3DBGRMAP: boolean;
  50924. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50925. EXPOSURE: boolean;
  50926. MULTIVIEW: boolean;
  50927. USEPHYSICALLIGHTFALLOFF: boolean;
  50928. USEGLTFLIGHTFALLOFF: boolean;
  50929. TWOSIDEDLIGHTING: boolean;
  50930. SHADOWFLOAT: boolean;
  50931. CLIPPLANE: boolean;
  50932. CLIPPLANE2: boolean;
  50933. CLIPPLANE3: boolean;
  50934. CLIPPLANE4: boolean;
  50935. CLIPPLANE5: boolean;
  50936. CLIPPLANE6: boolean;
  50937. POINTSIZE: boolean;
  50938. FOG: boolean;
  50939. LOGARITHMICDEPTH: boolean;
  50940. FORCENORMALFORWARD: boolean;
  50941. SPECULARAA: boolean;
  50942. CLEARCOAT: boolean;
  50943. CLEARCOAT_DEFAULTIOR: boolean;
  50944. CLEARCOAT_TEXTURE: boolean;
  50945. CLEARCOAT_TEXTUREDIRECTUV: number;
  50946. CLEARCOAT_BUMP: boolean;
  50947. CLEARCOAT_BUMPDIRECTUV: number;
  50948. CLEARCOAT_TINT: boolean;
  50949. CLEARCOAT_TINT_TEXTURE: boolean;
  50950. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50951. ANISOTROPIC: boolean;
  50952. ANISOTROPIC_TEXTURE: boolean;
  50953. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50954. BRDF_V_HEIGHT_CORRELATED: boolean;
  50955. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50956. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50957. SHEEN: boolean;
  50958. SHEEN_TEXTURE: boolean;
  50959. SHEEN_TEXTUREDIRECTUV: number;
  50960. SHEEN_LINKWITHALBEDO: boolean;
  50961. SUBSURFACE: boolean;
  50962. SS_REFRACTION: boolean;
  50963. SS_TRANSLUCENCY: boolean;
  50964. SS_SCATERRING: boolean;
  50965. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50966. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50967. SS_REFRACTIONMAP_3D: boolean;
  50968. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50969. SS_LODINREFRACTIONALPHA: boolean;
  50970. SS_GAMMAREFRACTION: boolean;
  50971. SS_RGBDREFRACTION: boolean;
  50972. SS_LINEARSPECULARREFRACTION: boolean;
  50973. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50974. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50975. UNLIT: boolean;
  50976. DEBUGMODE: number;
  50977. /**
  50978. * Initializes the PBR Material defines.
  50979. */
  50980. constructor();
  50981. /**
  50982. * Resets the PBR Material defines.
  50983. */
  50984. reset(): void;
  50985. }
  50986. /**
  50987. * The Physically based material base class of BJS.
  50988. *
  50989. * This offers the main features of a standard PBR material.
  50990. * For more information, please refer to the documentation :
  50991. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50992. */
  50993. export abstract class PBRBaseMaterial extends PushMaterial {
  50994. /**
  50995. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50996. */
  50997. static readonly PBRMATERIAL_OPAQUE: number;
  50998. /**
  50999. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51000. */
  51001. static readonly PBRMATERIAL_ALPHATEST: number;
  51002. /**
  51003. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51004. */
  51005. static readonly PBRMATERIAL_ALPHABLEND: number;
  51006. /**
  51007. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51008. * They are also discarded below the alpha cutoff threshold to improve performances.
  51009. */
  51010. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51011. /**
  51012. * Defines the default value of how much AO map is occluding the analytical lights
  51013. * (point spot...).
  51014. */
  51015. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51016. /**
  51017. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51018. */
  51019. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51020. /**
  51021. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51022. * to enhance interoperability with other engines.
  51023. */
  51024. static readonly LIGHTFALLOFF_GLTF: number;
  51025. /**
  51026. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51027. * to enhance interoperability with other materials.
  51028. */
  51029. static readonly LIGHTFALLOFF_STANDARD: number;
  51030. /**
  51031. * Intensity of the direct lights e.g. the four lights available in your scene.
  51032. * This impacts both the direct diffuse and specular highlights.
  51033. */
  51034. protected _directIntensity: number;
  51035. /**
  51036. * Intensity of the emissive part of the material.
  51037. * This helps controlling the emissive effect without modifying the emissive color.
  51038. */
  51039. protected _emissiveIntensity: number;
  51040. /**
  51041. * Intensity of the environment e.g. how much the environment will light the object
  51042. * either through harmonics for rough material or through the refelction for shiny ones.
  51043. */
  51044. protected _environmentIntensity: number;
  51045. /**
  51046. * This is a special control allowing the reduction of the specular highlights coming from the
  51047. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51048. */
  51049. protected _specularIntensity: number;
  51050. /**
  51051. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51052. */
  51053. private _lightingInfos;
  51054. /**
  51055. * Debug Control allowing disabling the bump map on this material.
  51056. */
  51057. protected _disableBumpMap: boolean;
  51058. /**
  51059. * AKA Diffuse Texture in standard nomenclature.
  51060. */
  51061. protected _albedoTexture: Nullable<BaseTexture>;
  51062. /**
  51063. * AKA Occlusion Texture in other nomenclature.
  51064. */
  51065. protected _ambientTexture: Nullable<BaseTexture>;
  51066. /**
  51067. * AKA Occlusion Texture Intensity in other nomenclature.
  51068. */
  51069. protected _ambientTextureStrength: number;
  51070. /**
  51071. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51072. * 1 means it completely occludes it
  51073. * 0 mean it has no impact
  51074. */
  51075. protected _ambientTextureImpactOnAnalyticalLights: number;
  51076. /**
  51077. * Stores the alpha values in a texture.
  51078. */
  51079. protected _opacityTexture: Nullable<BaseTexture>;
  51080. /**
  51081. * Stores the reflection values in a texture.
  51082. */
  51083. protected _reflectionTexture: Nullable<BaseTexture>;
  51084. /**
  51085. * Stores the emissive values in a texture.
  51086. */
  51087. protected _emissiveTexture: Nullable<BaseTexture>;
  51088. /**
  51089. * AKA Specular texture in other nomenclature.
  51090. */
  51091. protected _reflectivityTexture: Nullable<BaseTexture>;
  51092. /**
  51093. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51094. */
  51095. protected _metallicTexture: Nullable<BaseTexture>;
  51096. /**
  51097. * Specifies the metallic scalar of the metallic/roughness workflow.
  51098. * Can also be used to scale the metalness values of the metallic texture.
  51099. */
  51100. protected _metallic: Nullable<number>;
  51101. /**
  51102. * Specifies the roughness scalar of the metallic/roughness workflow.
  51103. * Can also be used to scale the roughness values of the metallic texture.
  51104. */
  51105. protected _roughness: Nullable<number>;
  51106. /**
  51107. * Specifies the an F0 factor to help configuring the material F0.
  51108. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51109. * to 0.5 the previously hard coded value stays the same.
  51110. * Can also be used to scale the F0 values of the metallic texture.
  51111. */
  51112. protected _metallicF0Factor: number;
  51113. /**
  51114. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51115. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51116. * your expectation as it multiplies with the texture data.
  51117. */
  51118. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51119. /**
  51120. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51121. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51122. */
  51123. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51124. /**
  51125. * Stores surface normal data used to displace a mesh in a texture.
  51126. */
  51127. protected _bumpTexture: Nullable<BaseTexture>;
  51128. /**
  51129. * Stores the pre-calculated light information of a mesh in a texture.
  51130. */
  51131. protected _lightmapTexture: Nullable<BaseTexture>;
  51132. /**
  51133. * The color of a material in ambient lighting.
  51134. */
  51135. protected _ambientColor: Color3;
  51136. /**
  51137. * AKA Diffuse Color in other nomenclature.
  51138. */
  51139. protected _albedoColor: Color3;
  51140. /**
  51141. * AKA Specular Color in other nomenclature.
  51142. */
  51143. protected _reflectivityColor: Color3;
  51144. /**
  51145. * The color applied when light is reflected from a material.
  51146. */
  51147. protected _reflectionColor: Color3;
  51148. /**
  51149. * The color applied when light is emitted from a material.
  51150. */
  51151. protected _emissiveColor: Color3;
  51152. /**
  51153. * AKA Glossiness in other nomenclature.
  51154. */
  51155. protected _microSurface: number;
  51156. /**
  51157. * Specifies that the material will use the light map as a show map.
  51158. */
  51159. protected _useLightmapAsShadowmap: boolean;
  51160. /**
  51161. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51162. * makes the reflect vector face the model (under horizon).
  51163. */
  51164. protected _useHorizonOcclusion: boolean;
  51165. /**
  51166. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51167. * too much the area relying on ambient texture to define their ambient occlusion.
  51168. */
  51169. protected _useRadianceOcclusion: boolean;
  51170. /**
  51171. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51172. */
  51173. protected _useAlphaFromAlbedoTexture: boolean;
  51174. /**
  51175. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51176. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51177. */
  51178. protected _useSpecularOverAlpha: boolean;
  51179. /**
  51180. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51181. */
  51182. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51183. /**
  51184. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51185. */
  51186. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51187. /**
  51188. * Specifies if the metallic texture contains the roughness information in its green channel.
  51189. */
  51190. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51191. /**
  51192. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51193. */
  51194. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51195. /**
  51196. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51197. */
  51198. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51199. /**
  51200. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51201. */
  51202. protected _useAmbientInGrayScale: boolean;
  51203. /**
  51204. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51205. * The material will try to infer what glossiness each pixel should be.
  51206. */
  51207. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51208. /**
  51209. * Defines the falloff type used in this material.
  51210. * It by default is Physical.
  51211. */
  51212. protected _lightFalloff: number;
  51213. /**
  51214. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51215. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51216. */
  51217. protected _useRadianceOverAlpha: boolean;
  51218. /**
  51219. * Allows using an object space normal map (instead of tangent space).
  51220. */
  51221. protected _useObjectSpaceNormalMap: boolean;
  51222. /**
  51223. * Allows using the bump map in parallax mode.
  51224. */
  51225. protected _useParallax: boolean;
  51226. /**
  51227. * Allows using the bump map in parallax occlusion mode.
  51228. */
  51229. protected _useParallaxOcclusion: boolean;
  51230. /**
  51231. * Controls the scale bias of the parallax mode.
  51232. */
  51233. protected _parallaxScaleBias: number;
  51234. /**
  51235. * If sets to true, disables all the lights affecting the material.
  51236. */
  51237. protected _disableLighting: boolean;
  51238. /**
  51239. * Number of Simultaneous lights allowed on the material.
  51240. */
  51241. protected _maxSimultaneousLights: number;
  51242. /**
  51243. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51244. */
  51245. protected _invertNormalMapX: boolean;
  51246. /**
  51247. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51248. */
  51249. protected _invertNormalMapY: boolean;
  51250. /**
  51251. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51252. */
  51253. protected _twoSidedLighting: boolean;
  51254. /**
  51255. * Defines the alpha limits in alpha test mode.
  51256. */
  51257. protected _alphaCutOff: number;
  51258. /**
  51259. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51260. */
  51261. protected _forceAlphaTest: boolean;
  51262. /**
  51263. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51264. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51265. */
  51266. protected _useAlphaFresnel: boolean;
  51267. /**
  51268. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51269. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51270. */
  51271. protected _useLinearAlphaFresnel: boolean;
  51272. /**
  51273. * The transparency mode of the material.
  51274. */
  51275. protected _transparencyMode: Nullable<number>;
  51276. /**
  51277. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51278. * from cos thetav and roughness:
  51279. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51280. */
  51281. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51282. /**
  51283. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51284. */
  51285. protected _forceIrradianceInFragment: boolean;
  51286. /**
  51287. * Force normal to face away from face.
  51288. */
  51289. protected _forceNormalForward: boolean;
  51290. /**
  51291. * Enables specular anti aliasing in the PBR shader.
  51292. * It will both interacts on the Geometry for analytical and IBL lighting.
  51293. * It also prefilter the roughness map based on the bump values.
  51294. */
  51295. protected _enableSpecularAntiAliasing: boolean;
  51296. /**
  51297. * Default configuration related to image processing available in the PBR Material.
  51298. */
  51299. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51300. /**
  51301. * Keep track of the image processing observer to allow dispose and replace.
  51302. */
  51303. private _imageProcessingObserver;
  51304. /**
  51305. * Attaches a new image processing configuration to the PBR Material.
  51306. * @param configuration
  51307. */
  51308. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51309. /**
  51310. * Stores the available render targets.
  51311. */
  51312. private _renderTargets;
  51313. /**
  51314. * Sets the global ambient color for the material used in lighting calculations.
  51315. */
  51316. private _globalAmbientColor;
  51317. /**
  51318. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51319. */
  51320. private _useLogarithmicDepth;
  51321. /**
  51322. * If set to true, no lighting calculations will be applied.
  51323. */
  51324. private _unlit;
  51325. private _debugMode;
  51326. /**
  51327. * @hidden
  51328. * This is reserved for the inspector.
  51329. * Defines the material debug mode.
  51330. * It helps seeing only some components of the material while troubleshooting.
  51331. */
  51332. debugMode: number;
  51333. /**
  51334. * @hidden
  51335. * This is reserved for the inspector.
  51336. * Specify from where on screen the debug mode should start.
  51337. * The value goes from -1 (full screen) to 1 (not visible)
  51338. * It helps with side by side comparison against the final render
  51339. * This defaults to -1
  51340. */
  51341. private debugLimit;
  51342. /**
  51343. * @hidden
  51344. * This is reserved for the inspector.
  51345. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51346. * You can use the factor to better multiply the final value.
  51347. */
  51348. private debugFactor;
  51349. /**
  51350. * Defines the clear coat layer parameters for the material.
  51351. */
  51352. readonly clearCoat: PBRClearCoatConfiguration;
  51353. /**
  51354. * Defines the anisotropic parameters for the material.
  51355. */
  51356. readonly anisotropy: PBRAnisotropicConfiguration;
  51357. /**
  51358. * Defines the BRDF parameters for the material.
  51359. */
  51360. readonly brdf: PBRBRDFConfiguration;
  51361. /**
  51362. * Defines the Sheen parameters for the material.
  51363. */
  51364. readonly sheen: PBRSheenConfiguration;
  51365. /**
  51366. * Defines the SubSurface parameters for the material.
  51367. */
  51368. readonly subSurface: PBRSubSurfaceConfiguration;
  51369. /**
  51370. * Custom callback helping to override the default shader used in the material.
  51371. */
  51372. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51373. protected _rebuildInParallel: boolean;
  51374. /**
  51375. * Instantiates a new PBRMaterial instance.
  51376. *
  51377. * @param name The material name
  51378. * @param scene The scene the material will be use in.
  51379. */
  51380. constructor(name: string, scene: Scene);
  51381. /**
  51382. * Gets a boolean indicating that current material needs to register RTT
  51383. */
  51384. get hasRenderTargetTextures(): boolean;
  51385. /**
  51386. * Gets the name of the material class.
  51387. */
  51388. getClassName(): string;
  51389. /**
  51390. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51391. */
  51392. get useLogarithmicDepth(): boolean;
  51393. /**
  51394. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51395. */
  51396. set useLogarithmicDepth(value: boolean);
  51397. /**
  51398. * Gets the current transparency mode.
  51399. */
  51400. get transparencyMode(): Nullable<number>;
  51401. /**
  51402. * Sets the transparency mode of the material.
  51403. *
  51404. * | Value | Type | Description |
  51405. * | ----- | ----------------------------------- | ----------- |
  51406. * | 0 | OPAQUE | |
  51407. * | 1 | ALPHATEST | |
  51408. * | 2 | ALPHABLEND | |
  51409. * | 3 | ALPHATESTANDBLEND | |
  51410. *
  51411. */
  51412. set transparencyMode(value: Nullable<number>);
  51413. /**
  51414. * Returns true if alpha blending should be disabled.
  51415. */
  51416. private get _disableAlphaBlending();
  51417. /**
  51418. * Specifies whether or not this material should be rendered in alpha blend mode.
  51419. */
  51420. needAlphaBlending(): boolean;
  51421. /**
  51422. * Specifies if the mesh will require alpha blending.
  51423. * @param mesh - BJS mesh.
  51424. */
  51425. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51426. /**
  51427. * Specifies whether or not this material should be rendered in alpha test mode.
  51428. */
  51429. needAlphaTesting(): boolean;
  51430. /**
  51431. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51432. */
  51433. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51434. /**
  51435. * Gets the texture used for the alpha test.
  51436. */
  51437. getAlphaTestTexture(): Nullable<BaseTexture>;
  51438. /**
  51439. * Specifies that the submesh is ready to be used.
  51440. * @param mesh - BJS mesh.
  51441. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51442. * @param useInstances - Specifies that instances should be used.
  51443. * @returns - boolean indicating that the submesh is ready or not.
  51444. */
  51445. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51446. /**
  51447. * Specifies if the material uses metallic roughness workflow.
  51448. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51449. */
  51450. isMetallicWorkflow(): boolean;
  51451. private _prepareEffect;
  51452. private _prepareDefines;
  51453. /**
  51454. * Force shader compilation
  51455. */
  51456. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51457. /**
  51458. * Initializes the uniform buffer layout for the shader.
  51459. */
  51460. buildUniformLayout(): void;
  51461. /**
  51462. * Unbinds the material from the mesh
  51463. */
  51464. unbind(): void;
  51465. /**
  51466. * Binds the submesh data.
  51467. * @param world - The world matrix.
  51468. * @param mesh - The BJS mesh.
  51469. * @param subMesh - A submesh of the BJS mesh.
  51470. */
  51471. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51472. /**
  51473. * Returns the animatable textures.
  51474. * @returns - Array of animatable textures.
  51475. */
  51476. getAnimatables(): IAnimatable[];
  51477. /**
  51478. * Returns the texture used for reflections.
  51479. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51480. */
  51481. private _getReflectionTexture;
  51482. /**
  51483. * Returns an array of the actively used textures.
  51484. * @returns - Array of BaseTextures
  51485. */
  51486. getActiveTextures(): BaseTexture[];
  51487. /**
  51488. * Checks to see if a texture is used in the material.
  51489. * @param texture - Base texture to use.
  51490. * @returns - Boolean specifying if a texture is used in the material.
  51491. */
  51492. hasTexture(texture: BaseTexture): boolean;
  51493. /**
  51494. * Disposes the resources of the material.
  51495. * @param forceDisposeEffect - Forces the disposal of effects.
  51496. * @param forceDisposeTextures - Forces the disposal of all textures.
  51497. */
  51498. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51499. }
  51500. }
  51501. declare module BABYLON {
  51502. /**
  51503. * The Physically based material of BJS.
  51504. *
  51505. * This offers the main features of a standard PBR material.
  51506. * For more information, please refer to the documentation :
  51507. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51508. */
  51509. export class PBRMaterial extends PBRBaseMaterial {
  51510. /**
  51511. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51512. */
  51513. static readonly PBRMATERIAL_OPAQUE: number;
  51514. /**
  51515. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51516. */
  51517. static readonly PBRMATERIAL_ALPHATEST: number;
  51518. /**
  51519. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51520. */
  51521. static readonly PBRMATERIAL_ALPHABLEND: number;
  51522. /**
  51523. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51524. * They are also discarded below the alpha cutoff threshold to improve performances.
  51525. */
  51526. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51527. /**
  51528. * Defines the default value of how much AO map is occluding the analytical lights
  51529. * (point spot...).
  51530. */
  51531. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51532. /**
  51533. * Intensity of the direct lights e.g. the four lights available in your scene.
  51534. * This impacts both the direct diffuse and specular highlights.
  51535. */
  51536. directIntensity: number;
  51537. /**
  51538. * Intensity of the emissive part of the material.
  51539. * This helps controlling the emissive effect without modifying the emissive color.
  51540. */
  51541. emissiveIntensity: number;
  51542. /**
  51543. * Intensity of the environment e.g. how much the environment will light the object
  51544. * either through harmonics for rough material or through the refelction for shiny ones.
  51545. */
  51546. environmentIntensity: number;
  51547. /**
  51548. * This is a special control allowing the reduction of the specular highlights coming from the
  51549. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51550. */
  51551. specularIntensity: number;
  51552. /**
  51553. * Debug Control allowing disabling the bump map on this material.
  51554. */
  51555. disableBumpMap: boolean;
  51556. /**
  51557. * AKA Diffuse Texture in standard nomenclature.
  51558. */
  51559. albedoTexture: BaseTexture;
  51560. /**
  51561. * AKA Occlusion Texture in other nomenclature.
  51562. */
  51563. ambientTexture: BaseTexture;
  51564. /**
  51565. * AKA Occlusion Texture Intensity in other nomenclature.
  51566. */
  51567. ambientTextureStrength: number;
  51568. /**
  51569. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51570. * 1 means it completely occludes it
  51571. * 0 mean it has no impact
  51572. */
  51573. ambientTextureImpactOnAnalyticalLights: number;
  51574. /**
  51575. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51576. */
  51577. opacityTexture: BaseTexture;
  51578. /**
  51579. * Stores the reflection values in a texture.
  51580. */
  51581. reflectionTexture: Nullable<BaseTexture>;
  51582. /**
  51583. * Stores the emissive values in a texture.
  51584. */
  51585. emissiveTexture: BaseTexture;
  51586. /**
  51587. * AKA Specular texture in other nomenclature.
  51588. */
  51589. reflectivityTexture: BaseTexture;
  51590. /**
  51591. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51592. */
  51593. metallicTexture: BaseTexture;
  51594. /**
  51595. * Specifies the metallic scalar of the metallic/roughness workflow.
  51596. * Can also be used to scale the metalness values of the metallic texture.
  51597. */
  51598. metallic: Nullable<number>;
  51599. /**
  51600. * Specifies the roughness scalar of the metallic/roughness workflow.
  51601. * Can also be used to scale the roughness values of the metallic texture.
  51602. */
  51603. roughness: Nullable<number>;
  51604. /**
  51605. * Specifies the an F0 factor to help configuring the material F0.
  51606. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51607. * to 0.5 the previously hard coded value stays the same.
  51608. * Can also be used to scale the F0 values of the metallic texture.
  51609. */
  51610. metallicF0Factor: number;
  51611. /**
  51612. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51613. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51614. * your expectation as it multiplies with the texture data.
  51615. */
  51616. useMetallicF0FactorFromMetallicTexture: boolean;
  51617. /**
  51618. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51619. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51620. */
  51621. microSurfaceTexture: BaseTexture;
  51622. /**
  51623. * Stores surface normal data used to displace a mesh in a texture.
  51624. */
  51625. bumpTexture: BaseTexture;
  51626. /**
  51627. * Stores the pre-calculated light information of a mesh in a texture.
  51628. */
  51629. lightmapTexture: BaseTexture;
  51630. /**
  51631. * Stores the refracted light information in a texture.
  51632. */
  51633. get refractionTexture(): Nullable<BaseTexture>;
  51634. set refractionTexture(value: Nullable<BaseTexture>);
  51635. /**
  51636. * The color of a material in ambient lighting.
  51637. */
  51638. ambientColor: Color3;
  51639. /**
  51640. * AKA Diffuse Color in other nomenclature.
  51641. */
  51642. albedoColor: Color3;
  51643. /**
  51644. * AKA Specular Color in other nomenclature.
  51645. */
  51646. reflectivityColor: Color3;
  51647. /**
  51648. * The color reflected from the material.
  51649. */
  51650. reflectionColor: Color3;
  51651. /**
  51652. * The color emitted from the material.
  51653. */
  51654. emissiveColor: Color3;
  51655. /**
  51656. * AKA Glossiness in other nomenclature.
  51657. */
  51658. microSurface: number;
  51659. /**
  51660. * source material index of refraction (IOR)' / 'destination material IOR.
  51661. */
  51662. get indexOfRefraction(): number;
  51663. set indexOfRefraction(value: number);
  51664. /**
  51665. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51666. */
  51667. get invertRefractionY(): boolean;
  51668. set invertRefractionY(value: boolean);
  51669. /**
  51670. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51671. * Materials half opaque for instance using refraction could benefit from this control.
  51672. */
  51673. get linkRefractionWithTransparency(): boolean;
  51674. set linkRefractionWithTransparency(value: boolean);
  51675. /**
  51676. * If true, the light map contains occlusion information instead of lighting info.
  51677. */
  51678. useLightmapAsShadowmap: boolean;
  51679. /**
  51680. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51681. */
  51682. useAlphaFromAlbedoTexture: boolean;
  51683. /**
  51684. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51685. */
  51686. forceAlphaTest: boolean;
  51687. /**
  51688. * Defines the alpha limits in alpha test mode.
  51689. */
  51690. alphaCutOff: number;
  51691. /**
  51692. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51693. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51694. */
  51695. useSpecularOverAlpha: boolean;
  51696. /**
  51697. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51698. */
  51699. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51700. /**
  51701. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51702. */
  51703. useRoughnessFromMetallicTextureAlpha: boolean;
  51704. /**
  51705. * Specifies if the metallic texture contains the roughness information in its green channel.
  51706. */
  51707. useRoughnessFromMetallicTextureGreen: boolean;
  51708. /**
  51709. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51710. */
  51711. useMetallnessFromMetallicTextureBlue: boolean;
  51712. /**
  51713. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51714. */
  51715. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51716. /**
  51717. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51718. */
  51719. useAmbientInGrayScale: boolean;
  51720. /**
  51721. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51722. * The material will try to infer what glossiness each pixel should be.
  51723. */
  51724. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51725. /**
  51726. * BJS is using an harcoded light falloff based on a manually sets up range.
  51727. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51728. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51729. */
  51730. get usePhysicalLightFalloff(): boolean;
  51731. /**
  51732. * BJS is using an harcoded light falloff based on a manually sets up range.
  51733. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51734. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51735. */
  51736. set usePhysicalLightFalloff(value: boolean);
  51737. /**
  51738. * In order to support the falloff compatibility with gltf, a special mode has been added
  51739. * to reproduce the gltf light falloff.
  51740. */
  51741. get useGLTFLightFalloff(): boolean;
  51742. /**
  51743. * In order to support the falloff compatibility with gltf, a special mode has been added
  51744. * to reproduce the gltf light falloff.
  51745. */
  51746. set useGLTFLightFalloff(value: boolean);
  51747. /**
  51748. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51749. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51750. */
  51751. useRadianceOverAlpha: boolean;
  51752. /**
  51753. * Allows using an object space normal map (instead of tangent space).
  51754. */
  51755. useObjectSpaceNormalMap: boolean;
  51756. /**
  51757. * Allows using the bump map in parallax mode.
  51758. */
  51759. useParallax: boolean;
  51760. /**
  51761. * Allows using the bump map in parallax occlusion mode.
  51762. */
  51763. useParallaxOcclusion: boolean;
  51764. /**
  51765. * Controls the scale bias of the parallax mode.
  51766. */
  51767. parallaxScaleBias: number;
  51768. /**
  51769. * If sets to true, disables all the lights affecting the material.
  51770. */
  51771. disableLighting: boolean;
  51772. /**
  51773. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51774. */
  51775. forceIrradianceInFragment: boolean;
  51776. /**
  51777. * Number of Simultaneous lights allowed on the material.
  51778. */
  51779. maxSimultaneousLights: number;
  51780. /**
  51781. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51782. */
  51783. invertNormalMapX: boolean;
  51784. /**
  51785. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51786. */
  51787. invertNormalMapY: boolean;
  51788. /**
  51789. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51790. */
  51791. twoSidedLighting: boolean;
  51792. /**
  51793. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51794. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51795. */
  51796. useAlphaFresnel: boolean;
  51797. /**
  51798. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51799. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51800. */
  51801. useLinearAlphaFresnel: boolean;
  51802. /**
  51803. * Let user defines the brdf lookup texture used for IBL.
  51804. * A default 8bit version is embedded but you could point at :
  51805. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51806. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51807. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51808. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51809. */
  51810. environmentBRDFTexture: Nullable<BaseTexture>;
  51811. /**
  51812. * Force normal to face away from face.
  51813. */
  51814. forceNormalForward: boolean;
  51815. /**
  51816. * Enables specular anti aliasing in the PBR shader.
  51817. * It will both interacts on the Geometry for analytical and IBL lighting.
  51818. * It also prefilter the roughness map based on the bump values.
  51819. */
  51820. enableSpecularAntiAliasing: boolean;
  51821. /**
  51822. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51823. * makes the reflect vector face the model (under horizon).
  51824. */
  51825. useHorizonOcclusion: boolean;
  51826. /**
  51827. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51828. * too much the area relying on ambient texture to define their ambient occlusion.
  51829. */
  51830. useRadianceOcclusion: boolean;
  51831. /**
  51832. * If set to true, no lighting calculations will be applied.
  51833. */
  51834. unlit: boolean;
  51835. /**
  51836. * Gets the image processing configuration used either in this material.
  51837. */
  51838. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51839. /**
  51840. * Sets the Default image processing configuration used either in the this material.
  51841. *
  51842. * If sets to null, the scene one is in use.
  51843. */
  51844. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51845. /**
  51846. * Gets wether the color curves effect is enabled.
  51847. */
  51848. get cameraColorCurvesEnabled(): boolean;
  51849. /**
  51850. * Sets wether the color curves effect is enabled.
  51851. */
  51852. set cameraColorCurvesEnabled(value: boolean);
  51853. /**
  51854. * Gets wether the color grading effect is enabled.
  51855. */
  51856. get cameraColorGradingEnabled(): boolean;
  51857. /**
  51858. * Gets wether the color grading effect is enabled.
  51859. */
  51860. set cameraColorGradingEnabled(value: boolean);
  51861. /**
  51862. * Gets wether tonemapping is enabled or not.
  51863. */
  51864. get cameraToneMappingEnabled(): boolean;
  51865. /**
  51866. * Sets wether tonemapping is enabled or not
  51867. */
  51868. set cameraToneMappingEnabled(value: boolean);
  51869. /**
  51870. * The camera exposure used on this material.
  51871. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51872. * This corresponds to a photographic exposure.
  51873. */
  51874. get cameraExposure(): number;
  51875. /**
  51876. * The camera exposure used on this material.
  51877. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51878. * This corresponds to a photographic exposure.
  51879. */
  51880. set cameraExposure(value: number);
  51881. /**
  51882. * Gets The camera contrast used on this material.
  51883. */
  51884. get cameraContrast(): number;
  51885. /**
  51886. * Sets The camera contrast used on this material.
  51887. */
  51888. set cameraContrast(value: number);
  51889. /**
  51890. * Gets the Color Grading 2D Lookup Texture.
  51891. */
  51892. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51893. /**
  51894. * Sets the Color Grading 2D Lookup Texture.
  51895. */
  51896. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51897. /**
  51898. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51899. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51900. * 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;
  51901. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51902. */
  51903. get cameraColorCurves(): Nullable<ColorCurves>;
  51904. /**
  51905. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51906. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51907. * 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;
  51908. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51909. */
  51910. set cameraColorCurves(value: Nullable<ColorCurves>);
  51911. /**
  51912. * Instantiates a new PBRMaterial instance.
  51913. *
  51914. * @param name The material name
  51915. * @param scene The scene the material will be use in.
  51916. */
  51917. constructor(name: string, scene: Scene);
  51918. /**
  51919. * Returns the name of this material class.
  51920. */
  51921. getClassName(): string;
  51922. /**
  51923. * Makes a duplicate of the current material.
  51924. * @param name - name to use for the new material.
  51925. */
  51926. clone(name: string): PBRMaterial;
  51927. /**
  51928. * Serializes this PBR Material.
  51929. * @returns - An object with the serialized material.
  51930. */
  51931. serialize(): any;
  51932. /**
  51933. * Parses a PBR Material from a serialized object.
  51934. * @param source - Serialized object.
  51935. * @param scene - BJS scene instance.
  51936. * @param rootUrl - url for the scene object
  51937. * @returns - PBRMaterial
  51938. */
  51939. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51940. }
  51941. }
  51942. declare module BABYLON {
  51943. /**
  51944. * Direct draw surface info
  51945. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51946. */
  51947. export interface DDSInfo {
  51948. /**
  51949. * Width of the texture
  51950. */
  51951. width: number;
  51952. /**
  51953. * Width of the texture
  51954. */
  51955. height: number;
  51956. /**
  51957. * Number of Mipmaps for the texture
  51958. * @see https://en.wikipedia.org/wiki/Mipmap
  51959. */
  51960. mipmapCount: number;
  51961. /**
  51962. * If the textures format is a known fourCC format
  51963. * @see https://www.fourcc.org/
  51964. */
  51965. isFourCC: boolean;
  51966. /**
  51967. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51968. */
  51969. isRGB: boolean;
  51970. /**
  51971. * If the texture is a lumincance format
  51972. */
  51973. isLuminance: boolean;
  51974. /**
  51975. * If this is a cube texture
  51976. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51977. */
  51978. isCube: boolean;
  51979. /**
  51980. * If the texture is a compressed format eg. FOURCC_DXT1
  51981. */
  51982. isCompressed: boolean;
  51983. /**
  51984. * The dxgiFormat of the texture
  51985. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51986. */
  51987. dxgiFormat: number;
  51988. /**
  51989. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51990. */
  51991. textureType: number;
  51992. /**
  51993. * Sphericle polynomial created for the dds texture
  51994. */
  51995. sphericalPolynomial?: SphericalPolynomial;
  51996. }
  51997. /**
  51998. * Class used to provide DDS decompression tools
  51999. */
  52000. export class DDSTools {
  52001. /**
  52002. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52003. */
  52004. static StoreLODInAlphaChannel: boolean;
  52005. /**
  52006. * Gets DDS information from an array buffer
  52007. * @param data defines the array buffer view to read data from
  52008. * @returns the DDS information
  52009. */
  52010. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52011. private static _FloatView;
  52012. private static _Int32View;
  52013. private static _ToHalfFloat;
  52014. private static _FromHalfFloat;
  52015. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52016. private static _GetHalfFloatRGBAArrayBuffer;
  52017. private static _GetFloatRGBAArrayBuffer;
  52018. private static _GetFloatAsUIntRGBAArrayBuffer;
  52019. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52020. private static _GetRGBAArrayBuffer;
  52021. private static _ExtractLongWordOrder;
  52022. private static _GetRGBArrayBuffer;
  52023. private static _GetLuminanceArrayBuffer;
  52024. /**
  52025. * Uploads DDS Levels to a Babylon Texture
  52026. * @hidden
  52027. */
  52028. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52029. }
  52030. interface ThinEngine {
  52031. /**
  52032. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52033. * @param rootUrl defines the url where the file to load is located
  52034. * @param scene defines the current scene
  52035. * @param lodScale defines scale to apply to the mip map selection
  52036. * @param lodOffset defines offset to apply to the mip map selection
  52037. * @param onLoad defines an optional callback raised when the texture is loaded
  52038. * @param onError defines an optional callback raised if there is an issue to load the texture
  52039. * @param format defines the format of the data
  52040. * @param forcedExtension defines the extension to use to pick the right loader
  52041. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52042. * @returns the cube texture as an InternalTexture
  52043. */
  52044. 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;
  52045. }
  52046. }
  52047. declare module BABYLON {
  52048. /**
  52049. * Implementation of the DDS Texture Loader.
  52050. * @hidden
  52051. */
  52052. export class _DDSTextureLoader implements IInternalTextureLoader {
  52053. /**
  52054. * Defines wether the loader supports cascade loading the different faces.
  52055. */
  52056. readonly supportCascades: boolean;
  52057. /**
  52058. * This returns if the loader support the current file information.
  52059. * @param extension defines the file extension of the file being loaded
  52060. * @returns true if the loader can load the specified file
  52061. */
  52062. canLoad(extension: string): boolean;
  52063. /**
  52064. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52065. * @param data contains the texture data
  52066. * @param texture defines the BabylonJS internal texture
  52067. * @param createPolynomials will be true if polynomials have been requested
  52068. * @param onLoad defines the callback to trigger once the texture is ready
  52069. * @param onError defines the callback to trigger in case of error
  52070. */
  52071. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52072. /**
  52073. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52074. * @param data contains the texture data
  52075. * @param texture defines the BabylonJS internal texture
  52076. * @param callback defines the method to call once ready to upload
  52077. */
  52078. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52079. }
  52080. }
  52081. declare module BABYLON {
  52082. /**
  52083. * Implementation of the ENV Texture Loader.
  52084. * @hidden
  52085. */
  52086. export class _ENVTextureLoader implements IInternalTextureLoader {
  52087. /**
  52088. * Defines wether the loader supports cascade loading the different faces.
  52089. */
  52090. readonly supportCascades: boolean;
  52091. /**
  52092. * This returns if the loader support the current file information.
  52093. * @param extension defines the file extension of the file being loaded
  52094. * @returns true if the loader can load the specified file
  52095. */
  52096. canLoad(extension: string): boolean;
  52097. /**
  52098. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52099. * @param data contains the texture data
  52100. * @param texture defines the BabylonJS internal texture
  52101. * @param createPolynomials will be true if polynomials have been requested
  52102. * @param onLoad defines the callback to trigger once the texture is ready
  52103. * @param onError defines the callback to trigger in case of error
  52104. */
  52105. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52106. /**
  52107. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52108. * @param data contains the texture data
  52109. * @param texture defines the BabylonJS internal texture
  52110. * @param callback defines the method to call once ready to upload
  52111. */
  52112. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52113. }
  52114. }
  52115. declare module BABYLON {
  52116. /**
  52117. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52118. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52119. */
  52120. export class KhronosTextureContainer {
  52121. /** contents of the KTX container file */
  52122. data: ArrayBufferView;
  52123. private static HEADER_LEN;
  52124. private static COMPRESSED_2D;
  52125. private static COMPRESSED_3D;
  52126. private static TEX_2D;
  52127. private static TEX_3D;
  52128. /**
  52129. * Gets the openGL type
  52130. */
  52131. glType: number;
  52132. /**
  52133. * Gets the openGL type size
  52134. */
  52135. glTypeSize: number;
  52136. /**
  52137. * Gets the openGL format
  52138. */
  52139. glFormat: number;
  52140. /**
  52141. * Gets the openGL internal format
  52142. */
  52143. glInternalFormat: number;
  52144. /**
  52145. * Gets the base internal format
  52146. */
  52147. glBaseInternalFormat: number;
  52148. /**
  52149. * Gets image width in pixel
  52150. */
  52151. pixelWidth: number;
  52152. /**
  52153. * Gets image height in pixel
  52154. */
  52155. pixelHeight: number;
  52156. /**
  52157. * Gets image depth in pixels
  52158. */
  52159. pixelDepth: number;
  52160. /**
  52161. * Gets the number of array elements
  52162. */
  52163. numberOfArrayElements: number;
  52164. /**
  52165. * Gets the number of faces
  52166. */
  52167. numberOfFaces: number;
  52168. /**
  52169. * Gets the number of mipmap levels
  52170. */
  52171. numberOfMipmapLevels: number;
  52172. /**
  52173. * Gets the bytes of key value data
  52174. */
  52175. bytesOfKeyValueData: number;
  52176. /**
  52177. * Gets the load type
  52178. */
  52179. loadType: number;
  52180. /**
  52181. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52182. */
  52183. isInvalid: boolean;
  52184. /**
  52185. * Creates a new KhronosTextureContainer
  52186. * @param data contents of the KTX container file
  52187. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52188. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52189. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52190. */
  52191. constructor(
  52192. /** contents of the KTX container file */
  52193. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52194. /**
  52195. * Uploads KTX content to a Babylon Texture.
  52196. * It is assumed that the texture has already been created & is currently bound
  52197. * @hidden
  52198. */
  52199. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52200. private _upload2DCompressedLevels;
  52201. /**
  52202. * Checks if the given data starts with a KTX file identifier.
  52203. * @param data the data to check
  52204. * @returns true if the data is a KTX file or false otherwise
  52205. */
  52206. static IsValid(data: ArrayBufferView): boolean;
  52207. }
  52208. }
  52209. declare module BABYLON {
  52210. /**
  52211. * Class for loading KTX2 files
  52212. * !!! Experimental Extension Subject to Changes !!!
  52213. * @hidden
  52214. */
  52215. export class KhronosTextureContainer2 {
  52216. private static _ModulePromise;
  52217. private static _TranscodeFormat;
  52218. constructor(engine: ThinEngine);
  52219. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52220. private _determineTranscodeFormat;
  52221. /**
  52222. * Checks if the given data starts with a KTX2 file identifier.
  52223. * @param data the data to check
  52224. * @returns true if the data is a KTX2 file or false otherwise
  52225. */
  52226. static IsValid(data: ArrayBufferView): boolean;
  52227. }
  52228. }
  52229. declare module BABYLON {
  52230. /**
  52231. * Implementation of the KTX Texture Loader.
  52232. * @hidden
  52233. */
  52234. export class _KTXTextureLoader implements IInternalTextureLoader {
  52235. /**
  52236. * Defines wether the loader supports cascade loading the different faces.
  52237. */
  52238. readonly supportCascades: boolean;
  52239. /**
  52240. * This returns if the loader support the current file information.
  52241. * @param extension defines the file extension of the file being loaded
  52242. * @returns true if the loader can load the specified file
  52243. */
  52244. canLoad(extension: string): boolean;
  52245. /**
  52246. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52247. * @param data contains the texture data
  52248. * @param texture defines the BabylonJS internal texture
  52249. * @param createPolynomials will be true if polynomials have been requested
  52250. * @param onLoad defines the callback to trigger once the texture is ready
  52251. * @param onError defines the callback to trigger in case of error
  52252. */
  52253. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52254. /**
  52255. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52256. * @param data contains the texture data
  52257. * @param texture defines the BabylonJS internal texture
  52258. * @param callback defines the method to call once ready to upload
  52259. */
  52260. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52261. }
  52262. }
  52263. declare module BABYLON {
  52264. /** @hidden */
  52265. export var _forceSceneHelpersToBundle: boolean;
  52266. interface Scene {
  52267. /**
  52268. * Creates a default light for the scene.
  52269. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52270. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52271. */
  52272. createDefaultLight(replace?: boolean): void;
  52273. /**
  52274. * Creates a default camera for the scene.
  52275. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52276. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52277. * @param replace has default false, when true replaces the active camera in the scene
  52278. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52279. */
  52280. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52281. /**
  52282. * Creates a default camera and a default light.
  52283. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52284. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52285. * @param replace has the default false, when true replaces the active camera/light in the scene
  52286. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52287. */
  52288. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52289. /**
  52290. * Creates a new sky box
  52291. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52292. * @param environmentTexture defines the texture to use as environment texture
  52293. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52294. * @param scale defines the overall scale of the skybox
  52295. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52296. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52297. * @returns a new mesh holding the sky box
  52298. */
  52299. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52300. /**
  52301. * Creates a new environment
  52302. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52303. * @param options defines the options you can use to configure the environment
  52304. * @returns the new EnvironmentHelper
  52305. */
  52306. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52307. /**
  52308. * Creates a new VREXperienceHelper
  52309. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52310. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52311. * @returns a new VREXperienceHelper
  52312. */
  52313. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52314. /**
  52315. * Creates a new WebXRDefaultExperience
  52316. * @see http://doc.babylonjs.com/how_to/webxr
  52317. * @param options experience options
  52318. * @returns a promise for a new WebXRDefaultExperience
  52319. */
  52320. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52321. }
  52322. }
  52323. declare module BABYLON {
  52324. /**
  52325. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52326. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52327. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52328. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52329. */
  52330. export class VideoDome extends TransformNode {
  52331. /**
  52332. * Define the video source as a Monoscopic panoramic 360 video.
  52333. */
  52334. static readonly MODE_MONOSCOPIC: number;
  52335. /**
  52336. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52337. */
  52338. static readonly MODE_TOPBOTTOM: number;
  52339. /**
  52340. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52341. */
  52342. static readonly MODE_SIDEBYSIDE: number;
  52343. private _halfDome;
  52344. private _useDirectMapping;
  52345. /**
  52346. * The video texture being displayed on the sphere
  52347. */
  52348. protected _videoTexture: VideoTexture;
  52349. /**
  52350. * Gets the video texture being displayed on the sphere
  52351. */
  52352. get videoTexture(): VideoTexture;
  52353. /**
  52354. * The skybox material
  52355. */
  52356. protected _material: BackgroundMaterial;
  52357. /**
  52358. * The surface used for the skybox
  52359. */
  52360. protected _mesh: Mesh;
  52361. /**
  52362. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52363. */
  52364. private _halfDomeMask;
  52365. /**
  52366. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52367. * Also see the options.resolution property.
  52368. */
  52369. get fovMultiplier(): number;
  52370. set fovMultiplier(value: number);
  52371. private _videoMode;
  52372. /**
  52373. * Gets or set the current video mode for the video. It can be:
  52374. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52375. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52376. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52377. */
  52378. get videoMode(): number;
  52379. set videoMode(value: number);
  52380. /**
  52381. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52382. *
  52383. */
  52384. get halfDome(): boolean;
  52385. /**
  52386. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52387. */
  52388. set halfDome(enabled: boolean);
  52389. /**
  52390. * Oberserver used in Stereoscopic VR Mode.
  52391. */
  52392. private _onBeforeCameraRenderObserver;
  52393. /**
  52394. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52395. * @param name Element's name, child elements will append suffixes for their own names.
  52396. * @param urlsOrVideo defines the url(s) or the video element to use
  52397. * @param options An object containing optional or exposed sub element properties
  52398. */
  52399. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52400. resolution?: number;
  52401. clickToPlay?: boolean;
  52402. autoPlay?: boolean;
  52403. loop?: boolean;
  52404. size?: number;
  52405. poster?: string;
  52406. faceForward?: boolean;
  52407. useDirectMapping?: boolean;
  52408. halfDomeMode?: boolean;
  52409. }, scene: Scene);
  52410. private _changeVideoMode;
  52411. /**
  52412. * Releases resources associated with this node.
  52413. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52414. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52415. */
  52416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52417. }
  52418. }
  52419. declare module BABYLON {
  52420. /**
  52421. * This class can be used to get instrumentation data from a Babylon engine
  52422. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52423. */
  52424. export class EngineInstrumentation implements IDisposable {
  52425. /**
  52426. * Define the instrumented engine.
  52427. */
  52428. engine: Engine;
  52429. private _captureGPUFrameTime;
  52430. private _gpuFrameTimeToken;
  52431. private _gpuFrameTime;
  52432. private _captureShaderCompilationTime;
  52433. private _shaderCompilationTime;
  52434. private _onBeginFrameObserver;
  52435. private _onEndFrameObserver;
  52436. private _onBeforeShaderCompilationObserver;
  52437. private _onAfterShaderCompilationObserver;
  52438. /**
  52439. * Gets the perf counter used for GPU frame time
  52440. */
  52441. get gpuFrameTimeCounter(): PerfCounter;
  52442. /**
  52443. * Gets the GPU frame time capture status
  52444. */
  52445. get captureGPUFrameTime(): boolean;
  52446. /**
  52447. * Enable or disable the GPU frame time capture
  52448. */
  52449. set captureGPUFrameTime(value: boolean);
  52450. /**
  52451. * Gets the perf counter used for shader compilation time
  52452. */
  52453. get shaderCompilationTimeCounter(): PerfCounter;
  52454. /**
  52455. * Gets the shader compilation time capture status
  52456. */
  52457. get captureShaderCompilationTime(): boolean;
  52458. /**
  52459. * Enable or disable the shader compilation time capture
  52460. */
  52461. set captureShaderCompilationTime(value: boolean);
  52462. /**
  52463. * Instantiates a new engine instrumentation.
  52464. * This class can be used to get instrumentation data from a Babylon engine
  52465. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52466. * @param engine Defines the engine to instrument
  52467. */
  52468. constructor(
  52469. /**
  52470. * Define the instrumented engine.
  52471. */
  52472. engine: Engine);
  52473. /**
  52474. * Dispose and release associated resources.
  52475. */
  52476. dispose(): void;
  52477. }
  52478. }
  52479. declare module BABYLON {
  52480. /**
  52481. * This class can be used to get instrumentation data from a Babylon engine
  52482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52483. */
  52484. export class SceneInstrumentation implements IDisposable {
  52485. /**
  52486. * Defines the scene to instrument
  52487. */
  52488. scene: Scene;
  52489. private _captureActiveMeshesEvaluationTime;
  52490. private _activeMeshesEvaluationTime;
  52491. private _captureRenderTargetsRenderTime;
  52492. private _renderTargetsRenderTime;
  52493. private _captureFrameTime;
  52494. private _frameTime;
  52495. private _captureRenderTime;
  52496. private _renderTime;
  52497. private _captureInterFrameTime;
  52498. private _interFrameTime;
  52499. private _captureParticlesRenderTime;
  52500. private _particlesRenderTime;
  52501. private _captureSpritesRenderTime;
  52502. private _spritesRenderTime;
  52503. private _capturePhysicsTime;
  52504. private _physicsTime;
  52505. private _captureAnimationsTime;
  52506. private _animationsTime;
  52507. private _captureCameraRenderTime;
  52508. private _cameraRenderTime;
  52509. private _onBeforeActiveMeshesEvaluationObserver;
  52510. private _onAfterActiveMeshesEvaluationObserver;
  52511. private _onBeforeRenderTargetsRenderObserver;
  52512. private _onAfterRenderTargetsRenderObserver;
  52513. private _onAfterRenderObserver;
  52514. private _onBeforeDrawPhaseObserver;
  52515. private _onAfterDrawPhaseObserver;
  52516. private _onBeforeAnimationsObserver;
  52517. private _onBeforeParticlesRenderingObserver;
  52518. private _onAfterParticlesRenderingObserver;
  52519. private _onBeforeSpritesRenderingObserver;
  52520. private _onAfterSpritesRenderingObserver;
  52521. private _onBeforePhysicsObserver;
  52522. private _onAfterPhysicsObserver;
  52523. private _onAfterAnimationsObserver;
  52524. private _onBeforeCameraRenderObserver;
  52525. private _onAfterCameraRenderObserver;
  52526. /**
  52527. * Gets the perf counter used for active meshes evaluation time
  52528. */
  52529. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52530. /**
  52531. * Gets the active meshes evaluation time capture status
  52532. */
  52533. get captureActiveMeshesEvaluationTime(): boolean;
  52534. /**
  52535. * Enable or disable the active meshes evaluation time capture
  52536. */
  52537. set captureActiveMeshesEvaluationTime(value: boolean);
  52538. /**
  52539. * Gets the perf counter used for render targets render time
  52540. */
  52541. get renderTargetsRenderTimeCounter(): PerfCounter;
  52542. /**
  52543. * Gets the render targets render time capture status
  52544. */
  52545. get captureRenderTargetsRenderTime(): boolean;
  52546. /**
  52547. * Enable or disable the render targets render time capture
  52548. */
  52549. set captureRenderTargetsRenderTime(value: boolean);
  52550. /**
  52551. * Gets the perf counter used for particles render time
  52552. */
  52553. get particlesRenderTimeCounter(): PerfCounter;
  52554. /**
  52555. * Gets the particles render time capture status
  52556. */
  52557. get captureParticlesRenderTime(): boolean;
  52558. /**
  52559. * Enable or disable the particles render time capture
  52560. */
  52561. set captureParticlesRenderTime(value: boolean);
  52562. /**
  52563. * Gets the perf counter used for sprites render time
  52564. */
  52565. get spritesRenderTimeCounter(): PerfCounter;
  52566. /**
  52567. * Gets the sprites render time capture status
  52568. */
  52569. get captureSpritesRenderTime(): boolean;
  52570. /**
  52571. * Enable or disable the sprites render time capture
  52572. */
  52573. set captureSpritesRenderTime(value: boolean);
  52574. /**
  52575. * Gets the perf counter used for physics time
  52576. */
  52577. get physicsTimeCounter(): PerfCounter;
  52578. /**
  52579. * Gets the physics time capture status
  52580. */
  52581. get capturePhysicsTime(): boolean;
  52582. /**
  52583. * Enable or disable the physics time capture
  52584. */
  52585. set capturePhysicsTime(value: boolean);
  52586. /**
  52587. * Gets the perf counter used for animations time
  52588. */
  52589. get animationsTimeCounter(): PerfCounter;
  52590. /**
  52591. * Gets the animations time capture status
  52592. */
  52593. get captureAnimationsTime(): boolean;
  52594. /**
  52595. * Enable or disable the animations time capture
  52596. */
  52597. set captureAnimationsTime(value: boolean);
  52598. /**
  52599. * Gets the perf counter used for frame time capture
  52600. */
  52601. get frameTimeCounter(): PerfCounter;
  52602. /**
  52603. * Gets the frame time capture status
  52604. */
  52605. get captureFrameTime(): boolean;
  52606. /**
  52607. * Enable or disable the frame time capture
  52608. */
  52609. set captureFrameTime(value: boolean);
  52610. /**
  52611. * Gets the perf counter used for inter-frames time capture
  52612. */
  52613. get interFrameTimeCounter(): PerfCounter;
  52614. /**
  52615. * Gets the inter-frames time capture status
  52616. */
  52617. get captureInterFrameTime(): boolean;
  52618. /**
  52619. * Enable or disable the inter-frames time capture
  52620. */
  52621. set captureInterFrameTime(value: boolean);
  52622. /**
  52623. * Gets the perf counter used for render time capture
  52624. */
  52625. get renderTimeCounter(): PerfCounter;
  52626. /**
  52627. * Gets the render time capture status
  52628. */
  52629. get captureRenderTime(): boolean;
  52630. /**
  52631. * Enable or disable the render time capture
  52632. */
  52633. set captureRenderTime(value: boolean);
  52634. /**
  52635. * Gets the perf counter used for camera render time capture
  52636. */
  52637. get cameraRenderTimeCounter(): PerfCounter;
  52638. /**
  52639. * Gets the camera render time capture status
  52640. */
  52641. get captureCameraRenderTime(): boolean;
  52642. /**
  52643. * Enable or disable the camera render time capture
  52644. */
  52645. set captureCameraRenderTime(value: boolean);
  52646. /**
  52647. * Gets the perf counter used for draw calls
  52648. */
  52649. get drawCallsCounter(): PerfCounter;
  52650. /**
  52651. * Instantiates a new scene instrumentation.
  52652. * This class can be used to get instrumentation data from a Babylon engine
  52653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52654. * @param scene Defines the scene to instrument
  52655. */
  52656. constructor(
  52657. /**
  52658. * Defines the scene to instrument
  52659. */
  52660. scene: Scene);
  52661. /**
  52662. * Dispose and release associated resources.
  52663. */
  52664. dispose(): void;
  52665. }
  52666. }
  52667. declare module BABYLON {
  52668. /** @hidden */
  52669. export var glowMapGenerationPixelShader: {
  52670. name: string;
  52671. shader: string;
  52672. };
  52673. }
  52674. declare module BABYLON {
  52675. /** @hidden */
  52676. export var glowMapGenerationVertexShader: {
  52677. name: string;
  52678. shader: string;
  52679. };
  52680. }
  52681. declare module BABYLON {
  52682. /**
  52683. * Effect layer options. This helps customizing the behaviour
  52684. * of the effect layer.
  52685. */
  52686. export interface IEffectLayerOptions {
  52687. /**
  52688. * Multiplication factor apply to the canvas size to compute the render target size
  52689. * used to generated the objects (the smaller the faster).
  52690. */
  52691. mainTextureRatio: number;
  52692. /**
  52693. * Enforces a fixed size texture to ensure effect stability across devices.
  52694. */
  52695. mainTextureFixedSize?: number;
  52696. /**
  52697. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52698. */
  52699. alphaBlendingMode: number;
  52700. /**
  52701. * The camera attached to the layer.
  52702. */
  52703. camera: Nullable<Camera>;
  52704. /**
  52705. * The rendering group to draw the layer in.
  52706. */
  52707. renderingGroupId: number;
  52708. }
  52709. /**
  52710. * The effect layer Helps adding post process effect blended with the main pass.
  52711. *
  52712. * This can be for instance use to generate glow or higlight effects on the scene.
  52713. *
  52714. * The effect layer class can not be used directly and is intented to inherited from to be
  52715. * customized per effects.
  52716. */
  52717. export abstract class EffectLayer {
  52718. private _vertexBuffers;
  52719. private _indexBuffer;
  52720. private _cachedDefines;
  52721. private _effectLayerMapGenerationEffect;
  52722. private _effectLayerOptions;
  52723. private _mergeEffect;
  52724. protected _scene: Scene;
  52725. protected _engine: Engine;
  52726. protected _maxSize: number;
  52727. protected _mainTextureDesiredSize: ISize;
  52728. protected _mainTexture: RenderTargetTexture;
  52729. protected _shouldRender: boolean;
  52730. protected _postProcesses: PostProcess[];
  52731. protected _textures: BaseTexture[];
  52732. protected _emissiveTextureAndColor: {
  52733. texture: Nullable<BaseTexture>;
  52734. color: Color4;
  52735. };
  52736. /**
  52737. * The name of the layer
  52738. */
  52739. name: string;
  52740. /**
  52741. * The clear color of the texture used to generate the glow map.
  52742. */
  52743. neutralColor: Color4;
  52744. /**
  52745. * Specifies whether the highlight layer is enabled or not.
  52746. */
  52747. isEnabled: boolean;
  52748. /**
  52749. * Gets the camera attached to the layer.
  52750. */
  52751. get camera(): Nullable<Camera>;
  52752. /**
  52753. * Gets the rendering group id the layer should render in.
  52754. */
  52755. get renderingGroupId(): number;
  52756. set renderingGroupId(renderingGroupId: number);
  52757. /**
  52758. * An event triggered when the effect layer has been disposed.
  52759. */
  52760. onDisposeObservable: Observable<EffectLayer>;
  52761. /**
  52762. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52763. */
  52764. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52765. /**
  52766. * An event triggered when the generated texture is being merged in the scene.
  52767. */
  52768. onBeforeComposeObservable: Observable<EffectLayer>;
  52769. /**
  52770. * An event triggered when the mesh is rendered into the effect render target.
  52771. */
  52772. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52773. /**
  52774. * An event triggered after the mesh has been rendered into the effect render target.
  52775. */
  52776. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52777. /**
  52778. * An event triggered when the generated texture has been merged in the scene.
  52779. */
  52780. onAfterComposeObservable: Observable<EffectLayer>;
  52781. /**
  52782. * An event triggered when the efffect layer changes its size.
  52783. */
  52784. onSizeChangedObservable: Observable<EffectLayer>;
  52785. /** @hidden */
  52786. static _SceneComponentInitialization: (scene: Scene) => void;
  52787. /**
  52788. * Instantiates a new effect Layer and references it in the scene.
  52789. * @param name The name of the layer
  52790. * @param scene The scene to use the layer in
  52791. */
  52792. constructor(
  52793. /** The Friendly of the effect in the scene */
  52794. name: string, scene: Scene);
  52795. /**
  52796. * Get the effect name of the layer.
  52797. * @return The effect name
  52798. */
  52799. abstract getEffectName(): string;
  52800. /**
  52801. * Checks for the readiness of the element composing the layer.
  52802. * @param subMesh the mesh to check for
  52803. * @param useInstances specify whether or not to use instances to render the mesh
  52804. * @return true if ready otherwise, false
  52805. */
  52806. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52807. /**
  52808. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52809. * @returns true if the effect requires stencil during the main canvas render pass.
  52810. */
  52811. abstract needStencil(): boolean;
  52812. /**
  52813. * Create the merge effect. This is the shader use to blit the information back
  52814. * to the main canvas at the end of the scene rendering.
  52815. * @returns The effect containing the shader used to merge the effect on the main canvas
  52816. */
  52817. protected abstract _createMergeEffect(): Effect;
  52818. /**
  52819. * Creates the render target textures and post processes used in the effect layer.
  52820. */
  52821. protected abstract _createTextureAndPostProcesses(): void;
  52822. /**
  52823. * Implementation specific of rendering the generating effect on the main canvas.
  52824. * @param effect The effect used to render through
  52825. */
  52826. protected abstract _internalRender(effect: Effect): void;
  52827. /**
  52828. * Sets the required values for both the emissive texture and and the main color.
  52829. */
  52830. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52831. /**
  52832. * Free any resources and references associated to a mesh.
  52833. * Internal use
  52834. * @param mesh The mesh to free.
  52835. */
  52836. abstract _disposeMesh(mesh: Mesh): void;
  52837. /**
  52838. * Serializes this layer (Glow or Highlight for example)
  52839. * @returns a serialized layer object
  52840. */
  52841. abstract serialize?(): any;
  52842. /**
  52843. * Initializes the effect layer with the required options.
  52844. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52845. */
  52846. protected _init(options: Partial<IEffectLayerOptions>): void;
  52847. /**
  52848. * Generates the index buffer of the full screen quad blending to the main canvas.
  52849. */
  52850. private _generateIndexBuffer;
  52851. /**
  52852. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52853. */
  52854. private _generateVertexBuffer;
  52855. /**
  52856. * Sets the main texture desired size which is the closest power of two
  52857. * of the engine canvas size.
  52858. */
  52859. private _setMainTextureSize;
  52860. /**
  52861. * Creates the main texture for the effect layer.
  52862. */
  52863. protected _createMainTexture(): void;
  52864. /**
  52865. * Adds specific effects defines.
  52866. * @param defines The defines to add specifics to.
  52867. */
  52868. protected _addCustomEffectDefines(defines: string[]): void;
  52869. /**
  52870. * Checks for the readiness of the element composing the layer.
  52871. * @param subMesh the mesh to check for
  52872. * @param useInstances specify whether or not to use instances to render the mesh
  52873. * @param emissiveTexture the associated emissive texture used to generate the glow
  52874. * @return true if ready otherwise, false
  52875. */
  52876. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52877. /**
  52878. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52879. */
  52880. render(): void;
  52881. /**
  52882. * Determine if a given mesh will be used in the current effect.
  52883. * @param mesh mesh to test
  52884. * @returns true if the mesh will be used
  52885. */
  52886. hasMesh(mesh: AbstractMesh): boolean;
  52887. /**
  52888. * Returns true if the layer contains information to display, otherwise false.
  52889. * @returns true if the glow layer should be rendered
  52890. */
  52891. shouldRender(): boolean;
  52892. /**
  52893. * Returns true if the mesh should render, otherwise false.
  52894. * @param mesh The mesh to render
  52895. * @returns true if it should render otherwise false
  52896. */
  52897. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52898. /**
  52899. * Returns true if the mesh can be rendered, otherwise false.
  52900. * @param mesh The mesh to render
  52901. * @param material The material used on the mesh
  52902. * @returns true if it can be rendered otherwise false
  52903. */
  52904. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52905. /**
  52906. * Returns true if the mesh should render, otherwise false.
  52907. * @param mesh The mesh to render
  52908. * @returns true if it should render otherwise false
  52909. */
  52910. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52911. /**
  52912. * Renders the submesh passed in parameter to the generation map.
  52913. */
  52914. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52915. /**
  52916. * Defines whether the current material of the mesh should be use to render the effect.
  52917. * @param mesh defines the current mesh to render
  52918. */
  52919. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52920. /**
  52921. * Rebuild the required buffers.
  52922. * @hidden Internal use only.
  52923. */
  52924. _rebuild(): void;
  52925. /**
  52926. * Dispose only the render target textures and post process.
  52927. */
  52928. private _disposeTextureAndPostProcesses;
  52929. /**
  52930. * Dispose the highlight layer and free resources.
  52931. */
  52932. dispose(): void;
  52933. /**
  52934. * Gets the class name of the effect layer
  52935. * @returns the string with the class name of the effect layer
  52936. */
  52937. getClassName(): string;
  52938. /**
  52939. * Creates an effect layer from parsed effect layer data
  52940. * @param parsedEffectLayer defines effect layer data
  52941. * @param scene defines the current scene
  52942. * @param rootUrl defines the root URL containing the effect layer information
  52943. * @returns a parsed effect Layer
  52944. */
  52945. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52946. }
  52947. }
  52948. declare module BABYLON {
  52949. interface AbstractScene {
  52950. /**
  52951. * The list of effect layers (highlights/glow) added to the scene
  52952. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52953. * @see http://doc.babylonjs.com/how_to/glow_layer
  52954. */
  52955. effectLayers: Array<EffectLayer>;
  52956. /**
  52957. * Removes the given effect layer from this scene.
  52958. * @param toRemove defines the effect layer to remove
  52959. * @returns the index of the removed effect layer
  52960. */
  52961. removeEffectLayer(toRemove: EffectLayer): number;
  52962. /**
  52963. * Adds the given effect layer to this scene
  52964. * @param newEffectLayer defines the effect layer to add
  52965. */
  52966. addEffectLayer(newEffectLayer: EffectLayer): void;
  52967. }
  52968. /**
  52969. * Defines the layer scene component responsible to manage any effect layers
  52970. * in a given scene.
  52971. */
  52972. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52973. /**
  52974. * The component name helpfull to identify the component in the list of scene components.
  52975. */
  52976. readonly name: string;
  52977. /**
  52978. * The scene the component belongs to.
  52979. */
  52980. scene: Scene;
  52981. private _engine;
  52982. private _renderEffects;
  52983. private _needStencil;
  52984. private _previousStencilState;
  52985. /**
  52986. * Creates a new instance of the component for the given scene
  52987. * @param scene Defines the scene to register the component in
  52988. */
  52989. constructor(scene: Scene);
  52990. /**
  52991. * Registers the component in a given scene
  52992. */
  52993. register(): void;
  52994. /**
  52995. * Rebuilds the elements related to this component in case of
  52996. * context lost for instance.
  52997. */
  52998. rebuild(): void;
  52999. /**
  53000. * Serializes the component data to the specified json object
  53001. * @param serializationObject The object to serialize to
  53002. */
  53003. serialize(serializationObject: any): void;
  53004. /**
  53005. * Adds all the elements from the container to the scene
  53006. * @param container the container holding the elements
  53007. */
  53008. addFromContainer(container: AbstractScene): void;
  53009. /**
  53010. * Removes all the elements in the container from the scene
  53011. * @param container contains the elements to remove
  53012. * @param dispose if the removed element should be disposed (default: false)
  53013. */
  53014. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53015. /**
  53016. * Disposes the component and the associated ressources.
  53017. */
  53018. dispose(): void;
  53019. private _isReadyForMesh;
  53020. private _renderMainTexture;
  53021. private _setStencil;
  53022. private _setStencilBack;
  53023. private _draw;
  53024. private _drawCamera;
  53025. private _drawRenderingGroup;
  53026. }
  53027. }
  53028. declare module BABYLON {
  53029. /** @hidden */
  53030. export var glowMapMergePixelShader: {
  53031. name: string;
  53032. shader: string;
  53033. };
  53034. }
  53035. declare module BABYLON {
  53036. /** @hidden */
  53037. export var glowMapMergeVertexShader: {
  53038. name: string;
  53039. shader: string;
  53040. };
  53041. }
  53042. declare module BABYLON {
  53043. interface AbstractScene {
  53044. /**
  53045. * Return a the first highlight layer of the scene with a given name.
  53046. * @param name The name of the highlight layer to look for.
  53047. * @return The highlight layer if found otherwise null.
  53048. */
  53049. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53050. }
  53051. /**
  53052. * Glow layer options. This helps customizing the behaviour
  53053. * of the glow layer.
  53054. */
  53055. export interface IGlowLayerOptions {
  53056. /**
  53057. * Multiplication factor apply to the canvas size to compute the render target size
  53058. * used to generated the glowing objects (the smaller the faster).
  53059. */
  53060. mainTextureRatio: number;
  53061. /**
  53062. * Enforces a fixed size texture to ensure resize independant blur.
  53063. */
  53064. mainTextureFixedSize?: number;
  53065. /**
  53066. * How big is the kernel of the blur texture.
  53067. */
  53068. blurKernelSize: number;
  53069. /**
  53070. * The camera attached to the layer.
  53071. */
  53072. camera: Nullable<Camera>;
  53073. /**
  53074. * Enable MSAA by chosing the number of samples.
  53075. */
  53076. mainTextureSamples?: number;
  53077. /**
  53078. * The rendering group to draw the layer in.
  53079. */
  53080. renderingGroupId: number;
  53081. }
  53082. /**
  53083. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53084. *
  53085. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53086. *
  53087. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53088. */
  53089. export class GlowLayer extends EffectLayer {
  53090. /**
  53091. * Effect Name of the layer.
  53092. */
  53093. static readonly EffectName: string;
  53094. /**
  53095. * The default blur kernel size used for the glow.
  53096. */
  53097. static DefaultBlurKernelSize: number;
  53098. /**
  53099. * The default texture size ratio used for the glow.
  53100. */
  53101. static DefaultTextureRatio: number;
  53102. /**
  53103. * Sets the kernel size of the blur.
  53104. */
  53105. set blurKernelSize(value: number);
  53106. /**
  53107. * Gets the kernel size of the blur.
  53108. */
  53109. get blurKernelSize(): number;
  53110. /**
  53111. * Sets the glow intensity.
  53112. */
  53113. set intensity(value: number);
  53114. /**
  53115. * Gets the glow intensity.
  53116. */
  53117. get intensity(): number;
  53118. private _options;
  53119. private _intensity;
  53120. private _horizontalBlurPostprocess1;
  53121. private _verticalBlurPostprocess1;
  53122. private _horizontalBlurPostprocess2;
  53123. private _verticalBlurPostprocess2;
  53124. private _blurTexture1;
  53125. private _blurTexture2;
  53126. private _postProcesses1;
  53127. private _postProcesses2;
  53128. private _includedOnlyMeshes;
  53129. private _excludedMeshes;
  53130. private _meshesUsingTheirOwnMaterials;
  53131. /**
  53132. * Callback used to let the user override the color selection on a per mesh basis
  53133. */
  53134. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53135. /**
  53136. * Callback used to let the user override the texture selection on a per mesh basis
  53137. */
  53138. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53139. /**
  53140. * Instantiates a new glow Layer and references it to the scene.
  53141. * @param name The name of the layer
  53142. * @param scene The scene to use the layer in
  53143. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53144. */
  53145. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53146. /**
  53147. * Get the effect name of the layer.
  53148. * @return The effect name
  53149. */
  53150. getEffectName(): string;
  53151. /**
  53152. * Create the merge effect. This is the shader use to blit the information back
  53153. * to the main canvas at the end of the scene rendering.
  53154. */
  53155. protected _createMergeEffect(): Effect;
  53156. /**
  53157. * Creates the render target textures and post processes used in the glow layer.
  53158. */
  53159. protected _createTextureAndPostProcesses(): void;
  53160. /**
  53161. * Checks for the readiness of the element composing the layer.
  53162. * @param subMesh the mesh to check for
  53163. * @param useInstances specify wether or not to use instances to render the mesh
  53164. * @param emissiveTexture the associated emissive texture used to generate the glow
  53165. * @return true if ready otherwise, false
  53166. */
  53167. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53168. /**
  53169. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53170. */
  53171. needStencil(): boolean;
  53172. /**
  53173. * Returns true if the mesh can be rendered, otherwise false.
  53174. * @param mesh The mesh to render
  53175. * @param material The material used on the mesh
  53176. * @returns true if it can be rendered otherwise false
  53177. */
  53178. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53179. /**
  53180. * Implementation specific of rendering the generating effect on the main canvas.
  53181. * @param effect The effect used to render through
  53182. */
  53183. protected _internalRender(effect: Effect): void;
  53184. /**
  53185. * Sets the required values for both the emissive texture and and the main color.
  53186. */
  53187. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53188. /**
  53189. * Returns true if the mesh should render, otherwise false.
  53190. * @param mesh The mesh to render
  53191. * @returns true if it should render otherwise false
  53192. */
  53193. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53194. /**
  53195. * Adds specific effects defines.
  53196. * @param defines The defines to add specifics to.
  53197. */
  53198. protected _addCustomEffectDefines(defines: string[]): void;
  53199. /**
  53200. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53201. * @param mesh The mesh to exclude from the glow layer
  53202. */
  53203. addExcludedMesh(mesh: Mesh): void;
  53204. /**
  53205. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53206. * @param mesh The mesh to remove
  53207. */
  53208. removeExcludedMesh(mesh: Mesh): void;
  53209. /**
  53210. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53211. * @param mesh The mesh to include in the glow layer
  53212. */
  53213. addIncludedOnlyMesh(mesh: Mesh): void;
  53214. /**
  53215. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53216. * @param mesh The mesh to remove
  53217. */
  53218. removeIncludedOnlyMesh(mesh: Mesh): void;
  53219. /**
  53220. * Determine if a given mesh will be used in the glow layer
  53221. * @param mesh The mesh to test
  53222. * @returns true if the mesh will be highlighted by the current glow layer
  53223. */
  53224. hasMesh(mesh: AbstractMesh): boolean;
  53225. /**
  53226. * Defines whether the current material of the mesh should be use to render the effect.
  53227. * @param mesh defines the current mesh to render
  53228. */
  53229. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53230. /**
  53231. * Add a mesh to be rendered through its own material and not with emissive only.
  53232. * @param mesh The mesh for which we need to use its material
  53233. */
  53234. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53235. /**
  53236. * Remove a mesh from being rendered through its own material and not with emissive only.
  53237. * @param mesh The mesh for which we need to not use its material
  53238. */
  53239. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53240. /**
  53241. * Free any resources and references associated to a mesh.
  53242. * Internal use
  53243. * @param mesh The mesh to free.
  53244. * @hidden
  53245. */
  53246. _disposeMesh(mesh: Mesh): void;
  53247. /**
  53248. * Gets the class name of the effect layer
  53249. * @returns the string with the class name of the effect layer
  53250. */
  53251. getClassName(): string;
  53252. /**
  53253. * Serializes this glow layer
  53254. * @returns a serialized glow layer object
  53255. */
  53256. serialize(): any;
  53257. /**
  53258. * Creates a Glow Layer from parsed glow layer data
  53259. * @param parsedGlowLayer defines glow layer data
  53260. * @param scene defines the current scene
  53261. * @param rootUrl defines the root URL containing the glow layer information
  53262. * @returns a parsed Glow Layer
  53263. */
  53264. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53265. }
  53266. }
  53267. declare module BABYLON {
  53268. /** @hidden */
  53269. export var glowBlurPostProcessPixelShader: {
  53270. name: string;
  53271. shader: string;
  53272. };
  53273. }
  53274. declare module BABYLON {
  53275. interface AbstractScene {
  53276. /**
  53277. * Return a the first highlight layer of the scene with a given name.
  53278. * @param name The name of the highlight layer to look for.
  53279. * @return The highlight layer if found otherwise null.
  53280. */
  53281. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53282. }
  53283. /**
  53284. * Highlight layer options. This helps customizing the behaviour
  53285. * of the highlight layer.
  53286. */
  53287. export interface IHighlightLayerOptions {
  53288. /**
  53289. * Multiplication factor apply to the canvas size to compute the render target size
  53290. * used to generated the glowing objects (the smaller the faster).
  53291. */
  53292. mainTextureRatio: number;
  53293. /**
  53294. * Enforces a fixed size texture to ensure resize independant blur.
  53295. */
  53296. mainTextureFixedSize?: number;
  53297. /**
  53298. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53299. * of the picture to blur (the smaller the faster).
  53300. */
  53301. blurTextureSizeRatio: number;
  53302. /**
  53303. * How big in texel of the blur texture is the vertical blur.
  53304. */
  53305. blurVerticalSize: number;
  53306. /**
  53307. * How big in texel of the blur texture is the horizontal blur.
  53308. */
  53309. blurHorizontalSize: number;
  53310. /**
  53311. * Alpha blending mode used to apply the blur. Default is combine.
  53312. */
  53313. alphaBlendingMode: number;
  53314. /**
  53315. * The camera attached to the layer.
  53316. */
  53317. camera: Nullable<Camera>;
  53318. /**
  53319. * Should we display highlight as a solid stroke?
  53320. */
  53321. isStroke?: boolean;
  53322. /**
  53323. * The rendering group to draw the layer in.
  53324. */
  53325. renderingGroupId: number;
  53326. }
  53327. /**
  53328. * The highlight layer Helps adding a glow effect around a mesh.
  53329. *
  53330. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53331. * glowy meshes to your scene.
  53332. *
  53333. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53334. */
  53335. export class HighlightLayer extends EffectLayer {
  53336. name: string;
  53337. /**
  53338. * Effect Name of the highlight layer.
  53339. */
  53340. static readonly EffectName: string;
  53341. /**
  53342. * The neutral color used during the preparation of the glow effect.
  53343. * This is black by default as the blend operation is a blend operation.
  53344. */
  53345. static NeutralColor: Color4;
  53346. /**
  53347. * Stencil value used for glowing meshes.
  53348. */
  53349. static GlowingMeshStencilReference: number;
  53350. /**
  53351. * Stencil value used for the other meshes in the scene.
  53352. */
  53353. static NormalMeshStencilReference: number;
  53354. /**
  53355. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53356. */
  53357. innerGlow: boolean;
  53358. /**
  53359. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53360. */
  53361. outerGlow: boolean;
  53362. /**
  53363. * Specifies the horizontal size of the blur.
  53364. */
  53365. set blurHorizontalSize(value: number);
  53366. /**
  53367. * Specifies the vertical size of the blur.
  53368. */
  53369. set blurVerticalSize(value: number);
  53370. /**
  53371. * Gets the horizontal size of the blur.
  53372. */
  53373. get blurHorizontalSize(): number;
  53374. /**
  53375. * Gets the vertical size of the blur.
  53376. */
  53377. get blurVerticalSize(): number;
  53378. /**
  53379. * An event triggered when the highlight layer is being blurred.
  53380. */
  53381. onBeforeBlurObservable: Observable<HighlightLayer>;
  53382. /**
  53383. * An event triggered when the highlight layer has been blurred.
  53384. */
  53385. onAfterBlurObservable: Observable<HighlightLayer>;
  53386. private _instanceGlowingMeshStencilReference;
  53387. private _options;
  53388. private _downSamplePostprocess;
  53389. private _horizontalBlurPostprocess;
  53390. private _verticalBlurPostprocess;
  53391. private _blurTexture;
  53392. private _meshes;
  53393. private _excludedMeshes;
  53394. /**
  53395. * Instantiates a new highlight Layer and references it to the scene..
  53396. * @param name The name of the layer
  53397. * @param scene The scene to use the layer in
  53398. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53399. */
  53400. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53401. /**
  53402. * Get the effect name of the layer.
  53403. * @return The effect name
  53404. */
  53405. getEffectName(): string;
  53406. /**
  53407. * Create the merge effect. This is the shader use to blit the information back
  53408. * to the main canvas at the end of the scene rendering.
  53409. */
  53410. protected _createMergeEffect(): Effect;
  53411. /**
  53412. * Creates the render target textures and post processes used in the highlight layer.
  53413. */
  53414. protected _createTextureAndPostProcesses(): void;
  53415. /**
  53416. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53417. */
  53418. needStencil(): boolean;
  53419. /**
  53420. * Checks for the readiness of the element composing the layer.
  53421. * @param subMesh the mesh to check for
  53422. * @param useInstances specify wether or not to use instances to render the mesh
  53423. * @param emissiveTexture the associated emissive texture used to generate the glow
  53424. * @return true if ready otherwise, false
  53425. */
  53426. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53427. /**
  53428. * Implementation specific of rendering the generating effect on the main canvas.
  53429. * @param effect The effect used to render through
  53430. */
  53431. protected _internalRender(effect: Effect): void;
  53432. /**
  53433. * Returns true if the layer contains information to display, otherwise false.
  53434. */
  53435. shouldRender(): boolean;
  53436. /**
  53437. * Returns true if the mesh should render, otherwise false.
  53438. * @param mesh The mesh to render
  53439. * @returns true if it should render otherwise false
  53440. */
  53441. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53442. /**
  53443. * Sets the required values for both the emissive texture and and the main color.
  53444. */
  53445. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53446. /**
  53447. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53448. * @param mesh The mesh to exclude from the highlight layer
  53449. */
  53450. addExcludedMesh(mesh: Mesh): void;
  53451. /**
  53452. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53453. * @param mesh The mesh to highlight
  53454. */
  53455. removeExcludedMesh(mesh: Mesh): void;
  53456. /**
  53457. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53458. * @param mesh mesh to test
  53459. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53460. */
  53461. hasMesh(mesh: AbstractMesh): boolean;
  53462. /**
  53463. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53464. * @param mesh The mesh to highlight
  53465. * @param color The color of the highlight
  53466. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53467. */
  53468. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53469. /**
  53470. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53471. * @param mesh The mesh to highlight
  53472. */
  53473. removeMesh(mesh: Mesh): void;
  53474. /**
  53475. * Remove all the meshes currently referenced in the highlight layer
  53476. */
  53477. removeAllMeshes(): void;
  53478. /**
  53479. * Force the stencil to the normal expected value for none glowing parts
  53480. */
  53481. private _defaultStencilReference;
  53482. /**
  53483. * Free any resources and references associated to a mesh.
  53484. * Internal use
  53485. * @param mesh The mesh to free.
  53486. * @hidden
  53487. */
  53488. _disposeMesh(mesh: Mesh): void;
  53489. /**
  53490. * Dispose the highlight layer and free resources.
  53491. */
  53492. dispose(): void;
  53493. /**
  53494. * Gets the class name of the effect layer
  53495. * @returns the string with the class name of the effect layer
  53496. */
  53497. getClassName(): string;
  53498. /**
  53499. * Serializes this Highlight layer
  53500. * @returns a serialized Highlight layer object
  53501. */
  53502. serialize(): any;
  53503. /**
  53504. * Creates a Highlight layer from parsed Highlight layer data
  53505. * @param parsedHightlightLayer defines the Highlight layer data
  53506. * @param scene defines the current scene
  53507. * @param rootUrl defines the root URL containing the Highlight layer information
  53508. * @returns a parsed Highlight layer
  53509. */
  53510. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53511. }
  53512. }
  53513. declare module BABYLON {
  53514. interface AbstractScene {
  53515. /**
  53516. * The list of layers (background and foreground) of the scene
  53517. */
  53518. layers: Array<Layer>;
  53519. }
  53520. /**
  53521. * Defines the layer scene component responsible to manage any layers
  53522. * in a given scene.
  53523. */
  53524. export class LayerSceneComponent implements ISceneComponent {
  53525. /**
  53526. * The component name helpfull to identify the component in the list of scene components.
  53527. */
  53528. readonly name: string;
  53529. /**
  53530. * The scene the component belongs to.
  53531. */
  53532. scene: Scene;
  53533. private _engine;
  53534. /**
  53535. * Creates a new instance of the component for the given scene
  53536. * @param scene Defines the scene to register the component in
  53537. */
  53538. constructor(scene: Scene);
  53539. /**
  53540. * Registers the component in a given scene
  53541. */
  53542. register(): void;
  53543. /**
  53544. * Rebuilds the elements related to this component in case of
  53545. * context lost for instance.
  53546. */
  53547. rebuild(): void;
  53548. /**
  53549. * Disposes the component and the associated ressources.
  53550. */
  53551. dispose(): void;
  53552. private _draw;
  53553. private _drawCameraPredicate;
  53554. private _drawCameraBackground;
  53555. private _drawCameraForeground;
  53556. private _drawRenderTargetPredicate;
  53557. private _drawRenderTargetBackground;
  53558. private _drawRenderTargetForeground;
  53559. /**
  53560. * Adds all the elements from the container to the scene
  53561. * @param container the container holding the elements
  53562. */
  53563. addFromContainer(container: AbstractScene): void;
  53564. /**
  53565. * Removes all the elements in the container from the scene
  53566. * @param container contains the elements to remove
  53567. * @param dispose if the removed element should be disposed (default: false)
  53568. */
  53569. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53570. }
  53571. }
  53572. declare module BABYLON {
  53573. /** @hidden */
  53574. export var layerPixelShader: {
  53575. name: string;
  53576. shader: string;
  53577. };
  53578. }
  53579. declare module BABYLON {
  53580. /** @hidden */
  53581. export var layerVertexShader: {
  53582. name: string;
  53583. shader: string;
  53584. };
  53585. }
  53586. declare module BABYLON {
  53587. /**
  53588. * This represents a full screen 2d layer.
  53589. * This can be useful to display a picture in the background of your scene for instance.
  53590. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53591. */
  53592. export class Layer {
  53593. /**
  53594. * Define the name of the layer.
  53595. */
  53596. name: string;
  53597. /**
  53598. * Define the texture the layer should display.
  53599. */
  53600. texture: Nullable<Texture>;
  53601. /**
  53602. * Is the layer in background or foreground.
  53603. */
  53604. isBackground: boolean;
  53605. /**
  53606. * Define the color of the layer (instead of texture).
  53607. */
  53608. color: Color4;
  53609. /**
  53610. * Define the scale of the layer in order to zoom in out of the texture.
  53611. */
  53612. scale: Vector2;
  53613. /**
  53614. * Define an offset for the layer in order to shift the texture.
  53615. */
  53616. offset: Vector2;
  53617. /**
  53618. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53619. */
  53620. alphaBlendingMode: number;
  53621. /**
  53622. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53623. * Alpha test will not mix with the background color in case of transparency.
  53624. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53625. */
  53626. alphaTest: boolean;
  53627. /**
  53628. * Define a mask to restrict the layer to only some of the scene cameras.
  53629. */
  53630. layerMask: number;
  53631. /**
  53632. * Define the list of render target the layer is visible into.
  53633. */
  53634. renderTargetTextures: RenderTargetTexture[];
  53635. /**
  53636. * Define if the layer is only used in renderTarget or if it also
  53637. * renders in the main frame buffer of the canvas.
  53638. */
  53639. renderOnlyInRenderTargetTextures: boolean;
  53640. private _scene;
  53641. private _vertexBuffers;
  53642. private _indexBuffer;
  53643. private _effect;
  53644. private _previousDefines;
  53645. /**
  53646. * An event triggered when the layer is disposed.
  53647. */
  53648. onDisposeObservable: Observable<Layer>;
  53649. private _onDisposeObserver;
  53650. /**
  53651. * Back compatibility with callback before the onDisposeObservable existed.
  53652. * The set callback will be triggered when the layer has been disposed.
  53653. */
  53654. set onDispose(callback: () => void);
  53655. /**
  53656. * An event triggered before rendering the scene
  53657. */
  53658. onBeforeRenderObservable: Observable<Layer>;
  53659. private _onBeforeRenderObserver;
  53660. /**
  53661. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53662. * The set callback will be triggered just before rendering the layer.
  53663. */
  53664. set onBeforeRender(callback: () => void);
  53665. /**
  53666. * An event triggered after rendering the scene
  53667. */
  53668. onAfterRenderObservable: Observable<Layer>;
  53669. private _onAfterRenderObserver;
  53670. /**
  53671. * Back compatibility with callback before the onAfterRenderObservable existed.
  53672. * The set callback will be triggered just after rendering the layer.
  53673. */
  53674. set onAfterRender(callback: () => void);
  53675. /**
  53676. * Instantiates a new layer.
  53677. * This represents a full screen 2d layer.
  53678. * This can be useful to display a picture in the background of your scene for instance.
  53679. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53680. * @param name Define the name of the layer in the scene
  53681. * @param imgUrl Define the url of the texture to display in the layer
  53682. * @param scene Define the scene the layer belongs to
  53683. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53684. * @param color Defines a color for the layer
  53685. */
  53686. constructor(
  53687. /**
  53688. * Define the name of the layer.
  53689. */
  53690. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53691. private _createIndexBuffer;
  53692. /** @hidden */
  53693. _rebuild(): void;
  53694. /**
  53695. * Renders the layer in the scene.
  53696. */
  53697. render(): void;
  53698. /**
  53699. * Disposes and releases the associated ressources.
  53700. */
  53701. dispose(): void;
  53702. }
  53703. }
  53704. declare module BABYLON {
  53705. /** @hidden */
  53706. export var lensFlarePixelShader: {
  53707. name: string;
  53708. shader: string;
  53709. };
  53710. }
  53711. declare module BABYLON {
  53712. /** @hidden */
  53713. export var lensFlareVertexShader: {
  53714. name: string;
  53715. shader: string;
  53716. };
  53717. }
  53718. declare module BABYLON {
  53719. /**
  53720. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53721. * It is usually composed of several `lensFlare`.
  53722. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53723. */
  53724. export class LensFlareSystem {
  53725. /**
  53726. * Define the name of the lens flare system
  53727. */
  53728. name: string;
  53729. /**
  53730. * List of lens flares used in this system.
  53731. */
  53732. lensFlares: LensFlare[];
  53733. /**
  53734. * Define a limit from the border the lens flare can be visible.
  53735. */
  53736. borderLimit: number;
  53737. /**
  53738. * Define a viewport border we do not want to see the lens flare in.
  53739. */
  53740. viewportBorder: number;
  53741. /**
  53742. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53743. */
  53744. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53745. /**
  53746. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53747. */
  53748. layerMask: number;
  53749. /**
  53750. * Define the id of the lens flare system in the scene.
  53751. * (equal to name by default)
  53752. */
  53753. id: string;
  53754. private _scene;
  53755. private _emitter;
  53756. private _vertexBuffers;
  53757. private _indexBuffer;
  53758. private _effect;
  53759. private _positionX;
  53760. private _positionY;
  53761. private _isEnabled;
  53762. /** @hidden */
  53763. static _SceneComponentInitialization: (scene: Scene) => void;
  53764. /**
  53765. * Instantiates a lens flare system.
  53766. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53767. * It is usually composed of several `lensFlare`.
  53768. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53769. * @param name Define the name of the lens flare system in the scene
  53770. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53771. * @param scene Define the scene the lens flare system belongs to
  53772. */
  53773. constructor(
  53774. /**
  53775. * Define the name of the lens flare system
  53776. */
  53777. name: string, emitter: any, scene: Scene);
  53778. /**
  53779. * Define if the lens flare system is enabled.
  53780. */
  53781. get isEnabled(): boolean;
  53782. set isEnabled(value: boolean);
  53783. /**
  53784. * Get the scene the effects belongs to.
  53785. * @returns the scene holding the lens flare system
  53786. */
  53787. getScene(): Scene;
  53788. /**
  53789. * Get the emitter of the lens flare system.
  53790. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53791. * @returns the emitter of the lens flare system
  53792. */
  53793. getEmitter(): any;
  53794. /**
  53795. * Set the emitter of the lens flare system.
  53796. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53797. * @param newEmitter Define the new emitter of the system
  53798. */
  53799. setEmitter(newEmitter: any): void;
  53800. /**
  53801. * Get the lens flare system emitter position.
  53802. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53803. * @returns the position
  53804. */
  53805. getEmitterPosition(): Vector3;
  53806. /**
  53807. * @hidden
  53808. */
  53809. computeEffectivePosition(globalViewport: Viewport): boolean;
  53810. /** @hidden */
  53811. _isVisible(): boolean;
  53812. /**
  53813. * @hidden
  53814. */
  53815. render(): boolean;
  53816. /**
  53817. * Dispose and release the lens flare with its associated resources.
  53818. */
  53819. dispose(): void;
  53820. /**
  53821. * Parse a lens flare system from a JSON repressentation
  53822. * @param parsedLensFlareSystem Define the JSON to parse
  53823. * @param scene Define the scene the parsed system should be instantiated in
  53824. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53825. * @returns the parsed system
  53826. */
  53827. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53828. /**
  53829. * Serialize the current Lens Flare System into a JSON representation.
  53830. * @returns the serialized JSON
  53831. */
  53832. serialize(): any;
  53833. }
  53834. }
  53835. declare module BABYLON {
  53836. /**
  53837. * This represents one of the lens effect in a `lensFlareSystem`.
  53838. * It controls one of the indiviual texture used in the effect.
  53839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53840. */
  53841. export class LensFlare {
  53842. /**
  53843. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53844. */
  53845. size: number;
  53846. /**
  53847. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  53848. */
  53849. position: number;
  53850. /**
  53851. * Define the lens color.
  53852. */
  53853. color: Color3;
  53854. /**
  53855. * Define the lens texture.
  53856. */
  53857. texture: Nullable<Texture>;
  53858. /**
  53859. * Define the alpha mode to render this particular lens.
  53860. */
  53861. alphaMode: number;
  53862. private _system;
  53863. /**
  53864. * Creates a new Lens Flare.
  53865. * This represents one of the lens effect in a `lensFlareSystem`.
  53866. * It controls one of the indiviual texture used in the effect.
  53867. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53868. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53869. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  53870. * @param color Define the lens color
  53871. * @param imgUrl Define the lens texture url
  53872. * @param system Define the `lensFlareSystem` this flare is part of
  53873. * @returns The newly created Lens Flare
  53874. */
  53875. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53876. /**
  53877. * Instantiates a new Lens Flare.
  53878. * This represents one of the lens effect in a `lensFlareSystem`.
  53879. * It controls one of the indiviual texture used in the effect.
  53880. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53881. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53882. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  53883. * @param color Define the lens color
  53884. * @param imgUrl Define the lens texture url
  53885. * @param system Define the `lensFlareSystem` this flare is part of
  53886. */
  53887. constructor(
  53888. /**
  53889. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53890. */
  53891. size: number,
  53892. /**
  53893. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  53894. */
  53895. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53896. /**
  53897. * Dispose and release the lens flare with its associated resources.
  53898. */
  53899. dispose(): void;
  53900. }
  53901. }
  53902. declare module BABYLON {
  53903. interface AbstractScene {
  53904. /**
  53905. * The list of lens flare system added to the scene
  53906. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53907. */
  53908. lensFlareSystems: Array<LensFlareSystem>;
  53909. /**
  53910. * Removes the given lens flare system from this scene.
  53911. * @param toRemove The lens flare system to remove
  53912. * @returns The index of the removed lens flare system
  53913. */
  53914. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53915. /**
  53916. * Adds the given lens flare system to this scene
  53917. * @param newLensFlareSystem The lens flare system to add
  53918. */
  53919. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53920. /**
  53921. * Gets a lens flare system using its name
  53922. * @param name defines the name to look for
  53923. * @returns the lens flare system or null if not found
  53924. */
  53925. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53926. /**
  53927. * Gets a lens flare system using its id
  53928. * @param id defines the id to look for
  53929. * @returns the lens flare system or null if not found
  53930. */
  53931. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53932. }
  53933. /**
  53934. * Defines the lens flare scene component responsible to manage any lens flares
  53935. * in a given scene.
  53936. */
  53937. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53938. /**
  53939. * The component name helpfull to identify the component in the list of scene components.
  53940. */
  53941. readonly name: string;
  53942. /**
  53943. * The scene the component belongs to.
  53944. */
  53945. scene: Scene;
  53946. /**
  53947. * Creates a new instance of the component for the given scene
  53948. * @param scene Defines the scene to register the component in
  53949. */
  53950. constructor(scene: Scene);
  53951. /**
  53952. * Registers the component in a given scene
  53953. */
  53954. register(): void;
  53955. /**
  53956. * Rebuilds the elements related to this component in case of
  53957. * context lost for instance.
  53958. */
  53959. rebuild(): void;
  53960. /**
  53961. * Adds all the elements from the container to the scene
  53962. * @param container the container holding the elements
  53963. */
  53964. addFromContainer(container: AbstractScene): void;
  53965. /**
  53966. * Removes all the elements in the container from the scene
  53967. * @param container contains the elements to remove
  53968. * @param dispose if the removed element should be disposed (default: false)
  53969. */
  53970. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53971. /**
  53972. * Serializes the component data to the specified json object
  53973. * @param serializationObject The object to serialize to
  53974. */
  53975. serialize(serializationObject: any): void;
  53976. /**
  53977. * Disposes the component and the associated ressources.
  53978. */
  53979. dispose(): void;
  53980. private _draw;
  53981. }
  53982. }
  53983. declare module BABYLON {
  53984. /** @hidden */
  53985. export var depthPixelShader: {
  53986. name: string;
  53987. shader: string;
  53988. };
  53989. }
  53990. declare module BABYLON {
  53991. /** @hidden */
  53992. export var depthVertexShader: {
  53993. name: string;
  53994. shader: string;
  53995. };
  53996. }
  53997. declare module BABYLON {
  53998. /**
  53999. * This represents a depth renderer in Babylon.
  54000. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54001. */
  54002. export class DepthRenderer {
  54003. private _scene;
  54004. private _depthMap;
  54005. private _effect;
  54006. private readonly _storeNonLinearDepth;
  54007. private readonly _clearColor;
  54008. /** Get if the depth renderer is using packed depth or not */
  54009. readonly isPacked: boolean;
  54010. private _cachedDefines;
  54011. private _camera;
  54012. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54013. enabled: boolean;
  54014. /**
  54015. * Specifiess that the depth renderer will only be used within
  54016. * the camera it is created for.
  54017. * This can help forcing its rendering during the camera processing.
  54018. */
  54019. useOnlyInActiveCamera: boolean;
  54020. /** @hidden */
  54021. static _SceneComponentInitialization: (scene: Scene) => void;
  54022. /**
  54023. * Instantiates a depth renderer
  54024. * @param scene The scene the renderer belongs to
  54025. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54026. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54027. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54028. */
  54029. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54030. /**
  54031. * Creates the depth rendering effect and checks if the effect is ready.
  54032. * @param subMesh The submesh to be used to render the depth map of
  54033. * @param useInstances If multiple world instances should be used
  54034. * @returns if the depth renderer is ready to render the depth map
  54035. */
  54036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54037. /**
  54038. * Gets the texture which the depth map will be written to.
  54039. * @returns The depth map texture
  54040. */
  54041. getDepthMap(): RenderTargetTexture;
  54042. /**
  54043. * Disposes of the depth renderer.
  54044. */
  54045. dispose(): void;
  54046. }
  54047. }
  54048. declare module BABYLON {
  54049. /** @hidden */
  54050. export var minmaxReduxPixelShader: {
  54051. name: string;
  54052. shader: string;
  54053. };
  54054. }
  54055. declare module BABYLON {
  54056. /**
  54057. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54058. * and maximum values from all values of the texture.
  54059. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54060. * The source values are read from the red channel of the texture.
  54061. */
  54062. export class MinMaxReducer {
  54063. /**
  54064. * Observable triggered when the computation has been performed
  54065. */
  54066. onAfterReductionPerformed: Observable<{
  54067. min: number;
  54068. max: number;
  54069. }>;
  54070. protected _camera: Camera;
  54071. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54072. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54073. protected _postProcessManager: PostProcessManager;
  54074. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54075. protected _forceFullscreenViewport: boolean;
  54076. /**
  54077. * Creates a min/max reducer
  54078. * @param camera The camera to use for the post processes
  54079. */
  54080. constructor(camera: Camera);
  54081. /**
  54082. * Gets the texture used to read the values from.
  54083. */
  54084. get sourceTexture(): Nullable<RenderTargetTexture>;
  54085. /**
  54086. * Sets the source texture to read the values from.
  54087. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54088. * because in such textures '1' value must not be taken into account to compute the maximum
  54089. * as this value is used to clear the texture.
  54090. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54091. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54092. * @param depthRedux Indicates if the texture is a depth texture or not
  54093. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54094. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54095. */
  54096. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54097. /**
  54098. * Defines the refresh rate of the computation.
  54099. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54100. */
  54101. get refreshRate(): number;
  54102. set refreshRate(value: number);
  54103. protected _activated: boolean;
  54104. /**
  54105. * Gets the activation status of the reducer
  54106. */
  54107. get activated(): boolean;
  54108. /**
  54109. * Activates the reduction computation.
  54110. * When activated, the observers registered in onAfterReductionPerformed are
  54111. * called after the compuation is performed
  54112. */
  54113. activate(): void;
  54114. /**
  54115. * Deactivates the reduction computation.
  54116. */
  54117. deactivate(): void;
  54118. /**
  54119. * Disposes the min/max reducer
  54120. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54121. */
  54122. dispose(disposeAll?: boolean): void;
  54123. }
  54124. }
  54125. declare module BABYLON {
  54126. /**
  54127. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54128. */
  54129. export class DepthReducer extends MinMaxReducer {
  54130. private _depthRenderer;
  54131. private _depthRendererId;
  54132. /**
  54133. * Gets the depth renderer used for the computation.
  54134. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54135. */
  54136. get depthRenderer(): Nullable<DepthRenderer>;
  54137. /**
  54138. * Creates a depth reducer
  54139. * @param camera The camera used to render the depth texture
  54140. */
  54141. constructor(camera: Camera);
  54142. /**
  54143. * Sets the depth renderer to use to generate the depth map
  54144. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54145. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54146. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54147. */
  54148. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54149. /** @hidden */
  54150. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54151. /**
  54152. * Activates the reduction computation.
  54153. * When activated, the observers registered in onAfterReductionPerformed are
  54154. * called after the compuation is performed
  54155. */
  54156. activate(): void;
  54157. /**
  54158. * Deactivates the reduction computation.
  54159. */
  54160. deactivate(): void;
  54161. /**
  54162. * Disposes the depth reducer
  54163. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54164. */
  54165. dispose(disposeAll?: boolean): void;
  54166. }
  54167. }
  54168. declare module BABYLON {
  54169. /**
  54170. * A CSM implementation allowing casting shadows on large scenes.
  54171. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54172. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54173. */
  54174. export class CascadedShadowGenerator extends ShadowGenerator {
  54175. private static readonly frustumCornersNDCSpace;
  54176. /**
  54177. * Name of the CSM class
  54178. */
  54179. static CLASSNAME: string;
  54180. /**
  54181. * Defines the default number of cascades used by the CSM.
  54182. */
  54183. static readonly DEFAULT_CASCADES_COUNT: number;
  54184. /**
  54185. * Defines the minimum number of cascades used by the CSM.
  54186. */
  54187. static readonly MIN_CASCADES_COUNT: number;
  54188. /**
  54189. * Defines the maximum number of cascades used by the CSM.
  54190. */
  54191. static readonly MAX_CASCADES_COUNT: number;
  54192. protected _validateFilter(filter: number): number;
  54193. /**
  54194. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54195. */
  54196. penumbraDarkness: number;
  54197. private _numCascades;
  54198. /**
  54199. * Gets or set the number of cascades used by the CSM.
  54200. */
  54201. get numCascades(): number;
  54202. set numCascades(value: number);
  54203. /**
  54204. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54205. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54206. */
  54207. stabilizeCascades: boolean;
  54208. private _freezeShadowCastersBoundingInfo;
  54209. private _freezeShadowCastersBoundingInfoObservable;
  54210. /**
  54211. * Enables or disables the shadow casters bounding info computation.
  54212. * If your shadow casters don't move, you can disable this feature.
  54213. * If it is enabled, the bounding box computation is done every frame.
  54214. */
  54215. get freezeShadowCastersBoundingInfo(): boolean;
  54216. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54217. private _scbiMin;
  54218. private _scbiMax;
  54219. protected _computeShadowCastersBoundingInfo(): void;
  54220. protected _shadowCastersBoundingInfo: BoundingInfo;
  54221. /**
  54222. * Gets or sets the shadow casters bounding info.
  54223. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54224. * so that the system won't overwrite the bounds you provide
  54225. */
  54226. get shadowCastersBoundingInfo(): BoundingInfo;
  54227. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54228. protected _breaksAreDirty: boolean;
  54229. protected _minDistance: number;
  54230. protected _maxDistance: number;
  54231. /**
  54232. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54233. *
  54234. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54235. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54236. * @param min minimal distance for the breaks (default to 0.)
  54237. * @param max maximal distance for the breaks (default to 1.)
  54238. */
  54239. setMinMaxDistance(min: number, max: number): void;
  54240. /** Gets the minimal distance used in the cascade break computation */
  54241. get minDistance(): number;
  54242. /** Gets the maximal distance used in the cascade break computation */
  54243. get maxDistance(): number;
  54244. /**
  54245. * Gets the class name of that object
  54246. * @returns "CascadedShadowGenerator"
  54247. */
  54248. getClassName(): string;
  54249. private _cascadeMinExtents;
  54250. private _cascadeMaxExtents;
  54251. /**
  54252. * Gets a cascade minimum extents
  54253. * @param cascadeIndex index of the cascade
  54254. * @returns the minimum cascade extents
  54255. */
  54256. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54257. /**
  54258. * Gets a cascade maximum extents
  54259. * @param cascadeIndex index of the cascade
  54260. * @returns the maximum cascade extents
  54261. */
  54262. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54263. private _cascades;
  54264. private _currentLayer;
  54265. private _viewSpaceFrustumsZ;
  54266. private _viewMatrices;
  54267. private _projectionMatrices;
  54268. private _transformMatrices;
  54269. private _transformMatricesAsArray;
  54270. private _frustumLengths;
  54271. private _lightSizeUVCorrection;
  54272. private _depthCorrection;
  54273. private _frustumCornersWorldSpace;
  54274. private _frustumCenter;
  54275. private _shadowCameraPos;
  54276. private _shadowMaxZ;
  54277. /**
  54278. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54279. * It defaults to camera.maxZ
  54280. */
  54281. get shadowMaxZ(): number;
  54282. /**
  54283. * Sets the shadow max z distance.
  54284. */
  54285. set shadowMaxZ(value: number);
  54286. protected _debug: boolean;
  54287. /**
  54288. * Gets or sets the debug flag.
  54289. * When enabled, the cascades are materialized by different colors on the screen.
  54290. */
  54291. get debug(): boolean;
  54292. set debug(dbg: boolean);
  54293. private _depthClamp;
  54294. /**
  54295. * Gets or sets the depth clamping value.
  54296. *
  54297. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54298. * to account for the shadow casters far away.
  54299. *
  54300. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54301. */
  54302. get depthClamp(): boolean;
  54303. set depthClamp(value: boolean);
  54304. private _cascadeBlendPercentage;
  54305. /**
  54306. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54307. * It defaults to 0.1 (10% blending).
  54308. */
  54309. get cascadeBlendPercentage(): number;
  54310. set cascadeBlendPercentage(value: number);
  54311. private _lambda;
  54312. /**
  54313. * Gets or set the lambda parameter.
  54314. * This parameter is used to split the camera frustum and create the cascades.
  54315. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  54316. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54317. */
  54318. get lambda(): number;
  54319. set lambda(value: number);
  54320. /**
  54321. * Gets the view matrix corresponding to a given cascade
  54322. * @param cascadeNum cascade to retrieve the view matrix from
  54323. * @returns the cascade view matrix
  54324. */
  54325. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54326. /**
  54327. * Gets the projection matrix corresponding to a given cascade
  54328. * @param cascadeNum cascade to retrieve the projection matrix from
  54329. * @returns the cascade projection matrix
  54330. */
  54331. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54332. /**
  54333. * Gets the transformation matrix corresponding to a given cascade
  54334. * @param cascadeNum cascade to retrieve the transformation matrix from
  54335. * @returns the cascade transformation matrix
  54336. */
  54337. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54338. private _depthRenderer;
  54339. /**
  54340. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54341. *
  54342. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54343. *
  54344. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54345. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54346. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  54347. */
  54348. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54349. private _depthReducer;
  54350. private _autoCalcDepthBounds;
  54351. /**
  54352. * Gets or sets the autoCalcDepthBounds property.
  54353. *
  54354. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54355. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54356. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54357. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54358. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54359. */
  54360. get autoCalcDepthBounds(): boolean;
  54361. set autoCalcDepthBounds(value: boolean);
  54362. /**
  54363. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54364. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54365. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54366. * for setting the refresh rate on the renderer yourself!
  54367. */
  54368. get autoCalcDepthBoundsRefreshRate(): number;
  54369. set autoCalcDepthBoundsRefreshRate(value: number);
  54370. /**
  54371. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54372. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54373. * you change the camera near/far planes!
  54374. */
  54375. splitFrustum(): void;
  54376. private _splitFrustum;
  54377. private _computeMatrices;
  54378. private _computeFrustumInWorldSpace;
  54379. private _computeCascadeFrustum;
  54380. /** @hidden */
  54381. static _SceneComponentInitialization: (scene: Scene) => void;
  54382. /**
  54383. * Creates a Cascaded Shadow Generator object.
  54384. * A ShadowGenerator is the required tool to use the shadows.
  54385. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54386. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54387. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54388. * @param light The directional light object generating the shadows.
  54389. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  54390. */
  54391. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54392. protected _initializeGenerator(): void;
  54393. protected _createTargetRenderTexture(): void;
  54394. protected _initializeShadowMap(): void;
  54395. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54396. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54397. /**
  54398. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54399. * @param defines Defines of the material we want to update
  54400. * @param lightIndex Index of the light in the enabled light list of the material
  54401. */
  54402. prepareDefines(defines: any, lightIndex: number): void;
  54403. /**
  54404. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54405. * defined in the generator but impacting the effect).
  54406. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54407. * @param effect The effect we are binfing the information for
  54408. */
  54409. bindShadowLight(lightIndex: string, effect: Effect): void;
  54410. /**
  54411. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54412. * (eq to view projection * shadow projection matrices)
  54413. * @returns The transform matrix used to create the shadow map
  54414. */
  54415. getTransformMatrix(): Matrix;
  54416. /**
  54417. * Disposes the ShadowGenerator.
  54418. * Returns nothing.
  54419. */
  54420. dispose(): void;
  54421. /**
  54422. * Serializes the shadow generator setup to a json object.
  54423. * @returns The serialized JSON object
  54424. */
  54425. serialize(): any;
  54426. /**
  54427. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54428. * @param parsedShadowGenerator The JSON object to parse
  54429. * @param scene The scene to create the shadow map for
  54430. * @returns The parsed shadow generator
  54431. */
  54432. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54433. }
  54434. }
  54435. declare module BABYLON {
  54436. /**
  54437. * Defines the shadow generator component responsible to manage any shadow generators
  54438. * in a given scene.
  54439. */
  54440. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54441. /**
  54442. * The component name helpfull to identify the component in the list of scene components.
  54443. */
  54444. readonly name: string;
  54445. /**
  54446. * The scene the component belongs to.
  54447. */
  54448. scene: Scene;
  54449. /**
  54450. * Creates a new instance of the component for the given scene
  54451. * @param scene Defines the scene to register the component in
  54452. */
  54453. constructor(scene: Scene);
  54454. /**
  54455. * Registers the component in a given scene
  54456. */
  54457. register(): void;
  54458. /**
  54459. * Rebuilds the elements related to this component in case of
  54460. * context lost for instance.
  54461. */
  54462. rebuild(): void;
  54463. /**
  54464. * Serializes the component data to the specified json object
  54465. * @param serializationObject The object to serialize to
  54466. */
  54467. serialize(serializationObject: any): void;
  54468. /**
  54469. * Adds all the elements from the container to the scene
  54470. * @param container the container holding the elements
  54471. */
  54472. addFromContainer(container: AbstractScene): void;
  54473. /**
  54474. * Removes all the elements in the container from the scene
  54475. * @param container contains the elements to remove
  54476. * @param dispose if the removed element should be disposed (default: false)
  54477. */
  54478. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54479. /**
  54480. * Rebuilds the elements related to this component in case of
  54481. * context lost for instance.
  54482. */
  54483. dispose(): void;
  54484. private _gatherRenderTargets;
  54485. }
  54486. }
  54487. declare module BABYLON {
  54488. /**
  54489. * A point light is a light defined by an unique point in world space.
  54490. * The light is emitted in every direction from this point.
  54491. * A good example of a point light is a standard light bulb.
  54492. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54493. */
  54494. export class PointLight extends ShadowLight {
  54495. private _shadowAngle;
  54496. /**
  54497. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54498. * This specifies what angle the shadow will use to be created.
  54499. *
  54500. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54501. */
  54502. get shadowAngle(): number;
  54503. /**
  54504. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54505. * This specifies what angle the shadow will use to be created.
  54506. *
  54507. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54508. */
  54509. set shadowAngle(value: number);
  54510. /**
  54511. * Gets the direction if it has been set.
  54512. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54513. */
  54514. get direction(): Vector3;
  54515. /**
  54516. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54517. */
  54518. set direction(value: Vector3);
  54519. /**
  54520. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54521. * A PointLight emits the light in every direction.
  54522. * It can cast shadows.
  54523. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54524. * ```javascript
  54525. * var pointLight = new PointLight("pl", camera.position, scene);
  54526. * ```
  54527. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54528. * @param name The light friendly name
  54529. * @param position The position of the point light in the scene
  54530. * @param scene The scene the lights belongs to
  54531. */
  54532. constructor(name: string, position: Vector3, scene: Scene);
  54533. /**
  54534. * Returns the string "PointLight"
  54535. * @returns the class name
  54536. */
  54537. getClassName(): string;
  54538. /**
  54539. * Returns the integer 0.
  54540. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54541. */
  54542. getTypeID(): number;
  54543. /**
  54544. * Specifies wether or not the shadowmap should be a cube texture.
  54545. * @returns true if the shadowmap needs to be a cube texture.
  54546. */
  54547. needCube(): boolean;
  54548. /**
  54549. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54550. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54551. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54552. */
  54553. getShadowDirection(faceIndex?: number): Vector3;
  54554. /**
  54555. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54556. * - fov = PI / 2
  54557. * - aspect ratio : 1.0
  54558. * - z-near and far equal to the active camera minZ and maxZ.
  54559. * Returns the PointLight.
  54560. */
  54561. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54562. protected _buildUniformLayout(): void;
  54563. /**
  54564. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54565. * @param effect The effect to update
  54566. * @param lightIndex The index of the light in the effect to update
  54567. * @returns The point light
  54568. */
  54569. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54570. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54571. /**
  54572. * Prepares the list of defines specific to the light type.
  54573. * @param defines the list of defines
  54574. * @param lightIndex defines the index of the light for the effect
  54575. */
  54576. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54577. }
  54578. }
  54579. declare module BABYLON {
  54580. /**
  54581. * Header information of HDR texture files.
  54582. */
  54583. export interface HDRInfo {
  54584. /**
  54585. * The height of the texture in pixels.
  54586. */
  54587. height: number;
  54588. /**
  54589. * The width of the texture in pixels.
  54590. */
  54591. width: number;
  54592. /**
  54593. * The index of the beginning of the data in the binary file.
  54594. */
  54595. dataPosition: number;
  54596. }
  54597. /**
  54598. * This groups tools to convert HDR texture to native colors array.
  54599. */
  54600. export class HDRTools {
  54601. private static Ldexp;
  54602. private static Rgbe2float;
  54603. private static readStringLine;
  54604. /**
  54605. * Reads header information from an RGBE texture stored in a native array.
  54606. * More information on this format are available here:
  54607. * https://en.wikipedia.org/wiki/RGBE_image_format
  54608. *
  54609. * @param uint8array The binary file stored in native array.
  54610. * @return The header information.
  54611. */
  54612. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54613. /**
  54614. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54615. * This RGBE texture needs to store the information as a panorama.
  54616. *
  54617. * More information on this format are available here:
  54618. * https://en.wikipedia.org/wiki/RGBE_image_format
  54619. *
  54620. * @param buffer The binary file stored in an array buffer.
  54621. * @param size The expected size of the extracted cubemap.
  54622. * @return The Cube Map information.
  54623. */
  54624. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54625. /**
  54626. * Returns the pixels data extracted from an RGBE texture.
  54627. * This pixels will be stored left to right up to down in the R G B order in one array.
  54628. *
  54629. * More information on this format are available here:
  54630. * https://en.wikipedia.org/wiki/RGBE_image_format
  54631. *
  54632. * @param uint8array The binary file stored in an array buffer.
  54633. * @param hdrInfo The header information of the file.
  54634. * @return The pixels data in RGB right to left up to down order.
  54635. */
  54636. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54637. private static RGBE_ReadPixels_RLE;
  54638. }
  54639. }
  54640. declare module BABYLON {
  54641. /**
  54642. * This represents a texture coming from an HDR input.
  54643. *
  54644. * The only supported format is currently panorama picture stored in RGBE format.
  54645. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54646. */
  54647. export class HDRCubeTexture extends BaseTexture {
  54648. private static _facesMapping;
  54649. private _generateHarmonics;
  54650. private _noMipmap;
  54651. private _textureMatrix;
  54652. private _size;
  54653. private _onLoad;
  54654. private _onError;
  54655. /**
  54656. * The texture URL.
  54657. */
  54658. url: string;
  54659. /**
  54660. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54661. */
  54662. coordinatesMode: number;
  54663. protected _isBlocking: boolean;
  54664. /**
  54665. * Sets wether or not the texture is blocking during loading.
  54666. */
  54667. set isBlocking(value: boolean);
  54668. /**
  54669. * Gets wether or not the texture is blocking during loading.
  54670. */
  54671. get isBlocking(): boolean;
  54672. protected _rotationY: number;
  54673. /**
  54674. * Sets texture matrix rotation angle around Y axis in radians.
  54675. */
  54676. set rotationY(value: number);
  54677. /**
  54678. * Gets texture matrix rotation angle around Y axis radians.
  54679. */
  54680. get rotationY(): number;
  54681. /**
  54682. * Gets or sets the center of the bounding box associated with the cube texture
  54683. * It must define where the camera used to render the texture was set
  54684. */
  54685. boundingBoxPosition: Vector3;
  54686. private _boundingBoxSize;
  54687. /**
  54688. * Gets or sets the size of the bounding box associated with the cube texture
  54689. * When defined, the cubemap will switch to local mode
  54690. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54691. * @example https://www.babylonjs-playground.com/#RNASML
  54692. */
  54693. set boundingBoxSize(value: Vector3);
  54694. get boundingBoxSize(): Vector3;
  54695. /**
  54696. * Instantiates an HDRTexture from the following parameters.
  54697. *
  54698. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54699. * @param scene The scene the texture will be used in
  54700. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54701. * @param noMipmap Forces to not generate the mipmap if true
  54702. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54703. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54704. * @param reserved Reserved flag for internal use.
  54705. */
  54706. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54707. /**
  54708. * Get the current class name of the texture useful for serialization or dynamic coding.
  54709. * @returns "HDRCubeTexture"
  54710. */
  54711. getClassName(): string;
  54712. /**
  54713. * Occurs when the file is raw .hdr file.
  54714. */
  54715. private loadTexture;
  54716. clone(): HDRCubeTexture;
  54717. delayLoad(): void;
  54718. /**
  54719. * Get the texture reflection matrix used to rotate/transform the reflection.
  54720. * @returns the reflection matrix
  54721. */
  54722. getReflectionTextureMatrix(): Matrix;
  54723. /**
  54724. * Set the texture reflection matrix used to rotate/transform the reflection.
  54725. * @param value Define the reflection matrix to set
  54726. */
  54727. setReflectionTextureMatrix(value: Matrix): void;
  54728. /**
  54729. * Parses a JSON representation of an HDR Texture in order to create the texture
  54730. * @param parsedTexture Define the JSON representation
  54731. * @param scene Define the scene the texture should be created in
  54732. * @param rootUrl Define the root url in case we need to load relative dependencies
  54733. * @returns the newly created texture after parsing
  54734. */
  54735. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54736. serialize(): any;
  54737. }
  54738. }
  54739. declare module BABYLON {
  54740. /**
  54741. * Class used to control physics engine
  54742. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54743. */
  54744. export class PhysicsEngine implements IPhysicsEngine {
  54745. private _physicsPlugin;
  54746. /**
  54747. * Global value used to control the smallest number supported by the simulation
  54748. */
  54749. static Epsilon: number;
  54750. private _impostors;
  54751. private _joints;
  54752. private _subTimeStep;
  54753. /**
  54754. * Gets the gravity vector used by the simulation
  54755. */
  54756. gravity: Vector3;
  54757. /**
  54758. * Factory used to create the default physics plugin.
  54759. * @returns The default physics plugin
  54760. */
  54761. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54762. /**
  54763. * Creates a new Physics Engine
  54764. * @param gravity defines the gravity vector used by the simulation
  54765. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54766. */
  54767. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54768. /**
  54769. * Sets the gravity vector used by the simulation
  54770. * @param gravity defines the gravity vector to use
  54771. */
  54772. setGravity(gravity: Vector3): void;
  54773. /**
  54774. * Set the time step of the physics engine.
  54775. * Default is 1/60.
  54776. * To slow it down, enter 1/600 for example.
  54777. * To speed it up, 1/30
  54778. * @param newTimeStep defines the new timestep to apply to this world.
  54779. */
  54780. setTimeStep(newTimeStep?: number): void;
  54781. /**
  54782. * Get the time step of the physics engine.
  54783. * @returns the current time step
  54784. */
  54785. getTimeStep(): number;
  54786. /**
  54787. * Set the sub time step of the physics engine.
  54788. * Default is 0 meaning there is no sub steps
  54789. * To increase physics resolution precision, set a small value (like 1 ms)
  54790. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54791. */
  54792. setSubTimeStep(subTimeStep?: number): void;
  54793. /**
  54794. * Get the sub time step of the physics engine.
  54795. * @returns the current sub time step
  54796. */
  54797. getSubTimeStep(): number;
  54798. /**
  54799. * Release all resources
  54800. */
  54801. dispose(): void;
  54802. /**
  54803. * Gets the name of the current physics plugin
  54804. * @returns the name of the plugin
  54805. */
  54806. getPhysicsPluginName(): string;
  54807. /**
  54808. * Adding a new impostor for the impostor tracking.
  54809. * This will be done by the impostor itself.
  54810. * @param impostor the impostor to add
  54811. */
  54812. addImpostor(impostor: PhysicsImpostor): void;
  54813. /**
  54814. * Remove an impostor from the engine.
  54815. * This impostor and its mesh will not longer be updated by the physics engine.
  54816. * @param impostor the impostor to remove
  54817. */
  54818. removeImpostor(impostor: PhysicsImpostor): void;
  54819. /**
  54820. * Add a joint to the physics engine
  54821. * @param mainImpostor defines the main impostor to which the joint is added.
  54822. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54823. * @param joint defines the joint that will connect both impostors.
  54824. */
  54825. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54826. /**
  54827. * Removes a joint from the simulation
  54828. * @param mainImpostor defines the impostor used with the joint
  54829. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54830. * @param joint defines the joint to remove
  54831. */
  54832. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54833. /**
  54834. * Called by the scene. No need to call it.
  54835. * @param delta defines the timespam between frames
  54836. */
  54837. _step(delta: number): void;
  54838. /**
  54839. * Gets the current plugin used to run the simulation
  54840. * @returns current plugin
  54841. */
  54842. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54843. /**
  54844. * Gets the list of physic impostors
  54845. * @returns an array of PhysicsImpostor
  54846. */
  54847. getImpostors(): Array<PhysicsImpostor>;
  54848. /**
  54849. * Gets the impostor for a physics enabled object
  54850. * @param object defines the object impersonated by the impostor
  54851. * @returns the PhysicsImpostor or null if not found
  54852. */
  54853. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54854. /**
  54855. * Gets the impostor for a physics body object
  54856. * @param body defines physics body used by the impostor
  54857. * @returns the PhysicsImpostor or null if not found
  54858. */
  54859. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54860. /**
  54861. * Does a raycast in the physics world
  54862. * @param from when should the ray start?
  54863. * @param to when should the ray end?
  54864. * @returns PhysicsRaycastResult
  54865. */
  54866. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54867. }
  54868. }
  54869. declare module BABYLON {
  54870. /** @hidden */
  54871. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54872. private _useDeltaForWorldStep;
  54873. world: any;
  54874. name: string;
  54875. private _physicsMaterials;
  54876. private _fixedTimeStep;
  54877. private _cannonRaycastResult;
  54878. private _raycastResult;
  54879. private _physicsBodysToRemoveAfterStep;
  54880. BJSCANNON: any;
  54881. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54882. setGravity(gravity: Vector3): void;
  54883. setTimeStep(timeStep: number): void;
  54884. getTimeStep(): number;
  54885. executeStep(delta: number): void;
  54886. private _removeMarkedPhysicsBodiesFromWorld;
  54887. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54888. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54889. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54890. private _processChildMeshes;
  54891. removePhysicsBody(impostor: PhysicsImpostor): void;
  54892. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54893. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54894. private _addMaterial;
  54895. private _checkWithEpsilon;
  54896. private _createShape;
  54897. private _createHeightmap;
  54898. private _minus90X;
  54899. private _plus90X;
  54900. private _tmpPosition;
  54901. private _tmpDeltaPosition;
  54902. private _tmpUnityRotation;
  54903. private _updatePhysicsBodyTransformation;
  54904. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54905. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54906. isSupported(): boolean;
  54907. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54908. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54909. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54910. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54911. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54912. getBodyMass(impostor: PhysicsImpostor): number;
  54913. getBodyFriction(impostor: PhysicsImpostor): number;
  54914. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54915. getBodyRestitution(impostor: PhysicsImpostor): number;
  54916. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54917. sleepBody(impostor: PhysicsImpostor): void;
  54918. wakeUpBody(impostor: PhysicsImpostor): void;
  54919. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54920. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54921. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54922. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54923. getRadius(impostor: PhysicsImpostor): number;
  54924. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54925. dispose(): void;
  54926. private _extendNamespace;
  54927. /**
  54928. * Does a raycast in the physics world
  54929. * @param from when should the ray start?
  54930. * @param to when should the ray end?
  54931. * @returns PhysicsRaycastResult
  54932. */
  54933. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54934. }
  54935. }
  54936. declare module BABYLON {
  54937. /** @hidden */
  54938. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54939. world: any;
  54940. name: string;
  54941. BJSOIMO: any;
  54942. private _raycastResult;
  54943. constructor(iterations?: number, oimoInjection?: any);
  54944. setGravity(gravity: Vector3): void;
  54945. setTimeStep(timeStep: number): void;
  54946. getTimeStep(): number;
  54947. private _tmpImpostorsArray;
  54948. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54949. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54950. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54951. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54952. private _tmpPositionVector;
  54953. removePhysicsBody(impostor: PhysicsImpostor): void;
  54954. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54955. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54956. isSupported(): boolean;
  54957. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54958. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54959. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54960. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54961. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54962. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54963. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54964. getBodyMass(impostor: PhysicsImpostor): number;
  54965. getBodyFriction(impostor: PhysicsImpostor): number;
  54966. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54967. getBodyRestitution(impostor: PhysicsImpostor): number;
  54968. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54969. sleepBody(impostor: PhysicsImpostor): void;
  54970. wakeUpBody(impostor: PhysicsImpostor): void;
  54971. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54972. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54973. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54974. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54975. getRadius(impostor: PhysicsImpostor): number;
  54976. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54977. dispose(): void;
  54978. /**
  54979. * Does a raycast in the physics world
  54980. * @param from when should the ray start?
  54981. * @param to when should the ray end?
  54982. * @returns PhysicsRaycastResult
  54983. */
  54984. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54985. }
  54986. }
  54987. declare module BABYLON {
  54988. /**
  54989. * Class containing static functions to help procedurally build meshes
  54990. */
  54991. export class RibbonBuilder {
  54992. /**
  54993. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54994. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54995. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54996. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54997. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  54998. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  54999. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  55000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55002. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55003. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  55004. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55005. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  55006. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55008. * @param name defines the name of the mesh
  55009. * @param options defines the options used to create the mesh
  55010. * @param scene defines the hosting scene
  55011. * @returns the ribbon mesh
  55012. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55013. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55014. */
  55015. static CreateRibbon(name: string, options: {
  55016. pathArray: Vector3[][];
  55017. closeArray?: boolean;
  55018. closePath?: boolean;
  55019. offset?: number;
  55020. updatable?: boolean;
  55021. sideOrientation?: number;
  55022. frontUVs?: Vector4;
  55023. backUVs?: Vector4;
  55024. instance?: Mesh;
  55025. invertUV?: boolean;
  55026. uvs?: Vector2[];
  55027. colors?: Color4[];
  55028. }, scene?: Nullable<Scene>): Mesh;
  55029. }
  55030. }
  55031. declare module BABYLON {
  55032. /**
  55033. * Class containing static functions to help procedurally build meshes
  55034. */
  55035. export class ShapeBuilder {
  55036. /**
  55037. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55038. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  55039. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55040. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  55041. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55042. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  55043. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  55044. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55047. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55049. * @param name defines the name of the mesh
  55050. * @param options defines the options used to create the mesh
  55051. * @param scene defines the hosting scene
  55052. * @returns the extruded shape mesh
  55053. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55055. */
  55056. static ExtrudeShape(name: string, options: {
  55057. shape: Vector3[];
  55058. path: Vector3[];
  55059. scale?: number;
  55060. rotation?: number;
  55061. cap?: number;
  55062. updatable?: boolean;
  55063. sideOrientation?: number;
  55064. frontUVs?: Vector4;
  55065. backUVs?: Vector4;
  55066. instance?: Mesh;
  55067. invertUV?: boolean;
  55068. }, scene?: Nullable<Scene>): Mesh;
  55069. /**
  55070. * Creates an custom extruded shape mesh.
  55071. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55072. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  55073. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55074. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  55075. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55076. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  55077. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55078. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55079. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55080. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  55081. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  55082. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55084. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55085. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55087. * @param name defines the name of the mesh
  55088. * @param options defines the options used to create the mesh
  55089. * @param scene defines the hosting scene
  55090. * @returns the custom extruded shape mesh
  55091. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55092. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55094. */
  55095. static ExtrudeShapeCustom(name: string, options: {
  55096. shape: Vector3[];
  55097. path: Vector3[];
  55098. scaleFunction?: any;
  55099. rotationFunction?: any;
  55100. ribbonCloseArray?: boolean;
  55101. ribbonClosePath?: boolean;
  55102. cap?: number;
  55103. updatable?: boolean;
  55104. sideOrientation?: number;
  55105. frontUVs?: Vector4;
  55106. backUVs?: Vector4;
  55107. instance?: Mesh;
  55108. invertUV?: boolean;
  55109. }, scene?: Nullable<Scene>): Mesh;
  55110. private static _ExtrudeShapeGeneric;
  55111. }
  55112. }
  55113. declare module BABYLON {
  55114. /**
  55115. * AmmoJS Physics plugin
  55116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55117. * @see https://github.com/kripken/ammo.js/
  55118. */
  55119. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55120. private _useDeltaForWorldStep;
  55121. /**
  55122. * Reference to the Ammo library
  55123. */
  55124. bjsAMMO: any;
  55125. /**
  55126. * Created ammoJS world which physics bodies are added to
  55127. */
  55128. world: any;
  55129. /**
  55130. * Name of the plugin
  55131. */
  55132. name: string;
  55133. private _timeStep;
  55134. private _fixedTimeStep;
  55135. private _maxSteps;
  55136. private _tmpQuaternion;
  55137. private _tmpAmmoTransform;
  55138. private _tmpAmmoQuaternion;
  55139. private _tmpAmmoConcreteContactResultCallback;
  55140. private _collisionConfiguration;
  55141. private _dispatcher;
  55142. private _overlappingPairCache;
  55143. private _solver;
  55144. private _softBodySolver;
  55145. private _tmpAmmoVectorA;
  55146. private _tmpAmmoVectorB;
  55147. private _tmpAmmoVectorC;
  55148. private _tmpAmmoVectorD;
  55149. private _tmpContactCallbackResult;
  55150. private _tmpAmmoVectorRCA;
  55151. private _tmpAmmoVectorRCB;
  55152. private _raycastResult;
  55153. private static readonly DISABLE_COLLISION_FLAG;
  55154. private static readonly KINEMATIC_FLAG;
  55155. private static readonly DISABLE_DEACTIVATION_FLAG;
  55156. /**
  55157. * Initializes the ammoJS plugin
  55158. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55159. * @param ammoInjection can be used to inject your own ammo reference
  55160. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55161. */
  55162. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55163. /**
  55164. * Sets the gravity of the physics world (m/(s^2))
  55165. * @param gravity Gravity to set
  55166. */
  55167. setGravity(gravity: Vector3): void;
  55168. /**
  55169. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55170. * @param timeStep timestep to use in seconds
  55171. */
  55172. setTimeStep(timeStep: number): void;
  55173. /**
  55174. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  55175. * @param fixedTimeStep fixedTimeStep to use in seconds
  55176. */
  55177. setFixedTimeStep(fixedTimeStep: number): void;
  55178. /**
  55179. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55180. * @param maxSteps the maximum number of steps by the physics engine per frame
  55181. */
  55182. setMaxSteps(maxSteps: number): void;
  55183. /**
  55184. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55185. * @returns the current timestep in seconds
  55186. */
  55187. getTimeStep(): number;
  55188. /**
  55189. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55190. */
  55191. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55192. private _isImpostorInContact;
  55193. private _isImpostorPairInContact;
  55194. private _stepSimulation;
  55195. /**
  55196. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55197. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55198. * After the step the babylon meshes are set to the position of the physics imposters
  55199. * @param delta amount of time to step forward
  55200. * @param impostors array of imposters to update before/after the step
  55201. */
  55202. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55203. /**
  55204. * Update babylon mesh to match physics world object
  55205. * @param impostor imposter to match
  55206. */
  55207. private _afterSoftStep;
  55208. /**
  55209. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55210. * @param impostor imposter to match
  55211. */
  55212. private _ropeStep;
  55213. /**
  55214. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55215. * @param impostor imposter to match
  55216. */
  55217. private _softbodyOrClothStep;
  55218. private _tmpVector;
  55219. private _tmpMatrix;
  55220. /**
  55221. * Applies an impulse on the imposter
  55222. * @param impostor imposter to apply impulse to
  55223. * @param force amount of force to be applied to the imposter
  55224. * @param contactPoint the location to apply the impulse on the imposter
  55225. */
  55226. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55227. /**
  55228. * Applies a force on the imposter
  55229. * @param impostor imposter to apply force
  55230. * @param force amount of force to be applied to the imposter
  55231. * @param contactPoint the location to apply the force on the imposter
  55232. */
  55233. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55234. /**
  55235. * Creates a physics body using the plugin
  55236. * @param impostor the imposter to create the physics body on
  55237. */
  55238. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55239. /**
  55240. * Removes the physics body from the imposter and disposes of the body's memory
  55241. * @param impostor imposter to remove the physics body from
  55242. */
  55243. removePhysicsBody(impostor: PhysicsImpostor): void;
  55244. /**
  55245. * Generates a joint
  55246. * @param impostorJoint the imposter joint to create the joint with
  55247. */
  55248. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55249. /**
  55250. * Removes a joint
  55251. * @param impostorJoint the imposter joint to remove the joint from
  55252. */
  55253. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55254. private _addMeshVerts;
  55255. /**
  55256. * Initialise the soft body vertices to match its object's (mesh) vertices
  55257. * Softbody vertices (nodes) are in world space and to match this
  55258. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55259. * @param impostor to create the softbody for
  55260. */
  55261. private _softVertexData;
  55262. /**
  55263. * Create an impostor's soft body
  55264. * @param impostor to create the softbody for
  55265. */
  55266. private _createSoftbody;
  55267. /**
  55268. * Create cloth for an impostor
  55269. * @param impostor to create the softbody for
  55270. */
  55271. private _createCloth;
  55272. /**
  55273. * Create rope for an impostor
  55274. * @param impostor to create the softbody for
  55275. */
  55276. private _createRope;
  55277. /**
  55278. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55279. * @param impostor to create the custom physics shape for
  55280. */
  55281. private _createCustom;
  55282. private _addHullVerts;
  55283. private _createShape;
  55284. /**
  55285. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55286. * @param impostor imposter containing the physics body and babylon object
  55287. */
  55288. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55289. /**
  55290. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55291. * @param impostor imposter containing the physics body and babylon object
  55292. * @param newPosition new position
  55293. * @param newRotation new rotation
  55294. */
  55295. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55296. /**
  55297. * If this plugin is supported
  55298. * @returns true if its supported
  55299. */
  55300. isSupported(): boolean;
  55301. /**
  55302. * Sets the linear velocity of the physics body
  55303. * @param impostor imposter to set the velocity on
  55304. * @param velocity velocity to set
  55305. */
  55306. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55307. /**
  55308. * Sets the angular velocity of the physics body
  55309. * @param impostor imposter to set the velocity on
  55310. * @param velocity velocity to set
  55311. */
  55312. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55313. /**
  55314. * gets the linear velocity
  55315. * @param impostor imposter to get linear velocity from
  55316. * @returns linear velocity
  55317. */
  55318. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55319. /**
  55320. * gets the angular velocity
  55321. * @param impostor imposter to get angular velocity from
  55322. * @returns angular velocity
  55323. */
  55324. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55325. /**
  55326. * Sets the mass of physics body
  55327. * @param impostor imposter to set the mass on
  55328. * @param mass mass to set
  55329. */
  55330. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55331. /**
  55332. * Gets the mass of the physics body
  55333. * @param impostor imposter to get the mass from
  55334. * @returns mass
  55335. */
  55336. getBodyMass(impostor: PhysicsImpostor): number;
  55337. /**
  55338. * Gets friction of the impostor
  55339. * @param impostor impostor to get friction from
  55340. * @returns friction value
  55341. */
  55342. getBodyFriction(impostor: PhysicsImpostor): number;
  55343. /**
  55344. * Sets friction of the impostor
  55345. * @param impostor impostor to set friction on
  55346. * @param friction friction value
  55347. */
  55348. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55349. /**
  55350. * Gets restitution of the impostor
  55351. * @param impostor impostor to get restitution from
  55352. * @returns restitution value
  55353. */
  55354. getBodyRestitution(impostor: PhysicsImpostor): number;
  55355. /**
  55356. * Sets resitution of the impostor
  55357. * @param impostor impostor to set resitution on
  55358. * @param restitution resitution value
  55359. */
  55360. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55361. /**
  55362. * Gets pressure inside the impostor
  55363. * @param impostor impostor to get pressure from
  55364. * @returns pressure value
  55365. */
  55366. getBodyPressure(impostor: PhysicsImpostor): number;
  55367. /**
  55368. * Sets pressure inside a soft body impostor
  55369. * Cloth and rope must remain 0 pressure
  55370. * @param impostor impostor to set pressure on
  55371. * @param pressure pressure value
  55372. */
  55373. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55374. /**
  55375. * Gets stiffness of the impostor
  55376. * @param impostor impostor to get stiffness from
  55377. * @returns pressure value
  55378. */
  55379. getBodyStiffness(impostor: PhysicsImpostor): number;
  55380. /**
  55381. * Sets stiffness of the impostor
  55382. * @param impostor impostor to set stiffness on
  55383. * @param stiffness stiffness value from 0 to 1
  55384. */
  55385. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55386. /**
  55387. * Gets velocityIterations of the impostor
  55388. * @param impostor impostor to get velocity iterations from
  55389. * @returns velocityIterations value
  55390. */
  55391. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55392. /**
  55393. * Sets velocityIterations of the impostor
  55394. * @param impostor impostor to set velocity iterations on
  55395. * @param velocityIterations velocityIterations value
  55396. */
  55397. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55398. /**
  55399. * Gets positionIterations of the impostor
  55400. * @param impostor impostor to get position iterations from
  55401. * @returns positionIterations value
  55402. */
  55403. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55404. /**
  55405. * Sets positionIterations of the impostor
  55406. * @param impostor impostor to set position on
  55407. * @param positionIterations positionIterations value
  55408. */
  55409. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55410. /**
  55411. * Append an anchor to a cloth object
  55412. * @param impostor is the cloth impostor to add anchor to
  55413. * @param otherImpostor is the rigid impostor to anchor to
  55414. * @param width ratio across width from 0 to 1
  55415. * @param height ratio up height from 0 to 1
  55416. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55417. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55418. */
  55419. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55420. /**
  55421. * Append an hook to a rope object
  55422. * @param impostor is the rope impostor to add hook to
  55423. * @param otherImpostor is the rigid impostor to hook to
  55424. * @param length ratio along the rope from 0 to 1
  55425. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55426. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55427. */
  55428. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55429. /**
  55430. * Sleeps the physics body and stops it from being active
  55431. * @param impostor impostor to sleep
  55432. */
  55433. sleepBody(impostor: PhysicsImpostor): void;
  55434. /**
  55435. * Activates the physics body
  55436. * @param impostor impostor to activate
  55437. */
  55438. wakeUpBody(impostor: PhysicsImpostor): void;
  55439. /**
  55440. * Updates the distance parameters of the joint
  55441. * @param joint joint to update
  55442. * @param maxDistance maximum distance of the joint
  55443. * @param minDistance minimum distance of the joint
  55444. */
  55445. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55446. /**
  55447. * Sets a motor on the joint
  55448. * @param joint joint to set motor on
  55449. * @param speed speed of the motor
  55450. * @param maxForce maximum force of the motor
  55451. * @param motorIndex index of the motor
  55452. */
  55453. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55454. /**
  55455. * Sets the motors limit
  55456. * @param joint joint to set limit on
  55457. * @param upperLimit upper limit
  55458. * @param lowerLimit lower limit
  55459. */
  55460. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55461. /**
  55462. * Syncs the position and rotation of a mesh with the impostor
  55463. * @param mesh mesh to sync
  55464. * @param impostor impostor to update the mesh with
  55465. */
  55466. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55467. /**
  55468. * Gets the radius of the impostor
  55469. * @param impostor impostor to get radius from
  55470. * @returns the radius
  55471. */
  55472. getRadius(impostor: PhysicsImpostor): number;
  55473. /**
  55474. * Gets the box size of the impostor
  55475. * @param impostor impostor to get box size from
  55476. * @param result the resulting box size
  55477. */
  55478. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55479. /**
  55480. * Disposes of the impostor
  55481. */
  55482. dispose(): void;
  55483. /**
  55484. * Does a raycast in the physics world
  55485. * @param from when should the ray start?
  55486. * @param to when should the ray end?
  55487. * @returns PhysicsRaycastResult
  55488. */
  55489. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55490. }
  55491. }
  55492. declare module BABYLON {
  55493. interface AbstractScene {
  55494. /**
  55495. * The list of reflection probes added to the scene
  55496. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55497. */
  55498. reflectionProbes: Array<ReflectionProbe>;
  55499. /**
  55500. * Removes the given reflection probe from this scene.
  55501. * @param toRemove The reflection probe to remove
  55502. * @returns The index of the removed reflection probe
  55503. */
  55504. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55505. /**
  55506. * Adds the given reflection probe to this scene.
  55507. * @param newReflectionProbe The reflection probe to add
  55508. */
  55509. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55510. }
  55511. /**
  55512. * Class used to generate realtime reflection / refraction cube textures
  55513. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55514. */
  55515. export class ReflectionProbe {
  55516. /** defines the name of the probe */
  55517. name: string;
  55518. private _scene;
  55519. private _renderTargetTexture;
  55520. private _projectionMatrix;
  55521. private _viewMatrix;
  55522. private _target;
  55523. private _add;
  55524. private _attachedMesh;
  55525. private _invertYAxis;
  55526. /** Gets or sets probe position (center of the cube map) */
  55527. position: Vector3;
  55528. /**
  55529. * Creates a new reflection probe
  55530. * @param name defines the name of the probe
  55531. * @param size defines the texture resolution (for each face)
  55532. * @param scene defines the hosting scene
  55533. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55534. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55535. */
  55536. constructor(
  55537. /** defines the name of the probe */
  55538. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55539. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55540. get samples(): number;
  55541. set samples(value: number);
  55542. /** Gets or sets the refresh rate to use (on every frame by default) */
  55543. get refreshRate(): number;
  55544. set refreshRate(value: number);
  55545. /**
  55546. * Gets the hosting scene
  55547. * @returns a Scene
  55548. */
  55549. getScene(): Scene;
  55550. /** Gets the internal CubeTexture used to render to */
  55551. get cubeTexture(): RenderTargetTexture;
  55552. /** Gets the list of meshes to render */
  55553. get renderList(): Nullable<AbstractMesh[]>;
  55554. /**
  55555. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55556. * @param mesh defines the mesh to attach to
  55557. */
  55558. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55559. /**
  55560. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55561. * @param renderingGroupId The rendering group id corresponding to its index
  55562. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55563. */
  55564. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55565. /**
  55566. * Clean all associated resources
  55567. */
  55568. dispose(): void;
  55569. /**
  55570. * Converts the reflection probe information to a readable string for debug purpose.
  55571. * @param fullDetails Supports for multiple levels of logging within scene loading
  55572. * @returns the human readable reflection probe info
  55573. */
  55574. toString(fullDetails?: boolean): string;
  55575. /**
  55576. * Get the class name of the relfection probe.
  55577. * @returns "ReflectionProbe"
  55578. */
  55579. getClassName(): string;
  55580. /**
  55581. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55582. * @returns The JSON representation of the texture
  55583. */
  55584. serialize(): any;
  55585. /**
  55586. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55587. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55588. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55589. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55590. * @returns The parsed reflection probe if successful
  55591. */
  55592. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55593. }
  55594. }
  55595. declare module BABYLON {
  55596. /** @hidden */
  55597. export var _BabylonLoaderRegistered: boolean;
  55598. /**
  55599. * Helps setting up some configuration for the babylon file loader.
  55600. */
  55601. export class BabylonFileLoaderConfiguration {
  55602. /**
  55603. * The loader does not allow injecting custom physix engine into the plugins.
  55604. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55605. * So you could set this variable to your engine import to make it work.
  55606. */
  55607. static LoaderInjectedPhysicsEngine: any;
  55608. }
  55609. }
  55610. declare module BABYLON {
  55611. /**
  55612. * The Physically based simple base material of BJS.
  55613. *
  55614. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55615. * It is used as the base class for both the specGloss and metalRough conventions.
  55616. */
  55617. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55618. /**
  55619. * Number of Simultaneous lights allowed on the material.
  55620. */
  55621. maxSimultaneousLights: number;
  55622. /**
  55623. * If sets to true, disables all the lights affecting the material.
  55624. */
  55625. disableLighting: boolean;
  55626. /**
  55627. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55628. */
  55629. environmentTexture: BaseTexture;
  55630. /**
  55631. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55632. */
  55633. invertNormalMapX: boolean;
  55634. /**
  55635. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55636. */
  55637. invertNormalMapY: boolean;
  55638. /**
  55639. * Normal map used in the model.
  55640. */
  55641. normalTexture: BaseTexture;
  55642. /**
  55643. * Emissivie color used to self-illuminate the model.
  55644. */
  55645. emissiveColor: Color3;
  55646. /**
  55647. * Emissivie texture used to self-illuminate the model.
  55648. */
  55649. emissiveTexture: BaseTexture;
  55650. /**
  55651. * Occlusion Channel Strenght.
  55652. */
  55653. occlusionStrength: number;
  55654. /**
  55655. * Occlusion Texture of the material (adding extra occlusion effects).
  55656. */
  55657. occlusionTexture: BaseTexture;
  55658. /**
  55659. * Defines the alpha limits in alpha test mode.
  55660. */
  55661. alphaCutOff: number;
  55662. /**
  55663. * Gets the current double sided mode.
  55664. */
  55665. get doubleSided(): boolean;
  55666. /**
  55667. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55668. */
  55669. set doubleSided(value: boolean);
  55670. /**
  55671. * Stores the pre-calculated light information of a mesh in a texture.
  55672. */
  55673. lightmapTexture: BaseTexture;
  55674. /**
  55675. * If true, the light map contains occlusion information instead of lighting info.
  55676. */
  55677. useLightmapAsShadowmap: boolean;
  55678. /**
  55679. * Instantiates a new PBRMaterial instance.
  55680. *
  55681. * @param name The material name
  55682. * @param scene The scene the material will be use in.
  55683. */
  55684. constructor(name: string, scene: Scene);
  55685. getClassName(): string;
  55686. }
  55687. }
  55688. declare module BABYLON {
  55689. /**
  55690. * The PBR material of BJS following the metal roughness convention.
  55691. *
  55692. * This fits to the PBR convention in the GLTF definition:
  55693. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55694. */
  55695. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55696. /**
  55697. * The base color has two different interpretations depending on the value of metalness.
  55698. * When the material is a metal, the base color is the specific measured reflectance value
  55699. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55700. * of the material.
  55701. */
  55702. baseColor: Color3;
  55703. /**
  55704. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55705. * well as opacity information in the alpha channel.
  55706. */
  55707. baseTexture: BaseTexture;
  55708. /**
  55709. * Specifies the metallic scalar value of the material.
  55710. * Can also be used to scale the metalness values of the metallic texture.
  55711. */
  55712. metallic: number;
  55713. /**
  55714. * Specifies the roughness scalar value of the material.
  55715. * Can also be used to scale the roughness values of the metallic texture.
  55716. */
  55717. roughness: number;
  55718. /**
  55719. * Texture containing both the metallic value in the B channel and the
  55720. * roughness value in the G channel to keep better precision.
  55721. */
  55722. metallicRoughnessTexture: BaseTexture;
  55723. /**
  55724. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55725. *
  55726. * @param name The material name
  55727. * @param scene The scene the material will be use in.
  55728. */
  55729. constructor(name: string, scene: Scene);
  55730. /**
  55731. * Return the currrent class name of the material.
  55732. */
  55733. getClassName(): string;
  55734. /**
  55735. * Makes a duplicate of the current material.
  55736. * @param name - name to use for the new material.
  55737. */
  55738. clone(name: string): PBRMetallicRoughnessMaterial;
  55739. /**
  55740. * Serialize the material to a parsable JSON object.
  55741. */
  55742. serialize(): any;
  55743. /**
  55744. * Parses a JSON object correponding to the serialize function.
  55745. */
  55746. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55747. }
  55748. }
  55749. declare module BABYLON {
  55750. /**
  55751. * The PBR material of BJS following the specular glossiness convention.
  55752. *
  55753. * This fits to the PBR convention in the GLTF definition:
  55754. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55755. */
  55756. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55757. /**
  55758. * Specifies the diffuse color of the material.
  55759. */
  55760. diffuseColor: Color3;
  55761. /**
  55762. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55763. * channel.
  55764. */
  55765. diffuseTexture: BaseTexture;
  55766. /**
  55767. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55768. */
  55769. specularColor: Color3;
  55770. /**
  55771. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55772. */
  55773. glossiness: number;
  55774. /**
  55775. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55776. */
  55777. specularGlossinessTexture: BaseTexture;
  55778. /**
  55779. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55780. *
  55781. * @param name The material name
  55782. * @param scene The scene the material will be use in.
  55783. */
  55784. constructor(name: string, scene: Scene);
  55785. /**
  55786. * Return the currrent class name of the material.
  55787. */
  55788. getClassName(): string;
  55789. /**
  55790. * Makes a duplicate of the current material.
  55791. * @param name - name to use for the new material.
  55792. */
  55793. clone(name: string): PBRSpecularGlossinessMaterial;
  55794. /**
  55795. * Serialize the material to a parsable JSON object.
  55796. */
  55797. serialize(): any;
  55798. /**
  55799. * Parses a JSON object correponding to the serialize function.
  55800. */
  55801. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55802. }
  55803. }
  55804. declare module BABYLON {
  55805. /**
  55806. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55807. * It can help converting any input color in a desired output one. This can then be used to create effects
  55808. * from sepia, black and white to sixties or futuristic rendering...
  55809. *
  55810. * The only supported format is currently 3dl.
  55811. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55812. */
  55813. export class ColorGradingTexture extends BaseTexture {
  55814. /**
  55815. * The current texture matrix. (will always be identity in color grading texture)
  55816. */
  55817. private _textureMatrix;
  55818. /**
  55819. * The texture URL.
  55820. */
  55821. url: string;
  55822. /**
  55823. * Empty line regex stored for GC.
  55824. */
  55825. private static _noneEmptyLineRegex;
  55826. private _engine;
  55827. /**
  55828. * Instantiates a ColorGradingTexture from the following parameters.
  55829. *
  55830. * @param url The location of the color gradind data (currently only supporting 3dl)
  55831. * @param scene The scene the texture will be used in
  55832. */
  55833. constructor(url: string, scene: Scene);
  55834. /**
  55835. * Returns the texture matrix used in most of the material.
  55836. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55837. */
  55838. getTextureMatrix(): Matrix;
  55839. /**
  55840. * Occurs when the file being loaded is a .3dl LUT file.
  55841. */
  55842. private load3dlTexture;
  55843. /**
  55844. * Starts the loading process of the texture.
  55845. */
  55846. private loadTexture;
  55847. /**
  55848. * Clones the color gradind texture.
  55849. */
  55850. clone(): ColorGradingTexture;
  55851. /**
  55852. * Called during delayed load for textures.
  55853. */
  55854. delayLoad(): void;
  55855. /**
  55856. * Parses a color grading texture serialized by Babylon.
  55857. * @param parsedTexture The texture information being parsedTexture
  55858. * @param scene The scene to load the texture in
  55859. * @param rootUrl The root url of the data assets to load
  55860. * @return A color gradind texture
  55861. */
  55862. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55863. /**
  55864. * Serializes the LUT texture to json format.
  55865. */
  55866. serialize(): any;
  55867. }
  55868. }
  55869. declare module BABYLON {
  55870. /**
  55871. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55872. */
  55873. export class EquiRectangularCubeTexture extends BaseTexture {
  55874. /** The six faces of the cube. */
  55875. private static _FacesMapping;
  55876. private _noMipmap;
  55877. private _onLoad;
  55878. private _onError;
  55879. /** The size of the cubemap. */
  55880. private _size;
  55881. /** The buffer of the image. */
  55882. private _buffer;
  55883. /** The width of the input image. */
  55884. private _width;
  55885. /** The height of the input image. */
  55886. private _height;
  55887. /** The URL to the image. */
  55888. url: string;
  55889. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55890. coordinatesMode: number;
  55891. /**
  55892. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55893. * @param url The location of the image
  55894. * @param scene The scene the texture will be used in
  55895. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55896. * @param noMipmap Forces to not generate the mipmap if true
  55897. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55898. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55899. * @param onLoad — defines a callback called when texture is loaded
  55900. * @param onError — defines a callback called if there is an error
  55901. */
  55902. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55903. /**
  55904. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55905. */
  55906. private loadImage;
  55907. /**
  55908. * Convert the image buffer into a cubemap and create a CubeTexture.
  55909. */
  55910. private loadTexture;
  55911. /**
  55912. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55913. * @param buffer The ArrayBuffer that should be converted.
  55914. * @returns The buffer as Float32Array.
  55915. */
  55916. private getFloat32ArrayFromArrayBuffer;
  55917. /**
  55918. * Get the current class name of the texture useful for serialization or dynamic coding.
  55919. * @returns "EquiRectangularCubeTexture"
  55920. */
  55921. getClassName(): string;
  55922. /**
  55923. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55924. * @returns A clone of the current EquiRectangularCubeTexture.
  55925. */
  55926. clone(): EquiRectangularCubeTexture;
  55927. }
  55928. }
  55929. declare module BABYLON {
  55930. /**
  55931. * Based on jsTGALoader - Javascript loader for TGA file
  55932. * By Vincent Thibault
  55933. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55934. */
  55935. export class TGATools {
  55936. private static _TYPE_INDEXED;
  55937. private static _TYPE_RGB;
  55938. private static _TYPE_GREY;
  55939. private static _TYPE_RLE_INDEXED;
  55940. private static _TYPE_RLE_RGB;
  55941. private static _TYPE_RLE_GREY;
  55942. private static _ORIGIN_MASK;
  55943. private static _ORIGIN_SHIFT;
  55944. private static _ORIGIN_BL;
  55945. private static _ORIGIN_BR;
  55946. private static _ORIGIN_UL;
  55947. private static _ORIGIN_UR;
  55948. /**
  55949. * Gets the header of a TGA file
  55950. * @param data defines the TGA data
  55951. * @returns the header
  55952. */
  55953. static GetTGAHeader(data: Uint8Array): any;
  55954. /**
  55955. * Uploads TGA content to a Babylon Texture
  55956. * @hidden
  55957. */
  55958. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55959. /** @hidden */
  55960. static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  55961. /** @hidden */
  55962. static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  55963. /** @hidden */
  55964. static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  55965. /** @hidden */
  55966. static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  55967. /** @hidden */
  55968. static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  55969. /** @hidden */
  55970. static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  55971. }
  55972. }
  55973. declare module BABYLON {
  55974. /**
  55975. * Implementation of the TGA Texture Loader.
  55976. * @hidden
  55977. */
  55978. export class _TGATextureLoader implements IInternalTextureLoader {
  55979. /**
  55980. * Defines wether the loader supports cascade loading the different faces.
  55981. */
  55982. readonly supportCascades: boolean;
  55983. /**
  55984. * This returns if the loader support the current file information.
  55985. * @param extension defines the file extension of the file being loaded
  55986. * @returns true if the loader can load the specified file
  55987. */
  55988. canLoad(extension: string): boolean;
  55989. /**
  55990. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55991. * @param data contains the texture data
  55992. * @param texture defines the BabylonJS internal texture
  55993. * @param createPolynomials will be true if polynomials have been requested
  55994. * @param onLoad defines the callback to trigger once the texture is ready
  55995. * @param onError defines the callback to trigger in case of error
  55996. */
  55997. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55998. /**
  55999. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56000. * @param data contains the texture data
  56001. * @param texture defines the BabylonJS internal texture
  56002. * @param callback defines the method to call once ready to upload
  56003. */
  56004. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56005. }
  56006. }
  56007. declare module BABYLON {
  56008. /**
  56009. * Info about the .basis files
  56010. */
  56011. class BasisFileInfo {
  56012. /**
  56013. * If the file has alpha
  56014. */
  56015. hasAlpha: boolean;
  56016. /**
  56017. * Info about each image of the basis file
  56018. */
  56019. images: Array<{
  56020. levels: Array<{
  56021. width: number;
  56022. height: number;
  56023. transcodedPixels: ArrayBufferView;
  56024. }>;
  56025. }>;
  56026. }
  56027. /**
  56028. * Result of transcoding a basis file
  56029. */
  56030. class TranscodeResult {
  56031. /**
  56032. * Info about the .basis file
  56033. */
  56034. fileInfo: BasisFileInfo;
  56035. /**
  56036. * Format to use when loading the file
  56037. */
  56038. format: number;
  56039. }
  56040. /**
  56041. * Configuration options for the Basis transcoder
  56042. */
  56043. export class BasisTranscodeConfiguration {
  56044. /**
  56045. * Supported compression formats used to determine the supported output format of the transcoder
  56046. */
  56047. supportedCompressionFormats?: {
  56048. /**
  56049. * etc1 compression format
  56050. */
  56051. etc1?: boolean;
  56052. /**
  56053. * s3tc compression format
  56054. */
  56055. s3tc?: boolean;
  56056. /**
  56057. * pvrtc compression format
  56058. */
  56059. pvrtc?: boolean;
  56060. /**
  56061. * etc2 compression format
  56062. */
  56063. etc2?: boolean;
  56064. };
  56065. /**
  56066. * If mipmap levels should be loaded for transcoded images (Default: true)
  56067. */
  56068. loadMipmapLevels?: boolean;
  56069. /**
  56070. * Index of a single image to load (Default: all images)
  56071. */
  56072. loadSingleImage?: number;
  56073. }
  56074. /**
  56075. * Used to load .Basis files
  56076. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56077. */
  56078. export class BasisTools {
  56079. private static _IgnoreSupportedFormats;
  56080. /**
  56081. * URL to use when loading the basis transcoder
  56082. */
  56083. static JSModuleURL: string;
  56084. /**
  56085. * URL to use when loading the wasm module for the transcoder
  56086. */
  56087. static WasmModuleURL: string;
  56088. /**
  56089. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56090. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56091. * @returns internal format corresponding to the Basis format
  56092. */
  56093. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56094. private static _WorkerPromise;
  56095. private static _Worker;
  56096. private static _actionId;
  56097. private static _CreateWorkerAsync;
  56098. /**
  56099. * Transcodes a loaded image file to compressed pixel data
  56100. * @param data image data to transcode
  56101. * @param config configuration options for the transcoding
  56102. * @returns a promise resulting in the transcoded image
  56103. */
  56104. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56105. /**
  56106. * Loads a texture from the transcode result
  56107. * @param texture texture load to
  56108. * @param transcodeResult the result of transcoding the basis file to load from
  56109. */
  56110. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56111. }
  56112. }
  56113. declare module BABYLON {
  56114. /**
  56115. * Loader for .basis file format
  56116. */
  56117. export class _BasisTextureLoader implements IInternalTextureLoader {
  56118. /**
  56119. * Defines whether the loader supports cascade loading the different faces.
  56120. */
  56121. readonly supportCascades: boolean;
  56122. /**
  56123. * This returns if the loader support the current file information.
  56124. * @param extension defines the file extension of the file being loaded
  56125. * @returns true if the loader can load the specified file
  56126. */
  56127. canLoad(extension: string): boolean;
  56128. /**
  56129. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56130. * @param data contains the texture data
  56131. * @param texture defines the BabylonJS internal texture
  56132. * @param createPolynomials will be true if polynomials have been requested
  56133. * @param onLoad defines the callback to trigger once the texture is ready
  56134. * @param onError defines the callback to trigger in case of error
  56135. */
  56136. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56137. /**
  56138. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56139. * @param data contains the texture data
  56140. * @param texture defines the BabylonJS internal texture
  56141. * @param callback defines the method to call once ready to upload
  56142. */
  56143. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56144. }
  56145. }
  56146. declare module BABYLON {
  56147. /**
  56148. * 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.
  56149. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56150. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56151. */
  56152. export class CustomProceduralTexture extends ProceduralTexture {
  56153. private _animate;
  56154. private _time;
  56155. private _config;
  56156. private _texturePath;
  56157. /**
  56158. * Instantiates a new Custom Procedural Texture.
  56159. * 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.
  56160. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56161. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56162. * @param name Define the name of the texture
  56163. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56164. * @param size Define the size of the texture to create
  56165. * @param scene Define the scene the texture belongs to
  56166. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56167. * @param generateMipMaps Define if the texture should creates mip maps or not
  56168. */
  56169. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56170. private _loadJson;
  56171. /**
  56172. * Is the texture ready to be used ? (rendered at least once)
  56173. * @returns true if ready, otherwise, false.
  56174. */
  56175. isReady(): boolean;
  56176. /**
  56177. * Render the texture to its associated render target.
  56178. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56179. */
  56180. render(useCameraPostProcess?: boolean): void;
  56181. /**
  56182. * Update the list of dependant textures samplers in the shader.
  56183. */
  56184. updateTextures(): void;
  56185. /**
  56186. * Update the uniform values of the procedural texture in the shader.
  56187. */
  56188. updateShaderUniforms(): void;
  56189. /**
  56190. * Define if the texture animates or not.
  56191. */
  56192. get animate(): boolean;
  56193. set animate(value: boolean);
  56194. }
  56195. }
  56196. declare module BABYLON {
  56197. /** @hidden */
  56198. export var noisePixelShader: {
  56199. name: string;
  56200. shader: string;
  56201. };
  56202. }
  56203. declare module BABYLON {
  56204. /**
  56205. * Class used to generate noise procedural textures
  56206. */
  56207. export class NoiseProceduralTexture extends ProceduralTexture {
  56208. private _time;
  56209. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56210. brightness: number;
  56211. /** Defines the number of octaves to process */
  56212. octaves: number;
  56213. /** Defines the level of persistence (0.8 by default) */
  56214. persistence: number;
  56215. /** Gets or sets animation speed factor (default is 1) */
  56216. animationSpeedFactor: number;
  56217. /**
  56218. * Creates a new NoiseProceduralTexture
  56219. * @param name defines the name fo the texture
  56220. * @param size defines the size of the texture (default is 256)
  56221. * @param scene defines the hosting scene
  56222. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56223. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56224. */
  56225. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56226. private _updateShaderUniforms;
  56227. protected _getDefines(): string;
  56228. /** Generate the current state of the procedural texture */
  56229. render(useCameraPostProcess?: boolean): void;
  56230. /**
  56231. * Serializes this noise procedural texture
  56232. * @returns a serialized noise procedural texture object
  56233. */
  56234. serialize(): any;
  56235. /**
  56236. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56237. * @param parsedTexture defines parsed texture data
  56238. * @param scene defines the current scene
  56239. * @param rootUrl defines the root URL containing noise procedural texture information
  56240. * @returns a parsed NoiseProceduralTexture
  56241. */
  56242. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56243. }
  56244. }
  56245. declare module BABYLON {
  56246. /**
  56247. * Raw cube texture where the raw buffers are passed in
  56248. */
  56249. export class RawCubeTexture extends CubeTexture {
  56250. /**
  56251. * Creates a cube texture where the raw buffers are passed in.
  56252. * @param scene defines the scene the texture is attached to
  56253. * @param data defines the array of data to use to create each face
  56254. * @param size defines the size of the textures
  56255. * @param format defines the format of the data
  56256. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56257. * @param generateMipMaps defines if the engine should generate the mip levels
  56258. * @param invertY defines if data must be stored with Y axis inverted
  56259. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56260. * @param compression defines the compression used (null by default)
  56261. */
  56262. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56263. /**
  56264. * Updates the raw cube texture.
  56265. * @param data defines the data to store
  56266. * @param format defines the data format
  56267. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56268. * @param invertY defines if data must be stored with Y axis inverted
  56269. * @param compression defines the compression used (null by default)
  56270. * @param level defines which level of the texture to update
  56271. */
  56272. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56273. /**
  56274. * Updates a raw cube texture with RGBD encoded data.
  56275. * @param data defines the array of data [mipmap][face] to use to create each face
  56276. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56277. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56278. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56279. * @returns a promsie that resolves when the operation is complete
  56280. */
  56281. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56282. /**
  56283. * Clones the raw cube texture.
  56284. * @return a new cube texture
  56285. */
  56286. clone(): CubeTexture;
  56287. /** @hidden */
  56288. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56289. }
  56290. }
  56291. declare module BABYLON {
  56292. /**
  56293. * Class used to store 3D textures containing user data
  56294. */
  56295. export class RawTexture3D extends Texture {
  56296. /** Gets or sets the texture format to use */
  56297. format: number;
  56298. private _engine;
  56299. /**
  56300. * Create a new RawTexture3D
  56301. * @param data defines the data of the texture
  56302. * @param width defines the width of the texture
  56303. * @param height defines the height of the texture
  56304. * @param depth defines the depth of the texture
  56305. * @param format defines the texture format to use
  56306. * @param scene defines the hosting scene
  56307. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56308. * @param invertY defines if texture must be stored with Y axis inverted
  56309. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56310. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56311. */
  56312. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56313. /** Gets or sets the texture format to use */
  56314. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56315. /**
  56316. * Update the texture with new data
  56317. * @param data defines the data to store in the texture
  56318. */
  56319. update(data: ArrayBufferView): void;
  56320. }
  56321. }
  56322. declare module BABYLON {
  56323. /**
  56324. * Class used to store 2D array textures containing user data
  56325. */
  56326. export class RawTexture2DArray extends Texture {
  56327. /** Gets or sets the texture format to use */
  56328. format: number;
  56329. private _engine;
  56330. /**
  56331. * Create a new RawTexture2DArray
  56332. * @param data defines the data of the texture
  56333. * @param width defines the width of the texture
  56334. * @param height defines the height of the texture
  56335. * @param depth defines the number of layers of the texture
  56336. * @param format defines the texture format to use
  56337. * @param scene defines the hosting scene
  56338. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56339. * @param invertY defines if texture must be stored with Y axis inverted
  56340. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56341. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56342. */
  56343. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56344. /** Gets or sets the texture format to use */
  56345. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56346. /**
  56347. * Update the texture with new data
  56348. * @param data defines the data to store in the texture
  56349. */
  56350. update(data: ArrayBufferView): void;
  56351. }
  56352. }
  56353. declare module BABYLON {
  56354. /**
  56355. * Creates a refraction texture used by refraction channel of the standard material.
  56356. * It is like a mirror but to see through a material.
  56357. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56358. */
  56359. export class RefractionTexture extends RenderTargetTexture {
  56360. /**
  56361. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56362. * 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.
  56363. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56364. */
  56365. refractionPlane: Plane;
  56366. /**
  56367. * Define how deep under the surface we should see.
  56368. */
  56369. depth: number;
  56370. /**
  56371. * Creates a refraction texture used by refraction channel of the standard material.
  56372. * It is like a mirror but to see through a material.
  56373. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56374. * @param name Define the texture name
  56375. * @param size Define the size of the underlying texture
  56376. * @param scene Define the scene the refraction belongs to
  56377. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56378. */
  56379. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56380. /**
  56381. * Clone the refraction texture.
  56382. * @returns the cloned texture
  56383. */
  56384. clone(): RefractionTexture;
  56385. /**
  56386. * Serialize the texture to a JSON representation you could use in Parse later on
  56387. * @returns the serialized JSON representation
  56388. */
  56389. serialize(): any;
  56390. }
  56391. }
  56392. declare module BABYLON {
  56393. /**
  56394. * Defines the options related to the creation of an HtmlElementTexture
  56395. */
  56396. export interface IHtmlElementTextureOptions {
  56397. /**
  56398. * Defines wether mip maps should be created or not.
  56399. */
  56400. generateMipMaps?: boolean;
  56401. /**
  56402. * Defines the sampling mode of the texture.
  56403. */
  56404. samplingMode?: number;
  56405. /**
  56406. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56407. */
  56408. engine: Nullable<ThinEngine>;
  56409. /**
  56410. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56411. */
  56412. scene: Nullable<Scene>;
  56413. }
  56414. /**
  56415. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56416. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56417. * is automatically managed.
  56418. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56419. * in your application.
  56420. *
  56421. * As the update is not automatic, you need to call them manually.
  56422. */
  56423. export class HtmlElementTexture extends BaseTexture {
  56424. /**
  56425. * The texture URL.
  56426. */
  56427. element: HTMLVideoElement | HTMLCanvasElement;
  56428. private static readonly DefaultOptions;
  56429. private _textureMatrix;
  56430. private _engine;
  56431. private _isVideo;
  56432. private _generateMipMaps;
  56433. private _samplingMode;
  56434. /**
  56435. * Instantiates a HtmlElementTexture from the following parameters.
  56436. *
  56437. * @param name Defines the name of the texture
  56438. * @param element Defines the video or canvas the texture is filled with
  56439. * @param options Defines the other none mandatory texture creation options
  56440. */
  56441. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56442. private _createInternalTexture;
  56443. /**
  56444. * Returns the texture matrix used in most of the material.
  56445. */
  56446. getTextureMatrix(): Matrix;
  56447. /**
  56448. * Updates the content of the texture.
  56449. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56450. */
  56451. update(invertY?: Nullable<boolean>): void;
  56452. }
  56453. }
  56454. declare module BABYLON {
  56455. /**
  56456. * Defines the basic options interface of a TexturePacker Frame
  56457. */
  56458. export interface ITexturePackerFrame {
  56459. /**
  56460. * The frame ID
  56461. */
  56462. id: number;
  56463. /**
  56464. * The frames Scale
  56465. */
  56466. scale: Vector2;
  56467. /**
  56468. * The Frames offset
  56469. */
  56470. offset: Vector2;
  56471. }
  56472. /**
  56473. * This is a support class for frame Data on texture packer sets.
  56474. */
  56475. export class TexturePackerFrame implements ITexturePackerFrame {
  56476. /**
  56477. * The frame ID
  56478. */
  56479. id: number;
  56480. /**
  56481. * The frames Scale
  56482. */
  56483. scale: Vector2;
  56484. /**
  56485. * The Frames offset
  56486. */
  56487. offset: Vector2;
  56488. /**
  56489. * Initializes a texture package frame.
  56490. * @param id The numerical frame identifier
  56491. * @param scale Scalar Vector2 for UV frame
  56492. * @param offset Vector2 for the frame position in UV units.
  56493. * @returns TexturePackerFrame
  56494. */
  56495. constructor(id: number, scale: Vector2, offset: Vector2);
  56496. }
  56497. }
  56498. declare module BABYLON {
  56499. /**
  56500. * Defines the basic options interface of a TexturePacker
  56501. */
  56502. export interface ITexturePackerOptions {
  56503. /**
  56504. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56505. */
  56506. map?: string[];
  56507. /**
  56508. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56509. */
  56510. uvsIn?: string;
  56511. /**
  56512. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56513. */
  56514. uvsOut?: string;
  56515. /**
  56516. * number representing the layout style. Defaults to LAYOUT_STRIP
  56517. */
  56518. layout?: number;
  56519. /**
  56520. * number of columns if using custom column count layout(2). This defaults to 4.
  56521. */
  56522. colnum?: number;
  56523. /**
  56524. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56525. */
  56526. updateInputMeshes?: boolean;
  56527. /**
  56528. * boolean flag to dispose all the source textures. Defaults to true.
  56529. */
  56530. disposeSources?: boolean;
  56531. /**
  56532. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56533. */
  56534. fillBlanks?: boolean;
  56535. /**
  56536. * string value representing the context fill style color. Defaults to 'black'.
  56537. */
  56538. customFillColor?: string;
  56539. /**
  56540. * Width and Height Value of each Frame in the TexturePacker Sets
  56541. */
  56542. frameSize?: number;
  56543. /**
  56544. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56545. */
  56546. paddingRatio?: number;
  56547. /**
  56548. * Number that declares the fill method for the padding gutter.
  56549. */
  56550. paddingMode?: number;
  56551. /**
  56552. * If in SUBUV_COLOR padding mode what color to use.
  56553. */
  56554. paddingColor?: Color3 | Color4;
  56555. }
  56556. /**
  56557. * Defines the basic interface of a TexturePacker JSON File
  56558. */
  56559. export interface ITexturePackerJSON {
  56560. /**
  56561. * The frame ID
  56562. */
  56563. name: string;
  56564. /**
  56565. * The base64 channel data
  56566. */
  56567. sets: any;
  56568. /**
  56569. * The options of the Packer
  56570. */
  56571. options: ITexturePackerOptions;
  56572. /**
  56573. * The frame data of the Packer
  56574. */
  56575. frames: Array<number>;
  56576. }
  56577. /**
  56578. * This is a support class that generates a series of packed texture sets.
  56579. * @see https://doc.babylonjs.com/babylon101/materials
  56580. */
  56581. export class TexturePacker {
  56582. /** Packer Layout Constant 0 */
  56583. static readonly LAYOUT_STRIP: number;
  56584. /** Packer Layout Constant 1 */
  56585. static readonly LAYOUT_POWER2: number;
  56586. /** Packer Layout Constant 2 */
  56587. static readonly LAYOUT_COLNUM: number;
  56588. /** Packer Layout Constant 0 */
  56589. static readonly SUBUV_WRAP: number;
  56590. /** Packer Layout Constant 1 */
  56591. static readonly SUBUV_EXTEND: number;
  56592. /** Packer Layout Constant 2 */
  56593. static readonly SUBUV_COLOR: number;
  56594. /** The Name of the Texture Package */
  56595. name: string;
  56596. /** The scene scope of the TexturePacker */
  56597. scene: Scene;
  56598. /** The Meshes to target */
  56599. meshes: AbstractMesh[];
  56600. /** Arguments passed with the Constructor */
  56601. options: ITexturePackerOptions;
  56602. /** The promise that is started upon initialization */
  56603. promise: Nullable<Promise<TexturePacker | string>>;
  56604. /** The Container object for the channel sets that are generated */
  56605. sets: object;
  56606. /** The Container array for the frames that are generated */
  56607. frames: TexturePackerFrame[];
  56608. /** The expected number of textures the system is parsing. */
  56609. private _expecting;
  56610. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56611. private _paddingValue;
  56612. /**
  56613. * Initializes a texture package series from an array of meshes or a single mesh.
  56614. * @param name The name of the package
  56615. * @param meshes The target meshes to compose the package from
  56616. * @param options The arguments that texture packer should follow while building.
  56617. * @param scene The scene which the textures are scoped to.
  56618. * @returns TexturePacker
  56619. */
  56620. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56621. /**
  56622. * Starts the package process
  56623. * @param resolve The promises resolution function
  56624. * @returns TexturePacker
  56625. */
  56626. private _createFrames;
  56627. /**
  56628. * Calculates the Size of the Channel Sets
  56629. * @returns Vector2
  56630. */
  56631. private _calculateSize;
  56632. /**
  56633. * Calculates the UV data for the frames.
  56634. * @param baseSize the base frameSize
  56635. * @param padding the base frame padding
  56636. * @param dtSize size of the Dynamic Texture for that channel
  56637. * @param dtUnits is 1/dtSize
  56638. * @param update flag to update the input meshes
  56639. */
  56640. private _calculateMeshUVFrames;
  56641. /**
  56642. * Calculates the frames Offset.
  56643. * @param index of the frame
  56644. * @returns Vector2
  56645. */
  56646. private _getFrameOffset;
  56647. /**
  56648. * Updates a Mesh to the frame data
  56649. * @param mesh that is the target
  56650. * @param frameID or the frame index
  56651. */
  56652. private _updateMeshUV;
  56653. /**
  56654. * Updates a Meshes materials to use the texture packer channels
  56655. * @param m is the mesh to target
  56656. * @param force all channels on the packer to be set.
  56657. */
  56658. private _updateTextureReferences;
  56659. /**
  56660. * Public method to set a Mesh to a frame
  56661. * @param m that is the target
  56662. * @param frameID or the frame index
  56663. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56664. */
  56665. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56666. /**
  56667. * Starts the async promise to compile the texture packer.
  56668. * @returns Promise<void>
  56669. */
  56670. processAsync(): Promise<void>;
  56671. /**
  56672. * Disposes all textures associated with this packer
  56673. */
  56674. dispose(): void;
  56675. /**
  56676. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56677. * @param imageType is the image type to use.
  56678. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56679. */
  56680. download(imageType?: string, quality?: number): void;
  56681. /**
  56682. * Public method to load a texturePacker JSON file.
  56683. * @param data of the JSON file in string format.
  56684. */
  56685. updateFromJSON(data: string): void;
  56686. }
  56687. }
  56688. declare module BABYLON {
  56689. /**
  56690. * Enum used to define the target of a block
  56691. */
  56692. export enum NodeMaterialBlockTargets {
  56693. /** Vertex shader */
  56694. Vertex = 1,
  56695. /** Fragment shader */
  56696. Fragment = 2,
  56697. /** Neutral */
  56698. Neutral = 4,
  56699. /** Vertex and Fragment */
  56700. VertexAndFragment = 3
  56701. }
  56702. }
  56703. declare module BABYLON {
  56704. /**
  56705. * Defines the kind of connection point for node based material
  56706. */
  56707. export enum NodeMaterialBlockConnectionPointTypes {
  56708. /** Float */
  56709. Float = 1,
  56710. /** Int */
  56711. Int = 2,
  56712. /** Vector2 */
  56713. Vector2 = 4,
  56714. /** Vector3 */
  56715. Vector3 = 8,
  56716. /** Vector4 */
  56717. Vector4 = 16,
  56718. /** Color3 */
  56719. Color3 = 32,
  56720. /** Color4 */
  56721. Color4 = 64,
  56722. /** Matrix */
  56723. Matrix = 128,
  56724. /** Detect type based on connection */
  56725. AutoDetect = 1024,
  56726. /** Output type that will be defined by input type */
  56727. BasedOnInput = 2048
  56728. }
  56729. }
  56730. declare module BABYLON {
  56731. /**
  56732. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56733. */
  56734. export enum NodeMaterialBlockConnectionPointMode {
  56735. /** Value is an uniform */
  56736. Uniform = 0,
  56737. /** Value is a mesh attribute */
  56738. Attribute = 1,
  56739. /** Value is a varying between vertex and fragment shaders */
  56740. Varying = 2,
  56741. /** Mode is undefined */
  56742. Undefined = 3
  56743. }
  56744. }
  56745. declare module BABYLON {
  56746. /**
  56747. * Enum used to define system values e.g. values automatically provided by the system
  56748. */
  56749. export enum NodeMaterialSystemValues {
  56750. /** World */
  56751. World = 1,
  56752. /** View */
  56753. View = 2,
  56754. /** Projection */
  56755. Projection = 3,
  56756. /** ViewProjection */
  56757. ViewProjection = 4,
  56758. /** WorldView */
  56759. WorldView = 5,
  56760. /** WorldViewProjection */
  56761. WorldViewProjection = 6,
  56762. /** CameraPosition */
  56763. CameraPosition = 7,
  56764. /** Fog Color */
  56765. FogColor = 8,
  56766. /** Delta time */
  56767. DeltaTime = 9
  56768. }
  56769. }
  56770. declare module BABYLON {
  56771. /**
  56772. * Root class for all node material optimizers
  56773. */
  56774. export class NodeMaterialOptimizer {
  56775. /**
  56776. * Function used to optimize a NodeMaterial graph
  56777. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56778. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56779. */
  56780. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56781. }
  56782. }
  56783. declare module BABYLON {
  56784. /**
  56785. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56786. */
  56787. export class TransformBlock extends NodeMaterialBlock {
  56788. /**
  56789. * Defines the value to use to complement W value to transform it to a Vector4
  56790. */
  56791. complementW: number;
  56792. /**
  56793. * Defines the value to use to complement z value to transform it to a Vector4
  56794. */
  56795. complementZ: number;
  56796. /**
  56797. * Creates a new TransformBlock
  56798. * @param name defines the block name
  56799. */
  56800. constructor(name: string);
  56801. /**
  56802. * Gets the current class name
  56803. * @returns the class name
  56804. */
  56805. getClassName(): string;
  56806. /**
  56807. * Gets the vector input
  56808. */
  56809. get vector(): NodeMaterialConnectionPoint;
  56810. /**
  56811. * Gets the output component
  56812. */
  56813. get output(): NodeMaterialConnectionPoint;
  56814. /**
  56815. * Gets the xyz output component
  56816. */
  56817. get xyz(): NodeMaterialConnectionPoint;
  56818. /**
  56819. * Gets the matrix transform input
  56820. */
  56821. get transform(): NodeMaterialConnectionPoint;
  56822. protected _buildBlock(state: NodeMaterialBuildState): this;
  56823. serialize(): any;
  56824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56825. protected _dumpPropertiesCode(): string;
  56826. }
  56827. }
  56828. declare module BABYLON {
  56829. /**
  56830. * Block used to output the vertex position
  56831. */
  56832. export class VertexOutputBlock extends NodeMaterialBlock {
  56833. /**
  56834. * Creates a new VertexOutputBlock
  56835. * @param name defines the block name
  56836. */
  56837. constructor(name: string);
  56838. /**
  56839. * Gets the current class name
  56840. * @returns the class name
  56841. */
  56842. getClassName(): string;
  56843. /**
  56844. * Gets the vector input component
  56845. */
  56846. get vector(): NodeMaterialConnectionPoint;
  56847. protected _buildBlock(state: NodeMaterialBuildState): this;
  56848. }
  56849. }
  56850. declare module BABYLON {
  56851. /**
  56852. * Block used to output the final color
  56853. */
  56854. export class FragmentOutputBlock extends NodeMaterialBlock {
  56855. /**
  56856. * Create a new FragmentOutputBlock
  56857. * @param name defines the block name
  56858. */
  56859. constructor(name: string);
  56860. /**
  56861. * Gets the current class name
  56862. * @returns the class name
  56863. */
  56864. getClassName(): string;
  56865. /**
  56866. * Gets the rgba input component
  56867. */
  56868. get rgba(): NodeMaterialConnectionPoint;
  56869. /**
  56870. * Gets the rgb input component
  56871. */
  56872. get rgb(): NodeMaterialConnectionPoint;
  56873. /**
  56874. * Gets the a input component
  56875. */
  56876. get a(): NodeMaterialConnectionPoint;
  56877. protected _buildBlock(state: NodeMaterialBuildState): this;
  56878. }
  56879. }
  56880. declare module BABYLON {
  56881. /**
  56882. * Block used to read a reflection texture from a sampler
  56883. */
  56884. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56885. private _define3DName;
  56886. private _defineCubicName;
  56887. private _defineExplicitName;
  56888. private _defineProjectionName;
  56889. private _defineLocalCubicName;
  56890. private _defineSphericalName;
  56891. private _definePlanarName;
  56892. private _defineEquirectangularName;
  56893. private _defineMirroredEquirectangularFixedName;
  56894. private _defineEquirectangularFixedName;
  56895. private _defineSkyboxName;
  56896. private _cubeSamplerName;
  56897. private _2DSamplerName;
  56898. private _positionUVWName;
  56899. private _directionWName;
  56900. private _reflectionCoordsName;
  56901. private _reflection2DCoordsName;
  56902. private _reflectionColorName;
  56903. private _reflectionMatrixName;
  56904. /**
  56905. * Gets or sets the texture associated with the node
  56906. */
  56907. texture: Nullable<BaseTexture>;
  56908. /**
  56909. * Create a new TextureBlock
  56910. * @param name defines the block name
  56911. */
  56912. constructor(name: string);
  56913. /**
  56914. * Gets the current class name
  56915. * @returns the class name
  56916. */
  56917. getClassName(): string;
  56918. /**
  56919. * Gets the world position input component
  56920. */
  56921. get position(): NodeMaterialConnectionPoint;
  56922. /**
  56923. * Gets the world position input component
  56924. */
  56925. get worldPosition(): NodeMaterialConnectionPoint;
  56926. /**
  56927. * Gets the world normal input component
  56928. */
  56929. get worldNormal(): NodeMaterialConnectionPoint;
  56930. /**
  56931. * Gets the world input component
  56932. */
  56933. get world(): NodeMaterialConnectionPoint;
  56934. /**
  56935. * Gets the camera (or eye) position component
  56936. */
  56937. get cameraPosition(): NodeMaterialConnectionPoint;
  56938. /**
  56939. * Gets the view input component
  56940. */
  56941. get view(): NodeMaterialConnectionPoint;
  56942. /**
  56943. * Gets the rgb output component
  56944. */
  56945. get rgb(): NodeMaterialConnectionPoint;
  56946. /**
  56947. * Gets the r output component
  56948. */
  56949. get r(): NodeMaterialConnectionPoint;
  56950. /**
  56951. * Gets the g output component
  56952. */
  56953. get g(): NodeMaterialConnectionPoint;
  56954. /**
  56955. * Gets the b output component
  56956. */
  56957. get b(): NodeMaterialConnectionPoint;
  56958. autoConfigure(material: NodeMaterial): void;
  56959. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56960. isReady(): boolean;
  56961. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56962. private _injectVertexCode;
  56963. private _writeOutput;
  56964. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56965. protected _dumpPropertiesCode(): string;
  56966. serialize(): any;
  56967. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56968. }
  56969. }
  56970. declare module BABYLON {
  56971. /**
  56972. * Interface used to configure the node material editor
  56973. */
  56974. export interface INodeMaterialEditorOptions {
  56975. /** Define the URl to load node editor script */
  56976. editorURL?: string;
  56977. }
  56978. /** @hidden */
  56979. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56980. NORMAL: boolean;
  56981. TANGENT: boolean;
  56982. UV1: boolean;
  56983. /** BONES */
  56984. NUM_BONE_INFLUENCERS: number;
  56985. BonesPerMesh: number;
  56986. BONETEXTURE: boolean;
  56987. /** MORPH TARGETS */
  56988. MORPHTARGETS: boolean;
  56989. MORPHTARGETS_NORMAL: boolean;
  56990. MORPHTARGETS_TANGENT: boolean;
  56991. MORPHTARGETS_UV: boolean;
  56992. NUM_MORPH_INFLUENCERS: number;
  56993. /** IMAGE PROCESSING */
  56994. IMAGEPROCESSING: boolean;
  56995. VIGNETTE: boolean;
  56996. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56997. VIGNETTEBLENDMODEOPAQUE: boolean;
  56998. TONEMAPPING: boolean;
  56999. TONEMAPPING_ACES: boolean;
  57000. CONTRAST: boolean;
  57001. EXPOSURE: boolean;
  57002. COLORCURVES: boolean;
  57003. COLORGRADING: boolean;
  57004. COLORGRADING3D: boolean;
  57005. SAMPLER3DGREENDEPTH: boolean;
  57006. SAMPLER3DBGRMAP: boolean;
  57007. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57008. /** MISC. */
  57009. BUMPDIRECTUV: number;
  57010. constructor();
  57011. setValue(name: string, value: boolean): void;
  57012. }
  57013. /**
  57014. * Class used to configure NodeMaterial
  57015. */
  57016. export interface INodeMaterialOptions {
  57017. /**
  57018. * Defines if blocks should emit comments
  57019. */
  57020. emitComments: boolean;
  57021. }
  57022. /**
  57023. * Class used to create a node based material built by assembling shader blocks
  57024. */
  57025. export class NodeMaterial extends PushMaterial {
  57026. private static _BuildIdGenerator;
  57027. private _options;
  57028. private _vertexCompilationState;
  57029. private _fragmentCompilationState;
  57030. private _sharedData;
  57031. private _buildId;
  57032. private _buildWasSuccessful;
  57033. private _cachedWorldViewMatrix;
  57034. private _cachedWorldViewProjectionMatrix;
  57035. private _optimizers;
  57036. private _animationFrame;
  57037. /** Define the Url to load node editor script */
  57038. static EditorURL: string;
  57039. /** Define the Url to load snippets */
  57040. static SnippetUrl: string;
  57041. private BJSNODEMATERIALEDITOR;
  57042. /** Get the inspector from bundle or global */
  57043. private _getGlobalNodeMaterialEditor;
  57044. /**
  57045. * Gets or sets data used by visual editor
  57046. * @see https://nme.babylonjs.com
  57047. */
  57048. editorData: any;
  57049. /**
  57050. * 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)
  57051. */
  57052. ignoreAlpha: boolean;
  57053. /**
  57054. * Defines the maximum number of lights that can be used in the material
  57055. */
  57056. maxSimultaneousLights: number;
  57057. /**
  57058. * Observable raised when the material is built
  57059. */
  57060. onBuildObservable: Observable<NodeMaterial>;
  57061. /**
  57062. * Gets or sets the root nodes of the material vertex shader
  57063. */
  57064. _vertexOutputNodes: NodeMaterialBlock[];
  57065. /**
  57066. * Gets or sets the root nodes of the material fragment (pixel) shader
  57067. */
  57068. _fragmentOutputNodes: NodeMaterialBlock[];
  57069. /** Gets or sets options to control the node material overall behavior */
  57070. get options(): INodeMaterialOptions;
  57071. set options(options: INodeMaterialOptions);
  57072. /**
  57073. * Default configuration related to image processing available in the standard Material.
  57074. */
  57075. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57076. /**
  57077. * Gets the image processing configuration used either in this material.
  57078. */
  57079. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57080. /**
  57081. * Sets the Default image processing configuration used either in the this material.
  57082. *
  57083. * If sets to null, the scene one is in use.
  57084. */
  57085. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57086. /**
  57087. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57088. */
  57089. attachedBlocks: NodeMaterialBlock[];
  57090. /**
  57091. * Create a new node based material
  57092. * @param name defines the material name
  57093. * @param scene defines the hosting scene
  57094. * @param options defines creation option
  57095. */
  57096. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57097. /**
  57098. * Gets the current class name of the material e.g. "NodeMaterial"
  57099. * @returns the class name
  57100. */
  57101. getClassName(): string;
  57102. /**
  57103. * Keep track of the image processing observer to allow dispose and replace.
  57104. */
  57105. private _imageProcessingObserver;
  57106. /**
  57107. * Attaches a new image processing configuration to the Standard Material.
  57108. * @param configuration
  57109. */
  57110. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57111. /**
  57112. * Get a block by its name
  57113. * @param name defines the name of the block to retrieve
  57114. * @returns the required block or null if not found
  57115. */
  57116. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57117. /**
  57118. * Get a block by its name
  57119. * @param predicate defines the predicate used to find the good candidate
  57120. * @returns the required block or null if not found
  57121. */
  57122. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57123. /**
  57124. * Get an input block by its name
  57125. * @param predicate defines the predicate used to find the good candidate
  57126. * @returns the required input block or null if not found
  57127. */
  57128. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57129. /**
  57130. * Gets the list of input blocks attached to this material
  57131. * @returns an array of InputBlocks
  57132. */
  57133. getInputBlocks(): InputBlock[];
  57134. /**
  57135. * Adds a new optimizer to the list of optimizers
  57136. * @param optimizer defines the optimizers to add
  57137. * @returns the current material
  57138. */
  57139. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57140. /**
  57141. * Remove an optimizer from the list of optimizers
  57142. * @param optimizer defines the optimizers to remove
  57143. * @returns the current material
  57144. */
  57145. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57146. /**
  57147. * Add a new block to the list of output nodes
  57148. * @param node defines the node to add
  57149. * @returns the current material
  57150. */
  57151. addOutputNode(node: NodeMaterialBlock): this;
  57152. /**
  57153. * Remove a block from the list of root nodes
  57154. * @param node defines the node to remove
  57155. * @returns the current material
  57156. */
  57157. removeOutputNode(node: NodeMaterialBlock): this;
  57158. private _addVertexOutputNode;
  57159. private _removeVertexOutputNode;
  57160. private _addFragmentOutputNode;
  57161. private _removeFragmentOutputNode;
  57162. /**
  57163. * Specifies if the material will require alpha blending
  57164. * @returns a boolean specifying if alpha blending is needed
  57165. */
  57166. needAlphaBlending(): boolean;
  57167. /**
  57168. * Specifies if this material should be rendered in alpha test mode
  57169. * @returns a boolean specifying if an alpha test is needed.
  57170. */
  57171. needAlphaTesting(): boolean;
  57172. private _initializeBlock;
  57173. private _resetDualBlocks;
  57174. /**
  57175. * Remove a block from the current node material
  57176. * @param block defines the block to remove
  57177. */
  57178. removeBlock(block: NodeMaterialBlock): void;
  57179. /**
  57180. * Build the material and generates the inner effect
  57181. * @param verbose defines if the build should log activity
  57182. */
  57183. build(verbose?: boolean): void;
  57184. /**
  57185. * Runs an otpimization phase to try to improve the shader code
  57186. */
  57187. optimize(): void;
  57188. private _prepareDefinesForAttributes;
  57189. /**
  57190. * Get if the submesh is ready to be used and all its information available.
  57191. * Child classes can use it to update shaders
  57192. * @param mesh defines the mesh to check
  57193. * @param subMesh defines which submesh to check
  57194. * @param useInstances specifies that instances should be used
  57195. * @returns a boolean indicating that the submesh is ready or not
  57196. */
  57197. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57198. /**
  57199. * Get a string representing the shaders built by the current node graph
  57200. */
  57201. get compiledShaders(): string;
  57202. /**
  57203. * Binds the world matrix to the material
  57204. * @param world defines the world transformation matrix
  57205. */
  57206. bindOnlyWorldMatrix(world: Matrix): void;
  57207. /**
  57208. * Binds the submesh to this material by preparing the effect and shader to draw
  57209. * @param world defines the world transformation matrix
  57210. * @param mesh defines the mesh containing the submesh
  57211. * @param subMesh defines the submesh to bind the material to
  57212. */
  57213. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57214. /**
  57215. * Gets the active textures from the material
  57216. * @returns an array of textures
  57217. */
  57218. getActiveTextures(): BaseTexture[];
  57219. /**
  57220. * Gets the list of texture blocks
  57221. * @returns an array of texture blocks
  57222. */
  57223. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57224. /**
  57225. * Specifies if the material uses a texture
  57226. * @param texture defines the texture to check against the material
  57227. * @returns a boolean specifying if the material uses the texture
  57228. */
  57229. hasTexture(texture: BaseTexture): boolean;
  57230. /**
  57231. * Disposes the material
  57232. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57233. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57234. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57235. */
  57236. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57237. /** Creates the node editor window. */
  57238. private _createNodeEditor;
  57239. /**
  57240. * Launch the node material editor
  57241. * @param config Define the configuration of the editor
  57242. * @return a promise fulfilled when the node editor is visible
  57243. */
  57244. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57245. /**
  57246. * Clear the current material
  57247. */
  57248. clear(): void;
  57249. /**
  57250. * Clear the current material and set it to a default state
  57251. */
  57252. setToDefault(): void;
  57253. /**
  57254. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57255. * @param url defines the url to load from
  57256. * @returns a promise that will fullfil when the material is fully loaded
  57257. */
  57258. loadAsync(url: string): Promise<void>;
  57259. private _gatherBlocks;
  57260. /**
  57261. * Generate a string containing the code declaration required to create an equivalent of this material
  57262. * @returns a string
  57263. */
  57264. generateCode(): string;
  57265. /**
  57266. * Serializes this material in a JSON representation
  57267. * @returns the serialized material object
  57268. */
  57269. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57270. private _restoreConnections;
  57271. /**
  57272. * Clear the current graph and load a new one from a serialization object
  57273. * @param source defines the JSON representation of the material
  57274. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57275. */
  57276. loadFromSerialization(source: any, rootUrl?: string): void;
  57277. /**
  57278. * Creates a node material from parsed material data
  57279. * @param source defines the JSON representation of the material
  57280. * @param scene defines the hosting scene
  57281. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57282. * @returns a new node material
  57283. */
  57284. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57285. /**
  57286. * Creates a node material from a snippet saved in a remote file
  57287. * @param name defines the name of the material to create
  57288. * @param url defines the url to load from
  57289. * @param scene defines the hosting scene
  57290. * @returns a promise that will resolve to the new node material
  57291. */
  57292. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57293. /**
  57294. * Creates a node material from a snippet saved by the node material editor
  57295. * @param snippetId defines the snippet to load
  57296. * @param scene defines the hosting scene
  57297. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57298. * @returns a promise that will resolve to the new node material
  57299. */
  57300. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57301. /**
  57302. * Creates a new node material set to default basic configuration
  57303. * @param name defines the name of the material
  57304. * @param scene defines the hosting scene
  57305. * @returns a new NodeMaterial
  57306. */
  57307. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57308. }
  57309. }
  57310. declare module BABYLON {
  57311. /**
  57312. * Block used to read a texture from a sampler
  57313. */
  57314. export class TextureBlock extends NodeMaterialBlock {
  57315. private _defineName;
  57316. private _linearDefineName;
  57317. private _tempTextureRead;
  57318. private _samplerName;
  57319. private _transformedUVName;
  57320. private _textureTransformName;
  57321. private _textureInfoName;
  57322. private _mainUVName;
  57323. private _mainUVDefineName;
  57324. /**
  57325. * Gets or sets the texture associated with the node
  57326. */
  57327. texture: Nullable<Texture>;
  57328. /**
  57329. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57330. */
  57331. convertToGammaSpace: boolean;
  57332. /**
  57333. * Create a new TextureBlock
  57334. * @param name defines the block name
  57335. */
  57336. constructor(name: string);
  57337. /**
  57338. * Gets the current class name
  57339. * @returns the class name
  57340. */
  57341. getClassName(): string;
  57342. /**
  57343. * Gets the uv input component
  57344. */
  57345. get uv(): NodeMaterialConnectionPoint;
  57346. /**
  57347. * Gets the rgba output component
  57348. */
  57349. get rgba(): NodeMaterialConnectionPoint;
  57350. /**
  57351. * Gets the rgb output component
  57352. */
  57353. get rgb(): NodeMaterialConnectionPoint;
  57354. /**
  57355. * Gets the r output component
  57356. */
  57357. get r(): NodeMaterialConnectionPoint;
  57358. /**
  57359. * Gets the g output component
  57360. */
  57361. get g(): NodeMaterialConnectionPoint;
  57362. /**
  57363. * Gets the b output component
  57364. */
  57365. get b(): NodeMaterialConnectionPoint;
  57366. /**
  57367. * Gets the a output component
  57368. */
  57369. get a(): NodeMaterialConnectionPoint;
  57370. get target(): NodeMaterialBlockTargets;
  57371. autoConfigure(material: NodeMaterial): void;
  57372. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57373. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57374. isReady(): boolean;
  57375. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57376. private get _isMixed();
  57377. private _injectVertexCode;
  57378. private _writeTextureRead;
  57379. private _writeOutput;
  57380. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57381. protected _dumpPropertiesCode(): string;
  57382. serialize(): any;
  57383. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57384. }
  57385. }
  57386. declare module BABYLON {
  57387. /**
  57388. * Class used to store shared data between 2 NodeMaterialBuildState
  57389. */
  57390. export class NodeMaterialBuildStateSharedData {
  57391. /**
  57392. * Gets the list of emitted varyings
  57393. */
  57394. temps: string[];
  57395. /**
  57396. * Gets the list of emitted varyings
  57397. */
  57398. varyings: string[];
  57399. /**
  57400. * Gets the varying declaration string
  57401. */
  57402. varyingDeclaration: string;
  57403. /**
  57404. * Input blocks
  57405. */
  57406. inputBlocks: InputBlock[];
  57407. /**
  57408. * Input blocks
  57409. */
  57410. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57411. /**
  57412. * Bindable blocks (Blocks that need to set data to the effect)
  57413. */
  57414. bindableBlocks: NodeMaterialBlock[];
  57415. /**
  57416. * List of blocks that can provide a compilation fallback
  57417. */
  57418. blocksWithFallbacks: NodeMaterialBlock[];
  57419. /**
  57420. * List of blocks that can provide a define update
  57421. */
  57422. blocksWithDefines: NodeMaterialBlock[];
  57423. /**
  57424. * List of blocks that can provide a repeatable content
  57425. */
  57426. repeatableContentBlocks: NodeMaterialBlock[];
  57427. /**
  57428. * List of blocks that can provide a dynamic list of uniforms
  57429. */
  57430. dynamicUniformBlocks: NodeMaterialBlock[];
  57431. /**
  57432. * List of blocks that can block the isReady function for the material
  57433. */
  57434. blockingBlocks: NodeMaterialBlock[];
  57435. /**
  57436. * Gets the list of animated inputs
  57437. */
  57438. animatedInputs: InputBlock[];
  57439. /**
  57440. * Build Id used to avoid multiple recompilations
  57441. */
  57442. buildId: number;
  57443. /** List of emitted variables */
  57444. variableNames: {
  57445. [key: string]: number;
  57446. };
  57447. /** List of emitted defines */
  57448. defineNames: {
  57449. [key: string]: number;
  57450. };
  57451. /** Should emit comments? */
  57452. emitComments: boolean;
  57453. /** Emit build activity */
  57454. verbose: boolean;
  57455. /** Gets or sets the hosting scene */
  57456. scene: Scene;
  57457. /**
  57458. * Gets the compilation hints emitted at compilation time
  57459. */
  57460. hints: {
  57461. needWorldViewMatrix: boolean;
  57462. needWorldViewProjectionMatrix: boolean;
  57463. needAlphaBlending: boolean;
  57464. needAlphaTesting: boolean;
  57465. };
  57466. /**
  57467. * List of compilation checks
  57468. */
  57469. checks: {
  57470. emitVertex: boolean;
  57471. emitFragment: boolean;
  57472. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57473. };
  57474. /** Creates a new shared data */
  57475. constructor();
  57476. /**
  57477. * Emits console errors and exceptions if there is a failing check
  57478. */
  57479. emitErrors(): void;
  57480. }
  57481. }
  57482. declare module BABYLON {
  57483. /**
  57484. * Class used to store node based material build state
  57485. */
  57486. export class NodeMaterialBuildState {
  57487. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57488. supportUniformBuffers: boolean;
  57489. /**
  57490. * Gets the list of emitted attributes
  57491. */
  57492. attributes: string[];
  57493. /**
  57494. * Gets the list of emitted uniforms
  57495. */
  57496. uniforms: string[];
  57497. /**
  57498. * Gets the list of emitted constants
  57499. */
  57500. constants: string[];
  57501. /**
  57502. * Gets the list of emitted samplers
  57503. */
  57504. samplers: string[];
  57505. /**
  57506. * Gets the list of emitted functions
  57507. */
  57508. functions: {
  57509. [key: string]: string;
  57510. };
  57511. /**
  57512. * Gets the list of emitted extensions
  57513. */
  57514. extensions: {
  57515. [key: string]: string;
  57516. };
  57517. /**
  57518. * Gets the target of the compilation state
  57519. */
  57520. target: NodeMaterialBlockTargets;
  57521. /**
  57522. * Gets the list of emitted counters
  57523. */
  57524. counters: {
  57525. [key: string]: number;
  57526. };
  57527. /**
  57528. * Shared data between multiple NodeMaterialBuildState instances
  57529. */
  57530. sharedData: NodeMaterialBuildStateSharedData;
  57531. /** @hidden */
  57532. _vertexState: NodeMaterialBuildState;
  57533. /** @hidden */
  57534. _attributeDeclaration: string;
  57535. /** @hidden */
  57536. _uniformDeclaration: string;
  57537. /** @hidden */
  57538. _constantDeclaration: string;
  57539. /** @hidden */
  57540. _samplerDeclaration: string;
  57541. /** @hidden */
  57542. _varyingTransfer: string;
  57543. private _repeatableContentAnchorIndex;
  57544. /** @hidden */
  57545. _builtCompilationString: string;
  57546. /**
  57547. * Gets the emitted compilation strings
  57548. */
  57549. compilationString: string;
  57550. /**
  57551. * Finalize the compilation strings
  57552. * @param state defines the current compilation state
  57553. */
  57554. finalize(state: NodeMaterialBuildState): void;
  57555. /** @hidden */
  57556. get _repeatableContentAnchor(): string;
  57557. /** @hidden */
  57558. _getFreeVariableName(prefix: string): string;
  57559. /** @hidden */
  57560. _getFreeDefineName(prefix: string): string;
  57561. /** @hidden */
  57562. _excludeVariableName(name: string): void;
  57563. /** @hidden */
  57564. _emit2DSampler(name: string): void;
  57565. /** @hidden */
  57566. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57567. /** @hidden */
  57568. _emitExtension(name: string, extension: string): void;
  57569. /** @hidden */
  57570. _emitFunction(name: string, code: string, comments: string): void;
  57571. /** @hidden */
  57572. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57573. replaceStrings?: {
  57574. search: RegExp;
  57575. replace: string;
  57576. }[];
  57577. repeatKey?: string;
  57578. }): string;
  57579. /** @hidden */
  57580. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57581. repeatKey?: string;
  57582. removeAttributes?: boolean;
  57583. removeUniforms?: boolean;
  57584. removeVaryings?: boolean;
  57585. removeIfDef?: boolean;
  57586. replaceStrings?: {
  57587. search: RegExp;
  57588. replace: string;
  57589. }[];
  57590. }, storeKey?: string): void;
  57591. /** @hidden */
  57592. _registerTempVariable(name: string): boolean;
  57593. /** @hidden */
  57594. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57595. /** @hidden */
  57596. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57597. /** @hidden */
  57598. _emitFloat(value: number): string;
  57599. }
  57600. }
  57601. declare module BABYLON {
  57602. /**
  57603. * Defines a block that can be used inside a node based material
  57604. */
  57605. export class NodeMaterialBlock {
  57606. private _buildId;
  57607. private _buildTarget;
  57608. private _target;
  57609. private _isFinalMerger;
  57610. private _isInput;
  57611. protected _isUnique: boolean;
  57612. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57613. inputsAreExclusive: boolean;
  57614. /** @hidden */
  57615. _codeVariableName: string;
  57616. /** @hidden */
  57617. _inputs: NodeMaterialConnectionPoint[];
  57618. /** @hidden */
  57619. _outputs: NodeMaterialConnectionPoint[];
  57620. /** @hidden */
  57621. _preparationId: number;
  57622. /**
  57623. * Gets or sets the name of the block
  57624. */
  57625. name: string;
  57626. /**
  57627. * Gets or sets the unique id of the node
  57628. */
  57629. uniqueId: number;
  57630. /**
  57631. * Gets or sets the comments associated with this block
  57632. */
  57633. comments: string;
  57634. /**
  57635. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57636. */
  57637. get isUnique(): boolean;
  57638. /**
  57639. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57640. */
  57641. get isFinalMerger(): boolean;
  57642. /**
  57643. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57644. */
  57645. get isInput(): boolean;
  57646. /**
  57647. * Gets or sets the build Id
  57648. */
  57649. get buildId(): number;
  57650. set buildId(value: number);
  57651. /**
  57652. * Gets or sets the target of the block
  57653. */
  57654. get target(): NodeMaterialBlockTargets;
  57655. set target(value: NodeMaterialBlockTargets);
  57656. /**
  57657. * Gets the list of input points
  57658. */
  57659. get inputs(): NodeMaterialConnectionPoint[];
  57660. /** Gets the list of output points */
  57661. get outputs(): NodeMaterialConnectionPoint[];
  57662. /**
  57663. * Find an input by its name
  57664. * @param name defines the name of the input to look for
  57665. * @returns the input or null if not found
  57666. */
  57667. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57668. /**
  57669. * Find an output by its name
  57670. * @param name defines the name of the outputto look for
  57671. * @returns the output or null if not found
  57672. */
  57673. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57674. /**
  57675. * Creates a new NodeMaterialBlock
  57676. * @param name defines the block name
  57677. * @param target defines the target of that block (Vertex by default)
  57678. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57679. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57680. */
  57681. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57682. /**
  57683. * Initialize the block and prepare the context for build
  57684. * @param state defines the state that will be used for the build
  57685. */
  57686. initialize(state: NodeMaterialBuildState): void;
  57687. /**
  57688. * Bind data to effect. Will only be called for blocks with isBindable === true
  57689. * @param effect defines the effect to bind data to
  57690. * @param nodeMaterial defines the hosting NodeMaterial
  57691. * @param mesh defines the mesh that will be rendered
  57692. */
  57693. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57694. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57695. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57696. protected _writeFloat(value: number): string;
  57697. /**
  57698. * Gets the current class name e.g. "NodeMaterialBlock"
  57699. * @returns the class name
  57700. */
  57701. getClassName(): string;
  57702. /**
  57703. * Register a new input. Must be called inside a block constructor
  57704. * @param name defines the connection point name
  57705. * @param type defines the connection point type
  57706. * @param isOptional defines a boolean indicating that this input can be omitted
  57707. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57708. * @returns the current block
  57709. */
  57710. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57711. /**
  57712. * Register a new output. Must be called inside a block constructor
  57713. * @param name defines the connection point name
  57714. * @param type defines the connection point type
  57715. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57716. * @returns the current block
  57717. */
  57718. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57719. /**
  57720. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57721. * @param forOutput defines an optional connection point to check compatibility with
  57722. * @returns the first available input or null
  57723. */
  57724. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57725. /**
  57726. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57727. * @param forBlock defines an optional block to check compatibility with
  57728. * @returns the first available input or null
  57729. */
  57730. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57731. /**
  57732. * Gets the sibling of the given output
  57733. * @param current defines the current output
  57734. * @returns the next output in the list or null
  57735. */
  57736. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57737. /**
  57738. * Connect current block with another block
  57739. * @param other defines the block to connect with
  57740. * @param options define the various options to help pick the right connections
  57741. * @returns the current block
  57742. */
  57743. connectTo(other: NodeMaterialBlock, options?: {
  57744. input?: string;
  57745. output?: string;
  57746. outputSwizzle?: string;
  57747. }): this | undefined;
  57748. protected _buildBlock(state: NodeMaterialBuildState): void;
  57749. /**
  57750. * Add uniforms, samplers and uniform buffers at compilation time
  57751. * @param state defines the state to update
  57752. * @param nodeMaterial defines the node material requesting the update
  57753. * @param defines defines the material defines to update
  57754. * @param uniformBuffers defines the list of uniform buffer names
  57755. */
  57756. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57757. /**
  57758. * Add potential fallbacks if shader compilation fails
  57759. * @param mesh defines the mesh to be rendered
  57760. * @param fallbacks defines the current prioritized list of fallbacks
  57761. */
  57762. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57763. /**
  57764. * Initialize defines for shader compilation
  57765. * @param mesh defines the mesh to be rendered
  57766. * @param nodeMaterial defines the node material requesting the update
  57767. * @param defines defines the material defines to update
  57768. * @param useInstances specifies that instances should be used
  57769. */
  57770. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57771. /**
  57772. * Update defines for shader compilation
  57773. * @param mesh defines the mesh to be rendered
  57774. * @param nodeMaterial defines the node material requesting the update
  57775. * @param defines defines the material defines to update
  57776. * @param useInstances specifies that instances should be used
  57777. */
  57778. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57779. /**
  57780. * Lets the block try to connect some inputs automatically
  57781. * @param material defines the hosting NodeMaterial
  57782. */
  57783. autoConfigure(material: NodeMaterial): void;
  57784. /**
  57785. * Function called when a block is declared as repeatable content generator
  57786. * @param vertexShaderState defines the current compilation state for the vertex shader
  57787. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57788. * @param mesh defines the mesh to be rendered
  57789. * @param defines defines the material defines to update
  57790. */
  57791. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57792. /**
  57793. * Checks if the block is ready
  57794. * @param mesh defines the mesh to be rendered
  57795. * @param nodeMaterial defines the node material requesting the update
  57796. * @param defines defines the material defines to update
  57797. * @param useInstances specifies that instances should be used
  57798. * @returns true if the block is ready
  57799. */
  57800. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57801. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57802. private _processBuild;
  57803. /**
  57804. * Compile the current node and generate the shader code
  57805. * @param state defines the current compilation state (uniforms, samplers, current string)
  57806. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57807. * @returns true if already built
  57808. */
  57809. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57810. protected _inputRename(name: string): string;
  57811. protected _outputRename(name: string): string;
  57812. protected _dumpPropertiesCode(): string;
  57813. /** @hidden */
  57814. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57815. /** @hidden */
  57816. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57817. /**
  57818. * Clone the current block to a new identical block
  57819. * @param scene defines the hosting scene
  57820. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57821. * @returns a copy of the current block
  57822. */
  57823. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57824. /**
  57825. * Serializes this block in a JSON representation
  57826. * @returns the serialized block object
  57827. */
  57828. serialize(): any;
  57829. /** @hidden */
  57830. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57831. /**
  57832. * Release resources
  57833. */
  57834. dispose(): void;
  57835. }
  57836. }
  57837. declare module BABYLON {
  57838. /**
  57839. * Enum defining the type of animations supported by InputBlock
  57840. */
  57841. export enum AnimatedInputBlockTypes {
  57842. /** No animation */
  57843. None = 0,
  57844. /** Time based animation. Will only work for floats */
  57845. Time = 1
  57846. }
  57847. }
  57848. declare module BABYLON {
  57849. /**
  57850. * Block used to expose an input value
  57851. */
  57852. export class InputBlock extends NodeMaterialBlock {
  57853. private _mode;
  57854. private _associatedVariableName;
  57855. private _storedValue;
  57856. private _valueCallback;
  57857. private _type;
  57858. private _animationType;
  57859. /** Gets or set a value used to limit the range of float values */
  57860. min: number;
  57861. /** Gets or set a value used to limit the range of float values */
  57862. max: number;
  57863. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57864. isBoolean: boolean;
  57865. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57866. matrixMode: number;
  57867. /** @hidden */
  57868. _systemValue: Nullable<NodeMaterialSystemValues>;
  57869. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57870. visibleInInspector: boolean;
  57871. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57872. isConstant: boolean;
  57873. /** Gets or sets the group to use to display this block in the Inspector */
  57874. groupInInspector: string;
  57875. /** Gets an observable raised when the value is changed */
  57876. onValueChangedObservable: Observable<InputBlock>;
  57877. /**
  57878. * Gets or sets the connection point type (default is float)
  57879. */
  57880. get type(): NodeMaterialBlockConnectionPointTypes;
  57881. /**
  57882. * Creates a new InputBlock
  57883. * @param name defines the block name
  57884. * @param target defines the target of that block (Vertex by default)
  57885. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57886. */
  57887. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57888. /**
  57889. * Gets the output component
  57890. */
  57891. get output(): NodeMaterialConnectionPoint;
  57892. /**
  57893. * Set the source of this connection point to a vertex attribute
  57894. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57895. * @returns the current connection point
  57896. */
  57897. setAsAttribute(attributeName?: string): InputBlock;
  57898. /**
  57899. * Set the source of this connection point to a system value
  57900. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57901. * @returns the current connection point
  57902. */
  57903. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57904. /**
  57905. * Gets or sets the value of that point.
  57906. * Please note that this value will be ignored if valueCallback is defined
  57907. */
  57908. get value(): any;
  57909. set value(value: any);
  57910. /**
  57911. * Gets or sets a callback used to get the value of that point.
  57912. * Please note that setting this value will force the connection point to ignore the value property
  57913. */
  57914. get valueCallback(): () => any;
  57915. set valueCallback(value: () => any);
  57916. /**
  57917. * Gets or sets the associated variable name in the shader
  57918. */
  57919. get associatedVariableName(): string;
  57920. set associatedVariableName(value: string);
  57921. /** Gets or sets the type of animation applied to the input */
  57922. get animationType(): AnimatedInputBlockTypes;
  57923. set animationType(value: AnimatedInputBlockTypes);
  57924. /**
  57925. * Gets a boolean indicating that this connection point not defined yet
  57926. */
  57927. get isUndefined(): boolean;
  57928. /**
  57929. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57930. * In this case the connection point name must be the name of the uniform to use.
  57931. * Can only be set on inputs
  57932. */
  57933. get isUniform(): boolean;
  57934. set isUniform(value: boolean);
  57935. /**
  57936. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57937. * In this case the connection point name must be the name of the attribute to use
  57938. * Can only be set on inputs
  57939. */
  57940. get isAttribute(): boolean;
  57941. set isAttribute(value: boolean);
  57942. /**
  57943. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57944. * Can only be set on exit points
  57945. */
  57946. get isVarying(): boolean;
  57947. set isVarying(value: boolean);
  57948. /**
  57949. * Gets a boolean indicating that the current connection point is a system value
  57950. */
  57951. get isSystemValue(): boolean;
  57952. /**
  57953. * Gets or sets the current well known value or null if not defined as a system value
  57954. */
  57955. get systemValue(): Nullable<NodeMaterialSystemValues>;
  57956. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  57957. /**
  57958. * Gets the current class name
  57959. * @returns the class name
  57960. */
  57961. getClassName(): string;
  57962. /**
  57963. * Animate the input if animationType !== None
  57964. * @param scene defines the rendering scene
  57965. */
  57966. animate(scene: Scene): void;
  57967. private _emitDefine;
  57968. initialize(state: NodeMaterialBuildState): void;
  57969. /**
  57970. * Set the input block to its default value (based on its type)
  57971. */
  57972. setDefaultValue(): void;
  57973. private _emitConstant;
  57974. private _emit;
  57975. /** @hidden */
  57976. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57977. /** @hidden */
  57978. _transmit(effect: Effect, scene: Scene): void;
  57979. protected _buildBlock(state: NodeMaterialBuildState): void;
  57980. protected _dumpPropertiesCode(): string;
  57981. dispose(): void;
  57982. serialize(): any;
  57983. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57984. }
  57985. }
  57986. declare module BABYLON {
  57987. /**
  57988. * Enum used to define the compatibility state between two connection points
  57989. */
  57990. export enum NodeMaterialConnectionPointCompatibilityStates {
  57991. /** Points are compatibles */
  57992. Compatible = 0,
  57993. /** Points are incompatible because of their types */
  57994. TypeIncompatible = 1,
  57995. /** Points are incompatible because of their targets (vertex vs fragment) */
  57996. TargetIncompatible = 2
  57997. }
  57998. /**
  57999. * Defines the direction of a connection point
  58000. */
  58001. export enum NodeMaterialConnectionPointDirection {
  58002. /** Input */
  58003. Input = 0,
  58004. /** Output */
  58005. Output = 1
  58006. }
  58007. /**
  58008. * Defines a connection point for a block
  58009. */
  58010. export class NodeMaterialConnectionPoint {
  58011. /** @hidden */
  58012. _ownerBlock: NodeMaterialBlock;
  58013. /** @hidden */
  58014. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58015. private _endpoints;
  58016. private _associatedVariableName;
  58017. private _direction;
  58018. /** @hidden */
  58019. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58020. /** @hidden */
  58021. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58022. private _type;
  58023. /** @hidden */
  58024. _enforceAssociatedVariableName: boolean;
  58025. /** Gets the direction of the point */
  58026. get direction(): NodeMaterialConnectionPointDirection;
  58027. /**
  58028. * Gets or sets the additional types supported by this connection point
  58029. */
  58030. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58031. /**
  58032. * Gets or sets the additional types excluded by this connection point
  58033. */
  58034. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58035. /**
  58036. * Observable triggered when this point is connected
  58037. */
  58038. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58039. /**
  58040. * Gets or sets the associated variable name in the shader
  58041. */
  58042. get associatedVariableName(): string;
  58043. set associatedVariableName(value: string);
  58044. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58045. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58046. /**
  58047. * Gets or sets the connection point type (default is float)
  58048. */
  58049. get type(): NodeMaterialBlockConnectionPointTypes;
  58050. set type(value: NodeMaterialBlockConnectionPointTypes);
  58051. /**
  58052. * Gets or sets the connection point name
  58053. */
  58054. name: string;
  58055. /**
  58056. * Gets or sets a boolean indicating that this connection point can be omitted
  58057. */
  58058. isOptional: boolean;
  58059. /**
  58060. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58061. */
  58062. define: string;
  58063. /** @hidden */
  58064. _prioritizeVertex: boolean;
  58065. private _target;
  58066. /** Gets or sets the target of that connection point */
  58067. get target(): NodeMaterialBlockTargets;
  58068. set target(value: NodeMaterialBlockTargets);
  58069. /**
  58070. * Gets a boolean indicating that the current point is connected
  58071. */
  58072. get isConnected(): boolean;
  58073. /**
  58074. * Gets a boolean indicating that the current point is connected to an input block
  58075. */
  58076. get isConnectedToInputBlock(): boolean;
  58077. /**
  58078. * Gets a the connected input block (if any)
  58079. */
  58080. get connectInputBlock(): Nullable<InputBlock>;
  58081. /** Get the other side of the connection (if any) */
  58082. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58083. /** Get the block that owns this connection point */
  58084. get ownerBlock(): NodeMaterialBlock;
  58085. /** Get the block connected on the other side of this connection (if any) */
  58086. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58087. /** Get the block connected on the endpoints of this connection (if any) */
  58088. get connectedBlocks(): Array<NodeMaterialBlock>;
  58089. /** Gets the list of connected endpoints */
  58090. get endpoints(): NodeMaterialConnectionPoint[];
  58091. /** Gets a boolean indicating if that output point is connected to at least one input */
  58092. get hasEndpoints(): boolean;
  58093. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58094. get isConnectedInVertexShader(): boolean;
  58095. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58096. get isConnectedInFragmentShader(): boolean;
  58097. /**
  58098. * Creates a new connection point
  58099. * @param name defines the connection point name
  58100. * @param ownerBlock defines the block hosting this connection point
  58101. * @param direction defines the direction of the connection point
  58102. */
  58103. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58104. /**
  58105. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58106. * @returns the class name
  58107. */
  58108. getClassName(): string;
  58109. /**
  58110. * Gets a boolean indicating if the current point can be connected to another point
  58111. * @param connectionPoint defines the other connection point
  58112. * @returns a boolean
  58113. */
  58114. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58115. /**
  58116. * Gets a number indicating if the current point can be connected to another point
  58117. * @param connectionPoint defines the other connection point
  58118. * @returns a number defining the compatibility state
  58119. */
  58120. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58121. /**
  58122. * Connect this point to another connection point
  58123. * @param connectionPoint defines the other connection point
  58124. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58125. * @returns the current connection point
  58126. */
  58127. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58128. /**
  58129. * Disconnect this point from one of his endpoint
  58130. * @param endpoint defines the other connection point
  58131. * @returns the current connection point
  58132. */
  58133. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58134. /**
  58135. * Serializes this point in a JSON representation
  58136. * @returns the serialized point object
  58137. */
  58138. serialize(): any;
  58139. /**
  58140. * Release resources
  58141. */
  58142. dispose(): void;
  58143. }
  58144. }
  58145. declare module BABYLON {
  58146. /**
  58147. * Block used to add support for vertex skinning (bones)
  58148. */
  58149. export class BonesBlock extends NodeMaterialBlock {
  58150. /**
  58151. * Creates a new BonesBlock
  58152. * @param name defines the block name
  58153. */
  58154. constructor(name: string);
  58155. /**
  58156. * Initialize the block and prepare the context for build
  58157. * @param state defines the state that will be used for the build
  58158. */
  58159. initialize(state: NodeMaterialBuildState): void;
  58160. /**
  58161. * Gets the current class name
  58162. * @returns the class name
  58163. */
  58164. getClassName(): string;
  58165. /**
  58166. * Gets the matrix indices input component
  58167. */
  58168. get matricesIndices(): NodeMaterialConnectionPoint;
  58169. /**
  58170. * Gets the matrix weights input component
  58171. */
  58172. get matricesWeights(): NodeMaterialConnectionPoint;
  58173. /**
  58174. * Gets the extra matrix indices input component
  58175. */
  58176. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58177. /**
  58178. * Gets the extra matrix weights input component
  58179. */
  58180. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58181. /**
  58182. * Gets the world input component
  58183. */
  58184. get world(): NodeMaterialConnectionPoint;
  58185. /**
  58186. * Gets the output component
  58187. */
  58188. get output(): NodeMaterialConnectionPoint;
  58189. autoConfigure(material: NodeMaterial): void;
  58190. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58191. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58192. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58193. protected _buildBlock(state: NodeMaterialBuildState): this;
  58194. }
  58195. }
  58196. declare module BABYLON {
  58197. /**
  58198. * Block used to add support for instances
  58199. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58200. */
  58201. export class InstancesBlock extends NodeMaterialBlock {
  58202. /**
  58203. * Creates a new InstancesBlock
  58204. * @param name defines the block name
  58205. */
  58206. constructor(name: string);
  58207. /**
  58208. * Gets the current class name
  58209. * @returns the class name
  58210. */
  58211. getClassName(): string;
  58212. /**
  58213. * Gets the first world row input component
  58214. */
  58215. get world0(): NodeMaterialConnectionPoint;
  58216. /**
  58217. * Gets the second world row input component
  58218. */
  58219. get world1(): NodeMaterialConnectionPoint;
  58220. /**
  58221. * Gets the third world row input component
  58222. */
  58223. get world2(): NodeMaterialConnectionPoint;
  58224. /**
  58225. * Gets the forth world row input component
  58226. */
  58227. get world3(): NodeMaterialConnectionPoint;
  58228. /**
  58229. * Gets the world input component
  58230. */
  58231. get world(): NodeMaterialConnectionPoint;
  58232. /**
  58233. * Gets the output component
  58234. */
  58235. get output(): NodeMaterialConnectionPoint;
  58236. /**
  58237. * Gets the isntanceID component
  58238. */
  58239. get instanceID(): NodeMaterialConnectionPoint;
  58240. autoConfigure(material: NodeMaterial): void;
  58241. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58242. protected _buildBlock(state: NodeMaterialBuildState): this;
  58243. }
  58244. }
  58245. declare module BABYLON {
  58246. /**
  58247. * Block used to add morph targets support to vertex shader
  58248. */
  58249. export class MorphTargetsBlock extends NodeMaterialBlock {
  58250. private _repeatableContentAnchor;
  58251. /**
  58252. * Create a new MorphTargetsBlock
  58253. * @param name defines the block name
  58254. */
  58255. constructor(name: string);
  58256. /**
  58257. * Gets the current class name
  58258. * @returns the class name
  58259. */
  58260. getClassName(): string;
  58261. /**
  58262. * Gets the position input component
  58263. */
  58264. get position(): NodeMaterialConnectionPoint;
  58265. /**
  58266. * Gets the normal input component
  58267. */
  58268. get normal(): NodeMaterialConnectionPoint;
  58269. /**
  58270. * Gets the tangent input component
  58271. */
  58272. get tangent(): NodeMaterialConnectionPoint;
  58273. /**
  58274. * Gets the tangent input component
  58275. */
  58276. get uv(): NodeMaterialConnectionPoint;
  58277. /**
  58278. * Gets the position output component
  58279. */
  58280. get positionOutput(): NodeMaterialConnectionPoint;
  58281. /**
  58282. * Gets the normal output component
  58283. */
  58284. get normalOutput(): NodeMaterialConnectionPoint;
  58285. /**
  58286. * Gets the tangent output component
  58287. */
  58288. get tangentOutput(): NodeMaterialConnectionPoint;
  58289. /**
  58290. * Gets the tangent output component
  58291. */
  58292. get uvOutput(): NodeMaterialConnectionPoint;
  58293. initialize(state: NodeMaterialBuildState): void;
  58294. autoConfigure(material: NodeMaterial): void;
  58295. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58296. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58297. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58298. protected _buildBlock(state: NodeMaterialBuildState): this;
  58299. }
  58300. }
  58301. declare module BABYLON {
  58302. /**
  58303. * Block used to get data information from a light
  58304. */
  58305. export class LightInformationBlock extends NodeMaterialBlock {
  58306. private _lightDataUniformName;
  58307. private _lightColorUniformName;
  58308. private _lightTypeDefineName;
  58309. /**
  58310. * Gets or sets the light associated with this block
  58311. */
  58312. light: Nullable<Light>;
  58313. /**
  58314. * Creates a new LightInformationBlock
  58315. * @param name defines the block name
  58316. */
  58317. constructor(name: string);
  58318. /**
  58319. * Gets the current class name
  58320. * @returns the class name
  58321. */
  58322. getClassName(): string;
  58323. /**
  58324. * Gets the world position input component
  58325. */
  58326. get worldPosition(): NodeMaterialConnectionPoint;
  58327. /**
  58328. * Gets the direction output component
  58329. */
  58330. get direction(): NodeMaterialConnectionPoint;
  58331. /**
  58332. * Gets the direction output component
  58333. */
  58334. get color(): NodeMaterialConnectionPoint;
  58335. /**
  58336. * Gets the direction output component
  58337. */
  58338. get intensity(): NodeMaterialConnectionPoint;
  58339. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58340. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58341. protected _buildBlock(state: NodeMaterialBuildState): this;
  58342. serialize(): any;
  58343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58344. }
  58345. }
  58346. declare module BABYLON {
  58347. /**
  58348. * Block used to add image processing support to fragment shader
  58349. */
  58350. export class ImageProcessingBlock extends NodeMaterialBlock {
  58351. /**
  58352. * Create a new ImageProcessingBlock
  58353. * @param name defines the block name
  58354. */
  58355. constructor(name: string);
  58356. /**
  58357. * Gets the current class name
  58358. * @returns the class name
  58359. */
  58360. getClassName(): string;
  58361. /**
  58362. * Gets the color input component
  58363. */
  58364. get color(): NodeMaterialConnectionPoint;
  58365. /**
  58366. * Gets the output component
  58367. */
  58368. get output(): NodeMaterialConnectionPoint;
  58369. /**
  58370. * Initialize the block and prepare the context for build
  58371. * @param state defines the state that will be used for the build
  58372. */
  58373. initialize(state: NodeMaterialBuildState): void;
  58374. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58375. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58376. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58377. protected _buildBlock(state: NodeMaterialBuildState): this;
  58378. }
  58379. }
  58380. declare module BABYLON {
  58381. /**
  58382. * Block used to pertub normals based on a normal map
  58383. */
  58384. export class PerturbNormalBlock extends NodeMaterialBlock {
  58385. private _tangentSpaceParameterName;
  58386. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58387. invertX: boolean;
  58388. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58389. invertY: boolean;
  58390. /**
  58391. * Create a new PerturbNormalBlock
  58392. * @param name defines the block name
  58393. */
  58394. constructor(name: string);
  58395. /**
  58396. * Gets the current class name
  58397. * @returns the class name
  58398. */
  58399. getClassName(): string;
  58400. /**
  58401. * Gets the world position input component
  58402. */
  58403. get worldPosition(): NodeMaterialConnectionPoint;
  58404. /**
  58405. * Gets the world normal input component
  58406. */
  58407. get worldNormal(): NodeMaterialConnectionPoint;
  58408. /**
  58409. * Gets the world tangent input component
  58410. */
  58411. get worldTangent(): NodeMaterialConnectionPoint;
  58412. /**
  58413. * Gets the uv input component
  58414. */
  58415. get uv(): NodeMaterialConnectionPoint;
  58416. /**
  58417. * Gets the normal map color input component
  58418. */
  58419. get normalMapColor(): NodeMaterialConnectionPoint;
  58420. /**
  58421. * Gets the strength input component
  58422. */
  58423. get strength(): NodeMaterialConnectionPoint;
  58424. /**
  58425. * Gets the output component
  58426. */
  58427. get output(): NodeMaterialConnectionPoint;
  58428. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58429. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58430. autoConfigure(material: NodeMaterial): void;
  58431. protected _buildBlock(state: NodeMaterialBuildState): this;
  58432. protected _dumpPropertiesCode(): string;
  58433. serialize(): any;
  58434. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58435. }
  58436. }
  58437. declare module BABYLON {
  58438. /**
  58439. * Block used to discard a pixel if a value is smaller than a cutoff
  58440. */
  58441. export class DiscardBlock extends NodeMaterialBlock {
  58442. /**
  58443. * Create a new DiscardBlock
  58444. * @param name defines the block name
  58445. */
  58446. constructor(name: string);
  58447. /**
  58448. * Gets the current class name
  58449. * @returns the class name
  58450. */
  58451. getClassName(): string;
  58452. /**
  58453. * Gets the color input component
  58454. */
  58455. get value(): NodeMaterialConnectionPoint;
  58456. /**
  58457. * Gets the cutoff input component
  58458. */
  58459. get cutoff(): NodeMaterialConnectionPoint;
  58460. protected _buildBlock(state: NodeMaterialBuildState): this;
  58461. }
  58462. }
  58463. declare module BABYLON {
  58464. /**
  58465. * Block used to test if the fragment shader is front facing
  58466. */
  58467. export class FrontFacingBlock extends NodeMaterialBlock {
  58468. /**
  58469. * Creates a new FrontFacingBlock
  58470. * @param name defines the block name
  58471. */
  58472. constructor(name: string);
  58473. /**
  58474. * Gets the current class name
  58475. * @returns the class name
  58476. */
  58477. getClassName(): string;
  58478. /**
  58479. * Gets the output component
  58480. */
  58481. get output(): NodeMaterialConnectionPoint;
  58482. protected _buildBlock(state: NodeMaterialBuildState): this;
  58483. }
  58484. }
  58485. declare module BABYLON {
  58486. /**
  58487. * Block used to get the derivative value on x and y of a given input
  58488. */
  58489. export class DerivativeBlock extends NodeMaterialBlock {
  58490. /**
  58491. * Create a new DerivativeBlock
  58492. * @param name defines the block name
  58493. */
  58494. constructor(name: string);
  58495. /**
  58496. * Gets the current class name
  58497. * @returns the class name
  58498. */
  58499. getClassName(): string;
  58500. /**
  58501. * Gets the input component
  58502. */
  58503. get input(): NodeMaterialConnectionPoint;
  58504. /**
  58505. * Gets the derivative output on x
  58506. */
  58507. get dx(): NodeMaterialConnectionPoint;
  58508. /**
  58509. * Gets the derivative output on y
  58510. */
  58511. get dy(): NodeMaterialConnectionPoint;
  58512. protected _buildBlock(state: NodeMaterialBuildState): this;
  58513. }
  58514. }
  58515. declare module BABYLON {
  58516. /**
  58517. * Block used to add support for scene fog
  58518. */
  58519. export class FogBlock extends NodeMaterialBlock {
  58520. private _fogDistanceName;
  58521. private _fogParameters;
  58522. /**
  58523. * Create a new FogBlock
  58524. * @param name defines the block name
  58525. */
  58526. constructor(name: string);
  58527. /**
  58528. * Gets the current class name
  58529. * @returns the class name
  58530. */
  58531. getClassName(): string;
  58532. /**
  58533. * Gets the world position input component
  58534. */
  58535. get worldPosition(): NodeMaterialConnectionPoint;
  58536. /**
  58537. * Gets the view input component
  58538. */
  58539. get view(): NodeMaterialConnectionPoint;
  58540. /**
  58541. * Gets the color input component
  58542. */
  58543. get input(): NodeMaterialConnectionPoint;
  58544. /**
  58545. * Gets the fog color input component
  58546. */
  58547. get fogColor(): NodeMaterialConnectionPoint;
  58548. /**
  58549. * Gets the output component
  58550. */
  58551. get output(): NodeMaterialConnectionPoint;
  58552. autoConfigure(material: NodeMaterial): void;
  58553. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58554. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58555. protected _buildBlock(state: NodeMaterialBuildState): this;
  58556. }
  58557. }
  58558. declare module BABYLON {
  58559. /**
  58560. * Block used to add light in the fragment shader
  58561. */
  58562. export class LightBlock extends NodeMaterialBlock {
  58563. private _lightId;
  58564. /**
  58565. * Gets or sets the light associated with this block
  58566. */
  58567. light: Nullable<Light>;
  58568. /**
  58569. * Create a new LightBlock
  58570. * @param name defines the block name
  58571. */
  58572. constructor(name: string);
  58573. /**
  58574. * Gets the current class name
  58575. * @returns the class name
  58576. */
  58577. getClassName(): string;
  58578. /**
  58579. * Gets the world position input component
  58580. */
  58581. get worldPosition(): NodeMaterialConnectionPoint;
  58582. /**
  58583. * Gets the world normal input component
  58584. */
  58585. get worldNormal(): NodeMaterialConnectionPoint;
  58586. /**
  58587. * Gets the camera (or eye) position component
  58588. */
  58589. get cameraPosition(): NodeMaterialConnectionPoint;
  58590. /**
  58591. * Gets the glossiness component
  58592. */
  58593. get glossiness(): NodeMaterialConnectionPoint;
  58594. /**
  58595. * Gets the glossinness power component
  58596. */
  58597. get glossPower(): NodeMaterialConnectionPoint;
  58598. /**
  58599. * Gets the diffuse color component
  58600. */
  58601. get diffuseColor(): NodeMaterialConnectionPoint;
  58602. /**
  58603. * Gets the specular color component
  58604. */
  58605. get specularColor(): NodeMaterialConnectionPoint;
  58606. /**
  58607. * Gets the diffuse output component
  58608. */
  58609. get diffuseOutput(): NodeMaterialConnectionPoint;
  58610. /**
  58611. * Gets the specular output component
  58612. */
  58613. get specularOutput(): NodeMaterialConnectionPoint;
  58614. /**
  58615. * Gets the shadow output component
  58616. */
  58617. get shadow(): NodeMaterialConnectionPoint;
  58618. autoConfigure(material: NodeMaterial): void;
  58619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58620. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58621. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58622. private _injectVertexCode;
  58623. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58624. serialize(): any;
  58625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58626. }
  58627. }
  58628. declare module BABYLON {
  58629. /**
  58630. * Block used to multiply 2 values
  58631. */
  58632. export class MultiplyBlock extends NodeMaterialBlock {
  58633. /**
  58634. * Creates a new MultiplyBlock
  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 add 2 vectors
  58661. */
  58662. export class AddBlock extends NodeMaterialBlock {
  58663. /**
  58664. * Creates a new AddBlock
  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 left operand input component
  58675. */
  58676. get left(): NodeMaterialConnectionPoint;
  58677. /**
  58678. * Gets the right operand input component
  58679. */
  58680. get right(): 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 scale a vector by a float
  58691. */
  58692. export class ScaleBlock extends NodeMaterialBlock {
  58693. /**
  58694. * Creates a new ScaleBlock
  58695. * @param name defines the block name
  58696. */
  58697. constructor(name: string);
  58698. /**
  58699. * Gets the current class name
  58700. * @returns the class name
  58701. */
  58702. getClassName(): string;
  58703. /**
  58704. * Gets the input component
  58705. */
  58706. get input(): NodeMaterialConnectionPoint;
  58707. /**
  58708. * Gets the factor input component
  58709. */
  58710. get factor(): NodeMaterialConnectionPoint;
  58711. /**
  58712. * Gets the output component
  58713. */
  58714. get output(): NodeMaterialConnectionPoint;
  58715. protected _buildBlock(state: NodeMaterialBuildState): this;
  58716. }
  58717. }
  58718. declare module BABYLON {
  58719. /**
  58720. * Block used to clamp a float
  58721. */
  58722. export class ClampBlock extends NodeMaterialBlock {
  58723. /** Gets or sets the minimum range */
  58724. minimum: number;
  58725. /** Gets or sets the maximum range */
  58726. maximum: number;
  58727. /**
  58728. * Creates a new ClampBlock
  58729. * @param name defines the block name
  58730. */
  58731. constructor(name: string);
  58732. /**
  58733. * Gets the current class name
  58734. * @returns the class name
  58735. */
  58736. getClassName(): string;
  58737. /**
  58738. * Gets the value input component
  58739. */
  58740. get value(): NodeMaterialConnectionPoint;
  58741. /**
  58742. * Gets the output component
  58743. */
  58744. get output(): NodeMaterialConnectionPoint;
  58745. protected _buildBlock(state: NodeMaterialBuildState): this;
  58746. protected _dumpPropertiesCode(): string;
  58747. serialize(): any;
  58748. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58749. }
  58750. }
  58751. declare module BABYLON {
  58752. /**
  58753. * Block used to apply a cross product between 2 vectors
  58754. */
  58755. export class CrossBlock extends NodeMaterialBlock {
  58756. /**
  58757. * Creates a new CrossBlock
  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 apply a dot product between 2 vectors
  58784. */
  58785. export class DotBlock extends NodeMaterialBlock {
  58786. /**
  58787. * Creates a new DotBlock
  58788. * @param name defines the block name
  58789. */
  58790. constructor(name: string);
  58791. /**
  58792. * Gets the current class name
  58793. * @returns the class name
  58794. */
  58795. getClassName(): string;
  58796. /**
  58797. * Gets the left operand input component
  58798. */
  58799. get left(): NodeMaterialConnectionPoint;
  58800. /**
  58801. * Gets the right operand input component
  58802. */
  58803. get right(): NodeMaterialConnectionPoint;
  58804. /**
  58805. * Gets the output component
  58806. */
  58807. get output(): NodeMaterialConnectionPoint;
  58808. protected _buildBlock(state: NodeMaterialBuildState): this;
  58809. }
  58810. }
  58811. declare module BABYLON {
  58812. /**
  58813. * Block used to remap a float from a range to a new one
  58814. */
  58815. export class RemapBlock extends NodeMaterialBlock {
  58816. /**
  58817. * Gets or sets the source range
  58818. */
  58819. sourceRange: Vector2;
  58820. /**
  58821. * Gets or sets the target range
  58822. */
  58823. targetRange: Vector2;
  58824. /**
  58825. * Creates a new RemapBlock
  58826. * @param name defines the block name
  58827. */
  58828. constructor(name: string);
  58829. /**
  58830. * Gets the current class name
  58831. * @returns the class name
  58832. */
  58833. getClassName(): string;
  58834. /**
  58835. * Gets the input component
  58836. */
  58837. get input(): NodeMaterialConnectionPoint;
  58838. /**
  58839. * Gets the source min input component
  58840. */
  58841. get sourceMin(): NodeMaterialConnectionPoint;
  58842. /**
  58843. * Gets the source max input component
  58844. */
  58845. get sourceMax(): NodeMaterialConnectionPoint;
  58846. /**
  58847. * Gets the target min input component
  58848. */
  58849. get targetMin(): NodeMaterialConnectionPoint;
  58850. /**
  58851. * Gets the target max input component
  58852. */
  58853. get targetMax(): NodeMaterialConnectionPoint;
  58854. /**
  58855. * Gets the output component
  58856. */
  58857. get output(): NodeMaterialConnectionPoint;
  58858. protected _buildBlock(state: NodeMaterialBuildState): this;
  58859. protected _dumpPropertiesCode(): string;
  58860. serialize(): any;
  58861. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58862. }
  58863. }
  58864. declare module BABYLON {
  58865. /**
  58866. * Block used to normalize a vector
  58867. */
  58868. export class NormalizeBlock extends NodeMaterialBlock {
  58869. /**
  58870. * Creates a new NormalizeBlock
  58871. * @param name defines the block name
  58872. */
  58873. constructor(name: string);
  58874. /**
  58875. * Gets the current class name
  58876. * @returns the class name
  58877. */
  58878. getClassName(): string;
  58879. /**
  58880. * Gets the input component
  58881. */
  58882. get input(): NodeMaterialConnectionPoint;
  58883. /**
  58884. * Gets the output component
  58885. */
  58886. get output(): NodeMaterialConnectionPoint;
  58887. protected _buildBlock(state: NodeMaterialBuildState): this;
  58888. }
  58889. }
  58890. declare module BABYLON {
  58891. /**
  58892. * Operations supported by the Trigonometry block
  58893. */
  58894. export enum TrigonometryBlockOperations {
  58895. /** Cos */
  58896. Cos = 0,
  58897. /** Sin */
  58898. Sin = 1,
  58899. /** Abs */
  58900. Abs = 2,
  58901. /** Exp */
  58902. Exp = 3,
  58903. /** Exp2 */
  58904. Exp2 = 4,
  58905. /** Round */
  58906. Round = 5,
  58907. /** Floor */
  58908. Floor = 6,
  58909. /** Ceiling */
  58910. Ceiling = 7,
  58911. /** Square root */
  58912. Sqrt = 8,
  58913. /** Log */
  58914. Log = 9,
  58915. /** Tangent */
  58916. Tan = 10,
  58917. /** Arc tangent */
  58918. ArcTan = 11,
  58919. /** Arc cosinus */
  58920. ArcCos = 12,
  58921. /** Arc sinus */
  58922. ArcSin = 13,
  58923. /** Fraction */
  58924. Fract = 14,
  58925. /** Sign */
  58926. Sign = 15,
  58927. /** To radians (from degrees) */
  58928. Radians = 16,
  58929. /** To degrees (from radians) */
  58930. Degrees = 17
  58931. }
  58932. /**
  58933. * Block used to apply trigonometry operation to floats
  58934. */
  58935. export class TrigonometryBlock extends NodeMaterialBlock {
  58936. /**
  58937. * Gets or sets the operation applied by the block
  58938. */
  58939. operation: TrigonometryBlockOperations;
  58940. /**
  58941. * Creates a new TrigonometryBlock
  58942. * @param name defines the block name
  58943. */
  58944. constructor(name: string);
  58945. /**
  58946. * Gets the current class name
  58947. * @returns the class name
  58948. */
  58949. getClassName(): string;
  58950. /**
  58951. * Gets the input component
  58952. */
  58953. get input(): NodeMaterialConnectionPoint;
  58954. /**
  58955. * Gets the output component
  58956. */
  58957. get output(): NodeMaterialConnectionPoint;
  58958. protected _buildBlock(state: NodeMaterialBuildState): this;
  58959. serialize(): any;
  58960. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58961. protected _dumpPropertiesCode(): string;
  58962. }
  58963. }
  58964. declare module BABYLON {
  58965. /**
  58966. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58967. */
  58968. export class ColorMergerBlock extends NodeMaterialBlock {
  58969. /**
  58970. * Create a new ColorMergerBlock
  58971. * @param name defines the block name
  58972. */
  58973. constructor(name: string);
  58974. /**
  58975. * Gets the current class name
  58976. * @returns the class name
  58977. */
  58978. getClassName(): string;
  58979. /**
  58980. * Gets the rgb component (input)
  58981. */
  58982. get rgbIn(): NodeMaterialConnectionPoint;
  58983. /**
  58984. * Gets the r component (input)
  58985. */
  58986. get r(): NodeMaterialConnectionPoint;
  58987. /**
  58988. * Gets the g component (input)
  58989. */
  58990. get g(): NodeMaterialConnectionPoint;
  58991. /**
  58992. * Gets the b component (input)
  58993. */
  58994. get b(): NodeMaterialConnectionPoint;
  58995. /**
  58996. * Gets the a component (input)
  58997. */
  58998. get a(): NodeMaterialConnectionPoint;
  58999. /**
  59000. * Gets the rgba component (output)
  59001. */
  59002. get rgba(): NodeMaterialConnectionPoint;
  59003. /**
  59004. * Gets the rgb component (output)
  59005. */
  59006. get rgbOut(): NodeMaterialConnectionPoint;
  59007. /**
  59008. * Gets the rgb component (output)
  59009. * @deprecated Please use rgbOut instead.
  59010. */
  59011. get rgb(): NodeMaterialConnectionPoint;
  59012. protected _buildBlock(state: NodeMaterialBuildState): this;
  59013. }
  59014. }
  59015. declare module BABYLON {
  59016. /**
  59017. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59018. */
  59019. export class VectorMergerBlock extends NodeMaterialBlock {
  59020. /**
  59021. * Create a new VectorMergerBlock
  59022. * @param name defines the block name
  59023. */
  59024. constructor(name: string);
  59025. /**
  59026. * Gets the current class name
  59027. * @returns the class name
  59028. */
  59029. getClassName(): string;
  59030. /**
  59031. * Gets the xyz component (input)
  59032. */
  59033. get xyzIn(): NodeMaterialConnectionPoint;
  59034. /**
  59035. * Gets the xy component (input)
  59036. */
  59037. get xyIn(): NodeMaterialConnectionPoint;
  59038. /**
  59039. * Gets the x component (input)
  59040. */
  59041. get x(): NodeMaterialConnectionPoint;
  59042. /**
  59043. * Gets the y component (input)
  59044. */
  59045. get y(): NodeMaterialConnectionPoint;
  59046. /**
  59047. * Gets the z component (input)
  59048. */
  59049. get z(): NodeMaterialConnectionPoint;
  59050. /**
  59051. * Gets the w component (input)
  59052. */
  59053. get w(): NodeMaterialConnectionPoint;
  59054. /**
  59055. * Gets the xyzw component (output)
  59056. */
  59057. get xyzw(): NodeMaterialConnectionPoint;
  59058. /**
  59059. * Gets the xyz component (output)
  59060. */
  59061. get xyzOut(): NodeMaterialConnectionPoint;
  59062. /**
  59063. * Gets the xy component (output)
  59064. */
  59065. get xyOut(): NodeMaterialConnectionPoint;
  59066. /**
  59067. * Gets the xy component (output)
  59068. * @deprecated Please use xyOut instead.
  59069. */
  59070. get xy(): NodeMaterialConnectionPoint;
  59071. /**
  59072. * Gets the xyz component (output)
  59073. * @deprecated Please use xyzOut instead.
  59074. */
  59075. get xyz(): NodeMaterialConnectionPoint;
  59076. protected _buildBlock(state: NodeMaterialBuildState): this;
  59077. }
  59078. }
  59079. declare module BABYLON {
  59080. /**
  59081. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59082. */
  59083. export class ColorSplitterBlock extends NodeMaterialBlock {
  59084. /**
  59085. * Create a new ColorSplitterBlock
  59086. * @param name defines the block name
  59087. */
  59088. constructor(name: string);
  59089. /**
  59090. * Gets the current class name
  59091. * @returns the class name
  59092. */
  59093. getClassName(): string;
  59094. /**
  59095. * Gets the rgba component (input)
  59096. */
  59097. get rgba(): NodeMaterialConnectionPoint;
  59098. /**
  59099. * Gets the rgb component (input)
  59100. */
  59101. get rgbIn(): NodeMaterialConnectionPoint;
  59102. /**
  59103. * Gets the rgb component (output)
  59104. */
  59105. get rgbOut(): NodeMaterialConnectionPoint;
  59106. /**
  59107. * Gets the r component (output)
  59108. */
  59109. get r(): NodeMaterialConnectionPoint;
  59110. /**
  59111. * Gets the g component (output)
  59112. */
  59113. get g(): NodeMaterialConnectionPoint;
  59114. /**
  59115. * Gets the b component (output)
  59116. */
  59117. get b(): NodeMaterialConnectionPoint;
  59118. /**
  59119. * Gets the a component (output)
  59120. */
  59121. get a(): NodeMaterialConnectionPoint;
  59122. protected _inputRename(name: string): string;
  59123. protected _outputRename(name: string): string;
  59124. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59125. }
  59126. }
  59127. declare module BABYLON {
  59128. /**
  59129. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59130. */
  59131. export class VectorSplitterBlock extends NodeMaterialBlock {
  59132. /**
  59133. * Create a new VectorSplitterBlock
  59134. * @param name defines the block name
  59135. */
  59136. constructor(name: string);
  59137. /**
  59138. * Gets the current class name
  59139. * @returns the class name
  59140. */
  59141. getClassName(): string;
  59142. /**
  59143. * Gets the xyzw component (input)
  59144. */
  59145. get xyzw(): NodeMaterialConnectionPoint;
  59146. /**
  59147. * Gets the xyz component (input)
  59148. */
  59149. get xyzIn(): NodeMaterialConnectionPoint;
  59150. /**
  59151. * Gets the xy component (input)
  59152. */
  59153. get xyIn(): NodeMaterialConnectionPoint;
  59154. /**
  59155. * Gets the xyz component (output)
  59156. */
  59157. get xyzOut(): NodeMaterialConnectionPoint;
  59158. /**
  59159. * Gets the xy component (output)
  59160. */
  59161. get xyOut(): NodeMaterialConnectionPoint;
  59162. /**
  59163. * Gets the x component (output)
  59164. */
  59165. get x(): NodeMaterialConnectionPoint;
  59166. /**
  59167. * Gets the y component (output)
  59168. */
  59169. get y(): NodeMaterialConnectionPoint;
  59170. /**
  59171. * Gets the z component (output)
  59172. */
  59173. get z(): NodeMaterialConnectionPoint;
  59174. /**
  59175. * Gets the w component (output)
  59176. */
  59177. get w(): NodeMaterialConnectionPoint;
  59178. protected _inputRename(name: string): string;
  59179. protected _outputRename(name: string): string;
  59180. protected _buildBlock(state: NodeMaterialBuildState): this;
  59181. }
  59182. }
  59183. declare module BABYLON {
  59184. /**
  59185. * Block used to lerp between 2 values
  59186. */
  59187. export class LerpBlock extends NodeMaterialBlock {
  59188. /**
  59189. * Creates a new LerpBlock
  59190. * @param name defines the block name
  59191. */
  59192. constructor(name: string);
  59193. /**
  59194. * Gets the current class name
  59195. * @returns the class name
  59196. */
  59197. getClassName(): string;
  59198. /**
  59199. * Gets the left operand input component
  59200. */
  59201. get left(): NodeMaterialConnectionPoint;
  59202. /**
  59203. * Gets the right operand input component
  59204. */
  59205. get right(): NodeMaterialConnectionPoint;
  59206. /**
  59207. * Gets the gradient operand input component
  59208. */
  59209. get gradient(): 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 divide 2 vectors
  59220. */
  59221. export class DivideBlock extends NodeMaterialBlock {
  59222. /**
  59223. * Creates a new DivideBlock
  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 subtract 2 vectors
  59250. */
  59251. export class SubtractBlock extends NodeMaterialBlock {
  59252. /**
  59253. * Creates a new SubtractBlock
  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 left operand input component
  59264. */
  59265. get left(): NodeMaterialConnectionPoint;
  59266. /**
  59267. * Gets the right operand input component
  59268. */
  59269. get right(): 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 step a value
  59280. */
  59281. export class StepBlock extends NodeMaterialBlock {
  59282. /**
  59283. * Creates a new StepBlock
  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 value operand input component
  59294. */
  59295. get value(): NodeMaterialConnectionPoint;
  59296. /**
  59297. * Gets the edge operand input component
  59298. */
  59299. get edge(): NodeMaterialConnectionPoint;
  59300. /**
  59301. * Gets the output component
  59302. */
  59303. get output(): NodeMaterialConnectionPoint;
  59304. protected _buildBlock(state: NodeMaterialBuildState): this;
  59305. }
  59306. }
  59307. declare module BABYLON {
  59308. /**
  59309. * Block used to get the opposite (1 - x) of a value
  59310. */
  59311. export class OneMinusBlock extends NodeMaterialBlock {
  59312. /**
  59313. * Creates a new OneMinusBlock
  59314. * @param name defines the block name
  59315. */
  59316. constructor(name: string);
  59317. /**
  59318. * Gets the current class name
  59319. * @returns the class name
  59320. */
  59321. getClassName(): string;
  59322. /**
  59323. * Gets the input component
  59324. */
  59325. get input(): NodeMaterialConnectionPoint;
  59326. /**
  59327. * Gets the output component
  59328. */
  59329. get output(): NodeMaterialConnectionPoint;
  59330. protected _buildBlock(state: NodeMaterialBuildState): this;
  59331. }
  59332. }
  59333. declare module BABYLON {
  59334. /**
  59335. * Block used to get the view direction
  59336. */
  59337. export class ViewDirectionBlock extends NodeMaterialBlock {
  59338. /**
  59339. * Creates a new ViewDirectionBlock
  59340. * @param name defines the block name
  59341. */
  59342. constructor(name: string);
  59343. /**
  59344. * Gets the current class name
  59345. * @returns the class name
  59346. */
  59347. getClassName(): string;
  59348. /**
  59349. * Gets the world position component
  59350. */
  59351. get worldPosition(): NodeMaterialConnectionPoint;
  59352. /**
  59353. * Gets the camera position component
  59354. */
  59355. get cameraPosition(): NodeMaterialConnectionPoint;
  59356. /**
  59357. * Gets the output component
  59358. */
  59359. get output(): NodeMaterialConnectionPoint;
  59360. autoConfigure(material: NodeMaterial): void;
  59361. protected _buildBlock(state: NodeMaterialBuildState): this;
  59362. }
  59363. }
  59364. declare module BABYLON {
  59365. /**
  59366. * Block used to compute fresnel value
  59367. */
  59368. export class FresnelBlock extends NodeMaterialBlock {
  59369. /**
  59370. * Create a new FresnelBlock
  59371. * @param name defines the block name
  59372. */
  59373. constructor(name: string);
  59374. /**
  59375. * Gets the current class name
  59376. * @returns the class name
  59377. */
  59378. getClassName(): string;
  59379. /**
  59380. * Gets the world normal input component
  59381. */
  59382. get worldNormal(): NodeMaterialConnectionPoint;
  59383. /**
  59384. * Gets the view direction input component
  59385. */
  59386. get viewDirection(): NodeMaterialConnectionPoint;
  59387. /**
  59388. * Gets the bias input component
  59389. */
  59390. get bias(): NodeMaterialConnectionPoint;
  59391. /**
  59392. * Gets the camera (or eye) position component
  59393. */
  59394. get power(): NodeMaterialConnectionPoint;
  59395. /**
  59396. * Gets the fresnel output component
  59397. */
  59398. get fresnel(): NodeMaterialConnectionPoint;
  59399. autoConfigure(material: NodeMaterial): void;
  59400. protected _buildBlock(state: NodeMaterialBuildState): this;
  59401. }
  59402. }
  59403. declare module BABYLON {
  59404. /**
  59405. * Block used to get the max of 2 values
  59406. */
  59407. export class MaxBlock extends NodeMaterialBlock {
  59408. /**
  59409. * Creates a new MaxBlock
  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 min of 2 values
  59436. */
  59437. export class MinBlock extends NodeMaterialBlock {
  59438. /**
  59439. * Creates a new MinBlock
  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 distance between 2 values
  59466. */
  59467. export class DistanceBlock extends NodeMaterialBlock {
  59468. /**
  59469. * Creates a new DistanceBlock
  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 left operand input component
  59480. */
  59481. get left(): NodeMaterialConnectionPoint;
  59482. /**
  59483. * Gets the right operand input component
  59484. */
  59485. get right(): NodeMaterialConnectionPoint;
  59486. /**
  59487. * Gets the output component
  59488. */
  59489. get output(): NodeMaterialConnectionPoint;
  59490. protected _buildBlock(state: NodeMaterialBuildState): this;
  59491. }
  59492. }
  59493. declare module BABYLON {
  59494. /**
  59495. * Block used to get the length of a vector
  59496. */
  59497. export class LengthBlock extends NodeMaterialBlock {
  59498. /**
  59499. * Creates a new LengthBlock
  59500. * @param name defines the block name
  59501. */
  59502. constructor(name: string);
  59503. /**
  59504. * Gets the current class name
  59505. * @returns the class name
  59506. */
  59507. getClassName(): string;
  59508. /**
  59509. * Gets the value input component
  59510. */
  59511. get value(): NodeMaterialConnectionPoint;
  59512. /**
  59513. * Gets the output component
  59514. */
  59515. get output(): NodeMaterialConnectionPoint;
  59516. protected _buildBlock(state: NodeMaterialBuildState): this;
  59517. }
  59518. }
  59519. declare module BABYLON {
  59520. /**
  59521. * Block used to get negative version of a value (i.e. x * -1)
  59522. */
  59523. export class NegateBlock extends NodeMaterialBlock {
  59524. /**
  59525. * Creates a new NegateBlock
  59526. * @param name defines the block name
  59527. */
  59528. constructor(name: string);
  59529. /**
  59530. * Gets the current class name
  59531. * @returns the class name
  59532. */
  59533. getClassName(): string;
  59534. /**
  59535. * Gets the value input component
  59536. */
  59537. get value(): 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 the value of the first parameter raised to the power of the second
  59548. */
  59549. export class PowBlock extends NodeMaterialBlock {
  59550. /**
  59551. * Creates a new PowBlock
  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 value operand input component
  59562. */
  59563. get value(): NodeMaterialConnectionPoint;
  59564. /**
  59565. * Gets the power operand input component
  59566. */
  59567. get power(): NodeMaterialConnectionPoint;
  59568. /**
  59569. * Gets the output component
  59570. */
  59571. get output(): NodeMaterialConnectionPoint;
  59572. protected _buildBlock(state: NodeMaterialBuildState): this;
  59573. }
  59574. }
  59575. declare module BABYLON {
  59576. /**
  59577. * Block used to get a random number
  59578. */
  59579. export class RandomNumberBlock extends NodeMaterialBlock {
  59580. /**
  59581. * Creates a new RandomNumberBlock
  59582. * @param name defines the block name
  59583. */
  59584. constructor(name: string);
  59585. /**
  59586. * Gets the current class name
  59587. * @returns the class name
  59588. */
  59589. getClassName(): string;
  59590. /**
  59591. * Gets the seed input component
  59592. */
  59593. get seed(): 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 compute arc tangent of 2 values
  59604. */
  59605. export class ArcTan2Block extends NodeMaterialBlock {
  59606. /**
  59607. * Creates a new ArcTan2Block
  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 x operand input component
  59618. */
  59619. get x(): NodeMaterialConnectionPoint;
  59620. /**
  59621. * Gets the y operand input component
  59622. */
  59623. get y(): NodeMaterialConnectionPoint;
  59624. /**
  59625. * Gets the output component
  59626. */
  59627. get output(): NodeMaterialConnectionPoint;
  59628. protected _buildBlock(state: NodeMaterialBuildState): this;
  59629. }
  59630. }
  59631. declare module BABYLON {
  59632. /**
  59633. * Block used to smooth step a value
  59634. */
  59635. export class SmoothStepBlock extends NodeMaterialBlock {
  59636. /**
  59637. * Creates a new SmoothStepBlock
  59638. * @param name defines the block name
  59639. */
  59640. constructor(name: string);
  59641. /**
  59642. * Gets the current class name
  59643. * @returns the class name
  59644. */
  59645. getClassName(): string;
  59646. /**
  59647. * Gets the value operand input component
  59648. */
  59649. get value(): NodeMaterialConnectionPoint;
  59650. /**
  59651. * Gets the first edge operand input component
  59652. */
  59653. get edge0(): NodeMaterialConnectionPoint;
  59654. /**
  59655. * Gets the second edge operand input component
  59656. */
  59657. get edge1(): NodeMaterialConnectionPoint;
  59658. /**
  59659. * Gets the output component
  59660. */
  59661. get output(): NodeMaterialConnectionPoint;
  59662. protected _buildBlock(state: NodeMaterialBuildState): this;
  59663. }
  59664. }
  59665. declare module BABYLON {
  59666. /**
  59667. * Block used to get the reciprocal (1 / x) of a value
  59668. */
  59669. export class ReciprocalBlock extends NodeMaterialBlock {
  59670. /**
  59671. * Creates a new ReciprocalBlock
  59672. * @param name defines the block name
  59673. */
  59674. constructor(name: string);
  59675. /**
  59676. * Gets the current class name
  59677. * @returns the class name
  59678. */
  59679. getClassName(): string;
  59680. /**
  59681. * Gets the input component
  59682. */
  59683. get input(): NodeMaterialConnectionPoint;
  59684. /**
  59685. * Gets the output component
  59686. */
  59687. get output(): NodeMaterialConnectionPoint;
  59688. protected _buildBlock(state: NodeMaterialBuildState): this;
  59689. }
  59690. }
  59691. declare module BABYLON {
  59692. /**
  59693. * Block used to replace a color by another one
  59694. */
  59695. export class ReplaceColorBlock extends NodeMaterialBlock {
  59696. /**
  59697. * Creates a new ReplaceColorBlock
  59698. * @param name defines the block name
  59699. */
  59700. constructor(name: string);
  59701. /**
  59702. * Gets the current class name
  59703. * @returns the class name
  59704. */
  59705. getClassName(): string;
  59706. /**
  59707. * Gets the value input component
  59708. */
  59709. get value(): NodeMaterialConnectionPoint;
  59710. /**
  59711. * Gets the reference input component
  59712. */
  59713. get reference(): NodeMaterialConnectionPoint;
  59714. /**
  59715. * Gets the distance input component
  59716. */
  59717. get distance(): NodeMaterialConnectionPoint;
  59718. /**
  59719. * Gets the replacement input component
  59720. */
  59721. get replacement(): NodeMaterialConnectionPoint;
  59722. /**
  59723. * Gets the output component
  59724. */
  59725. get output(): NodeMaterialConnectionPoint;
  59726. protected _buildBlock(state: NodeMaterialBuildState): this;
  59727. }
  59728. }
  59729. declare module BABYLON {
  59730. /**
  59731. * Block used to posterize a value
  59732. * @see https://en.wikipedia.org/wiki/Posterization
  59733. */
  59734. export class PosterizeBlock extends NodeMaterialBlock {
  59735. /**
  59736. * Creates a new PosterizeBlock
  59737. * @param name defines the block name
  59738. */
  59739. constructor(name: string);
  59740. /**
  59741. * Gets the current class name
  59742. * @returns the class name
  59743. */
  59744. getClassName(): string;
  59745. /**
  59746. * Gets the value input component
  59747. */
  59748. get value(): NodeMaterialConnectionPoint;
  59749. /**
  59750. * Gets the steps input component
  59751. */
  59752. get steps(): NodeMaterialConnectionPoint;
  59753. /**
  59754. * Gets the output component
  59755. */
  59756. get output(): NodeMaterialConnectionPoint;
  59757. protected _buildBlock(state: NodeMaterialBuildState): this;
  59758. }
  59759. }
  59760. declare module BABYLON {
  59761. /**
  59762. * Operations supported by the Wave block
  59763. */
  59764. export enum WaveBlockKind {
  59765. /** SawTooth */
  59766. SawTooth = 0,
  59767. /** Square */
  59768. Square = 1,
  59769. /** Triangle */
  59770. Triangle = 2
  59771. }
  59772. /**
  59773. * Block used to apply wave operation to floats
  59774. */
  59775. export class WaveBlock extends NodeMaterialBlock {
  59776. /**
  59777. * Gets or sets the kibnd of wave to be applied by the block
  59778. */
  59779. kind: WaveBlockKind;
  59780. /**
  59781. * Creates a new WaveBlock
  59782. * @param name defines the block name
  59783. */
  59784. constructor(name: string);
  59785. /**
  59786. * Gets the current class name
  59787. * @returns the class name
  59788. */
  59789. getClassName(): string;
  59790. /**
  59791. * Gets the input component
  59792. */
  59793. get input(): NodeMaterialConnectionPoint;
  59794. /**
  59795. * Gets the output component
  59796. */
  59797. get output(): NodeMaterialConnectionPoint;
  59798. protected _buildBlock(state: NodeMaterialBuildState): this;
  59799. serialize(): any;
  59800. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59801. }
  59802. }
  59803. declare module BABYLON {
  59804. /**
  59805. * Class used to store a color step for the GradientBlock
  59806. */
  59807. export class GradientBlockColorStep {
  59808. /**
  59809. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59810. */
  59811. step: number;
  59812. /**
  59813. * Gets or sets the color associated with this step
  59814. */
  59815. color: Color3;
  59816. /**
  59817. * Creates a new GradientBlockColorStep
  59818. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59819. * @param color defines the color associated with this step
  59820. */
  59821. constructor(
  59822. /**
  59823. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59824. */
  59825. step: number,
  59826. /**
  59827. * Gets or sets the color associated with this step
  59828. */
  59829. color: Color3);
  59830. }
  59831. /**
  59832. * Block used to return a color from a gradient based on an input value between 0 and 1
  59833. */
  59834. export class GradientBlock extends NodeMaterialBlock {
  59835. /**
  59836. * Gets or sets the list of color steps
  59837. */
  59838. colorSteps: GradientBlockColorStep[];
  59839. /**
  59840. * Creates a new GradientBlock
  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 gradient input component
  59851. */
  59852. get gradient(): NodeMaterialConnectionPoint;
  59853. /**
  59854. * Gets the output component
  59855. */
  59856. get output(): NodeMaterialConnectionPoint;
  59857. private _writeColorConstant;
  59858. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59859. serialize(): any;
  59860. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59861. protected _dumpPropertiesCode(): string;
  59862. }
  59863. }
  59864. declare module BABYLON {
  59865. /**
  59866. * Block used to normalize lerp between 2 values
  59867. */
  59868. export class NLerpBlock extends NodeMaterialBlock {
  59869. /**
  59870. * Creates a new NLerpBlock
  59871. * @param name defines the block name
  59872. */
  59873. constructor(name: string);
  59874. /**
  59875. * Gets the current class name
  59876. * @returns the class name
  59877. */
  59878. getClassName(): string;
  59879. /**
  59880. * Gets the left operand input component
  59881. */
  59882. get left(): NodeMaterialConnectionPoint;
  59883. /**
  59884. * Gets the right operand input component
  59885. */
  59886. get right(): NodeMaterialConnectionPoint;
  59887. /**
  59888. * Gets the gradient operand input component
  59889. */
  59890. get gradient(): NodeMaterialConnectionPoint;
  59891. /**
  59892. * Gets the output component
  59893. */
  59894. get output(): NodeMaterialConnectionPoint;
  59895. protected _buildBlock(state: NodeMaterialBuildState): this;
  59896. }
  59897. }
  59898. declare module BABYLON {
  59899. /**
  59900. * block used to Generate a Worley Noise 3D Noise Pattern
  59901. */
  59902. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59903. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59904. manhattanDistance: boolean;
  59905. /**
  59906. * Creates a new WorleyNoise3DBlock
  59907. * @param name defines the block name
  59908. */
  59909. constructor(name: string);
  59910. /**
  59911. * Gets the current class name
  59912. * @returns the class name
  59913. */
  59914. getClassName(): string;
  59915. /**
  59916. * Gets the seed input component
  59917. */
  59918. get seed(): NodeMaterialConnectionPoint;
  59919. /**
  59920. * Gets the jitter input component
  59921. */
  59922. get jitter(): NodeMaterialConnectionPoint;
  59923. /**
  59924. * Gets the output component
  59925. */
  59926. get output(): NodeMaterialConnectionPoint;
  59927. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59928. /**
  59929. * Exposes the properties to the UI?
  59930. */
  59931. protected _dumpPropertiesCode(): string;
  59932. /**
  59933. * Exposes the properties to the Seralize?
  59934. */
  59935. serialize(): any;
  59936. /**
  59937. * Exposes the properties to the deseralize?
  59938. */
  59939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59940. }
  59941. }
  59942. declare module BABYLON {
  59943. /**
  59944. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59945. */
  59946. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59947. /**
  59948. * Creates a new SimplexPerlin3DBlock
  59949. * @param name defines the block name
  59950. */
  59951. constructor(name: string);
  59952. /**
  59953. * Gets the current class name
  59954. * @returns the class name
  59955. */
  59956. getClassName(): string;
  59957. /**
  59958. * Gets the seed operand input component
  59959. */
  59960. get seed(): NodeMaterialConnectionPoint;
  59961. /**
  59962. * Gets the output component
  59963. */
  59964. get output(): NodeMaterialConnectionPoint;
  59965. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59966. }
  59967. }
  59968. declare module BABYLON {
  59969. /**
  59970. * Block used to blend normals
  59971. */
  59972. export class NormalBlendBlock extends NodeMaterialBlock {
  59973. /**
  59974. * Creates a new NormalBlendBlock
  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 first input component
  59985. */
  59986. get normalMap0(): NodeMaterialConnectionPoint;
  59987. /**
  59988. * Gets the second input component
  59989. */
  59990. get normalMap1(): NodeMaterialConnectionPoint;
  59991. /**
  59992. * Gets the output component
  59993. */
  59994. get output(): NodeMaterialConnectionPoint;
  59995. protected _buildBlock(state: NodeMaterialBuildState): this;
  59996. }
  59997. }
  59998. declare module BABYLON {
  59999. /**
  60000. * Block used to rotate a 2d vector by a given angle
  60001. */
  60002. export class Rotate2dBlock extends NodeMaterialBlock {
  60003. /**
  60004. * Creates a new Rotate2dBlock
  60005. * @param name defines the block name
  60006. */
  60007. constructor(name: string);
  60008. /**
  60009. * Gets the current class name
  60010. * @returns the class name
  60011. */
  60012. getClassName(): string;
  60013. /**
  60014. * Gets the input vector
  60015. */
  60016. get input(): NodeMaterialConnectionPoint;
  60017. /**
  60018. * Gets the input angle
  60019. */
  60020. get angle(): NodeMaterialConnectionPoint;
  60021. /**
  60022. * Gets the output component
  60023. */
  60024. get output(): NodeMaterialConnectionPoint;
  60025. autoConfigure(material: NodeMaterial): void;
  60026. protected _buildBlock(state: NodeMaterialBuildState): this;
  60027. }
  60028. }
  60029. declare module BABYLON {
  60030. /**
  60031. * Block used to get the reflected vector from a direction and a normal
  60032. */
  60033. export class ReflectBlock extends NodeMaterialBlock {
  60034. /**
  60035. * Creates a new ReflectBlock
  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 output component
  60054. */
  60055. get output(): NodeMaterialConnectionPoint;
  60056. protected _buildBlock(state: NodeMaterialBuildState): this;
  60057. }
  60058. }
  60059. declare module BABYLON {
  60060. /**
  60061. * Block used to get the refracted vector from a direction and a normal
  60062. */
  60063. export class RefractBlock extends NodeMaterialBlock {
  60064. /**
  60065. * Creates a new RefractBlock
  60066. * @param name defines the block name
  60067. */
  60068. constructor(name: string);
  60069. /**
  60070. * Gets the current class name
  60071. * @returns the class name
  60072. */
  60073. getClassName(): string;
  60074. /**
  60075. * Gets the incident component
  60076. */
  60077. get incident(): NodeMaterialConnectionPoint;
  60078. /**
  60079. * Gets the normal component
  60080. */
  60081. get normal(): NodeMaterialConnectionPoint;
  60082. /**
  60083. * Gets the index of refraction component
  60084. */
  60085. get ior(): NodeMaterialConnectionPoint;
  60086. /**
  60087. * Gets the output component
  60088. */
  60089. get output(): NodeMaterialConnectionPoint;
  60090. protected _buildBlock(state: NodeMaterialBuildState): this;
  60091. }
  60092. }
  60093. declare module BABYLON {
  60094. /**
  60095. * Block used to desaturate a color
  60096. */
  60097. export class DesaturateBlock extends NodeMaterialBlock {
  60098. /**
  60099. * Creates a new DesaturateBlock
  60100. * @param name defines the block name
  60101. */
  60102. constructor(name: string);
  60103. /**
  60104. * Gets the current class name
  60105. * @returns the class name
  60106. */
  60107. getClassName(): string;
  60108. /**
  60109. * Gets the color operand input component
  60110. */
  60111. get color(): NodeMaterialConnectionPoint;
  60112. /**
  60113. * Gets the level operand input component
  60114. */
  60115. get level(): NodeMaterialConnectionPoint;
  60116. /**
  60117. * Gets the output component
  60118. */
  60119. get output(): NodeMaterialConnectionPoint;
  60120. protected _buildBlock(state: NodeMaterialBuildState): this;
  60121. }
  60122. }
  60123. declare module BABYLON {
  60124. /**
  60125. * Effect Render Options
  60126. */
  60127. export interface IEffectRendererOptions {
  60128. /**
  60129. * Defines the vertices positions.
  60130. */
  60131. positions?: number[];
  60132. /**
  60133. * Defines the indices.
  60134. */
  60135. indices?: number[];
  60136. }
  60137. /**
  60138. * Helper class to render one or more effects
  60139. */
  60140. export class EffectRenderer {
  60141. private engine;
  60142. private static _DefaultOptions;
  60143. private _vertexBuffers;
  60144. private _indexBuffer;
  60145. private _ringBufferIndex;
  60146. private _ringScreenBuffer;
  60147. private _fullscreenViewport;
  60148. private _getNextFrameBuffer;
  60149. /**
  60150. * Creates an effect renderer
  60151. * @param engine the engine to use for rendering
  60152. * @param options defines the options of the effect renderer
  60153. */
  60154. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60155. /**
  60156. * Sets the current viewport in normalized coordinates 0-1
  60157. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60158. */
  60159. setViewport(viewport?: Viewport): void;
  60160. /**
  60161. * Binds the embedded attributes buffer to the effect.
  60162. * @param effect Defines the effect to bind the attributes for
  60163. */
  60164. bindBuffers(effect: Effect): void;
  60165. /**
  60166. * Sets the current effect wrapper to use during draw.
  60167. * The effect needs to be ready before calling this api.
  60168. * This also sets the default full screen position attribute.
  60169. * @param effectWrapper Defines the effect to draw with
  60170. */
  60171. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60172. /**
  60173. * Draws a full screen quad.
  60174. */
  60175. draw(): void;
  60176. /**
  60177. * renders one or more effects to a specified texture
  60178. * @param effectWrappers list of effects to renderer
  60179. * @param outputTexture texture to draw to, if null it will render to the screen
  60180. */
  60181. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60182. /**
  60183. * Disposes of the effect renderer
  60184. */
  60185. dispose(): void;
  60186. }
  60187. /**
  60188. * Options to create an EffectWrapper
  60189. */
  60190. interface EffectWrapperCreationOptions {
  60191. /**
  60192. * Engine to use to create the effect
  60193. */
  60194. engine: ThinEngine;
  60195. /**
  60196. * Fragment shader for the effect
  60197. */
  60198. fragmentShader: string;
  60199. /**
  60200. * Vertex shader for the effect
  60201. */
  60202. vertexShader?: string;
  60203. /**
  60204. * Attributes to use in the shader
  60205. */
  60206. attributeNames?: Array<string>;
  60207. /**
  60208. * Uniforms to use in the shader
  60209. */
  60210. uniformNames?: Array<string>;
  60211. /**
  60212. * Texture sampler names to use in the shader
  60213. */
  60214. samplerNames?: Array<string>;
  60215. /**
  60216. * The friendly name of the effect displayed in Spector.
  60217. */
  60218. name?: string;
  60219. }
  60220. /**
  60221. * Wraps an effect to be used for rendering
  60222. */
  60223. export class EffectWrapper {
  60224. /**
  60225. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60226. */
  60227. onApplyObservable: Observable<{}>;
  60228. /**
  60229. * The underlying effect
  60230. */
  60231. effect: Effect;
  60232. /**
  60233. * Creates an effect to be renderer
  60234. * @param creationOptions options to create the effect
  60235. */
  60236. constructor(creationOptions: EffectWrapperCreationOptions);
  60237. /**
  60238. * Disposes of the effect wrapper
  60239. */
  60240. dispose(): void;
  60241. }
  60242. }
  60243. declare module BABYLON {
  60244. /**
  60245. * Helper class to push actions to a pool of workers.
  60246. */
  60247. export class WorkerPool implements IDisposable {
  60248. private _workerInfos;
  60249. private _pendingActions;
  60250. /**
  60251. * Constructor
  60252. * @param workers Array of workers to use for actions
  60253. */
  60254. constructor(workers: Array<Worker>);
  60255. /**
  60256. * Terminates all workers and clears any pending actions.
  60257. */
  60258. dispose(): void;
  60259. /**
  60260. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60261. * pended until a worker has completed its action.
  60262. * @param action The action to perform. Call onComplete when the action is complete.
  60263. */
  60264. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60265. private _execute;
  60266. }
  60267. }
  60268. declare module BABYLON {
  60269. /**
  60270. * Configuration for Draco compression
  60271. */
  60272. export interface IDracoCompressionConfiguration {
  60273. /**
  60274. * Configuration for the decoder.
  60275. */
  60276. decoder: {
  60277. /**
  60278. * The url to the WebAssembly module.
  60279. */
  60280. wasmUrl?: string;
  60281. /**
  60282. * The url to the WebAssembly binary.
  60283. */
  60284. wasmBinaryUrl?: string;
  60285. /**
  60286. * The url to the fallback JavaScript module.
  60287. */
  60288. fallbackUrl?: string;
  60289. };
  60290. }
  60291. /**
  60292. * Draco compression (https://google.github.io/draco/)
  60293. *
  60294. * This class wraps the Draco module.
  60295. *
  60296. * **Encoder**
  60297. *
  60298. * The encoder is not currently implemented.
  60299. *
  60300. * **Decoder**
  60301. *
  60302. * 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.
  60303. *
  60304. * To update the configuration, use the following code:
  60305. * ```javascript
  60306. * DracoCompression.Configuration = {
  60307. * decoder: {
  60308. * wasmUrl: "<url to the WebAssembly library>",
  60309. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60310. * fallbackUrl: "<url to the fallback JavaScript library>",
  60311. * }
  60312. * };
  60313. * ```
  60314. *
  60315. * 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.
  60316. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60317. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60318. *
  60319. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60320. * ```javascript
  60321. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60322. * ```
  60323. *
  60324. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60325. */
  60326. export class DracoCompression implements IDisposable {
  60327. private _workerPoolPromise?;
  60328. private _decoderModulePromise?;
  60329. /**
  60330. * The configuration. Defaults to the following urls:
  60331. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60332. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60333. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60334. */
  60335. static Configuration: IDracoCompressionConfiguration;
  60336. /**
  60337. * Returns true if the decoder configuration is available.
  60338. */
  60339. static get DecoderAvailable(): boolean;
  60340. /**
  60341. * Default number of workers to create when creating the draco compression object.
  60342. */
  60343. static DefaultNumWorkers: number;
  60344. private static GetDefaultNumWorkers;
  60345. private static _Default;
  60346. /**
  60347. * Default instance for the draco compression object.
  60348. */
  60349. static get Default(): DracoCompression;
  60350. /**
  60351. * Constructor
  60352. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60353. */
  60354. constructor(numWorkers?: number);
  60355. /**
  60356. * Stop all async operations and release resources.
  60357. */
  60358. dispose(): void;
  60359. /**
  60360. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60361. * @returns a promise that resolves when ready
  60362. */
  60363. whenReadyAsync(): Promise<void>;
  60364. /**
  60365. * Decode Draco compressed mesh data to vertex data.
  60366. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60367. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60368. * @returns A promise that resolves with the decoded vertex data
  60369. */
  60370. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60371. [kind: string]: number;
  60372. }): Promise<VertexData>;
  60373. }
  60374. }
  60375. declare module BABYLON {
  60376. /**
  60377. * Class for building Constructive Solid Geometry
  60378. */
  60379. export class CSG {
  60380. private polygons;
  60381. /**
  60382. * The world matrix
  60383. */
  60384. matrix: Matrix;
  60385. /**
  60386. * Stores the position
  60387. */
  60388. position: Vector3;
  60389. /**
  60390. * Stores the rotation
  60391. */
  60392. rotation: Vector3;
  60393. /**
  60394. * Stores the rotation quaternion
  60395. */
  60396. rotationQuaternion: Nullable<Quaternion>;
  60397. /**
  60398. * Stores the scaling vector
  60399. */
  60400. scaling: Vector3;
  60401. /**
  60402. * Convert the Mesh to CSG
  60403. * @param mesh The Mesh to convert to CSG
  60404. * @returns A new CSG from the Mesh
  60405. */
  60406. static FromMesh(mesh: Mesh): CSG;
  60407. /**
  60408. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60409. * @param polygons Polygons used to construct a CSG solid
  60410. */
  60411. private static FromPolygons;
  60412. /**
  60413. * Clones, or makes a deep copy, of the CSG
  60414. * @returns A new CSG
  60415. */
  60416. clone(): CSG;
  60417. /**
  60418. * Unions this CSG with another CSG
  60419. * @param csg The CSG to union against this CSG
  60420. * @returns The unioned CSG
  60421. */
  60422. union(csg: CSG): CSG;
  60423. /**
  60424. * Unions this CSG with another CSG in place
  60425. * @param csg The CSG to union against this CSG
  60426. */
  60427. unionInPlace(csg: CSG): void;
  60428. /**
  60429. * Subtracts this CSG with another CSG
  60430. * @param csg The CSG to subtract against this CSG
  60431. * @returns A new CSG
  60432. */
  60433. subtract(csg: CSG): CSG;
  60434. /**
  60435. * Subtracts this CSG with another CSG in place
  60436. * @param csg The CSG to subtact against this CSG
  60437. */
  60438. subtractInPlace(csg: CSG): void;
  60439. /**
  60440. * Intersect this CSG with another CSG
  60441. * @param csg The CSG to intersect against this CSG
  60442. * @returns A new CSG
  60443. */
  60444. intersect(csg: CSG): CSG;
  60445. /**
  60446. * Intersects this CSG with another CSG in place
  60447. * @param csg The CSG to intersect against this CSG
  60448. */
  60449. intersectInPlace(csg: CSG): void;
  60450. /**
  60451. * Return a new CSG solid with solid and empty space switched. This solid is
  60452. * not modified.
  60453. * @returns A new CSG solid with solid and empty space switched
  60454. */
  60455. inverse(): CSG;
  60456. /**
  60457. * Inverses the CSG in place
  60458. */
  60459. inverseInPlace(): void;
  60460. /**
  60461. * This is used to keep meshes transformations so they can be restored
  60462. * when we build back a Babylon Mesh
  60463. * NB : All CSG operations are performed in world coordinates
  60464. * @param csg The CSG to copy the transform attributes from
  60465. * @returns This CSG
  60466. */
  60467. copyTransformAttributes(csg: CSG): CSG;
  60468. /**
  60469. * Build Raw mesh from CSG
  60470. * Coordinates here are in world space
  60471. * @param name The name of the mesh geometry
  60472. * @param scene The Scene
  60473. * @param keepSubMeshes Specifies if the submeshes should be kept
  60474. * @returns A new Mesh
  60475. */
  60476. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60477. /**
  60478. * Build Mesh from CSG taking material and transforms into account
  60479. * @param name The name of the Mesh
  60480. * @param material The material of the Mesh
  60481. * @param scene The Scene
  60482. * @param keepSubMeshes Specifies if submeshes should be kept
  60483. * @returns The new Mesh
  60484. */
  60485. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60486. }
  60487. }
  60488. declare module BABYLON {
  60489. /**
  60490. * Class used to create a trail following a mesh
  60491. */
  60492. export class TrailMesh extends Mesh {
  60493. private _generator;
  60494. private _autoStart;
  60495. private _running;
  60496. private _diameter;
  60497. private _length;
  60498. private _sectionPolygonPointsCount;
  60499. private _sectionVectors;
  60500. private _sectionNormalVectors;
  60501. private _beforeRenderObserver;
  60502. /**
  60503. * @constructor
  60504. * @param name The value used by scene.getMeshByName() to do a lookup.
  60505. * @param generator The mesh or transform node to generate a trail.
  60506. * @param scene The scene to add this mesh to.
  60507. * @param diameter Diameter of trailing mesh. Default is 1.
  60508. * @param length Length of trailing mesh. Default is 60.
  60509. * @param autoStart Automatically start trailing mesh. Default true.
  60510. */
  60511. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60512. /**
  60513. * "TrailMesh"
  60514. * @returns "TrailMesh"
  60515. */
  60516. getClassName(): string;
  60517. private _createMesh;
  60518. /**
  60519. * Start trailing mesh.
  60520. */
  60521. start(): void;
  60522. /**
  60523. * Stop trailing mesh.
  60524. */
  60525. stop(): void;
  60526. /**
  60527. * Update trailing mesh geometry.
  60528. */
  60529. update(): void;
  60530. /**
  60531. * Returns a new TrailMesh object.
  60532. * @param name is a string, the name given to the new mesh
  60533. * @param newGenerator use new generator object for cloned trail mesh
  60534. * @returns a new mesh
  60535. */
  60536. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60537. /**
  60538. * Serializes this trail mesh
  60539. * @param serializationObject object to write serialization to
  60540. */
  60541. serialize(serializationObject: any): void;
  60542. /**
  60543. * Parses a serialized trail mesh
  60544. * @param parsedMesh the serialized mesh
  60545. * @param scene the scene to create the trail mesh in
  60546. * @returns the created trail mesh
  60547. */
  60548. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60549. }
  60550. }
  60551. declare module BABYLON {
  60552. /**
  60553. * Class containing static functions to help procedurally build meshes
  60554. */
  60555. export class TiledBoxBuilder {
  60556. /**
  60557. * Creates a box mesh
  60558. * 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)
  60559. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60561. * * 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
  60562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60563. * @param name defines the name of the mesh
  60564. * @param options defines the options used to create the mesh
  60565. * @param scene defines the hosting scene
  60566. * @returns the box mesh
  60567. */
  60568. static CreateTiledBox(name: string, options: {
  60569. pattern?: number;
  60570. width?: number;
  60571. height?: number;
  60572. depth?: number;
  60573. tileSize?: number;
  60574. tileWidth?: number;
  60575. tileHeight?: number;
  60576. alignHorizontal?: number;
  60577. alignVertical?: number;
  60578. faceUV?: Vector4[];
  60579. faceColors?: Color4[];
  60580. sideOrientation?: number;
  60581. updatable?: boolean;
  60582. }, scene?: Nullable<Scene>): Mesh;
  60583. }
  60584. }
  60585. declare module BABYLON {
  60586. /**
  60587. * Class containing static functions to help procedurally build meshes
  60588. */
  60589. export class TorusKnotBuilder {
  60590. /**
  60591. * Creates a torus knot mesh
  60592. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60593. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60594. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60595. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60597. * * 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
  60598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60599. * @param name defines the name of the mesh
  60600. * @param options defines the options used to create the mesh
  60601. * @param scene defines the hosting scene
  60602. * @returns the torus knot mesh
  60603. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60604. */
  60605. static CreateTorusKnot(name: string, options: {
  60606. radius?: number;
  60607. tube?: number;
  60608. radialSegments?: number;
  60609. tubularSegments?: number;
  60610. p?: number;
  60611. q?: number;
  60612. updatable?: boolean;
  60613. sideOrientation?: number;
  60614. frontUVs?: Vector4;
  60615. backUVs?: Vector4;
  60616. }, scene: any): Mesh;
  60617. }
  60618. }
  60619. declare module BABYLON {
  60620. /**
  60621. * Polygon
  60622. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60623. */
  60624. export class Polygon {
  60625. /**
  60626. * Creates a rectangle
  60627. * @param xmin bottom X coord
  60628. * @param ymin bottom Y coord
  60629. * @param xmax top X coord
  60630. * @param ymax top Y coord
  60631. * @returns points that make the resulting rectation
  60632. */
  60633. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60634. /**
  60635. * Creates a circle
  60636. * @param radius radius of circle
  60637. * @param cx scale in x
  60638. * @param cy scale in y
  60639. * @param numberOfSides number of sides that make up the circle
  60640. * @returns points that make the resulting circle
  60641. */
  60642. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60643. /**
  60644. * Creates a polygon from input string
  60645. * @param input Input polygon data
  60646. * @returns the parsed points
  60647. */
  60648. static Parse(input: string): Vector2[];
  60649. /**
  60650. * Starts building a polygon from x and y coordinates
  60651. * @param x x coordinate
  60652. * @param y y coordinate
  60653. * @returns the started path2
  60654. */
  60655. static StartingAt(x: number, y: number): Path2;
  60656. }
  60657. /**
  60658. * Builds a polygon
  60659. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60660. */
  60661. export class PolygonMeshBuilder {
  60662. private _points;
  60663. private _outlinepoints;
  60664. private _holes;
  60665. private _name;
  60666. private _scene;
  60667. private _epoints;
  60668. private _eholes;
  60669. private _addToepoint;
  60670. /**
  60671. * Babylon reference to the earcut plugin.
  60672. */
  60673. bjsEarcut: any;
  60674. /**
  60675. * Creates a PolygonMeshBuilder
  60676. * @param name name of the builder
  60677. * @param contours Path of the polygon
  60678. * @param scene scene to add to when creating the mesh
  60679. * @param earcutInjection can be used to inject your own earcut reference
  60680. */
  60681. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60682. /**
  60683. * Adds a whole within the polygon
  60684. * @param hole Array of points defining the hole
  60685. * @returns this
  60686. */
  60687. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60688. /**
  60689. * Creates the polygon
  60690. * @param updatable If the mesh should be updatable
  60691. * @param depth The depth of the mesh created
  60692. * @returns the created mesh
  60693. */
  60694. build(updatable?: boolean, depth?: number): Mesh;
  60695. /**
  60696. * Creates the polygon
  60697. * @param depth The depth of the mesh created
  60698. * @returns the created VertexData
  60699. */
  60700. buildVertexData(depth?: number): VertexData;
  60701. /**
  60702. * Adds a side to the polygon
  60703. * @param positions points that make the polygon
  60704. * @param normals normals of the polygon
  60705. * @param uvs uvs of the polygon
  60706. * @param indices indices of the polygon
  60707. * @param bounds bounds of the polygon
  60708. * @param points points of the polygon
  60709. * @param depth depth of the polygon
  60710. * @param flip flip of the polygon
  60711. */
  60712. private addSide;
  60713. }
  60714. }
  60715. declare module BABYLON {
  60716. /**
  60717. * Class containing static functions to help procedurally build meshes
  60718. */
  60719. export class PolygonBuilder {
  60720. /**
  60721. * Creates a polygon mesh
  60722. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60723. * * 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
  60724. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60726. * * 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)
  60727. * * Remember you can only change the shape positions, not their number when updating a polygon
  60728. * @param name defines the name of the mesh
  60729. * @param options defines the options used to create the mesh
  60730. * @param scene defines the hosting scene
  60731. * @param earcutInjection can be used to inject your own earcut reference
  60732. * @returns the polygon mesh
  60733. */
  60734. static CreatePolygon(name: string, options: {
  60735. shape: Vector3[];
  60736. holes?: Vector3[][];
  60737. depth?: number;
  60738. faceUV?: Vector4[];
  60739. faceColors?: Color4[];
  60740. updatable?: boolean;
  60741. sideOrientation?: number;
  60742. frontUVs?: Vector4;
  60743. backUVs?: Vector4;
  60744. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60745. /**
  60746. * Creates an extruded polygon mesh, with depth in the Y direction.
  60747. * * 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)
  60748. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60749. * @param name defines the name of the mesh
  60750. * @param options defines the options used to create the mesh
  60751. * @param scene defines the hosting scene
  60752. * @param earcutInjection can be used to inject your own earcut reference
  60753. * @returns the polygon mesh
  60754. */
  60755. static ExtrudePolygon(name: string, options: {
  60756. shape: Vector3[];
  60757. holes?: Vector3[][];
  60758. depth?: number;
  60759. faceUV?: Vector4[];
  60760. faceColors?: Color4[];
  60761. updatable?: boolean;
  60762. sideOrientation?: number;
  60763. frontUVs?: Vector4;
  60764. backUVs?: Vector4;
  60765. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60766. }
  60767. }
  60768. declare module BABYLON {
  60769. /**
  60770. * Class containing static functions to help procedurally build meshes
  60771. */
  60772. export class LatheBuilder {
  60773. /**
  60774. * Creates lathe mesh.
  60775. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60776. * * 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
  60777. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60778. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60779. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60780. * * 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
  60781. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60782. * * 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
  60783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60784. * * 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
  60785. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60787. * @param name defines the name of the mesh
  60788. * @param options defines the options used to create the mesh
  60789. * @param scene defines the hosting scene
  60790. * @returns the lathe mesh
  60791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60792. */
  60793. static CreateLathe(name: string, options: {
  60794. shape: Vector3[];
  60795. radius?: number;
  60796. tessellation?: number;
  60797. clip?: number;
  60798. arc?: number;
  60799. closed?: boolean;
  60800. updatable?: boolean;
  60801. sideOrientation?: number;
  60802. frontUVs?: Vector4;
  60803. backUVs?: Vector4;
  60804. cap?: number;
  60805. invertUV?: boolean;
  60806. }, scene?: Nullable<Scene>): Mesh;
  60807. }
  60808. }
  60809. declare module BABYLON {
  60810. /**
  60811. * Class containing static functions to help procedurally build meshes
  60812. */
  60813. export class TiledPlaneBuilder {
  60814. /**
  60815. * Creates a tiled plane mesh
  60816. * * The parameter `pattern` will, depending on value, do nothing or
  60817. * * * flip (reflect about central vertical) alternate tiles across and up
  60818. * * * flip every tile on alternate rows
  60819. * * * rotate (180 degs) alternate tiles across and up
  60820. * * * rotate every tile on alternate rows
  60821. * * * flip and rotate alternate tiles across and up
  60822. * * * flip and rotate every tile on alternate rows
  60823. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60824. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60825. * * 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
  60826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60827. * * 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)
  60828. * * 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)
  60829. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60830. * @param name defines the name of the mesh
  60831. * @param options defines the options used to create the mesh
  60832. * @param scene defines the hosting scene
  60833. * @returns the box mesh
  60834. */
  60835. static CreateTiledPlane(name: string, options: {
  60836. pattern?: number;
  60837. tileSize?: number;
  60838. tileWidth?: number;
  60839. tileHeight?: number;
  60840. size?: number;
  60841. width?: number;
  60842. height?: number;
  60843. alignHorizontal?: number;
  60844. alignVertical?: number;
  60845. sideOrientation?: number;
  60846. frontUVs?: Vector4;
  60847. backUVs?: Vector4;
  60848. updatable?: boolean;
  60849. }, scene?: Nullable<Scene>): Mesh;
  60850. }
  60851. }
  60852. declare module BABYLON {
  60853. /**
  60854. * Class containing static functions to help procedurally build meshes
  60855. */
  60856. export class TubeBuilder {
  60857. /**
  60858. * Creates a tube mesh.
  60859. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60860. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60861. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60862. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60863. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60864. * * 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)
  60865. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60866. * * 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
  60867. * * 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
  60868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60869. * * 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
  60870. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60872. * @param name defines the name of the mesh
  60873. * @param options defines the options used to create the mesh
  60874. * @param scene defines the hosting scene
  60875. * @returns the tube mesh
  60876. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60877. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60878. */
  60879. static CreateTube(name: string, options: {
  60880. path: Vector3[];
  60881. radius?: number;
  60882. tessellation?: number;
  60883. radiusFunction?: {
  60884. (i: number, distance: number): number;
  60885. };
  60886. cap?: number;
  60887. arc?: number;
  60888. updatable?: boolean;
  60889. sideOrientation?: number;
  60890. frontUVs?: Vector4;
  60891. backUVs?: Vector4;
  60892. instance?: Mesh;
  60893. invertUV?: boolean;
  60894. }, scene?: Nullable<Scene>): Mesh;
  60895. }
  60896. }
  60897. declare module BABYLON {
  60898. /**
  60899. * Class containing static functions to help procedurally build meshes
  60900. */
  60901. export class IcoSphereBuilder {
  60902. /**
  60903. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60904. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60905. * * 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`)
  60906. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60907. * * 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
  60908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60909. * * 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
  60910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60911. * @param name defines the name of the mesh
  60912. * @param options defines the options used to create the mesh
  60913. * @param scene defines the hosting scene
  60914. * @returns the icosahedron mesh
  60915. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60916. */
  60917. static CreateIcoSphere(name: string, options: {
  60918. radius?: number;
  60919. radiusX?: number;
  60920. radiusY?: number;
  60921. radiusZ?: number;
  60922. flat?: boolean;
  60923. subdivisions?: number;
  60924. sideOrientation?: number;
  60925. frontUVs?: Vector4;
  60926. backUVs?: Vector4;
  60927. updatable?: boolean;
  60928. }, scene?: Nullable<Scene>): Mesh;
  60929. }
  60930. }
  60931. declare module BABYLON {
  60932. /**
  60933. * Class containing static functions to help procedurally build meshes
  60934. */
  60935. export class DecalBuilder {
  60936. /**
  60937. * Creates a decal mesh.
  60938. * 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
  60939. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60940. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60941. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60942. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60943. * @param name defines the name of the mesh
  60944. * @param sourceMesh defines the mesh where the decal must be applied
  60945. * @param options defines the options used to create the mesh
  60946. * @param scene defines the hosting scene
  60947. * @returns the decal mesh
  60948. * @see https://doc.babylonjs.com/how_to/decals
  60949. */
  60950. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60951. position?: Vector3;
  60952. normal?: Vector3;
  60953. size?: Vector3;
  60954. angle?: number;
  60955. }): Mesh;
  60956. }
  60957. }
  60958. declare module BABYLON {
  60959. /**
  60960. * Class containing static functions to help procedurally build meshes
  60961. */
  60962. export class MeshBuilder {
  60963. /**
  60964. * Creates a box mesh
  60965. * * The parameter `size` sets the size (float) of each box side (default 1)
  60966. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60967. * * 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)
  60968. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60970. * * 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
  60971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60972. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60973. * @param name defines the name of the mesh
  60974. * @param options defines the options used to create the mesh
  60975. * @param scene defines the hosting scene
  60976. * @returns the box mesh
  60977. */
  60978. static CreateBox(name: string, options: {
  60979. size?: number;
  60980. width?: number;
  60981. height?: number;
  60982. depth?: number;
  60983. faceUV?: Vector4[];
  60984. faceColors?: Color4[];
  60985. sideOrientation?: number;
  60986. frontUVs?: Vector4;
  60987. backUVs?: Vector4;
  60988. updatable?: boolean;
  60989. }, scene?: Nullable<Scene>): Mesh;
  60990. /**
  60991. * Creates a tiled box mesh
  60992. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60994. * @param name defines the name of the mesh
  60995. * @param options defines the options used to create the mesh
  60996. * @param scene defines the hosting scene
  60997. * @returns the tiled box mesh
  60998. */
  60999. static CreateTiledBox(name: string, options: {
  61000. pattern?: number;
  61001. size?: number;
  61002. width?: number;
  61003. height?: number;
  61004. depth: number;
  61005. tileSize?: number;
  61006. tileWidth?: number;
  61007. tileHeight?: number;
  61008. faceUV?: Vector4[];
  61009. faceColors?: Color4[];
  61010. alignHorizontal?: number;
  61011. alignVertical?: number;
  61012. sideOrientation?: number;
  61013. updatable?: boolean;
  61014. }, scene?: Nullable<Scene>): Mesh;
  61015. /**
  61016. * Creates a sphere mesh
  61017. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61018. * * 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`)
  61019. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61020. * * 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
  61021. * * 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)
  61022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61023. * * 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
  61024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61025. * @param name defines the name of the mesh
  61026. * @param options defines the options used to create the mesh
  61027. * @param scene defines the hosting scene
  61028. * @returns the sphere mesh
  61029. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61030. */
  61031. static CreateSphere(name: string, options: {
  61032. segments?: number;
  61033. diameter?: number;
  61034. diameterX?: number;
  61035. diameterY?: number;
  61036. diameterZ?: number;
  61037. arc?: number;
  61038. slice?: number;
  61039. sideOrientation?: number;
  61040. frontUVs?: Vector4;
  61041. backUVs?: Vector4;
  61042. updatable?: boolean;
  61043. }, scene?: Nullable<Scene>): Mesh;
  61044. /**
  61045. * Creates a plane polygonal mesh. By default, this is a disc
  61046. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61047. * * 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
  61048. * * 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
  61049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61050. * * 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
  61051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61052. * @param name defines the name of the mesh
  61053. * @param options defines the options used to create the mesh
  61054. * @param scene defines the hosting scene
  61055. * @returns the plane polygonal mesh
  61056. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61057. */
  61058. static CreateDisc(name: string, options: {
  61059. radius?: number;
  61060. tessellation?: number;
  61061. arc?: number;
  61062. updatable?: boolean;
  61063. sideOrientation?: number;
  61064. frontUVs?: Vector4;
  61065. backUVs?: Vector4;
  61066. }, scene?: Nullable<Scene>): Mesh;
  61067. /**
  61068. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61069. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61070. * * 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`)
  61071. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61072. * * 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
  61073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61074. * * 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
  61075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61076. * @param name defines the name of the mesh
  61077. * @param options defines the options used to create the mesh
  61078. * @param scene defines the hosting scene
  61079. * @returns the icosahedron mesh
  61080. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61081. */
  61082. static CreateIcoSphere(name: string, options: {
  61083. radius?: number;
  61084. radiusX?: number;
  61085. radiusY?: number;
  61086. radiusZ?: number;
  61087. flat?: boolean;
  61088. subdivisions?: number;
  61089. sideOrientation?: number;
  61090. frontUVs?: Vector4;
  61091. backUVs?: Vector4;
  61092. updatable?: boolean;
  61093. }, scene?: Nullable<Scene>): Mesh;
  61094. /**
  61095. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61096. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61097. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61098. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61099. * * 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
  61100. * * 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
  61101. * * 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
  61102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61104. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61105. * * 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
  61106. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61107. * * 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
  61108. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61110. * @param name defines the name of the mesh
  61111. * @param options defines the options used to create the mesh
  61112. * @param scene defines the hosting scene
  61113. * @returns the ribbon mesh
  61114. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61115. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61116. */
  61117. static CreateRibbon(name: string, options: {
  61118. pathArray: Vector3[][];
  61119. closeArray?: boolean;
  61120. closePath?: boolean;
  61121. offset?: number;
  61122. updatable?: boolean;
  61123. sideOrientation?: number;
  61124. frontUVs?: Vector4;
  61125. backUVs?: Vector4;
  61126. instance?: Mesh;
  61127. invertUV?: boolean;
  61128. uvs?: Vector2[];
  61129. colors?: Color4[];
  61130. }, scene?: Nullable<Scene>): Mesh;
  61131. /**
  61132. * Creates a cylinder or a cone mesh
  61133. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61134. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61135. * * 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.
  61136. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61137. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61138. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61139. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61140. * * 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).
  61141. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61142. * * 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).
  61143. * * 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
  61144. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61145. * * 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
  61146. * * 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.
  61147. * * If `enclose` is false, a ring surface is one element.
  61148. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61149. * * 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
  61150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61151. * * 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
  61152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61153. * @param name defines the name of the mesh
  61154. * @param options defines the options used to create the mesh
  61155. * @param scene defines the hosting scene
  61156. * @returns the cylinder mesh
  61157. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61158. */
  61159. static CreateCylinder(name: string, options: {
  61160. height?: number;
  61161. diameterTop?: number;
  61162. diameterBottom?: number;
  61163. diameter?: number;
  61164. tessellation?: number;
  61165. subdivisions?: number;
  61166. arc?: number;
  61167. faceColors?: Color4[];
  61168. faceUV?: Vector4[];
  61169. updatable?: boolean;
  61170. hasRings?: boolean;
  61171. enclose?: boolean;
  61172. cap?: number;
  61173. sideOrientation?: number;
  61174. frontUVs?: Vector4;
  61175. backUVs?: Vector4;
  61176. }, scene?: Nullable<Scene>): Mesh;
  61177. /**
  61178. * Creates a torus mesh
  61179. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61180. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61181. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61183. * * 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
  61184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61185. * @param name defines the name of the mesh
  61186. * @param options defines the options used to create the mesh
  61187. * @param scene defines the hosting scene
  61188. * @returns the torus mesh
  61189. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61190. */
  61191. static CreateTorus(name: string, options: {
  61192. diameter?: number;
  61193. thickness?: number;
  61194. tessellation?: number;
  61195. updatable?: boolean;
  61196. sideOrientation?: number;
  61197. frontUVs?: Vector4;
  61198. backUVs?: Vector4;
  61199. }, scene?: Nullable<Scene>): Mesh;
  61200. /**
  61201. * Creates a torus knot mesh
  61202. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61203. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61204. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61205. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61207. * * 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
  61208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61209. * @param name defines the name of the mesh
  61210. * @param options defines the options used to create the mesh
  61211. * @param scene defines the hosting scene
  61212. * @returns the torus knot mesh
  61213. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61214. */
  61215. static CreateTorusKnot(name: string, options: {
  61216. radius?: number;
  61217. tube?: number;
  61218. radialSegments?: number;
  61219. tubularSegments?: number;
  61220. p?: number;
  61221. q?: number;
  61222. updatable?: boolean;
  61223. sideOrientation?: number;
  61224. frontUVs?: Vector4;
  61225. backUVs?: Vector4;
  61226. }, scene?: Nullable<Scene>): Mesh;
  61227. /**
  61228. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61229. * * 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
  61230. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61231. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61232. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61233. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61234. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61235. * * 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
  61236. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61238. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61239. * @param name defines the name of the new line system
  61240. * @param options defines the options used to create the line system
  61241. * @param scene defines the hosting scene
  61242. * @returns a new line system mesh
  61243. */
  61244. static CreateLineSystem(name: string, options: {
  61245. lines: Vector3[][];
  61246. updatable?: boolean;
  61247. instance?: Nullable<LinesMesh>;
  61248. colors?: Nullable<Color4[][]>;
  61249. useVertexAlpha?: boolean;
  61250. }, scene: Nullable<Scene>): LinesMesh;
  61251. /**
  61252. * Creates a line mesh
  61253. * 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
  61254. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61255. * * The parameter `points` is an array successive Vector3
  61256. * * 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
  61257. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61258. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61259. * * When updating an instance, remember that only point positions can change, not the number of points
  61260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61261. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61262. * @param name defines the name of the new line system
  61263. * @param options defines the options used to create the line system
  61264. * @param scene defines the hosting scene
  61265. * @returns a new line mesh
  61266. */
  61267. static CreateLines(name: string, options: {
  61268. points: Vector3[];
  61269. updatable?: boolean;
  61270. instance?: Nullable<LinesMesh>;
  61271. colors?: Color4[];
  61272. useVertexAlpha?: boolean;
  61273. }, scene?: Nullable<Scene>): LinesMesh;
  61274. /**
  61275. * Creates a dashed line mesh
  61276. * * 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
  61277. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61278. * * The parameter `points` is an array successive Vector3
  61279. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61280. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61281. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61282. * * 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
  61283. * * When updating an instance, remember that only point positions can change, not the number of points
  61284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61285. * @param name defines the name of the mesh
  61286. * @param options defines the options used to create the mesh
  61287. * @param scene defines the hosting scene
  61288. * @returns the dashed line mesh
  61289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61290. */
  61291. static CreateDashedLines(name: string, options: {
  61292. points: Vector3[];
  61293. dashSize?: number;
  61294. gapSize?: number;
  61295. dashNb?: number;
  61296. updatable?: boolean;
  61297. instance?: LinesMesh;
  61298. }, scene?: Nullable<Scene>): LinesMesh;
  61299. /**
  61300. * 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.
  61301. * * 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.
  61302. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61303. * * 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.
  61304. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61305. * * 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
  61306. * * 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
  61307. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61309. * * 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
  61310. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61312. * @param name defines the name of the mesh
  61313. * @param options defines the options used to create the mesh
  61314. * @param scene defines the hosting scene
  61315. * @returns the extruded shape mesh
  61316. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61318. */
  61319. static ExtrudeShape(name: string, options: {
  61320. shape: Vector3[];
  61321. path: Vector3[];
  61322. scale?: number;
  61323. rotation?: number;
  61324. cap?: number;
  61325. updatable?: boolean;
  61326. sideOrientation?: number;
  61327. frontUVs?: Vector4;
  61328. backUVs?: Vector4;
  61329. instance?: Mesh;
  61330. invertUV?: boolean;
  61331. }, scene?: Nullable<Scene>): Mesh;
  61332. /**
  61333. * Creates an custom extruded shape mesh.
  61334. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61335. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  61336. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61337. * * The parameter `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
  61338. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61339. * * 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
  61340. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61341. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61342. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61343. * * 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
  61344. * * 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
  61345. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61347. * * 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
  61348. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61350. * @param name defines the name of the mesh
  61351. * @param options defines the options used to create the mesh
  61352. * @param scene defines the hosting scene
  61353. * @returns the custom extruded shape mesh
  61354. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61355. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61356. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61357. */
  61358. static ExtrudeShapeCustom(name: string, options: {
  61359. shape: Vector3[];
  61360. path: Vector3[];
  61361. scaleFunction?: any;
  61362. rotationFunction?: any;
  61363. ribbonCloseArray?: boolean;
  61364. ribbonClosePath?: boolean;
  61365. cap?: number;
  61366. updatable?: boolean;
  61367. sideOrientation?: number;
  61368. frontUVs?: Vector4;
  61369. backUVs?: Vector4;
  61370. instance?: Mesh;
  61371. invertUV?: boolean;
  61372. }, scene?: Nullable<Scene>): Mesh;
  61373. /**
  61374. * Creates lathe mesh.
  61375. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61376. * * 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
  61377. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61378. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61379. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61380. * * 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
  61381. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61382. * * 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
  61383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61384. * * 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
  61385. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61387. * @param name defines the name of the mesh
  61388. * @param options defines the options used to create the mesh
  61389. * @param scene defines the hosting scene
  61390. * @returns the lathe mesh
  61391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61392. */
  61393. static CreateLathe(name: string, options: {
  61394. shape: Vector3[];
  61395. radius?: number;
  61396. tessellation?: number;
  61397. clip?: number;
  61398. arc?: number;
  61399. closed?: boolean;
  61400. updatable?: boolean;
  61401. sideOrientation?: number;
  61402. frontUVs?: Vector4;
  61403. backUVs?: Vector4;
  61404. cap?: number;
  61405. invertUV?: boolean;
  61406. }, scene?: Nullable<Scene>): Mesh;
  61407. /**
  61408. * Creates a tiled plane mesh
  61409. * * You can set a limited pattern arrangement with the tiles
  61410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61411. * * 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
  61412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61413. * @param name defines the name of the mesh
  61414. * @param options defines the options used to create the mesh
  61415. * @param scene defines the hosting scene
  61416. * @returns the plane mesh
  61417. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61418. */
  61419. static CreateTiledPlane(name: string, options: {
  61420. pattern?: number;
  61421. tileSize?: number;
  61422. tileWidth?: number;
  61423. tileHeight?: number;
  61424. size?: number;
  61425. width?: number;
  61426. height?: number;
  61427. alignHorizontal?: number;
  61428. alignVertical?: number;
  61429. sideOrientation?: number;
  61430. frontUVs?: Vector4;
  61431. backUVs?: Vector4;
  61432. updatable?: boolean;
  61433. }, scene?: Nullable<Scene>): Mesh;
  61434. /**
  61435. * Creates a plane mesh
  61436. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61437. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61438. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61442. * @param name defines the name of the mesh
  61443. * @param options defines the options used to create the mesh
  61444. * @param scene defines the hosting scene
  61445. * @returns the plane mesh
  61446. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61447. */
  61448. static CreatePlane(name: string, options: {
  61449. size?: number;
  61450. width?: number;
  61451. height?: number;
  61452. sideOrientation?: number;
  61453. frontUVs?: Vector4;
  61454. backUVs?: Vector4;
  61455. updatable?: boolean;
  61456. sourcePlane?: Plane;
  61457. }, scene?: Nullable<Scene>): Mesh;
  61458. /**
  61459. * Creates a ground mesh
  61460. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61461. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61463. * @param name defines the name of the mesh
  61464. * @param options defines the options used to create the mesh
  61465. * @param scene defines the hosting scene
  61466. * @returns the ground mesh
  61467. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61468. */
  61469. static CreateGround(name: string, options: {
  61470. width?: number;
  61471. height?: number;
  61472. subdivisions?: number;
  61473. subdivisionsX?: number;
  61474. subdivisionsY?: number;
  61475. updatable?: boolean;
  61476. }, scene?: Nullable<Scene>): Mesh;
  61477. /**
  61478. * Creates a tiled ground mesh
  61479. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61480. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61481. * * 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
  61482. * * 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
  61483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61484. * @param name defines the name of the mesh
  61485. * @param options defines the options used to create the mesh
  61486. * @param scene defines the hosting scene
  61487. * @returns the tiled ground mesh
  61488. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61489. */
  61490. static CreateTiledGround(name: string, options: {
  61491. xmin: number;
  61492. zmin: number;
  61493. xmax: number;
  61494. zmax: number;
  61495. subdivisions?: {
  61496. w: number;
  61497. h: number;
  61498. };
  61499. precision?: {
  61500. w: number;
  61501. h: number;
  61502. };
  61503. updatable?: boolean;
  61504. }, scene?: Nullable<Scene>): Mesh;
  61505. /**
  61506. * Creates a ground mesh from a height map
  61507. * * The parameter `url` sets the URL of the height map image resource.
  61508. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61509. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61510. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61511. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61512. * * 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.
  61513. * * 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).
  61514. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61516. * @param name defines the name of the mesh
  61517. * @param url defines the url to the height map
  61518. * @param options defines the options used to create the mesh
  61519. * @param scene defines the hosting scene
  61520. * @returns the ground mesh
  61521. * @see https://doc.babylonjs.com/babylon101/height_map
  61522. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61523. */
  61524. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61525. width?: number;
  61526. height?: number;
  61527. subdivisions?: number;
  61528. minHeight?: number;
  61529. maxHeight?: number;
  61530. colorFilter?: Color3;
  61531. alphaFilter?: number;
  61532. updatable?: boolean;
  61533. onReady?: (mesh: GroundMesh) => void;
  61534. }, scene?: Nullable<Scene>): GroundMesh;
  61535. /**
  61536. * Creates a polygon mesh
  61537. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61538. * * 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
  61539. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61541. * * 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)
  61542. * * Remember you can only change the shape positions, not their number when updating a polygon
  61543. * @param name defines the name of the mesh
  61544. * @param options defines the options used to create the mesh
  61545. * @param scene defines the hosting scene
  61546. * @param earcutInjection can be used to inject your own earcut reference
  61547. * @returns the polygon mesh
  61548. */
  61549. static CreatePolygon(name: string, options: {
  61550. shape: Vector3[];
  61551. holes?: Vector3[][];
  61552. depth?: number;
  61553. faceUV?: Vector4[];
  61554. faceColors?: Color4[];
  61555. updatable?: boolean;
  61556. sideOrientation?: number;
  61557. frontUVs?: Vector4;
  61558. backUVs?: Vector4;
  61559. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61560. /**
  61561. * Creates an extruded polygon mesh, with depth in the Y direction.
  61562. * * 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)
  61563. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61564. * @param name defines the name of the mesh
  61565. * @param options defines the options used to create the mesh
  61566. * @param scene defines the hosting scene
  61567. * @param earcutInjection can be used to inject your own earcut reference
  61568. * @returns the polygon mesh
  61569. */
  61570. static ExtrudePolygon(name: string, options: {
  61571. shape: Vector3[];
  61572. holes?: Vector3[][];
  61573. depth?: number;
  61574. faceUV?: Vector4[];
  61575. faceColors?: Color4[];
  61576. updatable?: boolean;
  61577. sideOrientation?: number;
  61578. frontUVs?: Vector4;
  61579. backUVs?: Vector4;
  61580. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61581. /**
  61582. * Creates a tube mesh.
  61583. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61584. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61585. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61586. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61587. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61588. * * 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)
  61589. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61590. * * 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
  61591. * * 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
  61592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61593. * * 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
  61594. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61596. * @param name defines the name of the mesh
  61597. * @param options defines the options used to create the mesh
  61598. * @param scene defines the hosting scene
  61599. * @returns the tube mesh
  61600. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61601. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61602. */
  61603. static CreateTube(name: string, options: {
  61604. path: Vector3[];
  61605. radius?: number;
  61606. tessellation?: number;
  61607. radiusFunction?: {
  61608. (i: number, distance: number): number;
  61609. };
  61610. cap?: number;
  61611. arc?: number;
  61612. updatable?: boolean;
  61613. sideOrientation?: number;
  61614. frontUVs?: Vector4;
  61615. backUVs?: Vector4;
  61616. instance?: Mesh;
  61617. invertUV?: boolean;
  61618. }, scene?: Nullable<Scene>): Mesh;
  61619. /**
  61620. * Creates a polyhedron mesh
  61621. * * 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
  61622. * * The parameter `size` (positive float, default 1) sets the polygon size
  61623. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61624. * * 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`
  61625. * * 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
  61626. * * 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)`)
  61627. * * 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
  61628. * * 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
  61629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61630. * * 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
  61631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61632. * @param name defines the name of the mesh
  61633. * @param options defines the options used to create the mesh
  61634. * @param scene defines the hosting scene
  61635. * @returns the polyhedron mesh
  61636. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61637. */
  61638. static CreatePolyhedron(name: string, options: {
  61639. type?: number;
  61640. size?: number;
  61641. sizeX?: number;
  61642. sizeY?: number;
  61643. sizeZ?: number;
  61644. custom?: any;
  61645. faceUV?: Vector4[];
  61646. faceColors?: Color4[];
  61647. flat?: boolean;
  61648. updatable?: boolean;
  61649. sideOrientation?: number;
  61650. frontUVs?: Vector4;
  61651. backUVs?: Vector4;
  61652. }, scene?: Nullable<Scene>): Mesh;
  61653. /**
  61654. * Creates a decal mesh.
  61655. * 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
  61656. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61657. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61658. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61659. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61660. * @param name defines the name of the mesh
  61661. * @param sourceMesh defines the mesh where the decal must be applied
  61662. * @param options defines the options used to create the mesh
  61663. * @param scene defines the hosting scene
  61664. * @returns the decal mesh
  61665. * @see https://doc.babylonjs.com/how_to/decals
  61666. */
  61667. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61668. position?: Vector3;
  61669. normal?: Vector3;
  61670. size?: Vector3;
  61671. angle?: number;
  61672. }): Mesh;
  61673. }
  61674. }
  61675. declare module BABYLON {
  61676. /**
  61677. * A simplifier interface for future simplification implementations
  61678. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61679. */
  61680. export interface ISimplifier {
  61681. /**
  61682. * Simplification of a given mesh according to the given settings.
  61683. * Since this requires computation, it is assumed that the function runs async.
  61684. * @param settings The settings of the simplification, including quality and distance
  61685. * @param successCallback A callback that will be called after the mesh was simplified.
  61686. * @param errorCallback in case of an error, this callback will be called. optional.
  61687. */
  61688. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61689. }
  61690. /**
  61691. * Expected simplification settings.
  61692. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61693. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61694. */
  61695. export interface ISimplificationSettings {
  61696. /**
  61697. * Gets or sets the expected quality
  61698. */
  61699. quality: number;
  61700. /**
  61701. * Gets or sets the distance when this optimized version should be used
  61702. */
  61703. distance: number;
  61704. /**
  61705. * Gets an already optimized mesh
  61706. */
  61707. optimizeMesh?: boolean;
  61708. }
  61709. /**
  61710. * Class used to specify simplification options
  61711. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61712. */
  61713. export class SimplificationSettings implements ISimplificationSettings {
  61714. /** expected quality */
  61715. quality: number;
  61716. /** distance when this optimized version should be used */
  61717. distance: number;
  61718. /** already optimized mesh */
  61719. optimizeMesh?: boolean | undefined;
  61720. /**
  61721. * Creates a SimplificationSettings
  61722. * @param quality expected quality
  61723. * @param distance distance when this optimized version should be used
  61724. * @param optimizeMesh already optimized mesh
  61725. */
  61726. constructor(
  61727. /** expected quality */
  61728. quality: number,
  61729. /** distance when this optimized version should be used */
  61730. distance: number,
  61731. /** already optimized mesh */
  61732. optimizeMesh?: boolean | undefined);
  61733. }
  61734. /**
  61735. * Interface used to define a simplification task
  61736. */
  61737. export interface ISimplificationTask {
  61738. /**
  61739. * Array of settings
  61740. */
  61741. settings: Array<ISimplificationSettings>;
  61742. /**
  61743. * Simplification type
  61744. */
  61745. simplificationType: SimplificationType;
  61746. /**
  61747. * Mesh to simplify
  61748. */
  61749. mesh: Mesh;
  61750. /**
  61751. * Callback called on success
  61752. */
  61753. successCallback?: () => void;
  61754. /**
  61755. * Defines if parallel processing can be used
  61756. */
  61757. parallelProcessing: boolean;
  61758. }
  61759. /**
  61760. * Queue used to order the simplification tasks
  61761. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61762. */
  61763. export class SimplificationQueue {
  61764. private _simplificationArray;
  61765. /**
  61766. * Gets a boolean indicating that the process is still running
  61767. */
  61768. running: boolean;
  61769. /**
  61770. * Creates a new queue
  61771. */
  61772. constructor();
  61773. /**
  61774. * Adds a new simplification task
  61775. * @param task defines a task to add
  61776. */
  61777. addTask(task: ISimplificationTask): void;
  61778. /**
  61779. * Execute next task
  61780. */
  61781. executeNext(): void;
  61782. /**
  61783. * Execute a simplification task
  61784. * @param task defines the task to run
  61785. */
  61786. runSimplification(task: ISimplificationTask): void;
  61787. private getSimplifier;
  61788. }
  61789. /**
  61790. * The implemented types of simplification
  61791. * At the moment only Quadratic Error Decimation is implemented
  61792. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61793. */
  61794. export enum SimplificationType {
  61795. /** Quadratic error decimation */
  61796. QUADRATIC = 0
  61797. }
  61798. /**
  61799. * An implementation of the Quadratic Error simplification algorithm.
  61800. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  61801. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  61802. * @author RaananW
  61803. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61804. */
  61805. export class QuadraticErrorSimplification implements ISimplifier {
  61806. private _mesh;
  61807. private triangles;
  61808. private vertices;
  61809. private references;
  61810. private _reconstructedMesh;
  61811. /** Gets or sets the number pf sync interations */
  61812. syncIterations: number;
  61813. /** Gets or sets the aggressiveness of the simplifier */
  61814. aggressiveness: number;
  61815. /** Gets or sets the number of allowed iterations for decimation */
  61816. decimationIterations: number;
  61817. /** Gets or sets the espilon to use for bounding box computation */
  61818. boundingBoxEpsilon: number;
  61819. /**
  61820. * Creates a new QuadraticErrorSimplification
  61821. * @param _mesh defines the target mesh
  61822. */
  61823. constructor(_mesh: Mesh);
  61824. /**
  61825. * Simplification of a given mesh according to the given settings.
  61826. * Since this requires computation, it is assumed that the function runs async.
  61827. * @param settings The settings of the simplification, including quality and distance
  61828. * @param successCallback A callback that will be called after the mesh was simplified.
  61829. */
  61830. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  61831. private runDecimation;
  61832. private initWithMesh;
  61833. private init;
  61834. private reconstructMesh;
  61835. private initDecimatedMesh;
  61836. private isFlipped;
  61837. private updateTriangles;
  61838. private identifyBorder;
  61839. private updateMesh;
  61840. private vertexError;
  61841. private calculateError;
  61842. }
  61843. }
  61844. declare module BABYLON {
  61845. interface Scene {
  61846. /** @hidden (Backing field) */
  61847. _simplificationQueue: SimplificationQueue;
  61848. /**
  61849. * Gets or sets the simplification queue attached to the scene
  61850. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61851. */
  61852. simplificationQueue: SimplificationQueue;
  61853. }
  61854. interface Mesh {
  61855. /**
  61856. * Simplify the mesh according to the given array of settings.
  61857. * Function will return immediately and will simplify async
  61858. * @param settings a collection of simplification settings
  61859. * @param parallelProcessing should all levels calculate parallel or one after the other
  61860. * @param simplificationType the type of simplification to run
  61861. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61862. * @returns the current mesh
  61863. */
  61864. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61865. }
  61866. /**
  61867. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61868. * created in a scene
  61869. */
  61870. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61871. /**
  61872. * The component name helpfull to identify the component in the list of scene components.
  61873. */
  61874. readonly name: string;
  61875. /**
  61876. * The scene the component belongs to.
  61877. */
  61878. scene: Scene;
  61879. /**
  61880. * Creates a new instance of the component for the given scene
  61881. * @param scene Defines the scene to register the component in
  61882. */
  61883. constructor(scene: Scene);
  61884. /**
  61885. * Registers the component in a given scene
  61886. */
  61887. register(): void;
  61888. /**
  61889. * Rebuilds the elements related to this component in case of
  61890. * context lost for instance.
  61891. */
  61892. rebuild(): void;
  61893. /**
  61894. * Disposes the component and the associated ressources
  61895. */
  61896. dispose(): void;
  61897. private _beforeCameraUpdate;
  61898. }
  61899. }
  61900. declare module BABYLON {
  61901. /**
  61902. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61903. */
  61904. export interface INavigationEnginePlugin {
  61905. /**
  61906. * plugin name
  61907. */
  61908. name: string;
  61909. /**
  61910. * Creates a navigation mesh
  61911. * @param meshes array of all the geometry used to compute the navigatio mesh
  61912. * @param parameters bunch of parameters used to filter geometry
  61913. */
  61914. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61915. /**
  61916. * Create a navigation mesh debug mesh
  61917. * @param scene is where the mesh will be added
  61918. * @returns debug display mesh
  61919. */
  61920. createDebugNavMesh(scene: Scene): Mesh;
  61921. /**
  61922. * Get a navigation mesh constrained position, closest to the parameter position
  61923. * @param position world position
  61924. * @returns the closest point to position constrained by the navigation mesh
  61925. */
  61926. getClosestPoint(position: Vector3): Vector3;
  61927. /**
  61928. * Get a navigation mesh constrained position, within a particular radius
  61929. * @param position world position
  61930. * @param maxRadius the maximum distance to the constrained world position
  61931. * @returns the closest point to position constrained by the navigation mesh
  61932. */
  61933. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61934. /**
  61935. * Compute the final position from a segment made of destination-position
  61936. * @param position world position
  61937. * @param destination world position
  61938. * @returns the resulting point along the navmesh
  61939. */
  61940. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61941. /**
  61942. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61943. * @param start world position
  61944. * @param end world position
  61945. * @returns array containing world position composing the path
  61946. */
  61947. computePath(start: Vector3, end: Vector3): Vector3[];
  61948. /**
  61949. * If this plugin is supported
  61950. * @returns true if plugin is supported
  61951. */
  61952. isSupported(): boolean;
  61953. /**
  61954. * Create a new Crowd so you can add agents
  61955. * @param maxAgents the maximum agent count in the crowd
  61956. * @param maxAgentRadius the maximum radius an agent can have
  61957. * @param scene to attach the crowd to
  61958. * @returns the crowd you can add agents to
  61959. */
  61960. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  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. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61980. */
  61981. export interface ICrowd {
  61982. /**
  61983. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61984. * You can attach anything to that node. The node position is updated in the scene update tick.
  61985. * @param pos world position that will be constrained by the navigation mesh
  61986. * @param parameters agent parameters
  61987. * @param transform hooked to the agent that will be update by the scene
  61988. * @returns agent index
  61989. */
  61990. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61991. /**
  61992. * Returns the agent position in world space
  61993. * @param index agent index returned by addAgent
  61994. * @returns world space position
  61995. */
  61996. getAgentPosition(index: number): Vector3;
  61997. /**
  61998. * Gets the agent velocity in world space
  61999. * @param index agent index returned by addAgent
  62000. * @returns world space velocity
  62001. */
  62002. getAgentVelocity(index: number): Vector3;
  62003. /**
  62004. * remove a particular agent previously created
  62005. * @param index agent index returned by addAgent
  62006. */
  62007. removeAgent(index: number): void;
  62008. /**
  62009. * get the list of all agents attached to this crowd
  62010. * @returns list of agent indices
  62011. */
  62012. getAgents(): number[];
  62013. /**
  62014. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62015. * @param deltaTime in seconds
  62016. */
  62017. update(deltaTime: number): void;
  62018. /**
  62019. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62020. * @param index agent index returned by addAgent
  62021. * @param destination targeted world position
  62022. */
  62023. agentGoto(index: number, destination: Vector3): void;
  62024. /**
  62025. * Teleport the agent to a new position
  62026. * @param index agent index returned by addAgent
  62027. * @param destination targeted world position
  62028. */
  62029. agentTeleport(index: number, destination: Vector3): void;
  62030. /**
  62031. * Update agent parameters
  62032. * @param index agent index returned by addAgent
  62033. * @param parameters agent parameters
  62034. */
  62035. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62036. /**
  62037. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62038. * The queries will try to find a solution within those bounds
  62039. * default is (1,1,1)
  62040. * @param extent x,y,z value that define the extent around the queries point of reference
  62041. */
  62042. setDefaultQueryExtent(extent: Vector3): void;
  62043. /**
  62044. * Get the Bounding box extent specified by setDefaultQueryExtent
  62045. * @returns the box extent values
  62046. */
  62047. getDefaultQueryExtent(): Vector3;
  62048. /**
  62049. * Release all resources
  62050. */
  62051. dispose(): void;
  62052. }
  62053. /**
  62054. * Configures an agent
  62055. */
  62056. export interface IAgentParameters {
  62057. /**
  62058. * Agent radius. [Limit: >= 0]
  62059. */
  62060. radius: number;
  62061. /**
  62062. * Agent height. [Limit: > 0]
  62063. */
  62064. height: number;
  62065. /**
  62066. * Maximum allowed acceleration. [Limit: >= 0]
  62067. */
  62068. maxAcceleration: number;
  62069. /**
  62070. * Maximum allowed speed. [Limit: >= 0]
  62071. */
  62072. maxSpeed: number;
  62073. /**
  62074. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62075. */
  62076. collisionQueryRange: number;
  62077. /**
  62078. * The path visibility optimization range. [Limit: > 0]
  62079. */
  62080. pathOptimizationRange: number;
  62081. /**
  62082. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62083. */
  62084. separationWeight: number;
  62085. }
  62086. /**
  62087. * Configures the navigation mesh creation
  62088. */
  62089. export interface INavMeshParameters {
  62090. /**
  62091. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62092. */
  62093. cs: number;
  62094. /**
  62095. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62096. */
  62097. ch: number;
  62098. /**
  62099. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62100. */
  62101. walkableSlopeAngle: number;
  62102. /**
  62103. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62104. * be considered walkable. [Limit: >= 3] [Units: vx]
  62105. */
  62106. walkableHeight: number;
  62107. /**
  62108. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62109. */
  62110. walkableClimb: number;
  62111. /**
  62112. * The distance to erode/shrink the walkable area of the heightfield away from
  62113. * obstructions. [Limit: >=0] [Units: vx]
  62114. */
  62115. walkableRadius: number;
  62116. /**
  62117. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62118. */
  62119. maxEdgeLen: number;
  62120. /**
  62121. * The maximum distance a simplfied contour's border edges should deviate
  62122. * the original raw contour. [Limit: >=0] [Units: vx]
  62123. */
  62124. maxSimplificationError: number;
  62125. /**
  62126. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62127. */
  62128. minRegionArea: number;
  62129. /**
  62130. * Any regions with a span count smaller than this value will, if possible,
  62131. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62132. */
  62133. mergeRegionArea: number;
  62134. /**
  62135. * The maximum number of vertices allowed for polygons generated during the
  62136. * contour to polygon conversion process. [Limit: >= 3]
  62137. */
  62138. maxVertsPerPoly: number;
  62139. /**
  62140. * Sets the sampling distance to use when generating the detail mesh.
  62141. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62142. */
  62143. detailSampleDist: number;
  62144. /**
  62145. * The maximum distance the detail mesh surface should deviate from heightfield
  62146. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62147. */
  62148. detailSampleMaxError: number;
  62149. }
  62150. }
  62151. declare module BABYLON {
  62152. /**
  62153. * RecastJS navigation plugin
  62154. */
  62155. export class RecastJSPlugin implements INavigationEnginePlugin {
  62156. /**
  62157. * Reference to the Recast library
  62158. */
  62159. bjsRECAST: any;
  62160. /**
  62161. * plugin name
  62162. */
  62163. name: string;
  62164. /**
  62165. * the first navmesh created. We might extend this to support multiple navmeshes
  62166. */
  62167. navMesh: any;
  62168. /**
  62169. * Initializes the recastJS plugin
  62170. * @param recastInjection can be used to inject your own recast reference
  62171. */
  62172. constructor(recastInjection?: any);
  62173. /**
  62174. * Creates a navigation mesh
  62175. * @param meshes array of all the geometry used to compute the navigatio mesh
  62176. * @param parameters bunch of parameters used to filter geometry
  62177. */
  62178. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62179. /**
  62180. * Create a navigation mesh debug mesh
  62181. * @param scene is where the mesh will be added
  62182. * @returns debug display mesh
  62183. */
  62184. createDebugNavMesh(scene: Scene): Mesh;
  62185. /**
  62186. * Get a navigation mesh constrained position, closest to the parameter position
  62187. * @param position world position
  62188. * @returns the closest point to position constrained by the navigation mesh
  62189. */
  62190. getClosestPoint(position: Vector3): Vector3;
  62191. /**
  62192. * Get a navigation mesh constrained position, within a particular radius
  62193. * @param position world position
  62194. * @param maxRadius the maximum distance to the constrained world position
  62195. * @returns the closest point to position constrained by the navigation mesh
  62196. */
  62197. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62198. /**
  62199. * Compute the final position from a segment made of destination-position
  62200. * @param position world position
  62201. * @param destination world position
  62202. * @returns the resulting point along the navmesh
  62203. */
  62204. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62205. /**
  62206. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62207. * @param start world position
  62208. * @param end world position
  62209. * @returns array containing world position composing the path
  62210. */
  62211. computePath(start: Vector3, end: Vector3): Vector3[];
  62212. /**
  62213. * Create a new Crowd so you can add agents
  62214. * @param maxAgents the maximum agent count in the crowd
  62215. * @param maxAgentRadius the maximum radius an agent can have
  62216. * @param scene to attach the crowd to
  62217. * @returns the crowd you can add agents to
  62218. */
  62219. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62220. /**
  62221. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62222. * The queries will try to find a solution within those bounds
  62223. * default is (1,1,1)
  62224. * @param extent x,y,z value that define the extent around the queries point of reference
  62225. */
  62226. setDefaultQueryExtent(extent: Vector3): void;
  62227. /**
  62228. * Get the Bounding box extent specified by setDefaultQueryExtent
  62229. * @returns the box extent values
  62230. */
  62231. getDefaultQueryExtent(): Vector3;
  62232. /**
  62233. * Disposes
  62234. */
  62235. dispose(): void;
  62236. /**
  62237. * If this plugin is supported
  62238. * @returns true if plugin is supported
  62239. */
  62240. isSupported(): boolean;
  62241. }
  62242. /**
  62243. * Recast detour crowd implementation
  62244. */
  62245. export class RecastJSCrowd implements ICrowd {
  62246. /**
  62247. * Recast/detour plugin
  62248. */
  62249. bjsRECASTPlugin: RecastJSPlugin;
  62250. /**
  62251. * Link to the detour crowd
  62252. */
  62253. recastCrowd: any;
  62254. /**
  62255. * One transform per agent
  62256. */
  62257. transforms: TransformNode[];
  62258. /**
  62259. * All agents created
  62260. */
  62261. agents: number[];
  62262. /**
  62263. * Link to the scene is kept to unregister the crowd from the scene
  62264. */
  62265. private _scene;
  62266. /**
  62267. * Observer for crowd updates
  62268. */
  62269. private _onBeforeAnimationsObserver;
  62270. /**
  62271. * Constructor
  62272. * @param plugin recastJS plugin
  62273. * @param maxAgents the maximum agent count in the crowd
  62274. * @param maxAgentRadius the maximum radius an agent can have
  62275. * @param scene to attach the crowd to
  62276. * @returns the crowd you can add agents to
  62277. */
  62278. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62279. /**
  62280. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62281. * You can attach anything to that node. The node position is updated in the scene update tick.
  62282. * @param pos world position that will be constrained by the navigation mesh
  62283. * @param parameters agent parameters
  62284. * @param transform hooked to the agent that will be update by the scene
  62285. * @returns agent index
  62286. */
  62287. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62288. /**
  62289. * Returns the agent position in world space
  62290. * @param index agent index returned by addAgent
  62291. * @returns world space position
  62292. */
  62293. getAgentPosition(index: number): Vector3;
  62294. /**
  62295. * Returns the agent velocity in world space
  62296. * @param index agent index returned by addAgent
  62297. * @returns world space velocity
  62298. */
  62299. getAgentVelocity(index: number): Vector3;
  62300. /**
  62301. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62302. * @param index agent index returned by addAgent
  62303. * @param destination targeted world position
  62304. */
  62305. agentGoto(index: number, destination: Vector3): void;
  62306. /**
  62307. * Teleport the agent to a new position
  62308. * @param index agent index returned by addAgent
  62309. * @param destination targeted world position
  62310. */
  62311. agentTeleport(index: number, destination: Vector3): void;
  62312. /**
  62313. * Update agent parameters
  62314. * @param index agent index returned by addAgent
  62315. * @param parameters agent parameters
  62316. */
  62317. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62318. /**
  62319. * remove a particular agent previously created
  62320. * @param index agent index returned by addAgent
  62321. */
  62322. removeAgent(index: number): void;
  62323. /**
  62324. * get the list of all agents attached to this crowd
  62325. * @returns list of agent indices
  62326. */
  62327. getAgents(): number[];
  62328. /**
  62329. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62330. * @param deltaTime in seconds
  62331. */
  62332. update(deltaTime: number): void;
  62333. /**
  62334. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62335. * The queries will try to find a solution within those bounds
  62336. * default is (1,1,1)
  62337. * @param extent x,y,z value that define the extent around the queries point of reference
  62338. */
  62339. setDefaultQueryExtent(extent: Vector3): void;
  62340. /**
  62341. * Get the Bounding box extent specified by setDefaultQueryExtent
  62342. * @returns the box extent values
  62343. */
  62344. getDefaultQueryExtent(): Vector3;
  62345. /**
  62346. * Release all resources
  62347. */
  62348. dispose(): void;
  62349. }
  62350. }
  62351. declare module BABYLON {
  62352. /**
  62353. * Class used to enable access to IndexedDB
  62354. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62355. */
  62356. export class Database implements IOfflineProvider {
  62357. private _callbackManifestChecked;
  62358. private _currentSceneUrl;
  62359. private _db;
  62360. private _enableSceneOffline;
  62361. private _enableTexturesOffline;
  62362. private _manifestVersionFound;
  62363. private _mustUpdateRessources;
  62364. private _hasReachedQuota;
  62365. private _isSupported;
  62366. private _idbFactory;
  62367. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62368. private static IsUASupportingBlobStorage;
  62369. /**
  62370. * Gets a boolean indicating if Database storate is enabled (off by default)
  62371. */
  62372. static IDBStorageEnabled: boolean;
  62373. /**
  62374. * Gets a boolean indicating if scene must be saved in the database
  62375. */
  62376. get enableSceneOffline(): boolean;
  62377. /**
  62378. * Gets a boolean indicating if textures must be saved in the database
  62379. */
  62380. get enableTexturesOffline(): boolean;
  62381. /**
  62382. * Creates a new Database
  62383. * @param urlToScene defines the url to load the scene
  62384. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62385. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62386. */
  62387. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62388. private static _ParseURL;
  62389. private static _ReturnFullUrlLocation;
  62390. private _checkManifestFile;
  62391. /**
  62392. * Open the database and make it available
  62393. * @param successCallback defines the callback to call on success
  62394. * @param errorCallback defines the callback to call on error
  62395. */
  62396. open(successCallback: () => void, errorCallback: () => void): void;
  62397. /**
  62398. * Loads an image from the database
  62399. * @param url defines the url to load from
  62400. * @param image defines the target DOM image
  62401. */
  62402. loadImage(url: string, image: HTMLImageElement): void;
  62403. private _loadImageFromDBAsync;
  62404. private _saveImageIntoDBAsync;
  62405. private _checkVersionFromDB;
  62406. private _loadVersionFromDBAsync;
  62407. private _saveVersionIntoDBAsync;
  62408. /**
  62409. * Loads a file from database
  62410. * @param url defines the URL to load from
  62411. * @param sceneLoaded defines a callback to call on success
  62412. * @param progressCallBack defines a callback to call when progress changed
  62413. * @param errorCallback defines a callback to call on error
  62414. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62415. */
  62416. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62417. private _loadFileAsync;
  62418. private _saveFileAsync;
  62419. /**
  62420. * Validates if xhr data is correct
  62421. * @param xhr defines the request to validate
  62422. * @param dataType defines the expected data type
  62423. * @returns true if data is correct
  62424. */
  62425. private static _ValidateXHRData;
  62426. }
  62427. }
  62428. declare module BABYLON {
  62429. /** @hidden */
  62430. export var gpuUpdateParticlesPixelShader: {
  62431. name: string;
  62432. shader: string;
  62433. };
  62434. }
  62435. declare module BABYLON {
  62436. /** @hidden */
  62437. export var gpuUpdateParticlesVertexShader: {
  62438. name: string;
  62439. shader: string;
  62440. };
  62441. }
  62442. declare module BABYLON {
  62443. /** @hidden */
  62444. export var clipPlaneFragmentDeclaration2: {
  62445. name: string;
  62446. shader: string;
  62447. };
  62448. }
  62449. declare module BABYLON {
  62450. /** @hidden */
  62451. export var gpuRenderParticlesPixelShader: {
  62452. name: string;
  62453. shader: string;
  62454. };
  62455. }
  62456. declare module BABYLON {
  62457. /** @hidden */
  62458. export var clipPlaneVertexDeclaration2: {
  62459. name: string;
  62460. shader: string;
  62461. };
  62462. }
  62463. declare module BABYLON {
  62464. /** @hidden */
  62465. export var gpuRenderParticlesVertexShader: {
  62466. name: string;
  62467. shader: string;
  62468. };
  62469. }
  62470. declare module BABYLON {
  62471. /**
  62472. * This represents a GPU particle system in Babylon
  62473. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62474. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62475. */
  62476. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62477. /**
  62478. * The layer mask we are rendering the particles through.
  62479. */
  62480. layerMask: number;
  62481. private _capacity;
  62482. private _activeCount;
  62483. private _currentActiveCount;
  62484. private _accumulatedCount;
  62485. private _renderEffect;
  62486. private _updateEffect;
  62487. private _buffer0;
  62488. private _buffer1;
  62489. private _spriteBuffer;
  62490. private _updateVAO;
  62491. private _renderVAO;
  62492. private _targetIndex;
  62493. private _sourceBuffer;
  62494. private _targetBuffer;
  62495. private _engine;
  62496. private _currentRenderId;
  62497. private _started;
  62498. private _stopped;
  62499. private _timeDelta;
  62500. private _randomTexture;
  62501. private _randomTexture2;
  62502. private _attributesStrideSize;
  62503. private _updateEffectOptions;
  62504. private _randomTextureSize;
  62505. private _actualFrame;
  62506. private readonly _rawTextureWidth;
  62507. /**
  62508. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62509. */
  62510. static get IsSupported(): boolean;
  62511. /**
  62512. * An event triggered when the system is disposed.
  62513. */
  62514. onDisposeObservable: Observable<GPUParticleSystem>;
  62515. /**
  62516. * Gets the maximum number of particles active at the same time.
  62517. * @returns The max number of active particles.
  62518. */
  62519. getCapacity(): number;
  62520. /**
  62521. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62522. * to override the particles.
  62523. */
  62524. forceDepthWrite: boolean;
  62525. /**
  62526. * Gets or set the number of active particles
  62527. */
  62528. get activeParticleCount(): number;
  62529. set activeParticleCount(value: number);
  62530. private _preWarmDone;
  62531. /**
  62532. * Specifies if the particles are updated in emitter local space or world space.
  62533. * This is always false for GPU particles
  62534. */
  62535. get isLocal(): boolean;
  62536. set isLocal(value: boolean);
  62537. /**
  62538. * Is this system ready to be used/rendered
  62539. * @return true if the system is ready
  62540. */
  62541. isReady(): boolean;
  62542. /**
  62543. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62544. * @returns True if it has been started, otherwise false.
  62545. */
  62546. isStarted(): boolean;
  62547. /**
  62548. * Starts the particle system and begins to emit
  62549. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62550. */
  62551. start(delay?: number): void;
  62552. /**
  62553. * Stops the particle system.
  62554. */
  62555. stop(): void;
  62556. /**
  62557. * Remove all active particles
  62558. */
  62559. reset(): void;
  62560. /**
  62561. * Returns the string "GPUParticleSystem"
  62562. * @returns a string containing the class name
  62563. */
  62564. getClassName(): string;
  62565. private _colorGradientsTexture;
  62566. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62567. /**
  62568. * Adds a new color gradient
  62569. * @param gradient defines the gradient to use (between 0 and 1)
  62570. * @param color1 defines the color to affect to the specified gradient
  62571. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62572. * @returns the current particle system
  62573. */
  62574. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62575. /**
  62576. * Remove a specific color gradient
  62577. * @param gradient defines the gradient to remove
  62578. * @returns the current particle system
  62579. */
  62580. removeColorGradient(gradient: number): GPUParticleSystem;
  62581. private _angularSpeedGradientsTexture;
  62582. private _sizeGradientsTexture;
  62583. private _velocityGradientsTexture;
  62584. private _limitVelocityGradientsTexture;
  62585. private _dragGradientsTexture;
  62586. private _addFactorGradient;
  62587. /**
  62588. * Adds a new size gradient
  62589. * @param gradient defines the gradient to use (between 0 and 1)
  62590. * @param factor defines the size factor to affect to the specified gradient
  62591. * @returns the current particle system
  62592. */
  62593. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62594. /**
  62595. * Remove a specific size gradient
  62596. * @param gradient defines the gradient to remove
  62597. * @returns the current particle system
  62598. */
  62599. removeSizeGradient(gradient: number): GPUParticleSystem;
  62600. /**
  62601. * Adds a new angular speed gradient
  62602. * @param gradient defines the gradient to use (between 0 and 1)
  62603. * @param factor defines the angular speed to affect to the specified gradient
  62604. * @returns the current particle system
  62605. */
  62606. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62607. /**
  62608. * Remove a specific angular speed gradient
  62609. * @param gradient defines the gradient to remove
  62610. * @returns the current particle system
  62611. */
  62612. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62613. /**
  62614. * Adds a new velocity gradient
  62615. * @param gradient defines the gradient to use (between 0 and 1)
  62616. * @param factor defines the velocity to affect to the specified gradient
  62617. * @returns the current particle system
  62618. */
  62619. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62620. /**
  62621. * Remove a specific velocity gradient
  62622. * @param gradient defines the gradient to remove
  62623. * @returns the current particle system
  62624. */
  62625. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62626. /**
  62627. * Adds a new limit velocity gradient
  62628. * @param gradient defines the gradient to use (between 0 and 1)
  62629. * @param factor defines the limit velocity value to affect to the specified gradient
  62630. * @returns the current particle system
  62631. */
  62632. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62633. /**
  62634. * Remove a specific limit velocity gradient
  62635. * @param gradient defines the gradient to remove
  62636. * @returns the current particle system
  62637. */
  62638. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62639. /**
  62640. * Adds a new drag gradient
  62641. * @param gradient defines the gradient to use (between 0 and 1)
  62642. * @param factor defines the drag value to affect to the specified gradient
  62643. * @returns the current particle system
  62644. */
  62645. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62646. /**
  62647. * Remove a specific drag gradient
  62648. * @param gradient defines the gradient to remove
  62649. * @returns the current particle system
  62650. */
  62651. removeDragGradient(gradient: number): GPUParticleSystem;
  62652. /**
  62653. * Not supported by GPUParticleSystem
  62654. * @param gradient defines the gradient to use (between 0 and 1)
  62655. * @param factor defines the emit rate value to affect to the specified gradient
  62656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62657. * @returns the current particle system
  62658. */
  62659. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62660. /**
  62661. * Not supported by GPUParticleSystem
  62662. * @param gradient defines the gradient to remove
  62663. * @returns the current particle system
  62664. */
  62665. removeEmitRateGradient(gradient: number): IParticleSystem;
  62666. /**
  62667. * Not supported by GPUParticleSystem
  62668. * @param gradient defines the gradient to use (between 0 and 1)
  62669. * @param factor defines the start size value to affect to the specified gradient
  62670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62671. * @returns the current particle system
  62672. */
  62673. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62674. /**
  62675. * Not supported by GPUParticleSystem
  62676. * @param gradient defines the gradient to remove
  62677. * @returns the current particle system
  62678. */
  62679. removeStartSizeGradient(gradient: number): IParticleSystem;
  62680. /**
  62681. * Not supported by GPUParticleSystem
  62682. * @param gradient defines the gradient to use (between 0 and 1)
  62683. * @param min defines the color remap minimal range
  62684. * @param max defines the color remap maximal range
  62685. * @returns the current particle system
  62686. */
  62687. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62688. /**
  62689. * Not supported by GPUParticleSystem
  62690. * @param gradient defines the gradient to remove
  62691. * @returns the current particle system
  62692. */
  62693. removeColorRemapGradient(): IParticleSystem;
  62694. /**
  62695. * Not supported by GPUParticleSystem
  62696. * @param gradient defines the gradient to use (between 0 and 1)
  62697. * @param min defines the alpha remap minimal range
  62698. * @param max defines the alpha remap maximal range
  62699. * @returns the current particle system
  62700. */
  62701. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62702. /**
  62703. * Not supported by GPUParticleSystem
  62704. * @param gradient defines the gradient to remove
  62705. * @returns the current particle system
  62706. */
  62707. removeAlphaRemapGradient(): IParticleSystem;
  62708. /**
  62709. * Not supported by GPUParticleSystem
  62710. * @param gradient defines the gradient to use (between 0 and 1)
  62711. * @param color defines the color to affect to the specified gradient
  62712. * @returns the current particle system
  62713. */
  62714. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62715. /**
  62716. * Not supported by GPUParticleSystem
  62717. * @param gradient defines the gradient to remove
  62718. * @returns the current particle system
  62719. */
  62720. removeRampGradient(): IParticleSystem;
  62721. /**
  62722. * Not supported by GPUParticleSystem
  62723. * @returns the list of ramp gradients
  62724. */
  62725. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62726. /**
  62727. * Not supported by GPUParticleSystem
  62728. * Gets or sets a boolean indicating that ramp gradients must be used
  62729. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62730. */
  62731. get useRampGradients(): boolean;
  62732. set useRampGradients(value: boolean);
  62733. /**
  62734. * Not supported by GPUParticleSystem
  62735. * @param gradient defines the gradient to use (between 0 and 1)
  62736. * @param factor defines the life time factor to affect to the specified gradient
  62737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62738. * @returns the current particle system
  62739. */
  62740. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62741. /**
  62742. * Not supported by GPUParticleSystem
  62743. * @param gradient defines the gradient to remove
  62744. * @returns the current particle system
  62745. */
  62746. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62747. /**
  62748. * Instantiates a GPU particle system.
  62749. * 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.
  62750. * @param name The name of the particle system
  62751. * @param options The options used to create the system
  62752. * @param scene The scene the particle system belongs to
  62753. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62754. */
  62755. constructor(name: string, options: Partial<{
  62756. capacity: number;
  62757. randomTextureSize: number;
  62758. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62759. protected _reset(): void;
  62760. private _createUpdateVAO;
  62761. private _createRenderVAO;
  62762. private _initialize;
  62763. /** @hidden */
  62764. _recreateUpdateEffect(): void;
  62765. /** @hidden */
  62766. _recreateRenderEffect(): void;
  62767. /**
  62768. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62769. * @param preWarm defines if we are in the pre-warmimg phase
  62770. */
  62771. animate(preWarm?: boolean): void;
  62772. private _createFactorGradientTexture;
  62773. private _createSizeGradientTexture;
  62774. private _createAngularSpeedGradientTexture;
  62775. private _createVelocityGradientTexture;
  62776. private _createLimitVelocityGradientTexture;
  62777. private _createDragGradientTexture;
  62778. private _createColorGradientTexture;
  62779. /**
  62780. * Renders the particle system in its current state
  62781. * @param preWarm defines if the system should only update the particles but not render them
  62782. * @returns the current number of particles
  62783. */
  62784. render(preWarm?: boolean): number;
  62785. /**
  62786. * Rebuilds the particle system
  62787. */
  62788. rebuild(): void;
  62789. private _releaseBuffers;
  62790. private _releaseVAOs;
  62791. /**
  62792. * Disposes the particle system and free the associated resources
  62793. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62794. */
  62795. dispose(disposeTexture?: boolean): void;
  62796. /**
  62797. * Clones the particle system.
  62798. * @param name The name of the cloned object
  62799. * @param newEmitter The new emitter to use
  62800. * @returns the cloned particle system
  62801. */
  62802. clone(name: string, newEmitter: any): GPUParticleSystem;
  62803. /**
  62804. * Serializes the particle system to a JSON object.
  62805. * @returns the JSON object
  62806. */
  62807. serialize(): any;
  62808. /**
  62809. * Parses a JSON object to create a GPU particle system.
  62810. * @param parsedParticleSystem The JSON object to parse
  62811. * @param scene The scene to create the particle system in
  62812. * @param rootUrl The root url to use to load external dependencies like texture
  62813. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62814. * @returns the parsed GPU particle system
  62815. */
  62816. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62817. }
  62818. }
  62819. declare module BABYLON {
  62820. /**
  62821. * Represents a set of particle systems working together to create a specific effect
  62822. */
  62823. export class ParticleSystemSet implements IDisposable {
  62824. /**
  62825. * Gets or sets base Assets URL
  62826. */
  62827. static BaseAssetsUrl: string;
  62828. private _emitterCreationOptions;
  62829. private _emitterNode;
  62830. /**
  62831. * Gets the particle system list
  62832. */
  62833. systems: IParticleSystem[];
  62834. /**
  62835. * Gets the emitter node used with this set
  62836. */
  62837. get emitterNode(): Nullable<TransformNode>;
  62838. /**
  62839. * Creates a new emitter mesh as a sphere
  62840. * @param options defines the options used to create the sphere
  62841. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62842. * @param scene defines the hosting scene
  62843. */
  62844. setEmitterAsSphere(options: {
  62845. diameter: number;
  62846. segments: number;
  62847. color: Color3;
  62848. }, renderingGroupId: number, scene: Scene): void;
  62849. /**
  62850. * Starts all particle systems of the set
  62851. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62852. */
  62853. start(emitter?: AbstractMesh): void;
  62854. /**
  62855. * Release all associated resources
  62856. */
  62857. dispose(): void;
  62858. /**
  62859. * Serialize the set into a JSON compatible object
  62860. * @returns a JSON compatible representation of the set
  62861. */
  62862. serialize(): any;
  62863. /**
  62864. * Parse a new ParticleSystemSet from a serialized source
  62865. * @param data defines a JSON compatible representation of the set
  62866. * @param scene defines the hosting scene
  62867. * @param gpu defines if we want GPU particles or CPU particles
  62868. * @returns a new ParticleSystemSet
  62869. */
  62870. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62871. }
  62872. }
  62873. declare module BABYLON {
  62874. /**
  62875. * This class is made for on one-liner static method to help creating particle system set.
  62876. */
  62877. export class ParticleHelper {
  62878. /**
  62879. * Gets or sets base Assets URL
  62880. */
  62881. static BaseAssetsUrl: string;
  62882. /**
  62883. * Create a default particle system that you can tweak
  62884. * @param emitter defines the emitter to use
  62885. * @param capacity defines the system capacity (default is 500 particles)
  62886. * @param scene defines the hosting scene
  62887. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62888. * @returns the new Particle system
  62889. */
  62890. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62891. /**
  62892. * This is the main static method (one-liner) of this helper to create different particle systems
  62893. * @param type This string represents the type to the particle system to create
  62894. * @param scene The scene where the particle system should live
  62895. * @param gpu If the system will use gpu
  62896. * @returns the ParticleSystemSet created
  62897. */
  62898. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62899. /**
  62900. * Static function used to export a particle system to a ParticleSystemSet variable.
  62901. * Please note that the emitter shape is not exported
  62902. * @param systems defines the particle systems to export
  62903. * @returns the created particle system set
  62904. */
  62905. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62906. }
  62907. }
  62908. declare module BABYLON {
  62909. interface Engine {
  62910. /**
  62911. * Create an effect to use with particle systems.
  62912. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62913. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62914. * @param uniformsNames defines a list of attribute names
  62915. * @param samplers defines an array of string used to represent textures
  62916. * @param defines defines the string containing the defines to use to compile the shaders
  62917. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62918. * @param onCompiled defines a function to call when the effect creation is successful
  62919. * @param onError defines a function to call when the effect creation has failed
  62920. * @returns the new Effect
  62921. */
  62922. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62923. }
  62924. interface Mesh {
  62925. /**
  62926. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62927. * @returns an array of IParticleSystem
  62928. */
  62929. getEmittedParticleSystems(): IParticleSystem[];
  62930. /**
  62931. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62932. * @returns an array of IParticleSystem
  62933. */
  62934. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62935. }
  62936. /**
  62937. * @hidden
  62938. */
  62939. export var _IDoNeedToBeInTheBuild: number;
  62940. }
  62941. declare module BABYLON {
  62942. /** Defines the 4 color options */
  62943. export enum PointColor {
  62944. /** color value */
  62945. Color = 2,
  62946. /** uv value */
  62947. UV = 1,
  62948. /** random value */
  62949. Random = 0,
  62950. /** stated value */
  62951. Stated = 3
  62952. }
  62953. /**
  62954. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62955. * 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.
  62956. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62957. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62958. *
  62959. * Full documentation here : TO BE ENTERED
  62960. */
  62961. export class PointsCloudSystem implements IDisposable {
  62962. /**
  62963. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62964. * Example : var p = SPS.particles[i];
  62965. */
  62966. particles: CloudPoint[];
  62967. /**
  62968. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62969. */
  62970. nbParticles: number;
  62971. /**
  62972. * This a counter for your own usage. It's not set by any SPS functions.
  62973. */
  62974. counter: number;
  62975. /**
  62976. * The PCS name. This name is also given to the underlying mesh.
  62977. */
  62978. name: string;
  62979. /**
  62980. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62981. */
  62982. mesh: Mesh;
  62983. /**
  62984. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62985. * Please read :
  62986. */
  62987. vars: any;
  62988. /**
  62989. * @hidden
  62990. */
  62991. _size: number;
  62992. private _scene;
  62993. private _promises;
  62994. private _positions;
  62995. private _indices;
  62996. private _normals;
  62997. private _colors;
  62998. private _uvs;
  62999. private _indices32;
  63000. private _positions32;
  63001. private _colors32;
  63002. private _uvs32;
  63003. private _updatable;
  63004. private _isVisibilityBoxLocked;
  63005. private _alwaysVisible;
  63006. private _groups;
  63007. private _groupCounter;
  63008. private _computeParticleColor;
  63009. private _computeParticleTexture;
  63010. private _computeParticleRotation;
  63011. private _computeBoundingBox;
  63012. private _isReady;
  63013. /**
  63014. * Creates a PCS (Points Cloud System) object
  63015. * @param name (String) is the PCS name, this will be the underlying mesh name
  63016. * @param pointSize (number) is the size for each point
  63017. * @param scene (Scene) is the scene in which the PCS is added
  63018. * @param options defines the options of the PCS e.g.
  63019. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63020. */
  63021. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63022. updatable?: boolean;
  63023. });
  63024. /**
  63025. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63026. * If no points were added to the PCS, the returned mesh is just a single point.
  63027. * @returns a promise for the created mesh
  63028. */
  63029. buildMeshAsync(): Promise<Mesh>;
  63030. /**
  63031. * @hidden
  63032. */
  63033. private _buildMesh;
  63034. private _addParticle;
  63035. private _randomUnitVector;
  63036. private _getColorIndicesForCoord;
  63037. private _setPointsColorOrUV;
  63038. private _colorFromTexture;
  63039. private _calculateDensity;
  63040. /**
  63041. * Adds points to the PCS in random positions within a unit sphere
  63042. * @param nb (positive integer) the number of particles to be created from this model
  63043. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63044. * @returns the number of groups in the system
  63045. */
  63046. addPoints(nb: number, pointFunction?: any): number;
  63047. /**
  63048. * Adds points to the PCS from the surface of the model shape
  63049. * @param mesh is any Mesh object that will be used as a surface model for the points
  63050. * @param nb (positive integer) the number of particles to be created from this model
  63051. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63052. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63053. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63054. * @returns the number of groups in the system
  63055. */
  63056. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63057. /**
  63058. * Adds points to the PCS inside the model shape
  63059. * @param mesh is any Mesh object that will be used as a surface model for the points
  63060. * @param nb (positive integer) the number of particles to be created from this model
  63061. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63062. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63063. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63064. * @returns the number of groups in the system
  63065. */
  63066. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63067. /**
  63068. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63069. * This method calls `updateParticle()` for each particle of the SPS.
  63070. * For an animated SPS, it is usually called within the render loop.
  63071. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63072. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63073. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63074. * @returns the PCS.
  63075. */
  63076. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63077. /**
  63078. * Disposes the PCS.
  63079. */
  63080. dispose(): void;
  63081. /**
  63082. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63083. * doc :
  63084. * @returns the PCS.
  63085. */
  63086. refreshVisibleSize(): PointsCloudSystem;
  63087. /**
  63088. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63089. * @param size the size (float) of the visibility box
  63090. * note : this doesn't lock the PCS mesh bounding box.
  63091. * doc :
  63092. */
  63093. setVisibilityBox(size: number): void;
  63094. /**
  63095. * Gets whether the PCS is always visible or not
  63096. * doc :
  63097. */
  63098. get isAlwaysVisible(): boolean;
  63099. /**
  63100. * Sets the PCS as always visible or not
  63101. * doc :
  63102. */
  63103. set isAlwaysVisible(val: boolean);
  63104. /**
  63105. * Tells to `setParticles()` to compute the particle rotations or not
  63106. * Default value : false. The PCS is faster when it's set to false
  63107. * Note : particle rotations are only applied to parent particles
  63108. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63109. */
  63110. set computeParticleRotation(val: boolean);
  63111. /**
  63112. * Tells to `setParticles()` to compute the particle colors or not.
  63113. * Default value : true. The PCS is faster when it's set to false.
  63114. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63115. */
  63116. set computeParticleColor(val: boolean);
  63117. set computeParticleTexture(val: boolean);
  63118. /**
  63119. * Gets if `setParticles()` computes the particle colors or not.
  63120. * Default value : false. The PCS is faster when it's set to false.
  63121. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63122. */
  63123. get computeParticleColor(): boolean;
  63124. /**
  63125. * Gets if `setParticles()` computes the particle textures or not.
  63126. * Default value : false. The PCS is faster when it's set to false.
  63127. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63128. */
  63129. get computeParticleTexture(): boolean;
  63130. /**
  63131. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63132. */
  63133. set computeBoundingBox(val: boolean);
  63134. /**
  63135. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63136. */
  63137. get computeBoundingBox(): boolean;
  63138. /**
  63139. * This function does nothing. It may be overwritten to set all the particle first values.
  63140. * The PCS doesn't call this function, you may have to call it by your own.
  63141. * doc :
  63142. */
  63143. initParticles(): void;
  63144. /**
  63145. * This function does nothing. It may be overwritten to recycle a particle
  63146. * The PCS doesn't call this function, you can to call it
  63147. * doc :
  63148. * @param particle The particle to recycle
  63149. * @returns the recycled particle
  63150. */
  63151. recycleParticle(particle: CloudPoint): CloudPoint;
  63152. /**
  63153. * Updates a particle : this function should be overwritten by the user.
  63154. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63155. * doc :
  63156. * @example : just set a particle position or velocity and recycle conditions
  63157. * @param particle The particle to update
  63158. * @returns the updated particle
  63159. */
  63160. updateParticle(particle: CloudPoint): CloudPoint;
  63161. /**
  63162. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63163. * This does nothing and may be overwritten by the user.
  63164. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63165. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63166. * @param update the boolean update value actually passed to setParticles()
  63167. */
  63168. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63169. /**
  63170. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63171. * This will be passed three parameters.
  63172. * This does nothing and may be overwritten by the user.
  63173. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63174. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63175. * @param update the boolean update value actually passed to setParticles()
  63176. */
  63177. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63178. }
  63179. }
  63180. declare module BABYLON {
  63181. /**
  63182. * Represents one particle of a points cloud system.
  63183. */
  63184. export class CloudPoint {
  63185. /**
  63186. * particle global index
  63187. */
  63188. idx: number;
  63189. /**
  63190. * The color of the particle
  63191. */
  63192. color: Nullable<Color4>;
  63193. /**
  63194. * The world space position of the particle.
  63195. */
  63196. position: Vector3;
  63197. /**
  63198. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63199. */
  63200. rotation: Vector3;
  63201. /**
  63202. * The world space rotation quaternion of the particle.
  63203. */
  63204. rotationQuaternion: Nullable<Quaternion>;
  63205. /**
  63206. * The uv of the particle.
  63207. */
  63208. uv: Nullable<Vector2>;
  63209. /**
  63210. * The current speed of the particle.
  63211. */
  63212. velocity: Vector3;
  63213. /**
  63214. * The pivot point in the particle local space.
  63215. */
  63216. pivot: Vector3;
  63217. /**
  63218. * Must the particle be translated from its pivot point in its local space ?
  63219. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63220. * Default : false
  63221. */
  63222. translateFromPivot: boolean;
  63223. /**
  63224. * Index of this particle in the global "positions" array (Internal use)
  63225. * @hidden
  63226. */
  63227. _pos: number;
  63228. /**
  63229. * @hidden Index of this particle in the global "indices" array (Internal use)
  63230. */
  63231. _ind: number;
  63232. /**
  63233. * Group this particle belongs to
  63234. */
  63235. _group: PointsGroup;
  63236. /**
  63237. * Group id of this particle
  63238. */
  63239. groupId: number;
  63240. /**
  63241. * Index of the particle in its group id (Internal use)
  63242. */
  63243. idxInGroup: number;
  63244. /**
  63245. * @hidden Particle BoundingInfo object (Internal use)
  63246. */
  63247. _boundingInfo: BoundingInfo;
  63248. /**
  63249. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63250. */
  63251. _pcs: PointsCloudSystem;
  63252. /**
  63253. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63254. */
  63255. _stillInvisible: boolean;
  63256. /**
  63257. * @hidden Last computed particle rotation matrix
  63258. */
  63259. _rotationMatrix: number[];
  63260. /**
  63261. * Parent particle Id, if any.
  63262. * Default null.
  63263. */
  63264. parentId: Nullable<number>;
  63265. /**
  63266. * @hidden Internal global position in the PCS.
  63267. */
  63268. _globalPosition: Vector3;
  63269. /**
  63270. * Creates a Point Cloud object.
  63271. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63272. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63273. * @param group (PointsGroup) is the group the particle belongs to
  63274. * @param groupId (integer) is the group identifier in the PCS.
  63275. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63276. * @param pcs defines the PCS it is associated to
  63277. */
  63278. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63279. /**
  63280. * get point size
  63281. */
  63282. get size(): Vector3;
  63283. /**
  63284. * Set point size
  63285. */
  63286. set size(scale: Vector3);
  63287. /**
  63288. * Legacy support, changed quaternion to rotationQuaternion
  63289. */
  63290. get quaternion(): Nullable<Quaternion>;
  63291. /**
  63292. * Legacy support, changed quaternion to rotationQuaternion
  63293. */
  63294. set quaternion(q: Nullable<Quaternion>);
  63295. /**
  63296. * Returns a boolean. True if the particle intersects a mesh, else false
  63297. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63298. * @param target is the object (point or mesh) what the intersection is computed against
  63299. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63300. * @returns true if it intersects
  63301. */
  63302. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63303. /**
  63304. * get the rotation matrix of the particle
  63305. * @hidden
  63306. */
  63307. getRotationMatrix(m: Matrix): void;
  63308. }
  63309. /**
  63310. * Represents a group of points in a points cloud system
  63311. * * PCS internal tool, don't use it manually.
  63312. */
  63313. export class PointsGroup {
  63314. /**
  63315. * The group id
  63316. * @hidden
  63317. */
  63318. groupID: number;
  63319. /**
  63320. * image data for group (internal use)
  63321. * @hidden
  63322. */
  63323. _groupImageData: Nullable<ArrayBufferView>;
  63324. /**
  63325. * Image Width (internal use)
  63326. * @hidden
  63327. */
  63328. _groupImgWidth: number;
  63329. /**
  63330. * Image Height (internal use)
  63331. * @hidden
  63332. */
  63333. _groupImgHeight: number;
  63334. /**
  63335. * Custom position function (internal use)
  63336. * @hidden
  63337. */
  63338. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63339. /**
  63340. * density per facet for surface points
  63341. * @hidden
  63342. */
  63343. _groupDensity: number[];
  63344. /**
  63345. * Only when points are colored by texture carries pointer to texture list array
  63346. * @hidden
  63347. */
  63348. _textureNb: number;
  63349. /**
  63350. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63351. * PCS internal tool, don't use it manually.
  63352. * @hidden
  63353. */
  63354. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63355. }
  63356. }
  63357. declare module BABYLON {
  63358. interface Scene {
  63359. /** @hidden (Backing field) */
  63360. _physicsEngine: Nullable<IPhysicsEngine>;
  63361. /** @hidden */
  63362. _physicsTimeAccumulator: number;
  63363. /**
  63364. * Gets the current physics engine
  63365. * @returns a IPhysicsEngine or null if none attached
  63366. */
  63367. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63368. /**
  63369. * Enables physics to the current scene
  63370. * @param gravity defines the scene's gravity for the physics engine
  63371. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63372. * @return a boolean indicating if the physics engine was initialized
  63373. */
  63374. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63375. /**
  63376. * Disables and disposes the physics engine associated with the scene
  63377. */
  63378. disablePhysicsEngine(): void;
  63379. /**
  63380. * Gets a boolean indicating if there is an active physics engine
  63381. * @returns a boolean indicating if there is an active physics engine
  63382. */
  63383. isPhysicsEnabled(): boolean;
  63384. /**
  63385. * Deletes a physics compound impostor
  63386. * @param compound defines the compound to delete
  63387. */
  63388. deleteCompoundImpostor(compound: any): void;
  63389. /**
  63390. * An event triggered when physic simulation is about to be run
  63391. */
  63392. onBeforePhysicsObservable: Observable<Scene>;
  63393. /**
  63394. * An event triggered when physic simulation has been done
  63395. */
  63396. onAfterPhysicsObservable: Observable<Scene>;
  63397. }
  63398. interface AbstractMesh {
  63399. /** @hidden */
  63400. _physicsImpostor: Nullable<PhysicsImpostor>;
  63401. /**
  63402. * Gets or sets impostor used for physic simulation
  63403. * @see http://doc.babylonjs.com/features/physics_engine
  63404. */
  63405. physicsImpostor: Nullable<PhysicsImpostor>;
  63406. /**
  63407. * Gets the current physics impostor
  63408. * @see http://doc.babylonjs.com/features/physics_engine
  63409. * @returns a physics impostor or null
  63410. */
  63411. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63412. /** Apply a physic impulse to the mesh
  63413. * @param force defines the force to apply
  63414. * @param contactPoint defines where to apply the force
  63415. * @returns the current mesh
  63416. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63417. */
  63418. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63419. /**
  63420. * Creates a physic joint between two meshes
  63421. * @param otherMesh defines the other mesh to use
  63422. * @param pivot1 defines the pivot to use on this mesh
  63423. * @param pivot2 defines the pivot to use on the other mesh
  63424. * @param options defines additional options (can be plugin dependent)
  63425. * @returns the current mesh
  63426. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63427. */
  63428. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63429. /** @hidden */
  63430. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63431. }
  63432. /**
  63433. * Defines the physics engine scene component responsible to manage a physics engine
  63434. */
  63435. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63436. /**
  63437. * The component name helpful to identify the component in the list of scene components.
  63438. */
  63439. readonly name: string;
  63440. /**
  63441. * The scene the component belongs to.
  63442. */
  63443. scene: Scene;
  63444. /**
  63445. * Creates a new instance of the component for the given scene
  63446. * @param scene Defines the scene to register the component in
  63447. */
  63448. constructor(scene: Scene);
  63449. /**
  63450. * Registers the component in a given scene
  63451. */
  63452. register(): void;
  63453. /**
  63454. * Rebuilds the elements related to this component in case of
  63455. * context lost for instance.
  63456. */
  63457. rebuild(): void;
  63458. /**
  63459. * Disposes the component and the associated ressources
  63460. */
  63461. dispose(): void;
  63462. }
  63463. }
  63464. declare module BABYLON {
  63465. /**
  63466. * A helper for physics simulations
  63467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63468. */
  63469. export class PhysicsHelper {
  63470. private _scene;
  63471. private _physicsEngine;
  63472. /**
  63473. * Initializes the Physics helper
  63474. * @param scene Babylon.js scene
  63475. */
  63476. constructor(scene: Scene);
  63477. /**
  63478. * Applies a radial explosion impulse
  63479. * @param origin the origin of the explosion
  63480. * @param radiusOrEventOptions the radius or the options of radial explosion
  63481. * @param strength the explosion strength
  63482. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63483. * @returns A physics radial explosion event, or null
  63484. */
  63485. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63486. /**
  63487. * Applies a radial explosion force
  63488. * @param origin the origin of the explosion
  63489. * @param radiusOrEventOptions the radius or the options of radial explosion
  63490. * @param strength the explosion strength
  63491. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63492. * @returns A physics radial explosion event, or null
  63493. */
  63494. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63495. /**
  63496. * Creates a gravitational field
  63497. * @param origin the origin of the explosion
  63498. * @param radiusOrEventOptions the radius or the options of radial explosion
  63499. * @param strength the explosion strength
  63500. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63501. * @returns A physics gravitational field event, or null
  63502. */
  63503. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63504. /**
  63505. * Creates a physics updraft event
  63506. * @param origin the origin of the updraft
  63507. * @param radiusOrEventOptions the radius or the options of the updraft
  63508. * @param strength the strength of the updraft
  63509. * @param height the height of the updraft
  63510. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63511. * @returns A physics updraft event, or null
  63512. */
  63513. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63514. /**
  63515. * Creates a physics vortex event
  63516. * @param origin the of the vortex
  63517. * @param radiusOrEventOptions the radius or the options of the vortex
  63518. * @param strength the strength of the vortex
  63519. * @param height the height of the vortex
  63520. * @returns a Physics vortex event, or null
  63521. * A physics vortex event or null
  63522. */
  63523. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63524. }
  63525. /**
  63526. * Represents a physics radial explosion event
  63527. */
  63528. class PhysicsRadialExplosionEvent {
  63529. private _scene;
  63530. private _options;
  63531. private _sphere;
  63532. private _dataFetched;
  63533. /**
  63534. * Initializes a radial explosioin event
  63535. * @param _scene BabylonJS scene
  63536. * @param _options The options for the vortex event
  63537. */
  63538. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63539. /**
  63540. * Returns the data related to the radial explosion event (sphere).
  63541. * @returns The radial explosion event data
  63542. */
  63543. getData(): PhysicsRadialExplosionEventData;
  63544. /**
  63545. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63546. * @param impostor A physics imposter
  63547. * @param origin the origin of the explosion
  63548. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63549. */
  63550. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63551. /**
  63552. * Triggers affecterd impostors callbacks
  63553. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63554. */
  63555. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63556. /**
  63557. * Disposes the sphere.
  63558. * @param force Specifies if the sphere should be disposed by force
  63559. */
  63560. dispose(force?: boolean): void;
  63561. /*** Helpers ***/
  63562. private _prepareSphere;
  63563. private _intersectsWithSphere;
  63564. }
  63565. /**
  63566. * Represents a gravitational field event
  63567. */
  63568. class PhysicsGravitationalFieldEvent {
  63569. private _physicsHelper;
  63570. private _scene;
  63571. private _origin;
  63572. private _options;
  63573. private _tickCallback;
  63574. private _sphere;
  63575. private _dataFetched;
  63576. /**
  63577. * Initializes the physics gravitational field event
  63578. * @param _physicsHelper A physics helper
  63579. * @param _scene BabylonJS scene
  63580. * @param _origin The origin position of the gravitational field event
  63581. * @param _options The options for the vortex event
  63582. */
  63583. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63584. /**
  63585. * Returns the data related to the gravitational field event (sphere).
  63586. * @returns A gravitational field event
  63587. */
  63588. getData(): PhysicsGravitationalFieldEventData;
  63589. /**
  63590. * Enables the gravitational field.
  63591. */
  63592. enable(): void;
  63593. /**
  63594. * Disables the gravitational field.
  63595. */
  63596. disable(): void;
  63597. /**
  63598. * Disposes the sphere.
  63599. * @param force The force to dispose from the gravitational field event
  63600. */
  63601. dispose(force?: boolean): void;
  63602. private _tick;
  63603. }
  63604. /**
  63605. * Represents a physics updraft event
  63606. */
  63607. class PhysicsUpdraftEvent {
  63608. private _scene;
  63609. private _origin;
  63610. private _options;
  63611. private _physicsEngine;
  63612. private _originTop;
  63613. private _originDirection;
  63614. private _tickCallback;
  63615. private _cylinder;
  63616. private _cylinderPosition;
  63617. private _dataFetched;
  63618. /**
  63619. * Initializes the physics updraft event
  63620. * @param _scene BabylonJS scene
  63621. * @param _origin The origin position of the updraft
  63622. * @param _options The options for the updraft event
  63623. */
  63624. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63625. /**
  63626. * Returns the data related to the updraft event (cylinder).
  63627. * @returns A physics updraft event
  63628. */
  63629. getData(): PhysicsUpdraftEventData;
  63630. /**
  63631. * Enables the updraft.
  63632. */
  63633. enable(): void;
  63634. /**
  63635. * Disables the updraft.
  63636. */
  63637. disable(): void;
  63638. /**
  63639. * Disposes the cylinder.
  63640. * @param force Specifies if the updraft should be disposed by force
  63641. */
  63642. dispose(force?: boolean): void;
  63643. private getImpostorHitData;
  63644. private _tick;
  63645. /*** Helpers ***/
  63646. private _prepareCylinder;
  63647. private _intersectsWithCylinder;
  63648. }
  63649. /**
  63650. * Represents a physics vortex event
  63651. */
  63652. class PhysicsVortexEvent {
  63653. private _scene;
  63654. private _origin;
  63655. private _options;
  63656. private _physicsEngine;
  63657. private _originTop;
  63658. private _tickCallback;
  63659. private _cylinder;
  63660. private _cylinderPosition;
  63661. private _dataFetched;
  63662. /**
  63663. * Initializes the physics vortex event
  63664. * @param _scene The BabylonJS scene
  63665. * @param _origin The origin position of the vortex
  63666. * @param _options The options for the vortex event
  63667. */
  63668. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63669. /**
  63670. * Returns the data related to the vortex event (cylinder).
  63671. * @returns The physics vortex event data
  63672. */
  63673. getData(): PhysicsVortexEventData;
  63674. /**
  63675. * Enables the vortex.
  63676. */
  63677. enable(): void;
  63678. /**
  63679. * Disables the cortex.
  63680. */
  63681. disable(): void;
  63682. /**
  63683. * Disposes the sphere.
  63684. * @param force
  63685. */
  63686. dispose(force?: boolean): void;
  63687. private getImpostorHitData;
  63688. private _tick;
  63689. /*** Helpers ***/
  63690. private _prepareCylinder;
  63691. private _intersectsWithCylinder;
  63692. }
  63693. /**
  63694. * Options fot the radial explosion event
  63695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63696. */
  63697. export class PhysicsRadialExplosionEventOptions {
  63698. /**
  63699. * The radius of the sphere for the radial explosion.
  63700. */
  63701. radius: number;
  63702. /**
  63703. * The strenth of the explosion.
  63704. */
  63705. strength: number;
  63706. /**
  63707. * The strenght of the force in correspondence to the distance of the affected object
  63708. */
  63709. falloff: PhysicsRadialImpulseFalloff;
  63710. /**
  63711. * Sphere options for the radial explosion.
  63712. */
  63713. sphere: {
  63714. segments: number;
  63715. diameter: number;
  63716. };
  63717. /**
  63718. * Sphere options for the radial explosion.
  63719. */
  63720. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63721. }
  63722. /**
  63723. * Options fot the updraft event
  63724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63725. */
  63726. export class PhysicsUpdraftEventOptions {
  63727. /**
  63728. * The radius of the cylinder for the vortex
  63729. */
  63730. radius: number;
  63731. /**
  63732. * The strenth of the updraft.
  63733. */
  63734. strength: number;
  63735. /**
  63736. * The height of the cylinder for the updraft.
  63737. */
  63738. height: number;
  63739. /**
  63740. * The mode for the the updraft.
  63741. */
  63742. updraftMode: PhysicsUpdraftMode;
  63743. }
  63744. /**
  63745. * Options fot the vortex event
  63746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63747. */
  63748. export class PhysicsVortexEventOptions {
  63749. /**
  63750. * The radius of the cylinder for the vortex
  63751. */
  63752. radius: number;
  63753. /**
  63754. * The strenth of the vortex.
  63755. */
  63756. strength: number;
  63757. /**
  63758. * The height of the cylinder for the vortex.
  63759. */
  63760. height: number;
  63761. /**
  63762. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63763. */
  63764. centripetalForceThreshold: number;
  63765. /**
  63766. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63767. */
  63768. centripetalForceMultiplier: number;
  63769. /**
  63770. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63771. */
  63772. centrifugalForceMultiplier: number;
  63773. /**
  63774. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63775. */
  63776. updraftForceMultiplier: number;
  63777. }
  63778. /**
  63779. * The strenght of the force in correspondence to the distance of the affected object
  63780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63781. */
  63782. export enum PhysicsRadialImpulseFalloff {
  63783. /** Defines that impulse is constant in strength across it's whole radius */
  63784. Constant = 0,
  63785. /** Defines that impulse gets weaker if it's further from the origin */
  63786. Linear = 1
  63787. }
  63788. /**
  63789. * The strength of the force in correspondence to the distance of the affected object
  63790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63791. */
  63792. export enum PhysicsUpdraftMode {
  63793. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63794. Center = 0,
  63795. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63796. Perpendicular = 1
  63797. }
  63798. /**
  63799. * Interface for a physics hit data
  63800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63801. */
  63802. export interface PhysicsHitData {
  63803. /**
  63804. * The force applied at the contact point
  63805. */
  63806. force: Vector3;
  63807. /**
  63808. * The contact point
  63809. */
  63810. contactPoint: Vector3;
  63811. /**
  63812. * The distance from the origin to the contact point
  63813. */
  63814. distanceFromOrigin: number;
  63815. }
  63816. /**
  63817. * Interface for radial explosion event data
  63818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63819. */
  63820. export interface PhysicsRadialExplosionEventData {
  63821. /**
  63822. * A sphere used for the radial explosion event
  63823. */
  63824. sphere: Mesh;
  63825. }
  63826. /**
  63827. * Interface for gravitational field event data
  63828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63829. */
  63830. export interface PhysicsGravitationalFieldEventData {
  63831. /**
  63832. * A sphere mesh used for the gravitational field event
  63833. */
  63834. sphere: Mesh;
  63835. }
  63836. /**
  63837. * Interface for updraft event data
  63838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63839. */
  63840. export interface PhysicsUpdraftEventData {
  63841. /**
  63842. * A cylinder used for the updraft event
  63843. */
  63844. cylinder: Mesh;
  63845. }
  63846. /**
  63847. * Interface for vortex event data
  63848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63849. */
  63850. export interface PhysicsVortexEventData {
  63851. /**
  63852. * A cylinder used for the vortex event
  63853. */
  63854. cylinder: Mesh;
  63855. }
  63856. /**
  63857. * Interface for an affected physics impostor
  63858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63859. */
  63860. export interface PhysicsAffectedImpostorWithData {
  63861. /**
  63862. * The impostor affected by the effect
  63863. */
  63864. impostor: PhysicsImpostor;
  63865. /**
  63866. * The data about the hit/horce from the explosion
  63867. */
  63868. hitData: PhysicsHitData;
  63869. }
  63870. }
  63871. declare module BABYLON {
  63872. /** @hidden */
  63873. export var blackAndWhitePixelShader: {
  63874. name: string;
  63875. shader: string;
  63876. };
  63877. }
  63878. declare module BABYLON {
  63879. /**
  63880. * Post process used to render in black and white
  63881. */
  63882. export class BlackAndWhitePostProcess extends PostProcess {
  63883. /**
  63884. * Linear about to convert he result to black and white (default: 1)
  63885. */
  63886. degree: number;
  63887. /**
  63888. * Creates a black and white post process
  63889. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63890. * @param name The name of the effect.
  63891. * @param options The required width/height ratio to downsize to before computing the render pass.
  63892. * @param camera The camera to apply the render pass to.
  63893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63894. * @param engine The engine which the post process will be applied. (default: current engine)
  63895. * @param reusable If the post process can be reused on the same frame. (default: false)
  63896. */
  63897. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63898. }
  63899. }
  63900. declare module BABYLON {
  63901. /**
  63902. * This represents a set of one or more post processes in Babylon.
  63903. * A post process can be used to apply a shader to a texture after it is rendered.
  63904. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63905. */
  63906. export class PostProcessRenderEffect {
  63907. private _postProcesses;
  63908. private _getPostProcesses;
  63909. private _singleInstance;
  63910. private _cameras;
  63911. private _indicesForCamera;
  63912. /**
  63913. * Name of the effect
  63914. * @hidden
  63915. */
  63916. _name: string;
  63917. /**
  63918. * Instantiates a post process render effect.
  63919. * A post process can be used to apply a shader to a texture after it is rendered.
  63920. * @param engine The engine the effect is tied to
  63921. * @param name The name of the effect
  63922. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63923. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63924. */
  63925. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63926. /**
  63927. * Checks if all the post processes in the effect are supported.
  63928. */
  63929. get isSupported(): boolean;
  63930. /**
  63931. * Updates the current state of the effect
  63932. * @hidden
  63933. */
  63934. _update(): void;
  63935. /**
  63936. * Attaches the effect on cameras
  63937. * @param cameras The camera to attach to.
  63938. * @hidden
  63939. */
  63940. _attachCameras(cameras: Camera): void;
  63941. /**
  63942. * Attaches the effect on cameras
  63943. * @param cameras The camera to attach to.
  63944. * @hidden
  63945. */
  63946. _attachCameras(cameras: Camera[]): void;
  63947. /**
  63948. * Detaches the effect on cameras
  63949. * @param cameras The camera to detatch from.
  63950. * @hidden
  63951. */
  63952. _detachCameras(cameras: Camera): void;
  63953. /**
  63954. * Detatches the effect on cameras
  63955. * @param cameras The camera to detatch from.
  63956. * @hidden
  63957. */
  63958. _detachCameras(cameras: Camera[]): void;
  63959. /**
  63960. * Enables the effect on given cameras
  63961. * @param cameras The camera to enable.
  63962. * @hidden
  63963. */
  63964. _enable(cameras: Camera): void;
  63965. /**
  63966. * Enables the effect on given cameras
  63967. * @param cameras The camera to enable.
  63968. * @hidden
  63969. */
  63970. _enable(cameras: Nullable<Camera[]>): void;
  63971. /**
  63972. * Disables the effect on the given cameras
  63973. * @param cameras The camera to disable.
  63974. * @hidden
  63975. */
  63976. _disable(cameras: Camera): void;
  63977. /**
  63978. * Disables the effect on the given cameras
  63979. * @param cameras The camera to disable.
  63980. * @hidden
  63981. */
  63982. _disable(cameras: Nullable<Camera[]>): void;
  63983. /**
  63984. * Gets a list of the post processes contained in the effect.
  63985. * @param camera The camera to get the post processes on.
  63986. * @returns The list of the post processes in the effect.
  63987. */
  63988. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63989. }
  63990. }
  63991. declare module BABYLON {
  63992. /** @hidden */
  63993. export var extractHighlightsPixelShader: {
  63994. name: string;
  63995. shader: string;
  63996. };
  63997. }
  63998. declare module BABYLON {
  63999. /**
  64000. * 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.
  64001. */
  64002. export class ExtractHighlightsPostProcess extends PostProcess {
  64003. /**
  64004. * The luminance threshold, pixels below this value will be set to black.
  64005. */
  64006. threshold: number;
  64007. /** @hidden */
  64008. _exposure: number;
  64009. /**
  64010. * Post process which has the input texture to be used when performing highlight extraction
  64011. * @hidden
  64012. */
  64013. _inputPostProcess: Nullable<PostProcess>;
  64014. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64015. }
  64016. }
  64017. declare module BABYLON {
  64018. /** @hidden */
  64019. export var bloomMergePixelShader: {
  64020. name: string;
  64021. shader: string;
  64022. };
  64023. }
  64024. declare module BABYLON {
  64025. /**
  64026. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64027. */
  64028. export class BloomMergePostProcess extends PostProcess {
  64029. /** Weight of the bloom to be added to the original input. */
  64030. weight: number;
  64031. /**
  64032. * Creates a new instance of @see BloomMergePostProcess
  64033. * @param name The name of the effect.
  64034. * @param originalFromInput Post process which's input will be used for the merge.
  64035. * @param blurred Blurred highlights post process which's output will be used.
  64036. * @param weight Weight of the bloom to be added to the original input.
  64037. * @param options The required width/height ratio to downsize to before computing the render pass.
  64038. * @param camera The camera to apply the render pass to.
  64039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64040. * @param engine The engine which the post process will be applied. (default: current engine)
  64041. * @param reusable If the post process can be reused on the same frame. (default: false)
  64042. * @param textureType Type of textures used when performing the post process. (default: 0)
  64043. * @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)
  64044. */
  64045. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64046. /** Weight of the bloom to be added to the original input. */
  64047. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64048. }
  64049. }
  64050. declare module BABYLON {
  64051. /**
  64052. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64053. */
  64054. export class BloomEffect extends PostProcessRenderEffect {
  64055. private bloomScale;
  64056. /**
  64057. * @hidden Internal
  64058. */
  64059. _effects: Array<PostProcess>;
  64060. /**
  64061. * @hidden Internal
  64062. */
  64063. _downscale: ExtractHighlightsPostProcess;
  64064. private _blurX;
  64065. private _blurY;
  64066. private _merge;
  64067. /**
  64068. * The luminance threshold to find bright areas of the image to bloom.
  64069. */
  64070. get threshold(): number;
  64071. set threshold(value: number);
  64072. /**
  64073. * The strength of the bloom.
  64074. */
  64075. get weight(): number;
  64076. set weight(value: number);
  64077. /**
  64078. * Specifies the size of the bloom blur kernel, relative to the final output size
  64079. */
  64080. get kernel(): number;
  64081. set kernel(value: number);
  64082. /**
  64083. * Creates a new instance of @see BloomEffect
  64084. * @param scene The scene the effect belongs to.
  64085. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64086. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64087. * @param bloomWeight The the strength of bloom.
  64088. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64089. * @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)
  64090. */
  64091. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64092. /**
  64093. * Disposes each of the internal effects for a given camera.
  64094. * @param camera The camera to dispose the effect on.
  64095. */
  64096. disposeEffects(camera: Camera): void;
  64097. /**
  64098. * @hidden Internal
  64099. */
  64100. _updateEffects(): void;
  64101. /**
  64102. * Internal
  64103. * @returns if all the contained post processes are ready.
  64104. * @hidden
  64105. */
  64106. _isReady(): boolean;
  64107. }
  64108. }
  64109. declare module BABYLON {
  64110. /** @hidden */
  64111. export var chromaticAberrationPixelShader: {
  64112. name: string;
  64113. shader: string;
  64114. };
  64115. }
  64116. declare module BABYLON {
  64117. /**
  64118. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64119. */
  64120. export class ChromaticAberrationPostProcess extends PostProcess {
  64121. /**
  64122. * The amount of seperation of rgb channels (default: 30)
  64123. */
  64124. aberrationAmount: number;
  64125. /**
  64126. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64127. */
  64128. radialIntensity: number;
  64129. /**
  64130. * 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))
  64131. */
  64132. direction: Vector2;
  64133. /**
  64134. * 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))
  64135. */
  64136. centerPosition: Vector2;
  64137. /**
  64138. * Creates a new instance ChromaticAberrationPostProcess
  64139. * @param name The name of the effect.
  64140. * @param screenWidth The width of the screen to apply the effect on.
  64141. * @param screenHeight The height of the screen to apply the effect on.
  64142. * @param options The required width/height ratio to downsize to before computing the render pass.
  64143. * @param camera The camera to apply the render pass to.
  64144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64145. * @param engine The engine which the post process will be applied. (default: current engine)
  64146. * @param reusable If the post process can be reused on the same frame. (default: false)
  64147. * @param textureType Type of textures used when performing the post process. (default: 0)
  64148. * @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)
  64149. */
  64150. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64151. }
  64152. }
  64153. declare module BABYLON {
  64154. /** @hidden */
  64155. export var circleOfConfusionPixelShader: {
  64156. name: string;
  64157. shader: string;
  64158. };
  64159. }
  64160. declare module BABYLON {
  64161. /**
  64162. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64163. */
  64164. export class CircleOfConfusionPostProcess extends PostProcess {
  64165. /**
  64166. * 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.
  64167. */
  64168. lensSize: number;
  64169. /**
  64170. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64171. */
  64172. fStop: number;
  64173. /**
  64174. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64175. */
  64176. focusDistance: number;
  64177. /**
  64178. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64179. */
  64180. focalLength: number;
  64181. private _depthTexture;
  64182. /**
  64183. * Creates a new instance CircleOfConfusionPostProcess
  64184. * @param name The name of the effect.
  64185. * @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.
  64186. * @param options The required width/height ratio to downsize to before computing the render pass.
  64187. * @param camera The camera to apply the render pass to.
  64188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64189. * @param engine The engine which the post process will be applied. (default: current engine)
  64190. * @param reusable If the post process can be reused on the same frame. (default: false)
  64191. * @param textureType Type of textures used when performing the post process. (default: 0)
  64192. * @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)
  64193. */
  64194. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64195. /**
  64196. * 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.
  64197. */
  64198. set depthTexture(value: RenderTargetTexture);
  64199. }
  64200. }
  64201. declare module BABYLON {
  64202. /** @hidden */
  64203. export var colorCorrectionPixelShader: {
  64204. name: string;
  64205. shader: string;
  64206. };
  64207. }
  64208. declare module BABYLON {
  64209. /**
  64210. *
  64211. * This post-process allows the modification of rendered colors by using
  64212. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64213. *
  64214. * The object needs to be provided an url to a texture containing the color
  64215. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64216. * Use an image editing software to tweak the LUT to match your needs.
  64217. *
  64218. * For an example of a color LUT, see here:
  64219. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64220. * For explanations on color grading, see here:
  64221. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64222. *
  64223. */
  64224. export class ColorCorrectionPostProcess extends PostProcess {
  64225. private _colorTableTexture;
  64226. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64227. }
  64228. }
  64229. declare module BABYLON {
  64230. /** @hidden */
  64231. export var convolutionPixelShader: {
  64232. name: string;
  64233. shader: string;
  64234. };
  64235. }
  64236. declare module BABYLON {
  64237. /**
  64238. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64239. * input texture to perform effects such as edge detection or sharpening
  64240. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64241. */
  64242. export class ConvolutionPostProcess extends PostProcess {
  64243. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64244. kernel: number[];
  64245. /**
  64246. * Creates a new instance ConvolutionPostProcess
  64247. * @param name The name of the effect.
  64248. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64249. * @param options The required width/height ratio to downsize to before computing the render pass.
  64250. * @param camera The camera to apply the render pass to.
  64251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64252. * @param engine The engine which the post process will be applied. (default: current engine)
  64253. * @param reusable If the post process can be reused on the same frame. (default: false)
  64254. * @param textureType Type of textures used when performing the post process. (default: 0)
  64255. */
  64256. constructor(name: string,
  64257. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64258. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64259. /**
  64260. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64261. */
  64262. static EdgeDetect0Kernel: number[];
  64263. /**
  64264. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64265. */
  64266. static EdgeDetect1Kernel: number[];
  64267. /**
  64268. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64269. */
  64270. static EdgeDetect2Kernel: number[];
  64271. /**
  64272. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64273. */
  64274. static SharpenKernel: number[];
  64275. /**
  64276. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64277. */
  64278. static EmbossKernel: number[];
  64279. /**
  64280. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64281. */
  64282. static GaussianKernel: number[];
  64283. }
  64284. }
  64285. declare module BABYLON {
  64286. /**
  64287. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64288. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64289. * based on samples that have a large difference in distance than the center pixel.
  64290. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64291. */
  64292. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64293. direction: Vector2;
  64294. /**
  64295. * Creates a new instance CircleOfConfusionPostProcess
  64296. * @param name The name of the effect.
  64297. * @param scene The scene the effect belongs to.
  64298. * @param direction The direction the blur should be applied.
  64299. * @param kernel The size of the kernel used to blur.
  64300. * @param options The required width/height ratio to downsize to before computing the render pass.
  64301. * @param camera The camera to apply the render pass to.
  64302. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64303. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64304. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64305. * @param engine The engine which the post process will be applied. (default: current engine)
  64306. * @param reusable If the post process can be reused on the same frame. (default: false)
  64307. * @param textureType Type of textures used when performing the post process. (default: 0)
  64308. * @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)
  64309. */
  64310. 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);
  64311. }
  64312. }
  64313. declare module BABYLON {
  64314. /** @hidden */
  64315. export var depthOfFieldMergePixelShader: {
  64316. name: string;
  64317. shader: string;
  64318. };
  64319. }
  64320. declare module BABYLON {
  64321. /**
  64322. * Options to be set when merging outputs from the default pipeline.
  64323. */
  64324. export class DepthOfFieldMergePostProcessOptions {
  64325. /**
  64326. * The original image to merge on top of
  64327. */
  64328. originalFromInput: PostProcess;
  64329. /**
  64330. * Parameters to perform the merge of the depth of field effect
  64331. */
  64332. depthOfField?: {
  64333. circleOfConfusion: PostProcess;
  64334. blurSteps: Array<PostProcess>;
  64335. };
  64336. /**
  64337. * Parameters to perform the merge of bloom effect
  64338. */
  64339. bloom?: {
  64340. blurred: PostProcess;
  64341. weight: number;
  64342. };
  64343. }
  64344. /**
  64345. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64346. */
  64347. export class DepthOfFieldMergePostProcess extends PostProcess {
  64348. private blurSteps;
  64349. /**
  64350. * Creates a new instance of DepthOfFieldMergePostProcess
  64351. * @param name The name of the effect.
  64352. * @param originalFromInput Post process which's input will be used for the merge.
  64353. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64354. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64355. * @param options The required width/height ratio to downsize to before computing the render pass.
  64356. * @param camera The camera to apply the render pass to.
  64357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64358. * @param engine The engine which the post process will be applied. (default: current engine)
  64359. * @param reusable If the post process can be reused on the same frame. (default: false)
  64360. * @param textureType Type of textures used when performing the post process. (default: 0)
  64361. * @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)
  64362. */
  64363. 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);
  64364. /**
  64365. * Updates the effect with the current post process compile time values and recompiles the shader.
  64366. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64367. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64368. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64369. * @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
  64370. * @param onCompiled Called when the shader has been compiled.
  64371. * @param onError Called if there is an error when compiling a shader.
  64372. */
  64373. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64374. }
  64375. }
  64376. declare module BABYLON {
  64377. /**
  64378. * Specifies the level of max blur that should be applied when using the depth of field effect
  64379. */
  64380. export enum DepthOfFieldEffectBlurLevel {
  64381. /**
  64382. * Subtle blur
  64383. */
  64384. Low = 0,
  64385. /**
  64386. * Medium blur
  64387. */
  64388. Medium = 1,
  64389. /**
  64390. * Large blur
  64391. */
  64392. High = 2
  64393. }
  64394. /**
  64395. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64396. */
  64397. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64398. private _circleOfConfusion;
  64399. /**
  64400. * @hidden Internal, blurs from high to low
  64401. */
  64402. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64403. private _depthOfFieldBlurY;
  64404. private _dofMerge;
  64405. /**
  64406. * @hidden Internal post processes in depth of field effect
  64407. */
  64408. _effects: Array<PostProcess>;
  64409. /**
  64410. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64411. */
  64412. set focalLength(value: number);
  64413. get focalLength(): number;
  64414. /**
  64415. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64416. */
  64417. set fStop(value: number);
  64418. get fStop(): number;
  64419. /**
  64420. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64421. */
  64422. set focusDistance(value: number);
  64423. get focusDistance(): number;
  64424. /**
  64425. * 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.
  64426. */
  64427. set lensSize(value: number);
  64428. get lensSize(): number;
  64429. /**
  64430. * Creates a new instance DepthOfFieldEffect
  64431. * @param scene The scene the effect belongs to.
  64432. * @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.
  64433. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64434. * @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)
  64435. */
  64436. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64437. /**
  64438. * Get the current class name of the current effet
  64439. * @returns "DepthOfFieldEffect"
  64440. */
  64441. getClassName(): string;
  64442. /**
  64443. * 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.
  64444. */
  64445. set depthTexture(value: RenderTargetTexture);
  64446. /**
  64447. * Disposes each of the internal effects for a given camera.
  64448. * @param camera The camera to dispose the effect on.
  64449. */
  64450. disposeEffects(camera: Camera): void;
  64451. /**
  64452. * @hidden Internal
  64453. */
  64454. _updateEffects(): void;
  64455. /**
  64456. * Internal
  64457. * @returns if all the contained post processes are ready.
  64458. * @hidden
  64459. */
  64460. _isReady(): boolean;
  64461. }
  64462. }
  64463. declare module BABYLON {
  64464. /** @hidden */
  64465. export var displayPassPixelShader: {
  64466. name: string;
  64467. shader: string;
  64468. };
  64469. }
  64470. declare module BABYLON {
  64471. /**
  64472. * DisplayPassPostProcess which produces an output the same as it's input
  64473. */
  64474. export class DisplayPassPostProcess extends PostProcess {
  64475. /**
  64476. * Creates the DisplayPassPostProcess
  64477. * @param name The name of the effect.
  64478. * @param options The required width/height ratio to downsize to before computing the render pass.
  64479. * @param camera The camera to apply the render pass to.
  64480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64481. * @param engine The engine which the post process will be applied. (default: current engine)
  64482. * @param reusable If the post process can be reused on the same frame. (default: false)
  64483. */
  64484. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64485. }
  64486. }
  64487. declare module BABYLON {
  64488. /** @hidden */
  64489. export var filterPixelShader: {
  64490. name: string;
  64491. shader: string;
  64492. };
  64493. }
  64494. declare module BABYLON {
  64495. /**
  64496. * Applies a kernel filter to the image
  64497. */
  64498. export class FilterPostProcess extends PostProcess {
  64499. /** The matrix to be applied to the image */
  64500. kernelMatrix: Matrix;
  64501. /**
  64502. *
  64503. * @param name The name of the effect.
  64504. * @param kernelMatrix The matrix to be applied to the image
  64505. * @param options The required width/height ratio to downsize to before computing the render pass.
  64506. * @param camera The camera to apply the render pass to.
  64507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64508. * @param engine The engine which the post process will be applied. (default: current engine)
  64509. * @param reusable If the post process can be reused on the same frame. (default: false)
  64510. */
  64511. constructor(name: string,
  64512. /** The matrix to be applied to the image */
  64513. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64514. }
  64515. }
  64516. declare module BABYLON {
  64517. /** @hidden */
  64518. export var fxaaPixelShader: {
  64519. name: string;
  64520. shader: string;
  64521. };
  64522. }
  64523. declare module BABYLON {
  64524. /** @hidden */
  64525. export var fxaaVertexShader: {
  64526. name: string;
  64527. shader: string;
  64528. };
  64529. }
  64530. declare module BABYLON {
  64531. /**
  64532. * Fxaa post process
  64533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64534. */
  64535. export class FxaaPostProcess extends PostProcess {
  64536. /** @hidden */
  64537. texelWidth: number;
  64538. /** @hidden */
  64539. texelHeight: number;
  64540. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64541. private _getDefines;
  64542. }
  64543. }
  64544. declare module BABYLON {
  64545. /** @hidden */
  64546. export var grainPixelShader: {
  64547. name: string;
  64548. shader: string;
  64549. };
  64550. }
  64551. declare module BABYLON {
  64552. /**
  64553. * The GrainPostProcess adds noise to the image at mid luminance levels
  64554. */
  64555. export class GrainPostProcess extends PostProcess {
  64556. /**
  64557. * The intensity of the grain added (default: 30)
  64558. */
  64559. intensity: number;
  64560. /**
  64561. * If the grain should be randomized on every frame
  64562. */
  64563. animated: boolean;
  64564. /**
  64565. * Creates a new instance of @see GrainPostProcess
  64566. * @param name The name of the effect.
  64567. * @param options The required width/height ratio to downsize to before computing the render pass.
  64568. * @param camera The camera to apply the render pass to.
  64569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64570. * @param engine The engine which the post process will be applied. (default: current engine)
  64571. * @param reusable If the post process can be reused on the same frame. (default: false)
  64572. * @param textureType Type of textures used when performing the post process. (default: 0)
  64573. * @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)
  64574. */
  64575. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64576. }
  64577. }
  64578. declare module BABYLON {
  64579. /** @hidden */
  64580. export var highlightsPixelShader: {
  64581. name: string;
  64582. shader: string;
  64583. };
  64584. }
  64585. declare module BABYLON {
  64586. /**
  64587. * Extracts highlights from the image
  64588. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64589. */
  64590. export class HighlightsPostProcess extends PostProcess {
  64591. /**
  64592. * Extracts highlights from the image
  64593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64594. * @param name The name of the effect.
  64595. * @param options The required width/height ratio to downsize to before computing the render pass.
  64596. * @param camera The camera to apply the render pass to.
  64597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64598. * @param engine The engine which the post process will be applied. (default: current engine)
  64599. * @param reusable If the post process can be reused on the same frame. (default: false)
  64600. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64601. */
  64602. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64603. }
  64604. }
  64605. declare module BABYLON {
  64606. /** @hidden */
  64607. export var mrtFragmentDeclaration: {
  64608. name: string;
  64609. shader: string;
  64610. };
  64611. }
  64612. declare module BABYLON {
  64613. /** @hidden */
  64614. export var geometryPixelShader: {
  64615. name: string;
  64616. shader: string;
  64617. };
  64618. }
  64619. declare module BABYLON {
  64620. /** @hidden */
  64621. export var geometryVertexShader: {
  64622. name: string;
  64623. shader: string;
  64624. };
  64625. }
  64626. declare module BABYLON {
  64627. /** @hidden */
  64628. interface ISavedTransformationMatrix {
  64629. world: Matrix;
  64630. viewProjection: Matrix;
  64631. }
  64632. /**
  64633. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64634. */
  64635. export class GeometryBufferRenderer {
  64636. /**
  64637. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64638. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64639. */
  64640. static readonly POSITION_TEXTURE_TYPE: number;
  64641. /**
  64642. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64643. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64644. */
  64645. static readonly VELOCITY_TEXTURE_TYPE: number;
  64646. /**
  64647. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64648. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64649. */
  64650. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64651. /**
  64652. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64653. * in order to compute objects velocities when enableVelocity is set to "true"
  64654. * @hidden
  64655. */
  64656. _previousTransformationMatrices: {
  64657. [index: number]: ISavedTransformationMatrix;
  64658. };
  64659. /**
  64660. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64661. * in order to compute objects velocities when enableVelocity is set to "true"
  64662. * @hidden
  64663. */
  64664. _previousBonesTransformationMatrices: {
  64665. [index: number]: Float32Array;
  64666. };
  64667. /**
  64668. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64669. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64670. */
  64671. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64672. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64673. renderTransparentMeshes: boolean;
  64674. private _scene;
  64675. private _multiRenderTarget;
  64676. private _ratio;
  64677. private _enablePosition;
  64678. private _enableVelocity;
  64679. private _enableReflectivity;
  64680. private _positionIndex;
  64681. private _velocityIndex;
  64682. private _reflectivityIndex;
  64683. protected _effect: Effect;
  64684. protected _cachedDefines: string;
  64685. /**
  64686. * Set the render list (meshes to be rendered) used in the G buffer.
  64687. */
  64688. set renderList(meshes: Mesh[]);
  64689. /**
  64690. * Gets wether or not G buffer are supported by the running hardware.
  64691. * This requires draw buffer supports
  64692. */
  64693. get isSupported(): boolean;
  64694. /**
  64695. * Returns the index of the given texture type in the G-Buffer textures array
  64696. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64697. * @returns the index of the given texture type in the G-Buffer textures array
  64698. */
  64699. getTextureIndex(textureType: number): number;
  64700. /**
  64701. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64702. */
  64703. get enablePosition(): boolean;
  64704. /**
  64705. * Sets whether or not objects positions are enabled for the G buffer.
  64706. */
  64707. set enablePosition(enable: boolean);
  64708. /**
  64709. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64710. */
  64711. get enableVelocity(): boolean;
  64712. /**
  64713. * Sets wether or not objects velocities are enabled for the G buffer.
  64714. */
  64715. set enableVelocity(enable: boolean);
  64716. /**
  64717. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64718. */
  64719. get enableReflectivity(): boolean;
  64720. /**
  64721. * Sets wether or not objects roughness are enabled for the G buffer.
  64722. */
  64723. set enableReflectivity(enable: boolean);
  64724. /**
  64725. * Gets the scene associated with the buffer.
  64726. */
  64727. get scene(): Scene;
  64728. /**
  64729. * Gets the ratio used by the buffer during its creation.
  64730. * How big is the buffer related to the main canvas.
  64731. */
  64732. get ratio(): number;
  64733. /** @hidden */
  64734. static _SceneComponentInitialization: (scene: Scene) => void;
  64735. /**
  64736. * Creates a new G Buffer for the scene
  64737. * @param scene The scene the buffer belongs to
  64738. * @param ratio How big is the buffer related to the main canvas.
  64739. */
  64740. constructor(scene: Scene, ratio?: number);
  64741. /**
  64742. * Checks wether everything is ready to render a submesh to the G buffer.
  64743. * @param subMesh the submesh to check readiness for
  64744. * @param useInstances is the mesh drawn using instance or not
  64745. * @returns true if ready otherwise false
  64746. */
  64747. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64748. /**
  64749. * Gets the current underlying G Buffer.
  64750. * @returns the buffer
  64751. */
  64752. getGBuffer(): MultiRenderTarget;
  64753. /**
  64754. * Gets the number of samples used to render the buffer (anti aliasing).
  64755. */
  64756. get samples(): number;
  64757. /**
  64758. * Sets the number of samples used to render the buffer (anti aliasing).
  64759. */
  64760. set samples(value: number);
  64761. /**
  64762. * Disposes the renderer and frees up associated resources.
  64763. */
  64764. dispose(): void;
  64765. protected _createRenderTargets(): void;
  64766. private _copyBonesTransformationMatrices;
  64767. }
  64768. }
  64769. declare module BABYLON {
  64770. interface Scene {
  64771. /** @hidden (Backing field) */
  64772. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64773. /**
  64774. * Gets or Sets the current geometry buffer associated to the scene.
  64775. */
  64776. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64777. /**
  64778. * Enables a GeometryBufferRender and associates it with the scene
  64779. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64780. * @returns the GeometryBufferRenderer
  64781. */
  64782. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64783. /**
  64784. * Disables the GeometryBufferRender associated with the scene
  64785. */
  64786. disableGeometryBufferRenderer(): void;
  64787. }
  64788. /**
  64789. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64790. * in several rendering techniques.
  64791. */
  64792. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64793. /**
  64794. * The component name helpful to identify the component in the list of scene components.
  64795. */
  64796. readonly name: string;
  64797. /**
  64798. * The scene the component belongs to.
  64799. */
  64800. scene: Scene;
  64801. /**
  64802. * Creates a new instance of the component for the given scene
  64803. * @param scene Defines the scene to register the component in
  64804. */
  64805. constructor(scene: Scene);
  64806. /**
  64807. * Registers the component in a given scene
  64808. */
  64809. register(): void;
  64810. /**
  64811. * Rebuilds the elements related to this component in case of
  64812. * context lost for instance.
  64813. */
  64814. rebuild(): void;
  64815. /**
  64816. * Disposes the component and the associated ressources
  64817. */
  64818. dispose(): void;
  64819. private _gatherRenderTargets;
  64820. }
  64821. }
  64822. declare module BABYLON {
  64823. /** @hidden */
  64824. export var motionBlurPixelShader: {
  64825. name: string;
  64826. shader: string;
  64827. };
  64828. }
  64829. declare module BABYLON {
  64830. /**
  64831. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64832. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64833. * As an example, all you have to do is to create the post-process:
  64834. * var mb = new BABYLON.MotionBlurPostProcess(
  64835. * 'mb', // The name of the effect.
  64836. * scene, // The scene containing the objects to blur according to their velocity.
  64837. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64838. * camera // The camera to apply the render pass to.
  64839. * );
  64840. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64841. */
  64842. export class MotionBlurPostProcess extends PostProcess {
  64843. /**
  64844. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64845. */
  64846. motionStrength: number;
  64847. /**
  64848. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64849. */
  64850. get motionBlurSamples(): number;
  64851. /**
  64852. * Sets the number of iterations to be used for motion blur quality
  64853. */
  64854. set motionBlurSamples(samples: number);
  64855. private _motionBlurSamples;
  64856. private _geometryBufferRenderer;
  64857. /**
  64858. * Creates a new instance MotionBlurPostProcess
  64859. * @param name The name of the effect.
  64860. * @param scene The scene containing the objects to blur according to their velocity.
  64861. * @param options The required width/height ratio to downsize to before computing the render pass.
  64862. * @param camera The camera to apply the render pass to.
  64863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64864. * @param engine The engine which the post process will be applied. (default: current engine)
  64865. * @param reusable If the post process can be reused on the same frame. (default: false)
  64866. * @param textureType Type of textures used when performing the post process. (default: 0)
  64867. * @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)
  64868. */
  64869. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64870. /**
  64871. * Excludes the given skinned mesh from computing bones velocities.
  64872. * 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.
  64873. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64874. */
  64875. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64876. /**
  64877. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64878. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64879. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64880. */
  64881. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64882. /**
  64883. * Disposes the post process.
  64884. * @param camera The camera to dispose the post process on.
  64885. */
  64886. dispose(camera?: Camera): void;
  64887. }
  64888. }
  64889. declare module BABYLON {
  64890. /** @hidden */
  64891. export var refractionPixelShader: {
  64892. name: string;
  64893. shader: string;
  64894. };
  64895. }
  64896. declare module BABYLON {
  64897. /**
  64898. * Post process which applies a refractin texture
  64899. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64900. */
  64901. export class RefractionPostProcess extends PostProcess {
  64902. /** the base color of the refraction (used to taint the rendering) */
  64903. color: Color3;
  64904. /** simulated refraction depth */
  64905. depth: number;
  64906. /** the coefficient of the base color (0 to remove base color tainting) */
  64907. colorLevel: number;
  64908. private _refTexture;
  64909. private _ownRefractionTexture;
  64910. /**
  64911. * Gets or sets the refraction texture
  64912. * Please note that you are responsible for disposing the texture if you set it manually
  64913. */
  64914. get refractionTexture(): Texture;
  64915. set refractionTexture(value: Texture);
  64916. /**
  64917. * Initializes the RefractionPostProcess
  64918. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64919. * @param name The name of the effect.
  64920. * @param refractionTextureUrl Url of the refraction texture to use
  64921. * @param color the base color of the refraction (used to taint the rendering)
  64922. * @param depth simulated refraction depth
  64923. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64924. * @param camera The camera to apply the render pass to.
  64925. * @param options The required width/height ratio to downsize to before computing the render pass.
  64926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64927. * @param engine The engine which the post process will be applied. (default: current engine)
  64928. * @param reusable If the post process can be reused on the same frame. (default: false)
  64929. */
  64930. constructor(name: string, refractionTextureUrl: string,
  64931. /** the base color of the refraction (used to taint the rendering) */
  64932. color: Color3,
  64933. /** simulated refraction depth */
  64934. depth: number,
  64935. /** the coefficient of the base color (0 to remove base color tainting) */
  64936. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64937. /**
  64938. * Disposes of the post process
  64939. * @param camera Camera to dispose post process on
  64940. */
  64941. dispose(camera: Camera): void;
  64942. }
  64943. }
  64944. declare module BABYLON {
  64945. /** @hidden */
  64946. export var sharpenPixelShader: {
  64947. name: string;
  64948. shader: string;
  64949. };
  64950. }
  64951. declare module BABYLON {
  64952. /**
  64953. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64954. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64955. */
  64956. export class SharpenPostProcess extends PostProcess {
  64957. /**
  64958. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64959. */
  64960. colorAmount: number;
  64961. /**
  64962. * How much sharpness should be applied (default: 0.3)
  64963. */
  64964. edgeAmount: number;
  64965. /**
  64966. * Creates a new instance ConvolutionPostProcess
  64967. * @param name The name of the effect.
  64968. * @param options The required width/height ratio to downsize to before computing the render pass.
  64969. * @param camera The camera to apply the render pass to.
  64970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64971. * @param engine The engine which the post process will be applied. (default: current engine)
  64972. * @param reusable If the post process can be reused on the same frame. (default: false)
  64973. * @param textureType Type of textures used when performing the post process. (default: 0)
  64974. * @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)
  64975. */
  64976. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64977. }
  64978. }
  64979. declare module BABYLON {
  64980. /**
  64981. * PostProcessRenderPipeline
  64982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64983. */
  64984. export class PostProcessRenderPipeline {
  64985. private engine;
  64986. private _renderEffects;
  64987. private _renderEffectsForIsolatedPass;
  64988. /**
  64989. * List of inspectable custom properties (used by the Inspector)
  64990. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64991. */
  64992. inspectableCustomProperties: IInspectable[];
  64993. /**
  64994. * @hidden
  64995. */
  64996. protected _cameras: Camera[];
  64997. /** @hidden */
  64998. _name: string;
  64999. /**
  65000. * Gets pipeline name
  65001. */
  65002. get name(): string;
  65003. /** Gets the list of attached cameras */
  65004. get cameras(): Camera[];
  65005. /**
  65006. * Initializes a PostProcessRenderPipeline
  65007. * @param engine engine to add the pipeline to
  65008. * @param name name of the pipeline
  65009. */
  65010. constructor(engine: Engine, name: string);
  65011. /**
  65012. * Gets the class name
  65013. * @returns "PostProcessRenderPipeline"
  65014. */
  65015. getClassName(): string;
  65016. /**
  65017. * If all the render effects in the pipeline are supported
  65018. */
  65019. get isSupported(): boolean;
  65020. /**
  65021. * Adds an effect to the pipeline
  65022. * @param renderEffect the effect to add
  65023. */
  65024. addEffect(renderEffect: PostProcessRenderEffect): void;
  65025. /** @hidden */
  65026. _rebuild(): void;
  65027. /** @hidden */
  65028. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65029. /** @hidden */
  65030. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65031. /** @hidden */
  65032. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65033. /** @hidden */
  65034. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65035. /** @hidden */
  65036. _attachCameras(cameras: Camera, unique: boolean): void;
  65037. /** @hidden */
  65038. _attachCameras(cameras: Camera[], unique: boolean): void;
  65039. /** @hidden */
  65040. _detachCameras(cameras: Camera): void;
  65041. /** @hidden */
  65042. _detachCameras(cameras: Nullable<Camera[]>): void;
  65043. /** @hidden */
  65044. _update(): void;
  65045. /** @hidden */
  65046. _reset(): void;
  65047. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65048. /**
  65049. * Disposes of the pipeline
  65050. */
  65051. dispose(): void;
  65052. }
  65053. }
  65054. declare module BABYLON {
  65055. /**
  65056. * PostProcessRenderPipelineManager class
  65057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65058. */
  65059. export class PostProcessRenderPipelineManager {
  65060. private _renderPipelines;
  65061. /**
  65062. * Initializes a PostProcessRenderPipelineManager
  65063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65064. */
  65065. constructor();
  65066. /**
  65067. * Gets the list of supported render pipelines
  65068. */
  65069. get supportedPipelines(): PostProcessRenderPipeline[];
  65070. /**
  65071. * Adds a pipeline to the manager
  65072. * @param renderPipeline The pipeline to add
  65073. */
  65074. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65075. /**
  65076. * Attaches a camera to the pipeline
  65077. * @param renderPipelineName The name of the pipeline to attach to
  65078. * @param cameras the camera to attach
  65079. * @param unique if the camera can be attached multiple times to the pipeline
  65080. */
  65081. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65082. /**
  65083. * Detaches a camera from the pipeline
  65084. * @param renderPipelineName The name of the pipeline to detach from
  65085. * @param cameras the camera to detach
  65086. */
  65087. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65088. /**
  65089. * Enables an effect by name on a pipeline
  65090. * @param renderPipelineName the name of the pipeline to enable the effect in
  65091. * @param renderEffectName the name of the effect to enable
  65092. * @param cameras the cameras that the effect should be enabled on
  65093. */
  65094. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65095. /**
  65096. * Disables an effect by name on a pipeline
  65097. * @param renderPipelineName the name of the pipeline to disable the effect in
  65098. * @param renderEffectName the name of the effect to disable
  65099. * @param cameras the cameras that the effect should be disabled on
  65100. */
  65101. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65102. /**
  65103. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65104. */
  65105. update(): void;
  65106. /** @hidden */
  65107. _rebuild(): void;
  65108. /**
  65109. * Disposes of the manager and pipelines
  65110. */
  65111. dispose(): void;
  65112. }
  65113. }
  65114. declare module BABYLON {
  65115. interface Scene {
  65116. /** @hidden (Backing field) */
  65117. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65118. /**
  65119. * Gets the postprocess render pipeline manager
  65120. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65121. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65122. */
  65123. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65124. }
  65125. /**
  65126. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65127. */
  65128. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65129. /**
  65130. * The component name helpfull to identify the component in the list of scene components.
  65131. */
  65132. readonly name: string;
  65133. /**
  65134. * The scene the component belongs to.
  65135. */
  65136. scene: Scene;
  65137. /**
  65138. * Creates a new instance of the component for the given scene
  65139. * @param scene Defines the scene to register the component in
  65140. */
  65141. constructor(scene: Scene);
  65142. /**
  65143. * Registers the component in a given scene
  65144. */
  65145. register(): void;
  65146. /**
  65147. * Rebuilds the elements related to this component in case of
  65148. * context lost for instance.
  65149. */
  65150. rebuild(): void;
  65151. /**
  65152. * Disposes the component and the associated ressources
  65153. */
  65154. dispose(): void;
  65155. private _gatherRenderTargets;
  65156. }
  65157. }
  65158. declare module BABYLON {
  65159. /**
  65160. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65161. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65162. */
  65163. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65164. private _scene;
  65165. private _camerasToBeAttached;
  65166. /**
  65167. * ID of the sharpen post process,
  65168. */
  65169. private readonly SharpenPostProcessId;
  65170. /**
  65171. * @ignore
  65172. * ID of the image processing post process;
  65173. */
  65174. readonly ImageProcessingPostProcessId: string;
  65175. /**
  65176. * @ignore
  65177. * ID of the Fast Approximate Anti-Aliasing post process;
  65178. */
  65179. readonly FxaaPostProcessId: string;
  65180. /**
  65181. * ID of the chromatic aberration post process,
  65182. */
  65183. private readonly ChromaticAberrationPostProcessId;
  65184. /**
  65185. * ID of the grain post process
  65186. */
  65187. private readonly GrainPostProcessId;
  65188. /**
  65189. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65190. */
  65191. sharpen: SharpenPostProcess;
  65192. private _sharpenEffect;
  65193. private bloom;
  65194. /**
  65195. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65196. */
  65197. depthOfField: DepthOfFieldEffect;
  65198. /**
  65199. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65200. */
  65201. fxaa: FxaaPostProcess;
  65202. /**
  65203. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65204. */
  65205. imageProcessing: ImageProcessingPostProcess;
  65206. /**
  65207. * Chromatic aberration post process which will shift rgb colors in the image
  65208. */
  65209. chromaticAberration: ChromaticAberrationPostProcess;
  65210. private _chromaticAberrationEffect;
  65211. /**
  65212. * Grain post process which add noise to the image
  65213. */
  65214. grain: GrainPostProcess;
  65215. private _grainEffect;
  65216. /**
  65217. * Glow post process which adds a glow to emissive areas of the image
  65218. */
  65219. private _glowLayer;
  65220. /**
  65221. * Animations which can be used to tweak settings over a period of time
  65222. */
  65223. animations: Animation[];
  65224. private _imageProcessingConfigurationObserver;
  65225. private _sharpenEnabled;
  65226. private _bloomEnabled;
  65227. private _depthOfFieldEnabled;
  65228. private _depthOfFieldBlurLevel;
  65229. private _fxaaEnabled;
  65230. private _imageProcessingEnabled;
  65231. private _defaultPipelineTextureType;
  65232. private _bloomScale;
  65233. private _chromaticAberrationEnabled;
  65234. private _grainEnabled;
  65235. private _buildAllowed;
  65236. /**
  65237. * Gets active scene
  65238. */
  65239. get scene(): Scene;
  65240. /**
  65241. * Enable or disable the sharpen process from the pipeline
  65242. */
  65243. set sharpenEnabled(enabled: boolean);
  65244. get sharpenEnabled(): boolean;
  65245. private _resizeObserver;
  65246. private _hardwareScaleLevel;
  65247. private _bloomKernel;
  65248. /**
  65249. * Specifies the size of the bloom blur kernel, relative to the final output size
  65250. */
  65251. get bloomKernel(): number;
  65252. set bloomKernel(value: number);
  65253. /**
  65254. * Specifies the weight of the bloom in the final rendering
  65255. */
  65256. private _bloomWeight;
  65257. /**
  65258. * Specifies the luma threshold for the area that will be blurred by the bloom
  65259. */
  65260. private _bloomThreshold;
  65261. private _hdr;
  65262. /**
  65263. * The strength of the bloom.
  65264. */
  65265. set bloomWeight(value: number);
  65266. get bloomWeight(): number;
  65267. /**
  65268. * The strength of the bloom.
  65269. */
  65270. set bloomThreshold(value: number);
  65271. get bloomThreshold(): number;
  65272. /**
  65273. * The scale of the bloom, lower value will provide better performance.
  65274. */
  65275. set bloomScale(value: number);
  65276. get bloomScale(): number;
  65277. /**
  65278. * Enable or disable the bloom from the pipeline
  65279. */
  65280. set bloomEnabled(enabled: boolean);
  65281. get bloomEnabled(): boolean;
  65282. private _rebuildBloom;
  65283. /**
  65284. * If the depth of field is enabled.
  65285. */
  65286. get depthOfFieldEnabled(): boolean;
  65287. set depthOfFieldEnabled(enabled: boolean);
  65288. /**
  65289. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65290. */
  65291. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65292. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65293. /**
  65294. * If the anti aliasing is enabled.
  65295. */
  65296. set fxaaEnabled(enabled: boolean);
  65297. get fxaaEnabled(): boolean;
  65298. private _samples;
  65299. /**
  65300. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65301. */
  65302. set samples(sampleCount: number);
  65303. get samples(): number;
  65304. /**
  65305. * If image processing is enabled.
  65306. */
  65307. set imageProcessingEnabled(enabled: boolean);
  65308. get imageProcessingEnabled(): boolean;
  65309. /**
  65310. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65311. */
  65312. set glowLayerEnabled(enabled: boolean);
  65313. get glowLayerEnabled(): boolean;
  65314. /**
  65315. * Gets the glow layer (or null if not defined)
  65316. */
  65317. get glowLayer(): Nullable<GlowLayer>;
  65318. /**
  65319. * Enable or disable the chromaticAberration process from the pipeline
  65320. */
  65321. set chromaticAberrationEnabled(enabled: boolean);
  65322. get chromaticAberrationEnabled(): boolean;
  65323. /**
  65324. * Enable or disable the grain process from the pipeline
  65325. */
  65326. set grainEnabled(enabled: boolean);
  65327. get grainEnabled(): boolean;
  65328. /**
  65329. * @constructor
  65330. * @param name - The rendering pipeline name (default: "")
  65331. * @param hdr - If high dynamic range textures should be used (default: true)
  65332. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65333. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65334. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65335. */
  65336. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65337. /**
  65338. * Get the class name
  65339. * @returns "DefaultRenderingPipeline"
  65340. */
  65341. getClassName(): string;
  65342. /**
  65343. * Force the compilation of the entire pipeline.
  65344. */
  65345. prepare(): void;
  65346. private _hasCleared;
  65347. private _prevPostProcess;
  65348. private _prevPrevPostProcess;
  65349. private _setAutoClearAndTextureSharing;
  65350. private _depthOfFieldSceneObserver;
  65351. private _buildPipeline;
  65352. private _disposePostProcesses;
  65353. /**
  65354. * Adds a camera to the pipeline
  65355. * @param camera the camera to be added
  65356. */
  65357. addCamera(camera: Camera): void;
  65358. /**
  65359. * Removes a camera from the pipeline
  65360. * @param camera the camera to remove
  65361. */
  65362. removeCamera(camera: Camera): void;
  65363. /**
  65364. * Dispose of the pipeline and stop all post processes
  65365. */
  65366. dispose(): void;
  65367. /**
  65368. * Serialize the rendering pipeline (Used when exporting)
  65369. * @returns the serialized object
  65370. */
  65371. serialize(): any;
  65372. /**
  65373. * Parse the serialized pipeline
  65374. * @param source Source pipeline.
  65375. * @param scene The scene to load the pipeline to.
  65376. * @param rootUrl The URL of the serialized pipeline.
  65377. * @returns An instantiated pipeline from the serialized object.
  65378. */
  65379. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65380. }
  65381. }
  65382. declare module BABYLON {
  65383. /** @hidden */
  65384. export var lensHighlightsPixelShader: {
  65385. name: string;
  65386. shader: string;
  65387. };
  65388. }
  65389. declare module BABYLON {
  65390. /** @hidden */
  65391. export var depthOfFieldPixelShader: {
  65392. name: string;
  65393. shader: string;
  65394. };
  65395. }
  65396. declare module BABYLON {
  65397. /**
  65398. * BABYLON.JS Chromatic Aberration GLSL Shader
  65399. * Author: Olivier Guyot
  65400. * Separates very slightly R, G and B colors on the edges of the screen
  65401. * Inspired by Francois Tarlier & Martins Upitis
  65402. */
  65403. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65404. /**
  65405. * @ignore
  65406. * The chromatic aberration PostProcess id in the pipeline
  65407. */
  65408. LensChromaticAberrationEffect: string;
  65409. /**
  65410. * @ignore
  65411. * The highlights enhancing PostProcess id in the pipeline
  65412. */
  65413. HighlightsEnhancingEffect: string;
  65414. /**
  65415. * @ignore
  65416. * The depth-of-field PostProcess id in the pipeline
  65417. */
  65418. LensDepthOfFieldEffect: string;
  65419. private _scene;
  65420. private _depthTexture;
  65421. private _grainTexture;
  65422. private _chromaticAberrationPostProcess;
  65423. private _highlightsPostProcess;
  65424. private _depthOfFieldPostProcess;
  65425. private _edgeBlur;
  65426. private _grainAmount;
  65427. private _chromaticAberration;
  65428. private _distortion;
  65429. private _highlightsGain;
  65430. private _highlightsThreshold;
  65431. private _dofDistance;
  65432. private _dofAperture;
  65433. private _dofDarken;
  65434. private _dofPentagon;
  65435. private _blurNoise;
  65436. /**
  65437. * @constructor
  65438. *
  65439. * Effect parameters are as follow:
  65440. * {
  65441. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65442. * edge_blur: number; // from 0 to x (1 for realism)
  65443. * distortion: number; // from 0 to x (1 for realism)
  65444. * grain_amount: number; // from 0 to 1
  65445. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65446. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65447. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65448. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65449. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65450. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65451. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65452. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65453. * }
  65454. * Note: if an effect parameter is unset, effect is disabled
  65455. *
  65456. * @param name The rendering pipeline name
  65457. * @param parameters - An object containing all parameters (see above)
  65458. * @param scene The scene linked to this pipeline
  65459. * @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)
  65460. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65461. */
  65462. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65463. /**
  65464. * Get the class name
  65465. * @returns "LensRenderingPipeline"
  65466. */
  65467. getClassName(): string;
  65468. /**
  65469. * Gets associated scene
  65470. */
  65471. get scene(): Scene;
  65472. /**
  65473. * Gets or sets the edge blur
  65474. */
  65475. get edgeBlur(): number;
  65476. set edgeBlur(value: number);
  65477. /**
  65478. * Gets or sets the grain amount
  65479. */
  65480. get grainAmount(): number;
  65481. set grainAmount(value: number);
  65482. /**
  65483. * Gets or sets the chromatic aberration amount
  65484. */
  65485. get chromaticAberration(): number;
  65486. set chromaticAberration(value: number);
  65487. /**
  65488. * Gets or sets the depth of field aperture
  65489. */
  65490. get dofAperture(): number;
  65491. set dofAperture(value: number);
  65492. /**
  65493. * Gets or sets the edge distortion
  65494. */
  65495. get edgeDistortion(): number;
  65496. set edgeDistortion(value: number);
  65497. /**
  65498. * Gets or sets the depth of field distortion
  65499. */
  65500. get dofDistortion(): number;
  65501. set dofDistortion(value: number);
  65502. /**
  65503. * Gets or sets the darken out of focus amount
  65504. */
  65505. get darkenOutOfFocus(): number;
  65506. set darkenOutOfFocus(value: number);
  65507. /**
  65508. * Gets or sets a boolean indicating if blur noise is enabled
  65509. */
  65510. get blurNoise(): boolean;
  65511. set blurNoise(value: boolean);
  65512. /**
  65513. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65514. */
  65515. get pentagonBokeh(): boolean;
  65516. set pentagonBokeh(value: boolean);
  65517. /**
  65518. * Gets or sets the highlight grain amount
  65519. */
  65520. get highlightsGain(): number;
  65521. set highlightsGain(value: number);
  65522. /**
  65523. * Gets or sets the highlight threshold
  65524. */
  65525. get highlightsThreshold(): number;
  65526. set highlightsThreshold(value: number);
  65527. /**
  65528. * Sets the amount of blur at the edges
  65529. * @param amount blur amount
  65530. */
  65531. setEdgeBlur(amount: number): void;
  65532. /**
  65533. * Sets edge blur to 0
  65534. */
  65535. disableEdgeBlur(): void;
  65536. /**
  65537. * Sets the amout of grain
  65538. * @param amount Amount of grain
  65539. */
  65540. setGrainAmount(amount: number): void;
  65541. /**
  65542. * Set grain amount to 0
  65543. */
  65544. disableGrain(): void;
  65545. /**
  65546. * Sets the chromatic aberration amount
  65547. * @param amount amount of chromatic aberration
  65548. */
  65549. setChromaticAberration(amount: number): void;
  65550. /**
  65551. * Sets chromatic aberration amount to 0
  65552. */
  65553. disableChromaticAberration(): void;
  65554. /**
  65555. * Sets the EdgeDistortion amount
  65556. * @param amount amount of EdgeDistortion
  65557. */
  65558. setEdgeDistortion(amount: number): void;
  65559. /**
  65560. * Sets edge distortion to 0
  65561. */
  65562. disableEdgeDistortion(): void;
  65563. /**
  65564. * Sets the FocusDistance amount
  65565. * @param amount amount of FocusDistance
  65566. */
  65567. setFocusDistance(amount: number): void;
  65568. /**
  65569. * Disables depth of field
  65570. */
  65571. disableDepthOfField(): void;
  65572. /**
  65573. * Sets the Aperture amount
  65574. * @param amount amount of Aperture
  65575. */
  65576. setAperture(amount: number): void;
  65577. /**
  65578. * Sets the DarkenOutOfFocus amount
  65579. * @param amount amount of DarkenOutOfFocus
  65580. */
  65581. setDarkenOutOfFocus(amount: number): void;
  65582. private _pentagonBokehIsEnabled;
  65583. /**
  65584. * Creates a pentagon bokeh effect
  65585. */
  65586. enablePentagonBokeh(): void;
  65587. /**
  65588. * Disables the pentagon bokeh effect
  65589. */
  65590. disablePentagonBokeh(): void;
  65591. /**
  65592. * Enables noise blur
  65593. */
  65594. enableNoiseBlur(): void;
  65595. /**
  65596. * Disables noise blur
  65597. */
  65598. disableNoiseBlur(): void;
  65599. /**
  65600. * Sets the HighlightsGain amount
  65601. * @param amount amount of HighlightsGain
  65602. */
  65603. setHighlightsGain(amount: number): void;
  65604. /**
  65605. * Sets the HighlightsThreshold amount
  65606. * @param amount amount of HighlightsThreshold
  65607. */
  65608. setHighlightsThreshold(amount: number): void;
  65609. /**
  65610. * Disables highlights
  65611. */
  65612. disableHighlights(): void;
  65613. /**
  65614. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65615. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65616. */
  65617. dispose(disableDepthRender?: boolean): void;
  65618. private _createChromaticAberrationPostProcess;
  65619. private _createHighlightsPostProcess;
  65620. private _createDepthOfFieldPostProcess;
  65621. private _createGrainTexture;
  65622. }
  65623. }
  65624. declare module BABYLON {
  65625. /** @hidden */
  65626. export var ssao2PixelShader: {
  65627. name: string;
  65628. shader: string;
  65629. };
  65630. }
  65631. declare module BABYLON {
  65632. /** @hidden */
  65633. export var ssaoCombinePixelShader: {
  65634. name: string;
  65635. shader: string;
  65636. };
  65637. }
  65638. declare module BABYLON {
  65639. /**
  65640. * Render pipeline to produce ssao effect
  65641. */
  65642. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65643. /**
  65644. * @ignore
  65645. * The PassPostProcess id in the pipeline that contains the original scene color
  65646. */
  65647. SSAOOriginalSceneColorEffect: string;
  65648. /**
  65649. * @ignore
  65650. * The SSAO PostProcess id in the pipeline
  65651. */
  65652. SSAORenderEffect: string;
  65653. /**
  65654. * @ignore
  65655. * The horizontal blur PostProcess id in the pipeline
  65656. */
  65657. SSAOBlurHRenderEffect: string;
  65658. /**
  65659. * @ignore
  65660. * The vertical blur PostProcess id in the pipeline
  65661. */
  65662. SSAOBlurVRenderEffect: string;
  65663. /**
  65664. * @ignore
  65665. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65666. */
  65667. SSAOCombineRenderEffect: string;
  65668. /**
  65669. * The output strength of the SSAO post-process. Default value is 1.0.
  65670. */
  65671. totalStrength: number;
  65672. /**
  65673. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65674. */
  65675. maxZ: number;
  65676. /**
  65677. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65678. */
  65679. minZAspect: number;
  65680. private _samples;
  65681. /**
  65682. * Number of samples used for the SSAO calculations. Default value is 8
  65683. */
  65684. set samples(n: number);
  65685. get samples(): number;
  65686. private _textureSamples;
  65687. /**
  65688. * Number of samples to use for antialiasing
  65689. */
  65690. set textureSamples(n: number);
  65691. get textureSamples(): number;
  65692. /**
  65693. * Ratio object used for SSAO ratio and blur ratio
  65694. */
  65695. private _ratio;
  65696. /**
  65697. * Dynamically generated sphere sampler.
  65698. */
  65699. private _sampleSphere;
  65700. /**
  65701. * Blur filter offsets
  65702. */
  65703. private _samplerOffsets;
  65704. private _expensiveBlur;
  65705. /**
  65706. * If bilateral blur should be used
  65707. */
  65708. set expensiveBlur(b: boolean);
  65709. get expensiveBlur(): boolean;
  65710. /**
  65711. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65712. */
  65713. radius: number;
  65714. /**
  65715. * The base color of the SSAO post-process
  65716. * The final result is "base + ssao" between [0, 1]
  65717. */
  65718. base: number;
  65719. /**
  65720. * Support test.
  65721. */
  65722. static get IsSupported(): boolean;
  65723. private _scene;
  65724. private _depthTexture;
  65725. private _normalTexture;
  65726. private _randomTexture;
  65727. private _originalColorPostProcess;
  65728. private _ssaoPostProcess;
  65729. private _blurHPostProcess;
  65730. private _blurVPostProcess;
  65731. private _ssaoCombinePostProcess;
  65732. /**
  65733. * Gets active scene
  65734. */
  65735. get scene(): Scene;
  65736. /**
  65737. * @constructor
  65738. * @param name The rendering pipeline name
  65739. * @param scene The scene linked to this pipeline
  65740. * @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 }
  65741. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65742. */
  65743. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65744. /**
  65745. * Get the class name
  65746. * @returns "SSAO2RenderingPipeline"
  65747. */
  65748. getClassName(): string;
  65749. /**
  65750. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65751. */
  65752. dispose(disableGeometryBufferRenderer?: boolean): void;
  65753. private _createBlurPostProcess;
  65754. /** @hidden */
  65755. _rebuild(): void;
  65756. private _bits;
  65757. private _radicalInverse_VdC;
  65758. private _hammersley;
  65759. private _hemisphereSample_uniform;
  65760. private _generateHemisphere;
  65761. private _createSSAOPostProcess;
  65762. private _createSSAOCombinePostProcess;
  65763. private _createRandomTexture;
  65764. /**
  65765. * Serialize the rendering pipeline (Used when exporting)
  65766. * @returns the serialized object
  65767. */
  65768. serialize(): any;
  65769. /**
  65770. * Parse the serialized pipeline
  65771. * @param source Source pipeline.
  65772. * @param scene The scene to load the pipeline to.
  65773. * @param rootUrl The URL of the serialized pipeline.
  65774. * @returns An instantiated pipeline from the serialized object.
  65775. */
  65776. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65777. }
  65778. }
  65779. declare module BABYLON {
  65780. /** @hidden */
  65781. export var ssaoPixelShader: {
  65782. name: string;
  65783. shader: string;
  65784. };
  65785. }
  65786. declare module BABYLON {
  65787. /**
  65788. * Render pipeline to produce ssao effect
  65789. */
  65790. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65791. /**
  65792. * @ignore
  65793. * The PassPostProcess id in the pipeline that contains the original scene color
  65794. */
  65795. SSAOOriginalSceneColorEffect: string;
  65796. /**
  65797. * @ignore
  65798. * The SSAO PostProcess id in the pipeline
  65799. */
  65800. SSAORenderEffect: string;
  65801. /**
  65802. * @ignore
  65803. * The horizontal blur PostProcess id in the pipeline
  65804. */
  65805. SSAOBlurHRenderEffect: string;
  65806. /**
  65807. * @ignore
  65808. * The vertical blur PostProcess id in the pipeline
  65809. */
  65810. SSAOBlurVRenderEffect: string;
  65811. /**
  65812. * @ignore
  65813. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65814. */
  65815. SSAOCombineRenderEffect: string;
  65816. /**
  65817. * The output strength of the SSAO post-process. Default value is 1.0.
  65818. */
  65819. totalStrength: number;
  65820. /**
  65821. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65822. */
  65823. radius: number;
  65824. /**
  65825. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65826. * Must not be equal to fallOff and superior to fallOff.
  65827. * Default value is 0.0075
  65828. */
  65829. area: number;
  65830. /**
  65831. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65832. * Must not be equal to area and inferior to area.
  65833. * Default value is 0.000001
  65834. */
  65835. fallOff: number;
  65836. /**
  65837. * The base color of the SSAO post-process
  65838. * The final result is "base + ssao" between [0, 1]
  65839. */
  65840. base: number;
  65841. private _scene;
  65842. private _depthTexture;
  65843. private _randomTexture;
  65844. private _originalColorPostProcess;
  65845. private _ssaoPostProcess;
  65846. private _blurHPostProcess;
  65847. private _blurVPostProcess;
  65848. private _ssaoCombinePostProcess;
  65849. private _firstUpdate;
  65850. /**
  65851. * Gets active scene
  65852. */
  65853. get scene(): Scene;
  65854. /**
  65855. * @constructor
  65856. * @param name - The rendering pipeline name
  65857. * @param scene - The scene linked to this pipeline
  65858. * @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 }
  65859. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65860. */
  65861. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65862. /**
  65863. * Get the class name
  65864. * @returns "SSAORenderingPipeline"
  65865. */
  65866. getClassName(): string;
  65867. /**
  65868. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65869. */
  65870. dispose(disableDepthRender?: boolean): void;
  65871. private _createBlurPostProcess;
  65872. /** @hidden */
  65873. _rebuild(): void;
  65874. private _createSSAOPostProcess;
  65875. private _createSSAOCombinePostProcess;
  65876. private _createRandomTexture;
  65877. }
  65878. }
  65879. declare module BABYLON {
  65880. /** @hidden */
  65881. export var screenSpaceReflectionPixelShader: {
  65882. name: string;
  65883. shader: string;
  65884. };
  65885. }
  65886. declare module BABYLON {
  65887. /**
  65888. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65889. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65890. */
  65891. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65892. /**
  65893. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65894. */
  65895. threshold: number;
  65896. /**
  65897. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65898. */
  65899. strength: number;
  65900. /**
  65901. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65902. */
  65903. reflectionSpecularFalloffExponent: number;
  65904. /**
  65905. * 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]
  65906. */
  65907. step: number;
  65908. /**
  65909. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65910. */
  65911. roughnessFactor: number;
  65912. private _geometryBufferRenderer;
  65913. private _enableSmoothReflections;
  65914. private _reflectionSamples;
  65915. private _smoothSteps;
  65916. /**
  65917. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65918. * @param name The name of the effect.
  65919. * @param scene The scene containing the objects to calculate reflections.
  65920. * @param options The required width/height ratio to downsize to before computing the render pass.
  65921. * @param camera The camera to apply the render pass to.
  65922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65923. * @param engine The engine which the post process will be applied. (default: current engine)
  65924. * @param reusable If the post process can be reused on the same frame. (default: false)
  65925. * @param textureType Type of textures used when performing the post process. (default: 0)
  65926. * @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)
  65927. */
  65928. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65929. /**
  65930. * Gets wether or not smoothing reflections is enabled.
  65931. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65932. */
  65933. get enableSmoothReflections(): boolean;
  65934. /**
  65935. * Sets wether or not smoothing reflections is enabled.
  65936. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65937. */
  65938. set enableSmoothReflections(enabled: boolean);
  65939. /**
  65940. * Gets the number of samples taken while computing reflections. More samples count is high,
  65941. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65942. */
  65943. get reflectionSamples(): number;
  65944. /**
  65945. * Sets the number of samples taken while computing reflections. More samples count is high,
  65946. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65947. */
  65948. set reflectionSamples(samples: number);
  65949. /**
  65950. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65951. * more the post-process will require GPU power and can generate a drop in FPS.
  65952. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65953. */
  65954. get smoothSteps(): number;
  65955. set smoothSteps(steps: number);
  65956. private _updateEffectDefines;
  65957. }
  65958. }
  65959. declare module BABYLON {
  65960. /** @hidden */
  65961. export var standardPixelShader: {
  65962. name: string;
  65963. shader: string;
  65964. };
  65965. }
  65966. declare module BABYLON {
  65967. /**
  65968. * Standard rendering pipeline
  65969. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65970. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65971. */
  65972. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65973. /**
  65974. * Public members
  65975. */
  65976. /**
  65977. * Post-process which contains the original scene color before the pipeline applies all the effects
  65978. */
  65979. originalPostProcess: Nullable<PostProcess>;
  65980. /**
  65981. * Post-process used to down scale an image x4
  65982. */
  65983. downSampleX4PostProcess: Nullable<PostProcess>;
  65984. /**
  65985. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65986. */
  65987. brightPassPostProcess: Nullable<PostProcess>;
  65988. /**
  65989. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65990. */
  65991. blurHPostProcesses: PostProcess[];
  65992. /**
  65993. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65994. */
  65995. blurVPostProcesses: PostProcess[];
  65996. /**
  65997. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65998. */
  65999. textureAdderPostProcess: Nullable<PostProcess>;
  66000. /**
  66001. * Post-process used to create volumetric lighting effect
  66002. */
  66003. volumetricLightPostProcess: Nullable<PostProcess>;
  66004. /**
  66005. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66006. */
  66007. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66008. /**
  66009. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66010. */
  66011. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66012. /**
  66013. * Post-process used to merge the volumetric light effect and the real scene color
  66014. */
  66015. volumetricLightMergePostProces: Nullable<PostProcess>;
  66016. /**
  66017. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66018. */
  66019. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66020. /**
  66021. * Base post-process used to calculate the average luminance of the final image for HDR
  66022. */
  66023. luminancePostProcess: Nullable<PostProcess>;
  66024. /**
  66025. * Post-processes used to create down sample post-processes in order to get
  66026. * the average luminance of the final image for HDR
  66027. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66028. */
  66029. luminanceDownSamplePostProcesses: PostProcess[];
  66030. /**
  66031. * Post-process used to create a HDR effect (light adaptation)
  66032. */
  66033. hdrPostProcess: Nullable<PostProcess>;
  66034. /**
  66035. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66036. */
  66037. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66038. /**
  66039. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66040. */
  66041. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66042. /**
  66043. * Post-process used to merge the final HDR post-process and the real scene color
  66044. */
  66045. hdrFinalPostProcess: Nullable<PostProcess>;
  66046. /**
  66047. * Post-process used to create a lens flare effect
  66048. */
  66049. lensFlarePostProcess: Nullable<PostProcess>;
  66050. /**
  66051. * Post-process that merges the result of the lens flare post-process and the real scene color
  66052. */
  66053. lensFlareComposePostProcess: Nullable<PostProcess>;
  66054. /**
  66055. * Post-process used to create a motion blur effect
  66056. */
  66057. motionBlurPostProcess: Nullable<PostProcess>;
  66058. /**
  66059. * Post-process used to create a depth of field effect
  66060. */
  66061. depthOfFieldPostProcess: Nullable<PostProcess>;
  66062. /**
  66063. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66064. */
  66065. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66066. /**
  66067. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66068. */
  66069. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66070. /**
  66071. * Represents the brightness threshold in order to configure the illuminated surfaces
  66072. */
  66073. brightThreshold: number;
  66074. /**
  66075. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66076. */
  66077. blurWidth: number;
  66078. /**
  66079. * Sets if the blur for highlighted surfaces must be only horizontal
  66080. */
  66081. horizontalBlur: boolean;
  66082. /**
  66083. * Gets the overall exposure used by the pipeline
  66084. */
  66085. get exposure(): number;
  66086. /**
  66087. * Sets the overall exposure used by the pipeline
  66088. */
  66089. set exposure(value: number);
  66090. /**
  66091. * Texture used typically to simulate "dirty" on camera lens
  66092. */
  66093. lensTexture: Nullable<Texture>;
  66094. /**
  66095. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66096. */
  66097. volumetricLightCoefficient: number;
  66098. /**
  66099. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66100. */
  66101. volumetricLightPower: number;
  66102. /**
  66103. * Used the set the blur intensity to smooth the volumetric lights
  66104. */
  66105. volumetricLightBlurScale: number;
  66106. /**
  66107. * Light (spot or directional) used to generate the volumetric lights rays
  66108. * The source light must have a shadow generate so the pipeline can get its
  66109. * depth map
  66110. */
  66111. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66112. /**
  66113. * For eye adaptation, represents the minimum luminance the eye can see
  66114. */
  66115. hdrMinimumLuminance: number;
  66116. /**
  66117. * For eye adaptation, represents the decrease luminance speed
  66118. */
  66119. hdrDecreaseRate: number;
  66120. /**
  66121. * For eye adaptation, represents the increase luminance speed
  66122. */
  66123. hdrIncreaseRate: number;
  66124. /**
  66125. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66126. */
  66127. get hdrAutoExposure(): boolean;
  66128. /**
  66129. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66130. */
  66131. set hdrAutoExposure(value: boolean);
  66132. /**
  66133. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66134. */
  66135. lensColorTexture: Nullable<Texture>;
  66136. /**
  66137. * The overall strengh for the lens flare effect
  66138. */
  66139. lensFlareStrength: number;
  66140. /**
  66141. * Dispersion coefficient for lens flare ghosts
  66142. */
  66143. lensFlareGhostDispersal: number;
  66144. /**
  66145. * Main lens flare halo width
  66146. */
  66147. lensFlareHaloWidth: number;
  66148. /**
  66149. * Based on the lens distortion effect, defines how much the lens flare result
  66150. * is distorted
  66151. */
  66152. lensFlareDistortionStrength: number;
  66153. /**
  66154. * Configures the blur intensity used for for lens flare (halo)
  66155. */
  66156. lensFlareBlurWidth: number;
  66157. /**
  66158. * Lens star texture must be used to simulate rays on the flares and is available
  66159. * in the documentation
  66160. */
  66161. lensStarTexture: Nullable<Texture>;
  66162. /**
  66163. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66164. * flare effect by taking account of the dirt texture
  66165. */
  66166. lensFlareDirtTexture: Nullable<Texture>;
  66167. /**
  66168. * Represents the focal length for the depth of field effect
  66169. */
  66170. depthOfFieldDistance: number;
  66171. /**
  66172. * Represents the blur intensity for the blurred part of the depth of field effect
  66173. */
  66174. depthOfFieldBlurWidth: number;
  66175. /**
  66176. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66177. */
  66178. get motionStrength(): number;
  66179. /**
  66180. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66181. */
  66182. set motionStrength(strength: number);
  66183. /**
  66184. * Gets wether or not the motion blur post-process is object based or screen based.
  66185. */
  66186. get objectBasedMotionBlur(): boolean;
  66187. /**
  66188. * Sets wether or not the motion blur post-process should be object based or screen based
  66189. */
  66190. set objectBasedMotionBlur(value: boolean);
  66191. /**
  66192. * List of animations for the pipeline (IAnimatable implementation)
  66193. */
  66194. animations: Animation[];
  66195. /**
  66196. * Private members
  66197. */
  66198. private _scene;
  66199. private _currentDepthOfFieldSource;
  66200. private _basePostProcess;
  66201. private _fixedExposure;
  66202. private _currentExposure;
  66203. private _hdrAutoExposure;
  66204. private _hdrCurrentLuminance;
  66205. private _motionStrength;
  66206. private _isObjectBasedMotionBlur;
  66207. private _floatTextureType;
  66208. private _camerasToBeAttached;
  66209. private _ratio;
  66210. private _bloomEnabled;
  66211. private _depthOfFieldEnabled;
  66212. private _vlsEnabled;
  66213. private _lensFlareEnabled;
  66214. private _hdrEnabled;
  66215. private _motionBlurEnabled;
  66216. private _fxaaEnabled;
  66217. private _screenSpaceReflectionsEnabled;
  66218. private _motionBlurSamples;
  66219. private _volumetricLightStepsCount;
  66220. private _samples;
  66221. /**
  66222. * @ignore
  66223. * Specifies if the bloom pipeline is enabled
  66224. */
  66225. get BloomEnabled(): boolean;
  66226. set BloomEnabled(enabled: boolean);
  66227. /**
  66228. * @ignore
  66229. * Specifies if the depth of field pipeline is enabed
  66230. */
  66231. get DepthOfFieldEnabled(): boolean;
  66232. set DepthOfFieldEnabled(enabled: boolean);
  66233. /**
  66234. * @ignore
  66235. * Specifies if the lens flare pipeline is enabed
  66236. */
  66237. get LensFlareEnabled(): boolean;
  66238. set LensFlareEnabled(enabled: boolean);
  66239. /**
  66240. * @ignore
  66241. * Specifies if the HDR pipeline is enabled
  66242. */
  66243. get HDREnabled(): boolean;
  66244. set HDREnabled(enabled: boolean);
  66245. /**
  66246. * @ignore
  66247. * Specifies if the volumetric lights scattering effect is enabled
  66248. */
  66249. get VLSEnabled(): boolean;
  66250. set VLSEnabled(enabled: boolean);
  66251. /**
  66252. * @ignore
  66253. * Specifies if the motion blur effect is enabled
  66254. */
  66255. get MotionBlurEnabled(): boolean;
  66256. set MotionBlurEnabled(enabled: boolean);
  66257. /**
  66258. * Specifies if anti-aliasing is enabled
  66259. */
  66260. get fxaaEnabled(): boolean;
  66261. set fxaaEnabled(enabled: boolean);
  66262. /**
  66263. * Specifies if screen space reflections are enabled.
  66264. */
  66265. get screenSpaceReflectionsEnabled(): boolean;
  66266. set screenSpaceReflectionsEnabled(enabled: boolean);
  66267. /**
  66268. * Specifies the number of steps used to calculate the volumetric lights
  66269. * Typically in interval [50, 200]
  66270. */
  66271. get volumetricLightStepsCount(): number;
  66272. set volumetricLightStepsCount(count: number);
  66273. /**
  66274. * Specifies the number of samples used for the motion blur effect
  66275. * Typically in interval [16, 64]
  66276. */
  66277. get motionBlurSamples(): number;
  66278. set motionBlurSamples(samples: number);
  66279. /**
  66280. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66281. */
  66282. get samples(): number;
  66283. set samples(sampleCount: number);
  66284. /**
  66285. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66286. * @constructor
  66287. * @param name The rendering pipeline name
  66288. * @param scene The scene linked to this pipeline
  66289. * @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)
  66290. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66291. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66292. */
  66293. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66294. private _buildPipeline;
  66295. private _createDownSampleX4PostProcess;
  66296. private _createBrightPassPostProcess;
  66297. private _createBlurPostProcesses;
  66298. private _createTextureAdderPostProcess;
  66299. private _createVolumetricLightPostProcess;
  66300. private _createLuminancePostProcesses;
  66301. private _createHdrPostProcess;
  66302. private _createLensFlarePostProcess;
  66303. private _createDepthOfFieldPostProcess;
  66304. private _createMotionBlurPostProcess;
  66305. private _getDepthTexture;
  66306. private _disposePostProcesses;
  66307. /**
  66308. * Dispose of the pipeline and stop all post processes
  66309. */
  66310. dispose(): void;
  66311. /**
  66312. * Serialize the rendering pipeline (Used when exporting)
  66313. * @returns the serialized object
  66314. */
  66315. serialize(): any;
  66316. /**
  66317. * Parse the serialized pipeline
  66318. * @param source Source pipeline.
  66319. * @param scene The scene to load the pipeline to.
  66320. * @param rootUrl The URL of the serialized pipeline.
  66321. * @returns An instantiated pipeline from the serialized object.
  66322. */
  66323. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66324. /**
  66325. * Luminance steps
  66326. */
  66327. static LuminanceSteps: number;
  66328. }
  66329. }
  66330. declare module BABYLON {
  66331. /** @hidden */
  66332. export var tonemapPixelShader: {
  66333. name: string;
  66334. shader: string;
  66335. };
  66336. }
  66337. declare module BABYLON {
  66338. /** Defines operator used for tonemapping */
  66339. export enum TonemappingOperator {
  66340. /** Hable */
  66341. Hable = 0,
  66342. /** Reinhard */
  66343. Reinhard = 1,
  66344. /** HejiDawson */
  66345. HejiDawson = 2,
  66346. /** Photographic */
  66347. Photographic = 3
  66348. }
  66349. /**
  66350. * Defines a post process to apply tone mapping
  66351. */
  66352. export class TonemapPostProcess extends PostProcess {
  66353. private _operator;
  66354. /** Defines the required exposure adjustement */
  66355. exposureAdjustment: number;
  66356. /**
  66357. * Creates a new TonemapPostProcess
  66358. * @param name defines the name of the postprocess
  66359. * @param _operator defines the operator to use
  66360. * @param exposureAdjustment defines the required exposure adjustement
  66361. * @param camera defines the camera to use (can be null)
  66362. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66363. * @param engine defines the hosting engine (can be ignore if camera is set)
  66364. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66365. */
  66366. constructor(name: string, _operator: TonemappingOperator,
  66367. /** Defines the required exposure adjustement */
  66368. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66369. }
  66370. }
  66371. declare module BABYLON {
  66372. /** @hidden */
  66373. export var volumetricLightScatteringPixelShader: {
  66374. name: string;
  66375. shader: string;
  66376. };
  66377. }
  66378. declare module BABYLON {
  66379. /** @hidden */
  66380. export var volumetricLightScatteringPassVertexShader: {
  66381. name: string;
  66382. shader: string;
  66383. };
  66384. }
  66385. declare module BABYLON {
  66386. /** @hidden */
  66387. export var volumetricLightScatteringPassPixelShader: {
  66388. name: string;
  66389. shader: string;
  66390. };
  66391. }
  66392. declare module BABYLON {
  66393. /**
  66394. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66395. */
  66396. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66397. private _volumetricLightScatteringPass;
  66398. private _volumetricLightScatteringRTT;
  66399. private _viewPort;
  66400. private _screenCoordinates;
  66401. private _cachedDefines;
  66402. /**
  66403. * If not undefined, the mesh position is computed from the attached node position
  66404. */
  66405. attachedNode: {
  66406. position: Vector3;
  66407. };
  66408. /**
  66409. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66410. */
  66411. customMeshPosition: Vector3;
  66412. /**
  66413. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66414. */
  66415. useCustomMeshPosition: boolean;
  66416. /**
  66417. * If the post-process should inverse the light scattering direction
  66418. */
  66419. invert: boolean;
  66420. /**
  66421. * The internal mesh used by the post-process
  66422. */
  66423. mesh: Mesh;
  66424. /**
  66425. * @hidden
  66426. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66427. */
  66428. get useDiffuseColor(): boolean;
  66429. set useDiffuseColor(useDiffuseColor: boolean);
  66430. /**
  66431. * Array containing the excluded meshes not rendered in the internal pass
  66432. */
  66433. excludedMeshes: AbstractMesh[];
  66434. /**
  66435. * Controls the overall intensity of the post-process
  66436. */
  66437. exposure: number;
  66438. /**
  66439. * Dissipates each sample's contribution in range [0, 1]
  66440. */
  66441. decay: number;
  66442. /**
  66443. * Controls the overall intensity of each sample
  66444. */
  66445. weight: number;
  66446. /**
  66447. * Controls the density of each sample
  66448. */
  66449. density: number;
  66450. /**
  66451. * @constructor
  66452. * @param name The post-process name
  66453. * @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)
  66454. * @param camera The camera that the post-process will be attached to
  66455. * @param mesh The mesh used to create the light scattering
  66456. * @param samples The post-process quality, default 100
  66457. * @param samplingModeThe post-process filtering mode
  66458. * @param engine The babylon engine
  66459. * @param reusable If the post-process is reusable
  66460. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66461. */
  66462. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66463. /**
  66464. * Returns the string "VolumetricLightScatteringPostProcess"
  66465. * @returns "VolumetricLightScatteringPostProcess"
  66466. */
  66467. getClassName(): string;
  66468. private _isReady;
  66469. /**
  66470. * Sets the new light position for light scattering effect
  66471. * @param position The new custom light position
  66472. */
  66473. setCustomMeshPosition(position: Vector3): void;
  66474. /**
  66475. * Returns the light position for light scattering effect
  66476. * @return Vector3 The custom light position
  66477. */
  66478. getCustomMeshPosition(): Vector3;
  66479. /**
  66480. * Disposes the internal assets and detaches the post-process from the camera
  66481. */
  66482. dispose(camera: Camera): void;
  66483. /**
  66484. * Returns the render target texture used by the post-process
  66485. * @return the render target texture used by the post-process
  66486. */
  66487. getPass(): RenderTargetTexture;
  66488. private _meshExcluded;
  66489. private _createPass;
  66490. private _updateMeshScreenCoordinates;
  66491. /**
  66492. * Creates a default mesh for the Volumeric Light Scattering post-process
  66493. * @param name The mesh name
  66494. * @param scene The scene where to create the mesh
  66495. * @return the default mesh
  66496. */
  66497. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66498. }
  66499. }
  66500. declare module BABYLON {
  66501. interface Scene {
  66502. /** @hidden (Backing field) */
  66503. _boundingBoxRenderer: BoundingBoxRenderer;
  66504. /** @hidden (Backing field) */
  66505. _forceShowBoundingBoxes: boolean;
  66506. /**
  66507. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66508. */
  66509. forceShowBoundingBoxes: boolean;
  66510. /**
  66511. * Gets the bounding box renderer associated with the scene
  66512. * @returns a BoundingBoxRenderer
  66513. */
  66514. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66515. }
  66516. interface AbstractMesh {
  66517. /** @hidden (Backing field) */
  66518. _showBoundingBox: boolean;
  66519. /**
  66520. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66521. */
  66522. showBoundingBox: boolean;
  66523. }
  66524. /**
  66525. * Component responsible of rendering the bounding box of the meshes in a scene.
  66526. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66527. */
  66528. export class BoundingBoxRenderer implements ISceneComponent {
  66529. /**
  66530. * The component name helpfull to identify the component in the list of scene components.
  66531. */
  66532. readonly name: string;
  66533. /**
  66534. * The scene the component belongs to.
  66535. */
  66536. scene: Scene;
  66537. /**
  66538. * Color of the bounding box lines placed in front of an object
  66539. */
  66540. frontColor: Color3;
  66541. /**
  66542. * Color of the bounding box lines placed behind an object
  66543. */
  66544. backColor: Color3;
  66545. /**
  66546. * Defines if the renderer should show the back lines or not
  66547. */
  66548. showBackLines: boolean;
  66549. /**
  66550. * @hidden
  66551. */
  66552. renderList: SmartArray<BoundingBox>;
  66553. private _colorShader;
  66554. private _vertexBuffers;
  66555. private _indexBuffer;
  66556. private _fillIndexBuffer;
  66557. private _fillIndexData;
  66558. /**
  66559. * Instantiates a new bounding box renderer in a scene.
  66560. * @param scene the scene the renderer renders in
  66561. */
  66562. constructor(scene: Scene);
  66563. /**
  66564. * Registers the component in a given scene
  66565. */
  66566. register(): void;
  66567. private _evaluateSubMesh;
  66568. private _activeMesh;
  66569. private _prepareRessources;
  66570. private _createIndexBuffer;
  66571. /**
  66572. * Rebuilds the elements related to this component in case of
  66573. * context lost for instance.
  66574. */
  66575. rebuild(): void;
  66576. /**
  66577. * @hidden
  66578. */
  66579. reset(): void;
  66580. /**
  66581. * Render the bounding boxes of a specific rendering group
  66582. * @param renderingGroupId defines the rendering group to render
  66583. */
  66584. render(renderingGroupId: number): void;
  66585. /**
  66586. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66587. * @param mesh Define the mesh to render the occlusion bounding box for
  66588. */
  66589. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66590. /**
  66591. * Dispose and release the resources attached to this renderer.
  66592. */
  66593. dispose(): void;
  66594. }
  66595. }
  66596. declare module BABYLON {
  66597. interface Scene {
  66598. /** @hidden (Backing field) */
  66599. _depthRenderer: {
  66600. [id: string]: DepthRenderer;
  66601. };
  66602. /**
  66603. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66604. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66605. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66606. * @returns the created depth renderer
  66607. */
  66608. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66609. /**
  66610. * Disables a depth renderer for a given camera
  66611. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66612. */
  66613. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66614. }
  66615. /**
  66616. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66617. * in several rendering techniques.
  66618. */
  66619. export class DepthRendererSceneComponent implements ISceneComponent {
  66620. /**
  66621. * The component name helpfull to identify the component in the list of scene components.
  66622. */
  66623. readonly name: string;
  66624. /**
  66625. * The scene the component belongs to.
  66626. */
  66627. scene: Scene;
  66628. /**
  66629. * Creates a new instance of the component for the given scene
  66630. * @param scene Defines the scene to register the component in
  66631. */
  66632. constructor(scene: Scene);
  66633. /**
  66634. * Registers the component in a given scene
  66635. */
  66636. register(): void;
  66637. /**
  66638. * Rebuilds the elements related to this component in case of
  66639. * context lost for instance.
  66640. */
  66641. rebuild(): void;
  66642. /**
  66643. * Disposes the component and the associated ressources
  66644. */
  66645. dispose(): void;
  66646. private _gatherRenderTargets;
  66647. private _gatherActiveCameraRenderTargets;
  66648. }
  66649. }
  66650. declare module BABYLON {
  66651. /** @hidden */
  66652. export var outlinePixelShader: {
  66653. name: string;
  66654. shader: string;
  66655. };
  66656. }
  66657. declare module BABYLON {
  66658. /** @hidden */
  66659. export var outlineVertexShader: {
  66660. name: string;
  66661. shader: string;
  66662. };
  66663. }
  66664. declare module BABYLON {
  66665. interface Scene {
  66666. /** @hidden */
  66667. _outlineRenderer: OutlineRenderer;
  66668. /**
  66669. * Gets the outline renderer associated with the scene
  66670. * @returns a OutlineRenderer
  66671. */
  66672. getOutlineRenderer(): OutlineRenderer;
  66673. }
  66674. interface AbstractMesh {
  66675. /** @hidden (Backing field) */
  66676. _renderOutline: boolean;
  66677. /**
  66678. * Gets or sets a boolean indicating if the outline must be rendered as well
  66679. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66680. */
  66681. renderOutline: boolean;
  66682. /** @hidden (Backing field) */
  66683. _renderOverlay: boolean;
  66684. /**
  66685. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66686. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66687. */
  66688. renderOverlay: boolean;
  66689. }
  66690. /**
  66691. * This class is responsible to draw bothe outline/overlay of meshes.
  66692. * It should not be used directly but through the available method on mesh.
  66693. */
  66694. export class OutlineRenderer implements ISceneComponent {
  66695. /**
  66696. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66697. */
  66698. private static _StencilReference;
  66699. /**
  66700. * The name of the component. Each component must have a unique name.
  66701. */
  66702. name: string;
  66703. /**
  66704. * The scene the component belongs to.
  66705. */
  66706. scene: Scene;
  66707. /**
  66708. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66709. */
  66710. zOffset: number;
  66711. private _engine;
  66712. private _effect;
  66713. private _cachedDefines;
  66714. private _savedDepthWrite;
  66715. /**
  66716. * Instantiates a new outline renderer. (There could be only one per scene).
  66717. * @param scene Defines the scene it belongs to
  66718. */
  66719. constructor(scene: Scene);
  66720. /**
  66721. * Register the component to one instance of a scene.
  66722. */
  66723. register(): void;
  66724. /**
  66725. * Rebuilds the elements related to this component in case of
  66726. * context lost for instance.
  66727. */
  66728. rebuild(): void;
  66729. /**
  66730. * Disposes the component and the associated ressources.
  66731. */
  66732. dispose(): void;
  66733. /**
  66734. * Renders the outline in the canvas.
  66735. * @param subMesh Defines the sumesh to render
  66736. * @param batch Defines the batch of meshes in case of instances
  66737. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66738. */
  66739. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66740. /**
  66741. * Returns whether or not the outline renderer is ready for a given submesh.
  66742. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66743. * @param subMesh Defines the submesh to check readyness for
  66744. * @param useInstances Defines wheter wee are trying to render instances or not
  66745. * @returns true if ready otherwise false
  66746. */
  66747. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66748. private _beforeRenderingMesh;
  66749. private _afterRenderingMesh;
  66750. }
  66751. }
  66752. declare module BABYLON {
  66753. /**
  66754. * Defines the basic options interface of a Sprite Frame Source Size.
  66755. */
  66756. export interface ISpriteJSONSpriteSourceSize {
  66757. /**
  66758. * number of the original width of the Frame
  66759. */
  66760. w: number;
  66761. /**
  66762. * number of the original height of the Frame
  66763. */
  66764. h: number;
  66765. }
  66766. /**
  66767. * Defines the basic options interface of a Sprite Frame Data.
  66768. */
  66769. export interface ISpriteJSONSpriteFrameData {
  66770. /**
  66771. * number of the x offset of the Frame
  66772. */
  66773. x: number;
  66774. /**
  66775. * number of the y offset of the Frame
  66776. */
  66777. y: number;
  66778. /**
  66779. * number of the width of the Frame
  66780. */
  66781. w: number;
  66782. /**
  66783. * number of the height of the Frame
  66784. */
  66785. h: number;
  66786. }
  66787. /**
  66788. * Defines the basic options interface of a JSON Sprite.
  66789. */
  66790. export interface ISpriteJSONSprite {
  66791. /**
  66792. * string name of the Frame
  66793. */
  66794. filename: string;
  66795. /**
  66796. * ISpriteJSONSpriteFrame basic object of the frame data
  66797. */
  66798. frame: ISpriteJSONSpriteFrameData;
  66799. /**
  66800. * boolean to flag is the frame was rotated.
  66801. */
  66802. rotated: boolean;
  66803. /**
  66804. * boolean to flag is the frame was trimmed.
  66805. */
  66806. trimmed: boolean;
  66807. /**
  66808. * ISpriteJSONSpriteFrame basic object of the source data
  66809. */
  66810. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66811. /**
  66812. * ISpriteJSONSpriteFrame basic object of the source data
  66813. */
  66814. sourceSize: ISpriteJSONSpriteSourceSize;
  66815. }
  66816. /**
  66817. * Defines the basic options interface of a JSON atlas.
  66818. */
  66819. export interface ISpriteJSONAtlas {
  66820. /**
  66821. * Array of objects that contain the frame data.
  66822. */
  66823. frames: Array<ISpriteJSONSprite>;
  66824. /**
  66825. * object basic object containing the sprite meta data.
  66826. */
  66827. meta?: object;
  66828. }
  66829. }
  66830. declare module BABYLON {
  66831. /** @hidden */
  66832. export var spriteMapPixelShader: {
  66833. name: string;
  66834. shader: string;
  66835. };
  66836. }
  66837. declare module BABYLON {
  66838. /** @hidden */
  66839. export var spriteMapVertexShader: {
  66840. name: string;
  66841. shader: string;
  66842. };
  66843. }
  66844. declare module BABYLON {
  66845. /**
  66846. * Defines the basic options interface of a SpriteMap
  66847. */
  66848. export interface ISpriteMapOptions {
  66849. /**
  66850. * Vector2 of the number of cells in the grid.
  66851. */
  66852. stageSize?: Vector2;
  66853. /**
  66854. * Vector2 of the size of the output plane in World Units.
  66855. */
  66856. outputSize?: Vector2;
  66857. /**
  66858. * Vector3 of the position of the output plane in World Units.
  66859. */
  66860. outputPosition?: Vector3;
  66861. /**
  66862. * Vector3 of the rotation of the output plane.
  66863. */
  66864. outputRotation?: Vector3;
  66865. /**
  66866. * number of layers that the system will reserve in resources.
  66867. */
  66868. layerCount?: number;
  66869. /**
  66870. * number of max animation frames a single cell will reserve in resources.
  66871. */
  66872. maxAnimationFrames?: number;
  66873. /**
  66874. * number cell index of the base tile when the system compiles.
  66875. */
  66876. baseTile?: number;
  66877. /**
  66878. * boolean flip the sprite after its been repositioned by the framing data.
  66879. */
  66880. flipU?: boolean;
  66881. /**
  66882. * Vector3 scalar of the global RGB values of the SpriteMap.
  66883. */
  66884. colorMultiply?: Vector3;
  66885. }
  66886. /**
  66887. * Defines the IDisposable interface in order to be cleanable from resources.
  66888. */
  66889. export interface ISpriteMap extends IDisposable {
  66890. /**
  66891. * String name of the SpriteMap.
  66892. */
  66893. name: string;
  66894. /**
  66895. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66896. */
  66897. atlasJSON: ISpriteJSONAtlas;
  66898. /**
  66899. * Texture of the SpriteMap.
  66900. */
  66901. spriteSheet: Texture;
  66902. /**
  66903. * The parameters to initialize the SpriteMap with.
  66904. */
  66905. options: ISpriteMapOptions;
  66906. }
  66907. /**
  66908. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66909. */
  66910. export class SpriteMap implements ISpriteMap {
  66911. /** The Name of the spriteMap */
  66912. name: string;
  66913. /** The JSON file with the frame and meta data */
  66914. atlasJSON: ISpriteJSONAtlas;
  66915. /** The systems Sprite Sheet Texture */
  66916. spriteSheet: Texture;
  66917. /** Arguments passed with the Constructor */
  66918. options: ISpriteMapOptions;
  66919. /** Public Sprite Storage array, parsed from atlasJSON */
  66920. sprites: Array<ISpriteJSONSprite>;
  66921. /** Returns the Number of Sprites in the System */
  66922. get spriteCount(): number;
  66923. /** Returns the Position of Output Plane*/
  66924. get position(): Vector3;
  66925. /** Returns the Position of Output Plane*/
  66926. set position(v: Vector3);
  66927. /** Returns the Rotation of Output Plane*/
  66928. get rotation(): Vector3;
  66929. /** Returns the Rotation of Output Plane*/
  66930. set rotation(v: Vector3);
  66931. /** Sets the AnimationMap*/
  66932. get animationMap(): RawTexture;
  66933. /** Sets the AnimationMap*/
  66934. set animationMap(v: RawTexture);
  66935. /** Scene that the SpriteMap was created in */
  66936. private _scene;
  66937. /** Texture Buffer of Float32 that holds tile frame data*/
  66938. private _frameMap;
  66939. /** Texture Buffers of Float32 that holds tileMap data*/
  66940. private _tileMaps;
  66941. /** Texture Buffer of Float32 that holds Animation Data*/
  66942. private _animationMap;
  66943. /** Custom ShaderMaterial Central to the System*/
  66944. private _material;
  66945. /** Custom ShaderMaterial Central to the System*/
  66946. private _output;
  66947. /** Systems Time Ticker*/
  66948. private _time;
  66949. /**
  66950. * Creates a new SpriteMap
  66951. * @param name defines the SpriteMaps Name
  66952. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66953. * @param spriteSheet is the Texture that the Sprites are on.
  66954. * @param options a basic deployment configuration
  66955. * @param scene The Scene that the map is deployed on
  66956. */
  66957. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66958. /**
  66959. * Returns tileID location
  66960. * @returns Vector2 the cell position ID
  66961. */
  66962. getTileID(): Vector2;
  66963. /**
  66964. * Gets the UV location of the mouse over the SpriteMap.
  66965. * @returns Vector2 the UV position of the mouse interaction
  66966. */
  66967. getMousePosition(): Vector2;
  66968. /**
  66969. * Creates the "frame" texture Buffer
  66970. * -------------------------------------
  66971. * Structure of frames
  66972. * "filename": "Falling-Water-2.png",
  66973. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66974. * "rotated": true,
  66975. * "trimmed": true,
  66976. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66977. * "sourceSize": {"w":32,"h":32}
  66978. * @returns RawTexture of the frameMap
  66979. */
  66980. private _createFrameBuffer;
  66981. /**
  66982. * Creates the tileMap texture Buffer
  66983. * @param buffer normally and array of numbers, or a false to generate from scratch
  66984. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66985. * @returns RawTexture of the tileMap
  66986. */
  66987. private _createTileBuffer;
  66988. /**
  66989. * Modifies the data of the tileMaps
  66990. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66991. * @param pos is the iVector2 Coordinates of the Tile
  66992. * @param tile The SpriteIndex of the new Tile
  66993. */
  66994. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  66995. /**
  66996. * Creates the animationMap texture Buffer
  66997. * @param buffer normally and array of numbers, or a false to generate from scratch
  66998. * @returns RawTexture of the animationMap
  66999. */
  67000. private _createTileAnimationBuffer;
  67001. /**
  67002. * Modifies the data of the animationMap
  67003. * @param cellID is the Index of the Sprite
  67004. * @param _frame is the target Animation frame
  67005. * @param toCell is the Target Index of the next frame of the animation
  67006. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67007. * @param speed is a global scalar of the time variable on the map.
  67008. */
  67009. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67010. /**
  67011. * Exports the .tilemaps file
  67012. */
  67013. saveTileMaps(): void;
  67014. /**
  67015. * Imports the .tilemaps file
  67016. * @param url of the .tilemaps file
  67017. */
  67018. loadTileMaps(url: string): void;
  67019. /**
  67020. * Release associated resources
  67021. */
  67022. dispose(): void;
  67023. }
  67024. }
  67025. declare module BABYLON {
  67026. /**
  67027. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67028. * @see http://doc.babylonjs.com/babylon101/sprites
  67029. */
  67030. export class SpritePackedManager extends SpriteManager {
  67031. /** defines the packed manager's name */
  67032. name: string;
  67033. /**
  67034. * Creates a new sprite manager from a packed sprite sheet
  67035. * @param name defines the manager's name
  67036. * @param imgUrl defines the sprite sheet url
  67037. * @param capacity defines the maximum allowed number of sprites
  67038. * @param scene defines the hosting scene
  67039. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67040. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67041. * @param samplingMode defines the smapling mode to use with spritesheet
  67042. * @param fromPacked set to true; do not alter
  67043. */
  67044. constructor(
  67045. /** defines the packed manager's name */
  67046. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67047. }
  67048. }
  67049. declare module BABYLON {
  67050. /**
  67051. * Defines the list of states available for a task inside a AssetsManager
  67052. */
  67053. export enum AssetTaskState {
  67054. /**
  67055. * Initialization
  67056. */
  67057. INIT = 0,
  67058. /**
  67059. * Running
  67060. */
  67061. RUNNING = 1,
  67062. /**
  67063. * Done
  67064. */
  67065. DONE = 2,
  67066. /**
  67067. * Error
  67068. */
  67069. ERROR = 3
  67070. }
  67071. /**
  67072. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67073. */
  67074. export abstract class AbstractAssetTask {
  67075. /**
  67076. * Task name
  67077. */ name: string;
  67078. /**
  67079. * Callback called when the task is successful
  67080. */
  67081. onSuccess: (task: any) => void;
  67082. /**
  67083. * Callback called when the task is not successful
  67084. */
  67085. onError: (task: any, message?: string, exception?: any) => void;
  67086. /**
  67087. * Creates a new AssetsManager
  67088. * @param name defines the name of the task
  67089. */
  67090. constructor(
  67091. /**
  67092. * Task name
  67093. */ name: string);
  67094. private _isCompleted;
  67095. private _taskState;
  67096. private _errorObject;
  67097. /**
  67098. * Get if the task is completed
  67099. */
  67100. get isCompleted(): boolean;
  67101. /**
  67102. * Gets the current state of the task
  67103. */
  67104. get taskState(): AssetTaskState;
  67105. /**
  67106. * Gets the current error object (if task is in error)
  67107. */
  67108. get errorObject(): {
  67109. message?: string;
  67110. exception?: any;
  67111. };
  67112. /**
  67113. * Internal only
  67114. * @hidden
  67115. */
  67116. _setErrorObject(message?: string, exception?: any): void;
  67117. /**
  67118. * Execute the current task
  67119. * @param scene defines the scene where you want your assets to be loaded
  67120. * @param onSuccess is a callback called when the task is successfully executed
  67121. * @param onError is a callback called if an error occurs
  67122. */
  67123. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67124. /**
  67125. * Execute the current task
  67126. * @param scene defines the scene where you want your assets to be loaded
  67127. * @param onSuccess is a callback called when the task is successfully executed
  67128. * @param onError is a callback called if an error occurs
  67129. */
  67130. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67131. /**
  67132. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67133. * This can be used with failed tasks that have the reason for failure fixed.
  67134. */
  67135. reset(): void;
  67136. private onErrorCallback;
  67137. private onDoneCallback;
  67138. }
  67139. /**
  67140. * Define the interface used by progress events raised during assets loading
  67141. */
  67142. export interface IAssetsProgressEvent {
  67143. /**
  67144. * Defines the number of remaining tasks to process
  67145. */
  67146. remainingCount: number;
  67147. /**
  67148. * Defines the total number of tasks
  67149. */
  67150. totalCount: number;
  67151. /**
  67152. * Defines the task that was just processed
  67153. */
  67154. task: AbstractAssetTask;
  67155. }
  67156. /**
  67157. * Class used to share progress information about assets loading
  67158. */
  67159. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67160. /**
  67161. * Defines the number of remaining tasks to process
  67162. */
  67163. remainingCount: number;
  67164. /**
  67165. * Defines the total number of tasks
  67166. */
  67167. totalCount: number;
  67168. /**
  67169. * Defines the task that was just processed
  67170. */
  67171. task: AbstractAssetTask;
  67172. /**
  67173. * Creates a AssetsProgressEvent
  67174. * @param remainingCount defines the number of remaining tasks to process
  67175. * @param totalCount defines the total number of tasks
  67176. * @param task defines the task that was just processed
  67177. */
  67178. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67179. }
  67180. /**
  67181. * Define a task used by AssetsManager to load meshes
  67182. */
  67183. export class MeshAssetTask extends AbstractAssetTask {
  67184. /**
  67185. * Defines the name of the task
  67186. */
  67187. name: string;
  67188. /**
  67189. * Defines the list of mesh's names you want to load
  67190. */
  67191. meshesNames: any;
  67192. /**
  67193. * Defines the root url to use as a base to load your meshes and associated resources
  67194. */
  67195. rootUrl: string;
  67196. /**
  67197. * Defines the filename of the scene to load from
  67198. */
  67199. sceneFilename: string;
  67200. /**
  67201. * Gets the list of loaded meshes
  67202. */
  67203. loadedMeshes: Array<AbstractMesh>;
  67204. /**
  67205. * Gets the list of loaded particle systems
  67206. */
  67207. loadedParticleSystems: Array<IParticleSystem>;
  67208. /**
  67209. * Gets the list of loaded skeletons
  67210. */
  67211. loadedSkeletons: Array<Skeleton>;
  67212. /**
  67213. * Gets the list of loaded animation groups
  67214. */
  67215. loadedAnimationGroups: Array<AnimationGroup>;
  67216. /**
  67217. * Callback called when the task is successful
  67218. */
  67219. onSuccess: (task: MeshAssetTask) => void;
  67220. /**
  67221. * Callback called when the task is successful
  67222. */
  67223. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67224. /**
  67225. * Creates a new MeshAssetTask
  67226. * @param name defines the name of the task
  67227. * @param meshesNames defines the list of mesh's names you want to load
  67228. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67229. * @param sceneFilename defines the filename of the scene to load from
  67230. */
  67231. constructor(
  67232. /**
  67233. * Defines the name of the task
  67234. */
  67235. name: string,
  67236. /**
  67237. * Defines the list of mesh's names you want to load
  67238. */
  67239. meshesNames: any,
  67240. /**
  67241. * Defines the root url to use as a base to load your meshes and associated resources
  67242. */
  67243. rootUrl: string,
  67244. /**
  67245. * Defines the filename of the scene to load from
  67246. */
  67247. sceneFilename: string);
  67248. /**
  67249. * Execute the current task
  67250. * @param scene defines the scene where you want your assets to be loaded
  67251. * @param onSuccess is a callback called when the task is successfully executed
  67252. * @param onError is a callback called if an error occurs
  67253. */
  67254. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67255. }
  67256. /**
  67257. * Define a task used by AssetsManager to load text content
  67258. */
  67259. export class TextFileAssetTask extends AbstractAssetTask {
  67260. /**
  67261. * Defines the name of the task
  67262. */
  67263. name: string;
  67264. /**
  67265. * Defines the location of the file to load
  67266. */
  67267. url: string;
  67268. /**
  67269. * Gets the loaded text string
  67270. */
  67271. text: string;
  67272. /**
  67273. * Callback called when the task is successful
  67274. */
  67275. onSuccess: (task: TextFileAssetTask) => void;
  67276. /**
  67277. * Callback called when the task is successful
  67278. */
  67279. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67280. /**
  67281. * Creates a new TextFileAssetTask object
  67282. * @param name defines the name of the task
  67283. * @param url defines the location of the file to load
  67284. */
  67285. constructor(
  67286. /**
  67287. * Defines the name of the task
  67288. */
  67289. name: string,
  67290. /**
  67291. * Defines the location of the file to load
  67292. */
  67293. url: string);
  67294. /**
  67295. * Execute the current task
  67296. * @param scene defines the scene where you want your assets to be loaded
  67297. * @param onSuccess is a callback called when the task is successfully executed
  67298. * @param onError is a callback called if an error occurs
  67299. */
  67300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67301. }
  67302. /**
  67303. * Define a task used by AssetsManager to load binary data
  67304. */
  67305. export class BinaryFileAssetTask extends AbstractAssetTask {
  67306. /**
  67307. * Defines the name of the task
  67308. */
  67309. name: string;
  67310. /**
  67311. * Defines the location of the file to load
  67312. */
  67313. url: string;
  67314. /**
  67315. * Gets the lodaded data (as an array buffer)
  67316. */
  67317. data: ArrayBuffer;
  67318. /**
  67319. * Callback called when the task is successful
  67320. */
  67321. onSuccess: (task: BinaryFileAssetTask) => void;
  67322. /**
  67323. * Callback called when the task is successful
  67324. */
  67325. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67326. /**
  67327. * Creates a new BinaryFileAssetTask object
  67328. * @param name defines the name of the new task
  67329. * @param url defines the location of the file to load
  67330. */
  67331. constructor(
  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. * Execute the current task
  67342. * @param scene defines the scene where you want your assets to be loaded
  67343. * @param onSuccess is a callback called when the task is successfully executed
  67344. * @param onError is a callback called if an error occurs
  67345. */
  67346. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67347. }
  67348. /**
  67349. * Define a task used by AssetsManager to load images
  67350. */
  67351. export class ImageAssetTask extends AbstractAssetTask {
  67352. /**
  67353. * Defines the name of the task
  67354. */
  67355. name: string;
  67356. /**
  67357. * Defines the location of the image to load
  67358. */
  67359. url: string;
  67360. /**
  67361. * Gets the loaded images
  67362. */
  67363. image: HTMLImageElement;
  67364. /**
  67365. * Callback called when the task is successful
  67366. */
  67367. onSuccess: (task: ImageAssetTask) => void;
  67368. /**
  67369. * Callback called when the task is successful
  67370. */
  67371. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67372. /**
  67373. * Creates a new ImageAssetTask
  67374. * @param name defines the name of the task
  67375. * @param url defines the location of the image to load
  67376. */
  67377. constructor(
  67378. /**
  67379. * Defines the name of the task
  67380. */
  67381. name: string,
  67382. /**
  67383. * Defines the location of the image to load
  67384. */
  67385. url: string);
  67386. /**
  67387. * Execute the current task
  67388. * @param scene defines the scene where you want your assets to be loaded
  67389. * @param onSuccess is a callback called when the task is successfully executed
  67390. * @param onError is a callback called if an error occurs
  67391. */
  67392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67393. }
  67394. /**
  67395. * Defines the interface used by texture loading tasks
  67396. */
  67397. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67398. /**
  67399. * Gets the loaded texture
  67400. */
  67401. texture: TEX;
  67402. }
  67403. /**
  67404. * Define a task used by AssetsManager to load 2D textures
  67405. */
  67406. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67407. /**
  67408. * Defines the name of the task
  67409. */
  67410. name: string;
  67411. /**
  67412. * Defines the location of the file to load
  67413. */
  67414. url: string;
  67415. /**
  67416. * Defines if mipmap should not be generated (default is false)
  67417. */
  67418. noMipmap?: boolean | undefined;
  67419. /**
  67420. * Defines if texture must be inverted on Y axis (default is false)
  67421. */
  67422. invertY?: boolean | undefined;
  67423. /**
  67424. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67425. */
  67426. samplingMode: number;
  67427. /**
  67428. * Gets the loaded texture
  67429. */
  67430. texture: Texture;
  67431. /**
  67432. * Callback called when the task is successful
  67433. */
  67434. onSuccess: (task: TextureAssetTask) => void;
  67435. /**
  67436. * Callback called when the task is successful
  67437. */
  67438. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67439. /**
  67440. * Creates a new TextureAssetTask object
  67441. * @param name defines the name of the task
  67442. * @param url defines the location of the file to load
  67443. * @param noMipmap defines if mipmap should not be generated (default is false)
  67444. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67445. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67446. */
  67447. constructor(
  67448. /**
  67449. * Defines the name of the task
  67450. */
  67451. name: string,
  67452. /**
  67453. * Defines the location of the file to load
  67454. */
  67455. url: string,
  67456. /**
  67457. * Defines if mipmap should not be generated (default is false)
  67458. */
  67459. noMipmap?: boolean | undefined,
  67460. /**
  67461. * Defines if texture must be inverted on Y axis (default is false)
  67462. */
  67463. invertY?: boolean | undefined,
  67464. /**
  67465. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67466. */
  67467. samplingMode?: number);
  67468. /**
  67469. * Execute the current task
  67470. * @param scene defines the scene where you want your assets to be loaded
  67471. * @param onSuccess is a callback called when the task is successfully executed
  67472. * @param onError is a callback called if an error occurs
  67473. */
  67474. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67475. }
  67476. /**
  67477. * Define a task used by AssetsManager to load cube textures
  67478. */
  67479. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67480. /**
  67481. * Defines the name of the task
  67482. */
  67483. name: string;
  67484. /**
  67485. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67486. */
  67487. url: string;
  67488. /**
  67489. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67490. */
  67491. extensions?: string[] | undefined;
  67492. /**
  67493. * Defines if mipmaps should not be generated (default is false)
  67494. */
  67495. noMipmap?: boolean | undefined;
  67496. /**
  67497. * Defines the explicit list of files (undefined by default)
  67498. */
  67499. files?: string[] | undefined;
  67500. /**
  67501. * Gets the loaded texture
  67502. */
  67503. texture: CubeTexture;
  67504. /**
  67505. * Callback called when the task is successful
  67506. */
  67507. onSuccess: (task: CubeTextureAssetTask) => void;
  67508. /**
  67509. * Callback called when the task is successful
  67510. */
  67511. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67512. /**
  67513. * Creates a new CubeTextureAssetTask
  67514. * @param name defines the name of the task
  67515. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67516. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67517. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67518. * @param files defines the explicit list of files (undefined by default)
  67519. */
  67520. constructor(
  67521. /**
  67522. * Defines the name of the task
  67523. */
  67524. name: string,
  67525. /**
  67526. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67527. */
  67528. url: string,
  67529. /**
  67530. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67531. */
  67532. extensions?: string[] | undefined,
  67533. /**
  67534. * Defines if mipmaps should not be generated (default is false)
  67535. */
  67536. noMipmap?: boolean | undefined,
  67537. /**
  67538. * Defines the explicit list of files (undefined by default)
  67539. */
  67540. files?: string[] | undefined);
  67541. /**
  67542. * Execute the current task
  67543. * @param scene defines the scene where you want your assets to be loaded
  67544. * @param onSuccess is a callback called when the task is successfully executed
  67545. * @param onError is a callback called if an error occurs
  67546. */
  67547. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67548. }
  67549. /**
  67550. * Define a task used by AssetsManager to load HDR cube textures
  67551. */
  67552. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67553. /**
  67554. * Defines the name of the task
  67555. */
  67556. name: string;
  67557. /**
  67558. * Defines the location of the file to load
  67559. */
  67560. url: string;
  67561. /**
  67562. * Defines the desired size (the more it increases the longer the generation will be)
  67563. */
  67564. size: number;
  67565. /**
  67566. * Defines if mipmaps should not be generated (default is false)
  67567. */
  67568. noMipmap: boolean;
  67569. /**
  67570. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67571. */
  67572. generateHarmonics: boolean;
  67573. /**
  67574. * 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)
  67575. */
  67576. gammaSpace: boolean;
  67577. /**
  67578. * Internal Use Only
  67579. */
  67580. reserved: boolean;
  67581. /**
  67582. * Gets the loaded texture
  67583. */
  67584. texture: HDRCubeTexture;
  67585. /**
  67586. * Callback called when the task is successful
  67587. */
  67588. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67589. /**
  67590. * Callback called when the task is successful
  67591. */
  67592. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67593. /**
  67594. * Creates a new HDRCubeTextureAssetTask object
  67595. * @param name defines the name of the task
  67596. * @param url defines the location of the file to load
  67597. * @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.
  67598. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67599. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67600. * @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)
  67601. * @param reserved Internal use only
  67602. */
  67603. constructor(
  67604. /**
  67605. * Defines the name of the task
  67606. */
  67607. name: string,
  67608. /**
  67609. * Defines the location of the file to load
  67610. */
  67611. url: string,
  67612. /**
  67613. * Defines the desired size (the more it increases the longer the generation will be)
  67614. */
  67615. size: number,
  67616. /**
  67617. * Defines if mipmaps should not be generated (default is false)
  67618. */
  67619. noMipmap?: boolean,
  67620. /**
  67621. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67622. */
  67623. generateHarmonics?: boolean,
  67624. /**
  67625. * 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)
  67626. */
  67627. gammaSpace?: boolean,
  67628. /**
  67629. * Internal Use Only
  67630. */
  67631. reserved?: boolean);
  67632. /**
  67633. * Execute the current task
  67634. * @param scene defines the scene where you want your assets to be loaded
  67635. * @param onSuccess is a callback called when the task is successfully executed
  67636. * @param onError is a callback called if an error occurs
  67637. */
  67638. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67639. }
  67640. /**
  67641. * Define a task used by AssetsManager to load Equirectangular cube textures
  67642. */
  67643. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67644. /**
  67645. * Defines the name of the task
  67646. */
  67647. name: string;
  67648. /**
  67649. * Defines the location of the file to load
  67650. */
  67651. url: string;
  67652. /**
  67653. * Defines the desired size (the more it increases the longer the generation will be)
  67654. */
  67655. size: number;
  67656. /**
  67657. * Defines if mipmaps should not be generated (default is false)
  67658. */
  67659. noMipmap: boolean;
  67660. /**
  67661. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67662. * but the standard material would require them in Gamma space) (default is true)
  67663. */
  67664. gammaSpace: boolean;
  67665. /**
  67666. * Gets the loaded texture
  67667. */
  67668. texture: EquiRectangularCubeTexture;
  67669. /**
  67670. * Callback called when the task is successful
  67671. */
  67672. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67673. /**
  67674. * Callback called when the task is successful
  67675. */
  67676. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67677. /**
  67678. * Creates a new EquiRectangularCubeTextureAssetTask object
  67679. * @param name defines the name of the task
  67680. * @param url defines the location of the file to load
  67681. * @param size defines the desired size (the more it increases the longer the generation will be)
  67682. * If the size is omitted this implies you are using a preprocessed cubemap.
  67683. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67684. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67685. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67686. * (default is true)
  67687. */
  67688. constructor(
  67689. /**
  67690. * Defines the name of the task
  67691. */
  67692. name: string,
  67693. /**
  67694. * Defines the location of the file to load
  67695. */
  67696. url: string,
  67697. /**
  67698. * Defines the desired size (the more it increases the longer the generation will be)
  67699. */
  67700. size: number,
  67701. /**
  67702. * Defines if mipmaps should not be generated (default is false)
  67703. */
  67704. noMipmap?: boolean,
  67705. /**
  67706. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67707. * but the standard material would require them in Gamma space) (default is true)
  67708. */
  67709. gammaSpace?: boolean);
  67710. /**
  67711. * Execute the current task
  67712. * @param scene defines the scene where you want your assets to be loaded
  67713. * @param onSuccess is a callback called when the task is successfully executed
  67714. * @param onError is a callback called if an error occurs
  67715. */
  67716. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67717. }
  67718. /**
  67719. * This class can be used to easily import assets into a scene
  67720. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67721. */
  67722. export class AssetsManager {
  67723. private _scene;
  67724. private _isLoading;
  67725. protected _tasks: AbstractAssetTask[];
  67726. protected _waitingTasksCount: number;
  67727. protected _totalTasksCount: number;
  67728. /**
  67729. * Callback called when all tasks are processed
  67730. */
  67731. onFinish: (tasks: AbstractAssetTask[]) => void;
  67732. /**
  67733. * Callback called when a task is successful
  67734. */
  67735. onTaskSuccess: (task: AbstractAssetTask) => void;
  67736. /**
  67737. * Callback called when a task had an error
  67738. */
  67739. onTaskError: (task: AbstractAssetTask) => void;
  67740. /**
  67741. * Callback called when a task is done (whatever the result is)
  67742. */
  67743. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67744. /**
  67745. * Observable called when all tasks are processed
  67746. */
  67747. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67748. /**
  67749. * Observable called when a task had an error
  67750. */
  67751. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67752. /**
  67753. * Observable called when all tasks were executed
  67754. */
  67755. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67756. /**
  67757. * Observable called when a task is done (whatever the result is)
  67758. */
  67759. onProgressObservable: Observable<IAssetsProgressEvent>;
  67760. /**
  67761. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67762. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67763. */
  67764. useDefaultLoadingScreen: boolean;
  67765. /**
  67766. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67767. * when all assets have been downloaded.
  67768. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67769. */
  67770. autoHideLoadingUI: boolean;
  67771. /**
  67772. * Creates a new AssetsManager
  67773. * @param scene defines the scene to work on
  67774. */
  67775. constructor(scene: Scene);
  67776. /**
  67777. * Add a MeshAssetTask to the list of active tasks
  67778. * @param taskName defines the name of the new task
  67779. * @param meshesNames defines the name of meshes to load
  67780. * @param rootUrl defines the root url to use to locate files
  67781. * @param sceneFilename defines the filename of the scene file
  67782. * @returns a new MeshAssetTask object
  67783. */
  67784. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67785. /**
  67786. * Add a TextFileAssetTask to the list of active tasks
  67787. * @param taskName defines the name of the new task
  67788. * @param url defines the url of the file to load
  67789. * @returns a new TextFileAssetTask object
  67790. */
  67791. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67792. /**
  67793. * Add a BinaryFileAssetTask to the list of active tasks
  67794. * @param taskName defines the name of the new task
  67795. * @param url defines the url of the file to load
  67796. * @returns a new BinaryFileAssetTask object
  67797. */
  67798. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67799. /**
  67800. * Add a ImageAssetTask to the list of active tasks
  67801. * @param taskName defines the name of the new task
  67802. * @param url defines the url of the file to load
  67803. * @returns a new ImageAssetTask object
  67804. */
  67805. addImageTask(taskName: string, url: string): ImageAssetTask;
  67806. /**
  67807. * Add a TextureAssetTask to the list of active tasks
  67808. * @param taskName defines the name of the new task
  67809. * @param url defines the url of the file to load
  67810. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67811. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67812. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67813. * @returns a new TextureAssetTask object
  67814. */
  67815. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67816. /**
  67817. * Add a CubeTextureAssetTask to the list of active tasks
  67818. * @param taskName defines the name of the new task
  67819. * @param url defines the url of the file to load
  67820. * @param extensions defines the extension to use to load the cube map (can be null)
  67821. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67822. * @param files defines the list of files to load (can be null)
  67823. * @returns a new CubeTextureAssetTask object
  67824. */
  67825. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67826. /**
  67827. *
  67828. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67829. * @param taskName defines the name of the new task
  67830. * @param url defines the url of the file to load
  67831. * @param size defines the size you want for the cubemap (can be null)
  67832. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67833. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67834. * @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)
  67835. * @param reserved Internal use only
  67836. * @returns a new HDRCubeTextureAssetTask object
  67837. */
  67838. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67839. /**
  67840. *
  67841. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67842. * @param taskName defines the name of the new task
  67843. * @param url defines the url of the file to load
  67844. * @param size defines the size you want for the cubemap (can be null)
  67845. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67846. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67847. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67848. * @returns a new EquiRectangularCubeTextureAssetTask object
  67849. */
  67850. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67851. /**
  67852. * Remove a task from the assets manager.
  67853. * @param task the task to remove
  67854. */
  67855. removeTask(task: AbstractAssetTask): void;
  67856. private _decreaseWaitingTasksCount;
  67857. private _runTask;
  67858. /**
  67859. * Reset the AssetsManager and remove all tasks
  67860. * @return the current instance of the AssetsManager
  67861. */
  67862. reset(): AssetsManager;
  67863. /**
  67864. * Start the loading process
  67865. * @return the current instance of the AssetsManager
  67866. */
  67867. load(): AssetsManager;
  67868. /**
  67869. * Start the loading process as an async operation
  67870. * @return a promise returning the list of failed tasks
  67871. */
  67872. loadAsync(): Promise<void>;
  67873. }
  67874. }
  67875. declare module BABYLON {
  67876. /**
  67877. * Wrapper class for promise with external resolve and reject.
  67878. */
  67879. export class Deferred<T> {
  67880. /**
  67881. * The promise associated with this deferred object.
  67882. */
  67883. readonly promise: Promise<T>;
  67884. private _resolve;
  67885. private _reject;
  67886. /**
  67887. * The resolve method of the promise associated with this deferred object.
  67888. */
  67889. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67890. /**
  67891. * The reject method of the promise associated with this deferred object.
  67892. */
  67893. get reject(): (reason?: any) => void;
  67894. /**
  67895. * Constructor for this deferred object.
  67896. */
  67897. constructor();
  67898. }
  67899. }
  67900. declare module BABYLON {
  67901. /**
  67902. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67903. */
  67904. export class MeshExploder {
  67905. private _centerMesh;
  67906. private _meshes;
  67907. private _meshesOrigins;
  67908. private _toCenterVectors;
  67909. private _scaledDirection;
  67910. private _newPosition;
  67911. private _centerPosition;
  67912. /**
  67913. * Explodes meshes from a center mesh.
  67914. * @param meshes The meshes to explode.
  67915. * @param centerMesh The mesh to be center of explosion.
  67916. */
  67917. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67918. private _setCenterMesh;
  67919. /**
  67920. * Get class name
  67921. * @returns "MeshExploder"
  67922. */
  67923. getClassName(): string;
  67924. /**
  67925. * "Exploded meshes"
  67926. * @returns Array of meshes with the centerMesh at index 0.
  67927. */
  67928. getMeshes(): Array<Mesh>;
  67929. /**
  67930. * Explodes meshes giving a specific direction
  67931. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67932. */
  67933. explode(direction?: number): void;
  67934. }
  67935. }
  67936. declare module BABYLON {
  67937. /**
  67938. * Class used to help managing file picking and drag'n'drop
  67939. */
  67940. export class FilesInput {
  67941. /**
  67942. * List of files ready to be loaded
  67943. */
  67944. static get FilesToLoad(): {
  67945. [key: string]: File;
  67946. };
  67947. /**
  67948. * Callback called when a file is processed
  67949. */
  67950. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67951. private _engine;
  67952. private _currentScene;
  67953. private _sceneLoadedCallback;
  67954. private _progressCallback;
  67955. private _additionalRenderLoopLogicCallback;
  67956. private _textureLoadingCallback;
  67957. private _startingProcessingFilesCallback;
  67958. private _onReloadCallback;
  67959. private _errorCallback;
  67960. private _elementToMonitor;
  67961. private _sceneFileToLoad;
  67962. private _filesToLoad;
  67963. /**
  67964. * Creates a new FilesInput
  67965. * @param engine defines the rendering engine
  67966. * @param scene defines the hosting scene
  67967. * @param sceneLoadedCallback callback called when scene is loaded
  67968. * @param progressCallback callback called to track progress
  67969. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67970. * @param textureLoadingCallback callback called when a texture is loading
  67971. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67972. * @param onReloadCallback callback called when a reload is requested
  67973. * @param errorCallback callback call if an error occurs
  67974. */
  67975. 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);
  67976. private _dragEnterHandler;
  67977. private _dragOverHandler;
  67978. private _dropHandler;
  67979. /**
  67980. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67981. * @param elementToMonitor defines the DOM element to track
  67982. */
  67983. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67984. /**
  67985. * Release all associated resources
  67986. */
  67987. dispose(): void;
  67988. private renderFunction;
  67989. private drag;
  67990. private drop;
  67991. private _traverseFolder;
  67992. private _processFiles;
  67993. /**
  67994. * Load files from a drop event
  67995. * @param event defines the drop event to use as source
  67996. */
  67997. loadFiles(event: any): void;
  67998. private _processReload;
  67999. /**
  68000. * Reload the current scene from the loaded files
  68001. */
  68002. reload(): void;
  68003. }
  68004. }
  68005. declare module BABYLON {
  68006. /**
  68007. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68008. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68009. */
  68010. export class SceneOptimization {
  68011. /**
  68012. * Defines the priority of this optimization (0 by default which means first in the list)
  68013. */
  68014. priority: number;
  68015. /**
  68016. * Gets a string describing the action executed by the current optimization
  68017. * @returns description string
  68018. */
  68019. getDescription(): string;
  68020. /**
  68021. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68022. * @param scene defines the current scene where to apply this optimization
  68023. * @param optimizer defines the current optimizer
  68024. * @returns true if everything that can be done was applied
  68025. */
  68026. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68027. /**
  68028. * Creates the SceneOptimization object
  68029. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68030. * @param desc defines the description associated with the optimization
  68031. */
  68032. constructor(
  68033. /**
  68034. * Defines the priority of this optimization (0 by default which means first in the list)
  68035. */
  68036. priority?: number);
  68037. }
  68038. /**
  68039. * Defines an optimization used to reduce the size of render target textures
  68040. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68041. */
  68042. export class TextureOptimization extends SceneOptimization {
  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 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
  68049. */
  68050. maximumSize: number;
  68051. /**
  68052. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68053. */
  68054. step: number;
  68055. /**
  68056. * Gets a string describing the action executed by the current optimization
  68057. * @returns description string
  68058. */
  68059. getDescription(): string;
  68060. /**
  68061. * Creates the TextureOptimization object
  68062. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68063. * @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
  68064. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68065. */
  68066. constructor(
  68067. /**
  68068. * Defines the priority of this optimization (0 by default which means first in the list)
  68069. */
  68070. priority?: number,
  68071. /**
  68072. * 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
  68073. */
  68074. maximumSize?: number,
  68075. /**
  68076. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68077. */
  68078. step?: number);
  68079. /**
  68080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68081. * @param scene defines the current scene where to apply this optimization
  68082. * @param optimizer defines the current optimizer
  68083. * @returns true if everything that can be done was applied
  68084. */
  68085. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68086. }
  68087. /**
  68088. * Defines an optimization used to increase or decrease the rendering resolution
  68089. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68090. */
  68091. export class HardwareScalingOptimization extends SceneOptimization {
  68092. /**
  68093. * Defines the priority of this optimization (0 by default which means first in the list)
  68094. */
  68095. priority: number;
  68096. /**
  68097. * Defines the maximum scale to use (2 by default)
  68098. */
  68099. maximumScale: number;
  68100. /**
  68101. * Defines the step to use between two passes (0.5 by default)
  68102. */
  68103. step: number;
  68104. private _currentScale;
  68105. private _directionOffset;
  68106. /**
  68107. * Gets a string describing the action executed by the current optimization
  68108. * @return description string
  68109. */
  68110. getDescription(): string;
  68111. /**
  68112. * Creates the HardwareScalingOptimization object
  68113. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68114. * @param maximumScale defines the maximum scale to use (2 by default)
  68115. * @param step defines the step to use between two passes (0.5 by default)
  68116. */
  68117. constructor(
  68118. /**
  68119. * Defines the priority of this optimization (0 by default which means first in the list)
  68120. */
  68121. priority?: number,
  68122. /**
  68123. * Defines the maximum scale to use (2 by default)
  68124. */
  68125. maximumScale?: number,
  68126. /**
  68127. * Defines the step to use between two passes (0.5 by default)
  68128. */
  68129. step?: number);
  68130. /**
  68131. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68132. * @param scene defines the current scene where to apply this optimization
  68133. * @param optimizer defines the current optimizer
  68134. * @returns true if everything that can be done was applied
  68135. */
  68136. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68137. }
  68138. /**
  68139. * Defines an optimization used to remove shadows
  68140. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68141. */
  68142. export class ShadowsOptimization extends SceneOptimization {
  68143. /**
  68144. * Gets a string describing the action executed by the current optimization
  68145. * @return description string
  68146. */
  68147. getDescription(): string;
  68148. /**
  68149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68150. * @param scene defines the current scene where to apply this optimization
  68151. * @param optimizer defines the current optimizer
  68152. * @returns true if everything that can be done was applied
  68153. */
  68154. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68155. }
  68156. /**
  68157. * Defines an optimization used to turn post-processes off
  68158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68159. */
  68160. export class PostProcessesOptimization extends SceneOptimization {
  68161. /**
  68162. * Gets a string describing the action executed by the current optimization
  68163. * @return description string
  68164. */
  68165. getDescription(): string;
  68166. /**
  68167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68168. * @param scene defines the current scene where to apply this optimization
  68169. * @param optimizer defines the current optimizer
  68170. * @returns true if everything that can be done was applied
  68171. */
  68172. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68173. }
  68174. /**
  68175. * Defines an optimization used to turn lens flares off
  68176. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68177. */
  68178. export class LensFlaresOptimization extends SceneOptimization {
  68179. /**
  68180. * Gets a string describing the action executed by the current optimization
  68181. * @return description string
  68182. */
  68183. getDescription(): string;
  68184. /**
  68185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68186. * @param scene defines the current scene where to apply this optimization
  68187. * @param optimizer defines the current optimizer
  68188. * @returns true if everything that can be done was applied
  68189. */
  68190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68191. }
  68192. /**
  68193. * Defines an optimization based on user defined callback.
  68194. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68195. */
  68196. export class CustomOptimization extends SceneOptimization {
  68197. /**
  68198. * Callback called to apply the custom optimization.
  68199. */
  68200. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68201. /**
  68202. * Callback called to get custom description
  68203. */
  68204. onGetDescription: () => string;
  68205. /**
  68206. * Gets a string describing the action executed by the current optimization
  68207. * @returns description string
  68208. */
  68209. getDescription(): string;
  68210. /**
  68211. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68212. * @param scene defines the current scene where to apply this optimization
  68213. * @param optimizer defines the current optimizer
  68214. * @returns true if everything that can be done was applied
  68215. */
  68216. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68217. }
  68218. /**
  68219. * Defines an optimization used to turn particles off
  68220. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68221. */
  68222. export class ParticlesOptimization extends SceneOptimization {
  68223. /**
  68224. * Gets a string describing the action executed by the current optimization
  68225. * @return description string
  68226. */
  68227. getDescription(): string;
  68228. /**
  68229. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68230. * @param scene defines the current scene where to apply this optimization
  68231. * @param optimizer defines the current optimizer
  68232. * @returns true if everything that can be done was applied
  68233. */
  68234. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68235. }
  68236. /**
  68237. * Defines an optimization used to turn render targets off
  68238. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68239. */
  68240. export class RenderTargetsOptimization extends SceneOptimization {
  68241. /**
  68242. * Gets a string describing the action executed by the current optimization
  68243. * @return description string
  68244. */
  68245. getDescription(): string;
  68246. /**
  68247. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68248. * @param scene defines the current scene where to apply this optimization
  68249. * @param optimizer defines the current optimizer
  68250. * @returns true if everything that can be done was applied
  68251. */
  68252. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68253. }
  68254. /**
  68255. * Defines an optimization used to merge meshes with compatible materials
  68256. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68257. */
  68258. export class MergeMeshesOptimization extends SceneOptimization {
  68259. private static _UpdateSelectionTree;
  68260. /**
  68261. * Gets or sets a boolean which defines if optimization octree has to be updated
  68262. */
  68263. static get UpdateSelectionTree(): boolean;
  68264. /**
  68265. * Gets or sets a boolean which defines if optimization octree has to be updated
  68266. */
  68267. static set UpdateSelectionTree(value: boolean);
  68268. /**
  68269. * Gets a string describing the action executed by the current optimization
  68270. * @return description string
  68271. */
  68272. getDescription(): string;
  68273. private _canBeMerged;
  68274. /**
  68275. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68276. * @param scene defines the current scene where to apply this optimization
  68277. * @param optimizer defines the current optimizer
  68278. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68279. * @returns true if everything that can be done was applied
  68280. */
  68281. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68282. }
  68283. /**
  68284. * Defines a list of options used by SceneOptimizer
  68285. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68286. */
  68287. export class SceneOptimizerOptions {
  68288. /**
  68289. * Defines the target frame rate to reach (60 by default)
  68290. */
  68291. targetFrameRate: number;
  68292. /**
  68293. * Defines the interval between two checkes (2000ms by default)
  68294. */
  68295. trackerDuration: number;
  68296. /**
  68297. * Gets the list of optimizations to apply
  68298. */
  68299. optimizations: SceneOptimization[];
  68300. /**
  68301. * Creates a new list of options used by SceneOptimizer
  68302. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68303. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68304. */
  68305. constructor(
  68306. /**
  68307. * Defines the target frame rate to reach (60 by default)
  68308. */
  68309. targetFrameRate?: number,
  68310. /**
  68311. * Defines the interval between two checkes (2000ms by default)
  68312. */
  68313. trackerDuration?: number);
  68314. /**
  68315. * Add a new optimization
  68316. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68317. * @returns the current SceneOptimizerOptions
  68318. */
  68319. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68320. /**
  68321. * Add a new custom optimization
  68322. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68323. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68324. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68325. * @returns the current SceneOptimizerOptions
  68326. */
  68327. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68328. /**
  68329. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68330. * @param targetFrameRate defines the target frame rate (60 by default)
  68331. * @returns a SceneOptimizerOptions object
  68332. */
  68333. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68334. /**
  68335. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68336. * @param targetFrameRate defines the target frame rate (60 by default)
  68337. * @returns a SceneOptimizerOptions object
  68338. */
  68339. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68340. /**
  68341. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68342. * @param targetFrameRate defines the target frame rate (60 by default)
  68343. * @returns a SceneOptimizerOptions object
  68344. */
  68345. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68346. }
  68347. /**
  68348. * Class used to run optimizations in order to reach a target frame rate
  68349. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68350. */
  68351. export class SceneOptimizer implements IDisposable {
  68352. private _isRunning;
  68353. private _options;
  68354. private _scene;
  68355. private _currentPriorityLevel;
  68356. private _targetFrameRate;
  68357. private _trackerDuration;
  68358. private _currentFrameRate;
  68359. private _sceneDisposeObserver;
  68360. private _improvementMode;
  68361. /**
  68362. * Defines an observable called when the optimizer reaches the target frame rate
  68363. */
  68364. onSuccessObservable: Observable<SceneOptimizer>;
  68365. /**
  68366. * Defines an observable called when the optimizer enables an optimization
  68367. */
  68368. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68369. /**
  68370. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68371. */
  68372. onFailureObservable: Observable<SceneOptimizer>;
  68373. /**
  68374. * Gets a boolean indicating if the optimizer is in improvement mode
  68375. */
  68376. get isInImprovementMode(): boolean;
  68377. /**
  68378. * Gets the current priority level (0 at start)
  68379. */
  68380. get currentPriorityLevel(): number;
  68381. /**
  68382. * Gets the current frame rate checked by the SceneOptimizer
  68383. */
  68384. get currentFrameRate(): number;
  68385. /**
  68386. * Gets or sets the current target frame rate (60 by default)
  68387. */
  68388. get targetFrameRate(): number;
  68389. /**
  68390. * Gets or sets the current target frame rate (60 by default)
  68391. */
  68392. set targetFrameRate(value: number);
  68393. /**
  68394. * Gets or sets the current interval between two checks (every 2000ms by default)
  68395. */
  68396. get trackerDuration(): number;
  68397. /**
  68398. * Gets or sets the current interval between two checks (every 2000ms by default)
  68399. */
  68400. set trackerDuration(value: number);
  68401. /**
  68402. * Gets the list of active optimizations
  68403. */
  68404. get optimizations(): SceneOptimization[];
  68405. /**
  68406. * Creates a new SceneOptimizer
  68407. * @param scene defines the scene to work on
  68408. * @param options defines the options to use with the SceneOptimizer
  68409. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68410. * @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)
  68411. */
  68412. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68413. /**
  68414. * Stops the current optimizer
  68415. */
  68416. stop(): void;
  68417. /**
  68418. * Reset the optimizer to initial step (current priority level = 0)
  68419. */
  68420. reset(): void;
  68421. /**
  68422. * Start the optimizer. By default it will try to reach a specific framerate
  68423. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68424. */
  68425. start(): void;
  68426. private _checkCurrentState;
  68427. /**
  68428. * Release all resources
  68429. */
  68430. dispose(): void;
  68431. /**
  68432. * Helper function to create a SceneOptimizer with one single line of code
  68433. * @param scene defines the scene to work on
  68434. * @param options defines the options to use with the SceneOptimizer
  68435. * @param onSuccess defines a callback to call on success
  68436. * @param onFailure defines a callback to call on failure
  68437. * @returns the new SceneOptimizer object
  68438. */
  68439. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68440. }
  68441. }
  68442. declare module BABYLON {
  68443. /**
  68444. * Class used to serialize a scene into a string
  68445. */
  68446. export class SceneSerializer {
  68447. /**
  68448. * Clear cache used by a previous serialization
  68449. */
  68450. static ClearCache(): void;
  68451. /**
  68452. * Serialize a scene into a JSON compatible object
  68453. * @param scene defines the scene to serialize
  68454. * @returns a JSON compatible object
  68455. */
  68456. static Serialize(scene: Scene): any;
  68457. /**
  68458. * Serialize a mesh into a JSON compatible object
  68459. * @param toSerialize defines the mesh to serialize
  68460. * @param withParents defines if parents must be serialized as well
  68461. * @param withChildren defines if children must be serialized as well
  68462. * @returns a JSON compatible object
  68463. */
  68464. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68465. }
  68466. }
  68467. declare module BABYLON {
  68468. /**
  68469. * Class used to host texture specific utilities
  68470. */
  68471. export class TextureTools {
  68472. /**
  68473. * Uses the GPU to create a copy texture rescaled at a given size
  68474. * @param texture Texture to copy from
  68475. * @param width defines the desired width
  68476. * @param height defines the desired height
  68477. * @param useBilinearMode defines if bilinear mode has to be used
  68478. * @return the generated texture
  68479. */
  68480. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68481. }
  68482. }
  68483. declare module BABYLON {
  68484. /**
  68485. * This represents the different options available for the video capture.
  68486. */
  68487. export interface VideoRecorderOptions {
  68488. /** Defines the mime type of the video. */
  68489. mimeType: string;
  68490. /** Defines the FPS the video should be recorded at. */
  68491. fps: number;
  68492. /** Defines the chunk size for the recording data. */
  68493. recordChunckSize: number;
  68494. /** The audio tracks to attach to the recording. */
  68495. audioTracks?: MediaStreamTrack[];
  68496. }
  68497. /**
  68498. * This can help with recording videos from BabylonJS.
  68499. * This is based on the available WebRTC functionalities of the browser.
  68500. *
  68501. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68502. */
  68503. export class VideoRecorder {
  68504. private static readonly _defaultOptions;
  68505. /**
  68506. * Returns whether or not the VideoRecorder is available in your browser.
  68507. * @param engine Defines the Babylon Engine.
  68508. * @returns true if supported otherwise false.
  68509. */
  68510. static IsSupported(engine: Engine): boolean;
  68511. private readonly _options;
  68512. private _canvas;
  68513. private _mediaRecorder;
  68514. private _recordedChunks;
  68515. private _fileName;
  68516. private _resolve;
  68517. private _reject;
  68518. /**
  68519. * True when a recording is already in progress.
  68520. */
  68521. get isRecording(): boolean;
  68522. /**
  68523. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68524. * @param engine Defines the BabylonJS Engine you wish to record.
  68525. * @param options Defines options that can be used to customize the capture.
  68526. */
  68527. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68528. /**
  68529. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68530. */
  68531. stopRecording(): void;
  68532. /**
  68533. * Starts recording the canvas for a max duration specified in parameters.
  68534. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68535. * If null no automatic download will start and you can rely on the promise to get the data back.
  68536. * @param maxDuration Defines the maximum recording time in seconds.
  68537. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68538. * @return A promise callback at the end of the recording with the video data in Blob.
  68539. */
  68540. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68541. /**
  68542. * Releases internal resources used during the recording.
  68543. */
  68544. dispose(): void;
  68545. private _handleDataAvailable;
  68546. private _handleError;
  68547. private _handleStop;
  68548. }
  68549. }
  68550. declare module BABYLON {
  68551. /**
  68552. * Class containing a set of static utilities functions for screenshots
  68553. */
  68554. export class ScreenshotTools {
  68555. /**
  68556. * Captures a screenshot of the current rendering
  68557. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68558. * @param engine defines the rendering engine
  68559. * @param camera defines the source camera
  68560. * @param size This parameter can be set to a single number or to an object with the
  68561. * following (optional) properties: precision, width, height. If a single number is passed,
  68562. * it will be used for both width and height. If an object is passed, the screenshot size
  68563. * will be derived from the parameters. The precision property is a multiplier allowing
  68564. * rendering at a higher or lower resolution
  68565. * @param successCallback defines the callback receives a single parameter which contains the
  68566. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68567. * src parameter of an <img> to display it
  68568. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68569. * Check your browser for supported MIME types
  68570. */
  68571. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68572. /**
  68573. * Captures a screenshot of the current rendering
  68574. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68575. * @param engine defines the rendering engine
  68576. * @param camera defines the source camera
  68577. * @param size This parameter can be set to a single number or to an object with the
  68578. * following (optional) properties: precision, width, height. If a single number is passed,
  68579. * it will be used for both width and height. If an object is passed, the screenshot size
  68580. * will be derived from the parameters. The precision property is a multiplier allowing
  68581. * rendering at a higher or lower resolution
  68582. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68583. * Check your browser for supported MIME types
  68584. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68585. * to the src parameter of an <img> to display it
  68586. */
  68587. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68588. /**
  68589. * Generates an image screenshot from the specified camera.
  68590. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68591. * @param engine The engine to use for rendering
  68592. * @param camera The camera to use for rendering
  68593. * @param size This parameter can be set to a single number or to an object with the
  68594. * following (optional) properties: precision, width, height. If a single number is passed,
  68595. * it will be used for both width and height. If an object is passed, the screenshot size
  68596. * will be derived from the parameters. The precision property is a multiplier allowing
  68597. * rendering at a higher or lower resolution
  68598. * @param successCallback The callback receives a single parameter which contains the
  68599. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68600. * src parameter of an <img> to display it
  68601. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68602. * Check your browser for supported MIME types
  68603. * @param samples Texture samples (default: 1)
  68604. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68605. * @param fileName A name for for the downloaded file.
  68606. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68607. */
  68608. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  68609. /**
  68610. * Generates an image screenshot from the specified camera.
  68611. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68612. * @param engine The engine to use for rendering
  68613. * @param camera The camera to use for rendering
  68614. * @param size This parameter can be set to a single number or to an object with the
  68615. * following (optional) properties: precision, width, height. If a single number is passed,
  68616. * it will be used for both width and height. If an object is passed, the screenshot size
  68617. * will be derived from the parameters. The precision property is a multiplier allowing
  68618. * rendering at a higher or lower resolution
  68619. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68620. * Check your browser for supported MIME types
  68621. * @param samples Texture samples (default: 1)
  68622. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68623. * @param fileName A name for for the downloaded file.
  68624. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68625. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68626. * to the src parameter of an <img> to display it
  68627. */
  68628. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  68629. /**
  68630. * Gets height and width for screenshot size
  68631. * @private
  68632. */
  68633. private static _getScreenshotSize;
  68634. }
  68635. }
  68636. declare module BABYLON {
  68637. /**
  68638. * Interface for a data buffer
  68639. */
  68640. export interface IDataBuffer {
  68641. /**
  68642. * Reads bytes from the data buffer.
  68643. * @param byteOffset The byte offset to read
  68644. * @param byteLength The byte length to read
  68645. * @returns A promise that resolves when the bytes are read
  68646. */
  68647. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68648. /**
  68649. * The byte length of the buffer.
  68650. */
  68651. readonly byteLength: number;
  68652. }
  68653. /**
  68654. * Utility class for reading from a data buffer
  68655. */
  68656. export class DataReader {
  68657. /**
  68658. * The data buffer associated with this data reader.
  68659. */
  68660. readonly buffer: IDataBuffer;
  68661. /**
  68662. * The current byte offset from the beginning of the data buffer.
  68663. */
  68664. byteOffset: number;
  68665. private _dataView;
  68666. private _dataByteOffset;
  68667. /**
  68668. * Constructor
  68669. * @param buffer The buffer to read
  68670. */
  68671. constructor(buffer: IDataBuffer);
  68672. /**
  68673. * Loads the given byte length.
  68674. * @param byteLength The byte length to load
  68675. * @returns A promise that resolves when the load is complete
  68676. */
  68677. loadAsync(byteLength: number): Promise<void>;
  68678. /**
  68679. * Read a unsigned 32-bit integer from the currently loaded data range.
  68680. * @returns The 32-bit integer read
  68681. */
  68682. readUint32(): number;
  68683. /**
  68684. * Read a byte array from the currently loaded data range.
  68685. * @param byteLength The byte length to read
  68686. * @returns The byte array read
  68687. */
  68688. readUint8Array(byteLength: number): Uint8Array;
  68689. /**
  68690. * Read a string from the currently loaded data range.
  68691. * @param byteLength The byte length to read
  68692. * @returns The string read
  68693. */
  68694. readString(byteLength: number): string;
  68695. /**
  68696. * Skips the given byte length the currently loaded data range.
  68697. * @param byteLength The byte length to skip
  68698. */
  68699. skipBytes(byteLength: number): void;
  68700. }
  68701. }
  68702. declare module BABYLON {
  68703. /**
  68704. * Class for storing data to local storage if available or in-memory storage otherwise
  68705. */
  68706. export class DataStorage {
  68707. private static _Storage;
  68708. private static _GetStorage;
  68709. /**
  68710. * Reads a string from the data storage
  68711. * @param key The key to read
  68712. * @param defaultValue The value if the key doesn't exist
  68713. * @returns The string value
  68714. */
  68715. static ReadString(key: string, defaultValue: string): string;
  68716. /**
  68717. * Writes a string to the data storage
  68718. * @param key The key to write
  68719. * @param value The value to write
  68720. */
  68721. static WriteString(key: string, value: string): void;
  68722. /**
  68723. * Reads a boolean from the data storage
  68724. * @param key The key to read
  68725. * @param defaultValue The value if the key doesn't exist
  68726. * @returns The boolean value
  68727. */
  68728. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  68729. /**
  68730. * Writes a boolean to the data storage
  68731. * @param key The key to write
  68732. * @param value The value to write
  68733. */
  68734. static WriteBoolean(key: string, value: boolean): void;
  68735. /**
  68736. * Reads a number from the data storage
  68737. * @param key The key to read
  68738. * @param defaultValue The value if the key doesn't exist
  68739. * @returns The number value
  68740. */
  68741. static ReadNumber(key: string, defaultValue: number): number;
  68742. /**
  68743. * Writes a number to the data storage
  68744. * @param key The key to write
  68745. * @param value The value to write
  68746. */
  68747. static WriteNumber(key: string, value: number): void;
  68748. }
  68749. }
  68750. declare module BABYLON {
  68751. /**
  68752. * Options used for hit testing
  68753. */
  68754. export interface IWebXRHitTestOptions {
  68755. /**
  68756. * Only test when user interacted with the scene. Default - hit test every frame
  68757. */
  68758. testOnPointerDownOnly?: boolean;
  68759. /**
  68760. * The node to use to transform the local results to world coordinates
  68761. */
  68762. worldParentNode?: TransformNode;
  68763. }
  68764. /**
  68765. * Interface defining the babylon result of raycasting/hit-test
  68766. */
  68767. export interface IWebXRHitResult {
  68768. /**
  68769. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68770. */
  68771. transformationMatrix: Matrix;
  68772. /**
  68773. * The native hit test result
  68774. */
  68775. xrHitResult: XRHitResult;
  68776. }
  68777. /**
  68778. * The currently-working hit-test module.
  68779. * Hit test (or Ray-casting) is used to interact with the real world.
  68780. * For further information read here - https://github.com/immersive-web/hit-test
  68781. */
  68782. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68783. /**
  68784. * options to use when constructing this feature
  68785. */
  68786. readonly options: IWebXRHitTestOptions;
  68787. private _direction;
  68788. private _mat;
  68789. private _onSelectEnabled;
  68790. private _origin;
  68791. /**
  68792. * The module's name
  68793. */
  68794. static readonly Name: string;
  68795. /**
  68796. * The (Babylon) version of this module.
  68797. * This is an integer representing the implementation version.
  68798. * This number does not correspond to the WebXR specs version
  68799. */
  68800. static readonly Version: number;
  68801. /**
  68802. * Populated with the last native XR Hit Results
  68803. */
  68804. lastNativeXRHitResults: XRHitResult[];
  68805. /**
  68806. * Triggered when new babylon (transformed) hit test results are available
  68807. */
  68808. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68809. /**
  68810. * Creates a new instance of the (legacy version) hit test feature
  68811. * @param _xrSessionManager an instance of WebXRSessionManager
  68812. * @param options options to use when constructing this feature
  68813. */
  68814. constructor(_xrSessionManager: WebXRSessionManager,
  68815. /**
  68816. * options to use when constructing this feature
  68817. */
  68818. options?: IWebXRHitTestOptions);
  68819. /**
  68820. * execute a hit test with an XR Ray
  68821. *
  68822. * @param xrSession a native xrSession that will execute this hit test
  68823. * @param xrRay the ray (position and direction) to use for ray-casting
  68824. * @param referenceSpace native XR reference space to use for the hit-test
  68825. * @param filter filter function that will filter the results
  68826. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68827. */
  68828. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  68829. /**
  68830. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68831. * @param event the (select) event to use to select with
  68832. * @param referenceSpace the reference space to use for this hit test
  68833. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68834. */
  68835. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68836. /**
  68837. * attach this feature
  68838. * Will usually be called by the features manager
  68839. *
  68840. * @returns true if successful.
  68841. */
  68842. attach(): boolean;
  68843. /**
  68844. * detach this feature.
  68845. * Will usually be called by the features manager
  68846. *
  68847. * @returns true if successful.
  68848. */
  68849. detach(): boolean;
  68850. /**
  68851. * Dispose this feature and all of the resources attached
  68852. */
  68853. dispose(): void;
  68854. protected _onXRFrame(frame: XRFrame): void;
  68855. private _onHitTestResults;
  68856. private _onSelect;
  68857. }
  68858. }
  68859. declare module BABYLON {
  68860. /**
  68861. * Options used in the plane detector module
  68862. */
  68863. export interface IWebXRPlaneDetectorOptions {
  68864. /**
  68865. * The node to use to transform the local results to world coordinates
  68866. */
  68867. worldParentNode?: TransformNode;
  68868. }
  68869. /**
  68870. * A babylon interface for a WebXR plane.
  68871. * A Plane is actually a polygon, built from N points in space
  68872. *
  68873. * Supported in chrome 79, not supported in canary 81 ATM
  68874. */
  68875. export interface IWebXRPlane {
  68876. /**
  68877. * a babylon-assigned ID for this polygon
  68878. */
  68879. id: number;
  68880. /**
  68881. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  68882. */
  68883. polygonDefinition: Array<Vector3>;
  68884. /**
  68885. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  68886. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  68887. */
  68888. transformationMatrix: Matrix;
  68889. /**
  68890. * the native xr-plane object
  68891. */
  68892. xrPlane: XRPlane;
  68893. }
  68894. /**
  68895. * The plane detector is used to detect planes in the real world when in AR
  68896. * For more information see https://github.com/immersive-web/real-world-geometry/
  68897. */
  68898. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  68899. private _options;
  68900. private _detectedPlanes;
  68901. private _enabled;
  68902. private _lastFrameDetected;
  68903. /**
  68904. * The module's name
  68905. */
  68906. static readonly Name: string;
  68907. /**
  68908. * The (Babylon) version of this module.
  68909. * This is an integer representing the implementation version.
  68910. * This number does not correspond to the WebXR specs version
  68911. */
  68912. static readonly Version: number;
  68913. /**
  68914. * Observers registered here will be executed when a new plane was added to the session
  68915. */
  68916. onPlaneAddedObservable: Observable<IWebXRPlane>;
  68917. /**
  68918. * Observers registered here will be executed when a plane is no longer detected in the session
  68919. */
  68920. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  68921. /**
  68922. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  68923. * This can execute N times every frame
  68924. */
  68925. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  68926. /**
  68927. * construct a new Plane Detector
  68928. * @param _xrSessionManager an instance of xr Session manager
  68929. * @param _options configuration to use when constructing this feature
  68930. */
  68931. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  68932. /**
  68933. * Dispose this feature and all of the resources attached
  68934. */
  68935. dispose(): void;
  68936. protected _onXRFrame(frame: XRFrame): void;
  68937. private _init;
  68938. private _updatePlaneWithXRPlane;
  68939. /**
  68940. * avoiding using Array.find for global support.
  68941. * @param xrPlane the plane to find in the array
  68942. */
  68943. private findIndexInPlaneArray;
  68944. }
  68945. }
  68946. declare module BABYLON {
  68947. /**
  68948. * Configuration options of the anchor system
  68949. */
  68950. export interface IWebXRAnchorSystemOptions {
  68951. /**
  68952. * Should a new anchor be added every time a select event is triggered
  68953. */
  68954. addAnchorOnSelect?: boolean;
  68955. /**
  68956. * should the anchor system use plane detection.
  68957. * If set to true, the plane-detection feature should be set using setPlaneDetector
  68958. */
  68959. usePlaneDetection?: boolean;
  68960. /**
  68961. * a node that will be used to convert local to world coordinates
  68962. */
  68963. worldParentNode?: TransformNode;
  68964. }
  68965. /**
  68966. * A babylon container for an XR Anchor
  68967. */
  68968. export interface IWebXRAnchor {
  68969. /**
  68970. * A babylon-assigned ID for this anchor
  68971. */
  68972. id: number;
  68973. /**
  68974. * Transformation matrix to apply to an object attached to this anchor
  68975. */
  68976. transformationMatrix: Matrix;
  68977. /**
  68978. * The native anchor object
  68979. */
  68980. xrAnchor: XRAnchor;
  68981. }
  68982. /**
  68983. * An implementation of the anchor system of WebXR.
  68984. * Note that the current documented implementation is not available in any browser. Future implementations
  68985. * will use the frame to create an anchor and not the session or a detected plane
  68986. * For further information see https://github.com/immersive-web/anchors/
  68987. */
  68988. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  68989. private _options;
  68990. private _enabled;
  68991. private _hitTestModule;
  68992. private _lastFrameDetected;
  68993. private _onSelect;
  68994. private _planeDetector;
  68995. private _trackedAnchors;
  68996. /**
  68997. * The module's name
  68998. */
  68999. static readonly Name: string;
  69000. /**
  69001. * The (Babylon) version of this module.
  69002. * This is an integer representing the implementation version.
  69003. * This number does not correspond to the WebXR specs version
  69004. */
  69005. static readonly Version: number;
  69006. /**
  69007. * Observers registered here will be executed when a new anchor was added to the session
  69008. */
  69009. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69010. /**
  69011. * Observers registered here will be executed when an anchor was removed from the session
  69012. */
  69013. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69014. /**
  69015. * Observers registered here will be executed when an existing anchor updates
  69016. * This can execute N times every frame
  69017. */
  69018. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69019. /**
  69020. * constructs a new anchor system
  69021. * @param _xrSessionManager an instance of WebXRSessionManager
  69022. * @param _options configuration object for this feature
  69023. */
  69024. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69025. /**
  69026. * Add anchor at a specific XR point.
  69027. *
  69028. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69029. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69030. * @returns a promise the fulfills when the anchor was created
  69031. */
  69032. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69033. /**
  69034. * attach this feature
  69035. * Will usually be called by the features manager
  69036. *
  69037. * @returns true if successful.
  69038. */
  69039. attach(): boolean;
  69040. /**
  69041. * detach this feature.
  69042. * Will usually be called by the features manager
  69043. *
  69044. * @returns true if successful.
  69045. */
  69046. detach(): boolean;
  69047. /**
  69048. * Dispose this feature and all of the resources attached
  69049. */
  69050. dispose(): void;
  69051. /**
  69052. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69053. * @param hitTestModule the hit-test module to use.
  69054. */
  69055. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69056. /**
  69057. * set the plane detector to use in order to create anchors from frames
  69058. * @param planeDetector the plane-detector module to use
  69059. * @param enable enable plane-anchors. default is true
  69060. */
  69061. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69062. protected _onXRFrame(frame: XRFrame): void;
  69063. /**
  69064. * avoiding using Array.find for global support.
  69065. * @param xrAnchor the plane to find in the array
  69066. */
  69067. private _findIndexInAnchorArray;
  69068. private _updateAnchorWithXRFrame;
  69069. }
  69070. }
  69071. declare module BABYLON {
  69072. /**
  69073. * Options interface for the background remover plugin
  69074. */
  69075. export interface IWebXRBackgroundRemoverOptions {
  69076. /**
  69077. * Further background meshes to disable when entering AR
  69078. */
  69079. backgroundMeshes?: AbstractMesh[];
  69080. /**
  69081. * flags to configure the removal of the environment helper.
  69082. * If not set, the entire background will be removed. If set, flags should be set as well.
  69083. */
  69084. environmentHelperRemovalFlags?: {
  69085. /**
  69086. * Should the skybox be removed (default false)
  69087. */
  69088. skyBox?: boolean;
  69089. /**
  69090. * Should the ground be removed (default false)
  69091. */
  69092. ground?: boolean;
  69093. };
  69094. /**
  69095. * don't disable the environment helper
  69096. */
  69097. ignoreEnvironmentHelper?: boolean;
  69098. }
  69099. /**
  69100. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69101. */
  69102. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69103. /**
  69104. * read-only options to be used in this module
  69105. */
  69106. readonly options: IWebXRBackgroundRemoverOptions;
  69107. /**
  69108. * The module's name
  69109. */
  69110. static readonly Name: string;
  69111. /**
  69112. * The (Babylon) version of this module.
  69113. * This is an integer representing the implementation version.
  69114. * This number does not correspond to the WebXR specs version
  69115. */
  69116. static readonly Version: number;
  69117. /**
  69118. * registered observers will be triggered when the background state changes
  69119. */
  69120. onBackgroundStateChangedObservable: Observable<boolean>;
  69121. /**
  69122. * constructs a new background remover module
  69123. * @param _xrSessionManager the session manager for this module
  69124. * @param options read-only options to be used in this module
  69125. */
  69126. constructor(_xrSessionManager: WebXRSessionManager,
  69127. /**
  69128. * read-only options to be used in this module
  69129. */
  69130. options?: IWebXRBackgroundRemoverOptions);
  69131. /**
  69132. * attach this feature
  69133. * Will usually be called by the features manager
  69134. *
  69135. * @returns true if successful.
  69136. */
  69137. attach(): boolean;
  69138. /**
  69139. * detach this feature.
  69140. * Will usually be called by the features manager
  69141. *
  69142. * @returns true if successful.
  69143. */
  69144. detach(): boolean;
  69145. /**
  69146. * Dispose this feature and all of the resources attached
  69147. */
  69148. dispose(): void;
  69149. protected _onXRFrame(_xrFrame: XRFrame): void;
  69150. private _setBackgroundState;
  69151. }
  69152. }
  69153. declare module BABYLON {
  69154. /**
  69155. * Options for the controller physics feature
  69156. */
  69157. export class IWebXRControllerPhysicsOptions {
  69158. /**
  69159. * Should the headset get its own impostor
  69160. */
  69161. enableHeadsetImpostor?: boolean;
  69162. /**
  69163. * Optional parameters for the headset impostor
  69164. */
  69165. headsetImpostorParams?: {
  69166. /**
  69167. * The type of impostor to create. Default is sphere
  69168. */
  69169. impostorType: number;
  69170. /**
  69171. * the size of the impostor. Defaults to 10cm
  69172. */
  69173. impostorSize?: number | {
  69174. width: number;
  69175. height: number;
  69176. depth: number;
  69177. };
  69178. /**
  69179. * Friction definitions
  69180. */
  69181. friction?: number;
  69182. /**
  69183. * Restitution
  69184. */
  69185. restitution?: number;
  69186. };
  69187. /**
  69188. * The physics properties of the future impostors
  69189. */
  69190. physicsProperties?: {
  69191. /**
  69192. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69193. * Note that this requires a physics engine that supports mesh impostors!
  69194. */
  69195. useControllerMesh?: boolean;
  69196. /**
  69197. * The type of impostor to create. Default is sphere
  69198. */
  69199. impostorType?: number;
  69200. /**
  69201. * the size of the impostor. Defaults to 10cm
  69202. */
  69203. impostorSize?: number | {
  69204. width: number;
  69205. height: number;
  69206. depth: number;
  69207. };
  69208. /**
  69209. * Friction definitions
  69210. */
  69211. friction?: number;
  69212. /**
  69213. * Restitution
  69214. */
  69215. restitution?: number;
  69216. };
  69217. /**
  69218. * the xr input to use with this pointer selection
  69219. */
  69220. xrInput: WebXRInput;
  69221. }
  69222. /**
  69223. * Add physics impostor to your webxr controllers,
  69224. * including naive calculation of their linear and angular velocity
  69225. */
  69226. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69227. private readonly _options;
  69228. private _attachController;
  69229. private _controllers;
  69230. private _debugMode;
  69231. private _delta;
  69232. private _headsetImpostor?;
  69233. private _headsetMesh?;
  69234. private _lastTimestamp;
  69235. private _tmpQuaternion;
  69236. private _tmpVector;
  69237. /**
  69238. * The module's name
  69239. */
  69240. static readonly Name: string;
  69241. /**
  69242. * The (Babylon) version of this module.
  69243. * This is an integer representing the implementation version.
  69244. * This number does not correspond to the webxr specs version
  69245. */
  69246. static readonly Version: number;
  69247. /**
  69248. * Construct a new Controller Physics Feature
  69249. * @param _xrSessionManager the corresponding xr session manager
  69250. * @param _options options to create this feature with
  69251. */
  69252. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69253. /**
  69254. * @hidden
  69255. * enable debugging - will show console outputs and the impostor mesh
  69256. */
  69257. _enablePhysicsDebug(): void;
  69258. /**
  69259. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69260. * @param xrController the controller to add
  69261. */
  69262. addController(xrController: WebXRInputSource): void;
  69263. /**
  69264. * attach this feature
  69265. * Will usually be called by the features manager
  69266. *
  69267. * @returns true if successful.
  69268. */
  69269. attach(): boolean;
  69270. /**
  69271. * detach this feature.
  69272. * Will usually be called by the features manager
  69273. *
  69274. * @returns true if successful.
  69275. */
  69276. detach(): boolean;
  69277. /**
  69278. * Get the headset impostor, if enabled
  69279. * @returns the impostor
  69280. */
  69281. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69282. /**
  69283. * Get the physics impostor of a specific controller.
  69284. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69285. * @param controller the controller or the controller id of which to get the impostor
  69286. * @returns the impostor or null
  69287. */
  69288. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69289. /**
  69290. * Update the physics properties provided in the constructor
  69291. * @param newProperties the new properties object
  69292. */
  69293. setPhysicsProperties(newProperties: {
  69294. impostorType?: number;
  69295. impostorSize?: number | {
  69296. width: number;
  69297. height: number;
  69298. depth: number;
  69299. };
  69300. friction?: number;
  69301. restitution?: number;
  69302. }): void;
  69303. protected _onXRFrame(_xrFrame: any): void;
  69304. private _detachController;
  69305. }
  69306. }
  69307. declare module BABYLON {
  69308. /**
  69309. * The motion controller class for all microsoft mixed reality controllers
  69310. */
  69311. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69312. protected readonly _mapping: {
  69313. defaultButton: {
  69314. "valueNodeName": string;
  69315. "unpressedNodeName": string;
  69316. "pressedNodeName": string;
  69317. };
  69318. defaultAxis: {
  69319. "valueNodeName": string;
  69320. "minNodeName": string;
  69321. "maxNodeName": string;
  69322. };
  69323. buttons: {
  69324. "xr-standard-trigger": {
  69325. "rootNodeName": string;
  69326. "componentProperty": string;
  69327. "states": string[];
  69328. };
  69329. "xr-standard-squeeze": {
  69330. "rootNodeName": string;
  69331. "componentProperty": string;
  69332. "states": string[];
  69333. };
  69334. "xr-standard-touchpad": {
  69335. "rootNodeName": string;
  69336. "labelAnchorNodeName": string;
  69337. "touchPointNodeName": string;
  69338. };
  69339. "xr-standard-thumbstick": {
  69340. "rootNodeName": string;
  69341. "componentProperty": string;
  69342. "states": string[];
  69343. };
  69344. };
  69345. axes: {
  69346. "xr-standard-touchpad": {
  69347. "x-axis": {
  69348. "rootNodeName": string;
  69349. };
  69350. "y-axis": {
  69351. "rootNodeName": string;
  69352. };
  69353. };
  69354. "xr-standard-thumbstick": {
  69355. "x-axis": {
  69356. "rootNodeName": string;
  69357. };
  69358. "y-axis": {
  69359. "rootNodeName": string;
  69360. };
  69361. };
  69362. };
  69363. };
  69364. /**
  69365. * The base url used to load the left and right controller models
  69366. */
  69367. static MODEL_BASE_URL: string;
  69368. /**
  69369. * The name of the left controller model file
  69370. */
  69371. static MODEL_LEFT_FILENAME: string;
  69372. /**
  69373. * The name of the right controller model file
  69374. */
  69375. static MODEL_RIGHT_FILENAME: string;
  69376. profileId: string;
  69377. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69378. protected _getFilenameAndPath(): {
  69379. filename: string;
  69380. path: string;
  69381. };
  69382. protected _getModelLoadingConstraints(): boolean;
  69383. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69384. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69385. protected _updateModel(): void;
  69386. }
  69387. }
  69388. declare module BABYLON {
  69389. /**
  69390. * The motion controller class for oculus touch (quest, rift).
  69391. * This class supports legacy mapping as well the standard xr mapping
  69392. */
  69393. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69394. private _forceLegacyControllers;
  69395. private _modelRootNode;
  69396. /**
  69397. * The base url used to load the left and right controller models
  69398. */
  69399. static MODEL_BASE_URL: string;
  69400. /**
  69401. * The name of the left controller model file
  69402. */
  69403. static MODEL_LEFT_FILENAME: string;
  69404. /**
  69405. * The name of the right controller model file
  69406. */
  69407. static MODEL_RIGHT_FILENAME: string;
  69408. /**
  69409. * Base Url for the Quest controller model.
  69410. */
  69411. static QUEST_MODEL_BASE_URL: string;
  69412. profileId: string;
  69413. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69414. protected _getFilenameAndPath(): {
  69415. filename: string;
  69416. path: string;
  69417. };
  69418. protected _getModelLoadingConstraints(): boolean;
  69419. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69420. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69421. protected _updateModel(): void;
  69422. /**
  69423. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69424. * between the touch and touch 2.
  69425. */
  69426. private _isQuest;
  69427. }
  69428. }
  69429. declare module BABYLON {
  69430. /**
  69431. * The motion controller class for the standard HTC-Vive controllers
  69432. */
  69433. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69434. private _modelRootNode;
  69435. /**
  69436. * The base url used to load the left and right controller models
  69437. */
  69438. static MODEL_BASE_URL: string;
  69439. /**
  69440. * File name for the controller model.
  69441. */
  69442. static MODEL_FILENAME: string;
  69443. profileId: string;
  69444. /**
  69445. * Create a new Vive motion controller object
  69446. * @param scene the scene to use to create this controller
  69447. * @param gamepadObject the corresponding gamepad object
  69448. * @param handness the handness of the controller
  69449. */
  69450. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69451. protected _getFilenameAndPath(): {
  69452. filename: string;
  69453. path: string;
  69454. };
  69455. protected _getModelLoadingConstraints(): boolean;
  69456. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69457. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69458. protected _updateModel(): void;
  69459. }
  69460. }
  69461. declare module BABYLON {
  69462. /**
  69463. * A cursor which tracks a point on a path
  69464. */
  69465. export class PathCursor {
  69466. private path;
  69467. /**
  69468. * Stores path cursor callbacks for when an onchange event is triggered
  69469. */
  69470. private _onchange;
  69471. /**
  69472. * The value of the path cursor
  69473. */
  69474. value: number;
  69475. /**
  69476. * The animation array of the path cursor
  69477. */
  69478. animations: Animation[];
  69479. /**
  69480. * Initializes the path cursor
  69481. * @param path The path to track
  69482. */
  69483. constructor(path: Path2);
  69484. /**
  69485. * Gets the cursor point on the path
  69486. * @returns A point on the path cursor at the cursor location
  69487. */
  69488. getPoint(): Vector3;
  69489. /**
  69490. * Moves the cursor ahead by the step amount
  69491. * @param step The amount to move the cursor forward
  69492. * @returns This path cursor
  69493. */
  69494. moveAhead(step?: number): PathCursor;
  69495. /**
  69496. * Moves the cursor behind by the step amount
  69497. * @param step The amount to move the cursor back
  69498. * @returns This path cursor
  69499. */
  69500. moveBack(step?: number): PathCursor;
  69501. /**
  69502. * Moves the cursor by the step amount
  69503. * If the step amount is greater than one, an exception is thrown
  69504. * @param step The amount to move the cursor
  69505. * @returns This path cursor
  69506. */
  69507. move(step: number): PathCursor;
  69508. /**
  69509. * Ensures that the value is limited between zero and one
  69510. * @returns This path cursor
  69511. */
  69512. private ensureLimits;
  69513. /**
  69514. * Runs onchange callbacks on change (used by the animation engine)
  69515. * @returns This path cursor
  69516. */
  69517. private raiseOnChange;
  69518. /**
  69519. * Executes a function on change
  69520. * @param f A path cursor onchange callback
  69521. * @returns This path cursor
  69522. */
  69523. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69524. }
  69525. }
  69526. declare module BABYLON {
  69527. /** @hidden */
  69528. export var blurPixelShader: {
  69529. name: string;
  69530. shader: string;
  69531. };
  69532. }
  69533. declare module BABYLON {
  69534. /** @hidden */
  69535. export var pointCloudVertexDeclaration: {
  69536. name: string;
  69537. shader: string;
  69538. };
  69539. }
  69540. // Mixins
  69541. interface Window {
  69542. mozIndexedDB: IDBFactory;
  69543. webkitIndexedDB: IDBFactory;
  69544. msIndexedDB: IDBFactory;
  69545. webkitURL: typeof URL;
  69546. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69547. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69548. WebGLRenderingContext: WebGLRenderingContext;
  69549. MSGesture: MSGesture;
  69550. CANNON: any;
  69551. AudioContext: AudioContext;
  69552. webkitAudioContext: AudioContext;
  69553. PointerEvent: any;
  69554. Math: Math;
  69555. Uint8Array: Uint8ArrayConstructor;
  69556. Float32Array: Float32ArrayConstructor;
  69557. mozURL: typeof URL;
  69558. msURL: typeof URL;
  69559. VRFrameData: any; // WebVR, from specs 1.1
  69560. DracoDecoderModule: any;
  69561. setImmediate(handler: (...args: any[]) => void): number;
  69562. }
  69563. interface HTMLCanvasElement {
  69564. requestPointerLock(): void;
  69565. msRequestPointerLock?(): void;
  69566. mozRequestPointerLock?(): void;
  69567. webkitRequestPointerLock?(): void;
  69568. /** Track wether a record is in progress */
  69569. isRecording: boolean;
  69570. /** Capture Stream method defined by some browsers */
  69571. captureStream(fps?: number): MediaStream;
  69572. }
  69573. interface CanvasRenderingContext2D {
  69574. msImageSmoothingEnabled: boolean;
  69575. }
  69576. interface MouseEvent {
  69577. mozMovementX: number;
  69578. mozMovementY: number;
  69579. webkitMovementX: number;
  69580. webkitMovementY: number;
  69581. msMovementX: number;
  69582. msMovementY: number;
  69583. }
  69584. interface Navigator {
  69585. mozGetVRDevices: (any: any) => any;
  69586. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69587. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69588. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69589. webkitGetGamepads(): Gamepad[];
  69590. msGetGamepads(): Gamepad[];
  69591. webkitGamepads(): Gamepad[];
  69592. }
  69593. interface HTMLVideoElement {
  69594. mozSrcObject: any;
  69595. }
  69596. interface Math {
  69597. fround(x: number): number;
  69598. imul(a: number, b: number): number;
  69599. }
  69600. interface WebGLRenderingContext {
  69601. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69602. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69603. vertexAttribDivisor(index: number, divisor: number): void;
  69604. createVertexArray(): any;
  69605. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69606. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69607. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69608. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69609. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69610. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69611. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69612. // Queries
  69613. createQuery(): WebGLQuery;
  69614. deleteQuery(query: WebGLQuery): void;
  69615. beginQuery(target: number, query: WebGLQuery): void;
  69616. endQuery(target: number): void;
  69617. getQueryParameter(query: WebGLQuery, pname: number): any;
  69618. getQuery(target: number, pname: number): any;
  69619. MAX_SAMPLES: number;
  69620. RGBA8: number;
  69621. READ_FRAMEBUFFER: number;
  69622. DRAW_FRAMEBUFFER: number;
  69623. UNIFORM_BUFFER: number;
  69624. HALF_FLOAT_OES: number;
  69625. RGBA16F: number;
  69626. RGBA32F: number;
  69627. R32F: number;
  69628. RG32F: number;
  69629. RGB32F: number;
  69630. R16F: number;
  69631. RG16F: number;
  69632. RGB16F: number;
  69633. RED: number;
  69634. RG: number;
  69635. R8: number;
  69636. RG8: number;
  69637. UNSIGNED_INT_24_8: number;
  69638. DEPTH24_STENCIL8: number;
  69639. MIN: number;
  69640. MAX: number;
  69641. /* Multiple Render Targets */
  69642. drawBuffers(buffers: number[]): void;
  69643. readBuffer(src: number): void;
  69644. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69645. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69646. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69647. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69648. // Occlusion Query
  69649. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69650. ANY_SAMPLES_PASSED: number;
  69651. QUERY_RESULT_AVAILABLE: number;
  69652. QUERY_RESULT: number;
  69653. }
  69654. interface WebGLProgram {
  69655. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69656. }
  69657. interface EXT_disjoint_timer_query {
  69658. QUERY_COUNTER_BITS_EXT: number;
  69659. TIME_ELAPSED_EXT: number;
  69660. TIMESTAMP_EXT: number;
  69661. GPU_DISJOINT_EXT: number;
  69662. QUERY_RESULT_EXT: number;
  69663. QUERY_RESULT_AVAILABLE_EXT: number;
  69664. queryCounterEXT(query: WebGLQuery, target: number): void;
  69665. createQueryEXT(): WebGLQuery;
  69666. beginQueryEXT(target: number, query: WebGLQuery): void;
  69667. endQueryEXT(target: number): void;
  69668. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69669. deleteQueryEXT(query: WebGLQuery): void;
  69670. }
  69671. interface WebGLUniformLocation {
  69672. _currentState: any;
  69673. }
  69674. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69675. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69676. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69677. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69678. interface WebGLRenderingContext {
  69679. readonly RASTERIZER_DISCARD: number;
  69680. readonly DEPTH_COMPONENT24: number;
  69681. readonly TEXTURE_3D: number;
  69682. readonly TEXTURE_2D_ARRAY: number;
  69683. readonly TEXTURE_COMPARE_FUNC: number;
  69684. readonly TEXTURE_COMPARE_MODE: number;
  69685. readonly COMPARE_REF_TO_TEXTURE: number;
  69686. readonly TEXTURE_WRAP_R: number;
  69687. readonly HALF_FLOAT: number;
  69688. readonly RGB8: number;
  69689. readonly RED_INTEGER: number;
  69690. readonly RG_INTEGER: number;
  69691. readonly RGB_INTEGER: number;
  69692. readonly RGBA_INTEGER: number;
  69693. readonly R8_SNORM: number;
  69694. readonly RG8_SNORM: number;
  69695. readonly RGB8_SNORM: number;
  69696. readonly RGBA8_SNORM: number;
  69697. readonly R8I: number;
  69698. readonly RG8I: number;
  69699. readonly RGB8I: number;
  69700. readonly RGBA8I: number;
  69701. readonly R8UI: number;
  69702. readonly RG8UI: number;
  69703. readonly RGB8UI: number;
  69704. readonly RGBA8UI: number;
  69705. readonly R16I: number;
  69706. readonly RG16I: number;
  69707. readonly RGB16I: number;
  69708. readonly RGBA16I: number;
  69709. readonly R16UI: number;
  69710. readonly RG16UI: number;
  69711. readonly RGB16UI: number;
  69712. readonly RGBA16UI: number;
  69713. readonly R32I: number;
  69714. readonly RG32I: number;
  69715. readonly RGB32I: number;
  69716. readonly RGBA32I: number;
  69717. readonly R32UI: number;
  69718. readonly RG32UI: number;
  69719. readonly RGB32UI: number;
  69720. readonly RGBA32UI: number;
  69721. readonly RGB10_A2UI: number;
  69722. readonly R11F_G11F_B10F: number;
  69723. readonly RGB9_E5: number;
  69724. readonly RGB10_A2: number;
  69725. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69726. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69727. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69728. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69729. readonly DEPTH_COMPONENT32F: number;
  69730. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69731. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69732. 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;
  69733. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69734. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69735. readonly TRANSFORM_FEEDBACK: number;
  69736. readonly INTERLEAVED_ATTRIBS: number;
  69737. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69738. createTransformFeedback(): WebGLTransformFeedback;
  69739. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69740. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69741. beginTransformFeedback(primitiveMode: number): void;
  69742. endTransformFeedback(): void;
  69743. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69744. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69745. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69746. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69747. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69748. }
  69749. interface ImageBitmap {
  69750. readonly width: number;
  69751. readonly height: number;
  69752. close(): void;
  69753. }
  69754. interface WebGLQuery extends WebGLObject {
  69755. }
  69756. declare var WebGLQuery: {
  69757. prototype: WebGLQuery;
  69758. new(): WebGLQuery;
  69759. };
  69760. interface WebGLSampler extends WebGLObject {
  69761. }
  69762. declare var WebGLSampler: {
  69763. prototype: WebGLSampler;
  69764. new(): WebGLSampler;
  69765. };
  69766. interface WebGLSync extends WebGLObject {
  69767. }
  69768. declare var WebGLSync: {
  69769. prototype: WebGLSync;
  69770. new(): WebGLSync;
  69771. };
  69772. interface WebGLTransformFeedback extends WebGLObject {
  69773. }
  69774. declare var WebGLTransformFeedback: {
  69775. prototype: WebGLTransformFeedback;
  69776. new(): WebGLTransformFeedback;
  69777. };
  69778. interface WebGLVertexArrayObject extends WebGLObject {
  69779. }
  69780. declare var WebGLVertexArrayObject: {
  69781. prototype: WebGLVertexArrayObject;
  69782. new(): WebGLVertexArrayObject;
  69783. };
  69784. // Type definitions for WebVR API
  69785. // Project: https://w3c.github.io/webvr/
  69786. // Definitions by: six a <https://github.com/lostfictions>
  69787. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69788. interface VRDisplay extends EventTarget {
  69789. /**
  69790. * Dictionary of capabilities describing the VRDisplay.
  69791. */
  69792. readonly capabilities: VRDisplayCapabilities;
  69793. /**
  69794. * z-depth defining the far plane of the eye view frustum
  69795. * enables mapping of values in the render target depth
  69796. * attachment to scene coordinates. Initially set to 10000.0.
  69797. */
  69798. depthFar: number;
  69799. /**
  69800. * z-depth defining the near plane of the eye view frustum
  69801. * enables mapping of values in the render target depth
  69802. * attachment to scene coordinates. Initially set to 0.01.
  69803. */
  69804. depthNear: number;
  69805. /**
  69806. * An identifier for this distinct VRDisplay. Used as an
  69807. * association point in the Gamepad API.
  69808. */
  69809. readonly displayId: number;
  69810. /**
  69811. * A display name, a user-readable name identifying it.
  69812. */
  69813. readonly displayName: string;
  69814. readonly isConnected: boolean;
  69815. readonly isPresenting: boolean;
  69816. /**
  69817. * If this VRDisplay supports room-scale experiences, the optional
  69818. * stage attribute contains details on the room-scale parameters.
  69819. */
  69820. readonly stageParameters: VRStageParameters | null;
  69821. /**
  69822. * Passing the value returned by `requestAnimationFrame` to
  69823. * `cancelAnimationFrame` will unregister the callback.
  69824. * @param handle Define the hanle of the request to cancel
  69825. */
  69826. cancelAnimationFrame(handle: number): void;
  69827. /**
  69828. * Stops presenting to the VRDisplay.
  69829. * @returns a promise to know when it stopped
  69830. */
  69831. exitPresent(): Promise<void>;
  69832. /**
  69833. * Return the current VREyeParameters for the given eye.
  69834. * @param whichEye Define the eye we want the parameter for
  69835. * @returns the eye parameters
  69836. */
  69837. getEyeParameters(whichEye: string): VREyeParameters;
  69838. /**
  69839. * Populates the passed VRFrameData with the information required to render
  69840. * the current frame.
  69841. * @param frameData Define the data structure to populate
  69842. * @returns true if ok otherwise false
  69843. */
  69844. getFrameData(frameData: VRFrameData): boolean;
  69845. /**
  69846. * Get the layers currently being presented.
  69847. * @returns the list of VR layers
  69848. */
  69849. getLayers(): VRLayer[];
  69850. /**
  69851. * Return a VRPose containing the future predicted pose of the VRDisplay
  69852. * when the current frame will be presented. The value returned will not
  69853. * change until JavaScript has returned control to the browser.
  69854. *
  69855. * The VRPose will contain the position, orientation, velocity,
  69856. * and acceleration of each of these properties.
  69857. * @returns the pose object
  69858. */
  69859. getPose(): VRPose;
  69860. /**
  69861. * Return the current instantaneous pose of the VRDisplay, with no
  69862. * prediction applied.
  69863. * @returns the current instantaneous pose
  69864. */
  69865. getImmediatePose(): VRPose;
  69866. /**
  69867. * The callback passed to `requestAnimationFrame` will be called
  69868. * any time a new frame should be rendered. When the VRDisplay is
  69869. * presenting the callback will be called at the native refresh
  69870. * rate of the HMD. When not presenting this function acts
  69871. * identically to how window.requestAnimationFrame acts. Content should
  69872. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69873. * asynchronously from other displays and at differing refresh rates.
  69874. * @param callback Define the eaction to run next frame
  69875. * @returns the request handle it
  69876. */
  69877. requestAnimationFrame(callback: FrameRequestCallback): number;
  69878. /**
  69879. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69880. * Repeat calls while already presenting will update the VRLayers being displayed.
  69881. * @param layers Define the list of layer to present
  69882. * @returns a promise to know when the request has been fulfilled
  69883. */
  69884. requestPresent(layers: VRLayer[]): Promise<void>;
  69885. /**
  69886. * Reset the pose for this display, treating its current position and
  69887. * orientation as the "origin/zero" values. VRPose.position,
  69888. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69889. * updated when calling resetPose(). This should be called in only
  69890. * sitting-space experiences.
  69891. */
  69892. resetPose(): void;
  69893. /**
  69894. * The VRLayer provided to the VRDisplay will be captured and presented
  69895. * in the HMD. Calling this function has the same effect on the source
  69896. * canvas as any other operation that uses its source image, and canvases
  69897. * created without preserveDrawingBuffer set to true will be cleared.
  69898. * @param pose Define the pose to submit
  69899. */
  69900. submitFrame(pose?: VRPose): void;
  69901. }
  69902. declare var VRDisplay: {
  69903. prototype: VRDisplay;
  69904. new(): VRDisplay;
  69905. };
  69906. interface VRLayer {
  69907. leftBounds?: number[] | Float32Array | null;
  69908. rightBounds?: number[] | Float32Array | null;
  69909. source?: HTMLCanvasElement | null;
  69910. }
  69911. interface VRDisplayCapabilities {
  69912. readonly canPresent: boolean;
  69913. readonly hasExternalDisplay: boolean;
  69914. readonly hasOrientation: boolean;
  69915. readonly hasPosition: boolean;
  69916. readonly maxLayers: number;
  69917. }
  69918. interface VREyeParameters {
  69919. /** @deprecated */
  69920. readonly fieldOfView: VRFieldOfView;
  69921. readonly offset: Float32Array;
  69922. readonly renderHeight: number;
  69923. readonly renderWidth: number;
  69924. }
  69925. interface VRFieldOfView {
  69926. readonly downDegrees: number;
  69927. readonly leftDegrees: number;
  69928. readonly rightDegrees: number;
  69929. readonly upDegrees: number;
  69930. }
  69931. interface VRFrameData {
  69932. readonly leftProjectionMatrix: Float32Array;
  69933. readonly leftViewMatrix: Float32Array;
  69934. readonly pose: VRPose;
  69935. readonly rightProjectionMatrix: Float32Array;
  69936. readonly rightViewMatrix: Float32Array;
  69937. readonly timestamp: number;
  69938. }
  69939. interface VRPose {
  69940. readonly angularAcceleration: Float32Array | null;
  69941. readonly angularVelocity: Float32Array | null;
  69942. readonly linearAcceleration: Float32Array | null;
  69943. readonly linearVelocity: Float32Array | null;
  69944. readonly orientation: Float32Array | null;
  69945. readonly position: Float32Array | null;
  69946. readonly timestamp: number;
  69947. }
  69948. interface VRStageParameters {
  69949. sittingToStandingTransform?: Float32Array;
  69950. sizeX?: number;
  69951. sizeY?: number;
  69952. }
  69953. interface Navigator {
  69954. getVRDisplays(): Promise<VRDisplay[]>;
  69955. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69956. }
  69957. interface Window {
  69958. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69959. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69960. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69961. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69962. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69963. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69964. }
  69965. interface Gamepad {
  69966. readonly displayId: number;
  69967. }
  69968. type XRSessionMode =
  69969. | "inline"
  69970. | "immersive-vr"
  69971. | "immersive-ar";
  69972. type XRReferenceSpaceType =
  69973. | "viewer"
  69974. | "local"
  69975. | "local-floor"
  69976. | "bounded-floor"
  69977. | "unbounded";
  69978. type XREnvironmentBlendMode =
  69979. | "opaque"
  69980. | "additive"
  69981. | "alpha-blend";
  69982. type XRVisibilityState =
  69983. | "visible"
  69984. | "visible-blurred"
  69985. | "hidden";
  69986. type XRHandedness =
  69987. | "none"
  69988. | "left"
  69989. | "right";
  69990. type XRTargetRayMode =
  69991. | "gaze"
  69992. | "tracked-pointer"
  69993. | "screen";
  69994. type XREye =
  69995. | "none"
  69996. | "left"
  69997. | "right";
  69998. interface XRSpace extends EventTarget {
  69999. }
  70000. interface XRRenderState {
  70001. depthNear?: number;
  70002. depthFar?: number;
  70003. inlineVerticalFieldOfView?: number;
  70004. baseLayer?: XRWebGLLayer;
  70005. }
  70006. interface XRInputSource {
  70007. handedness: XRHandedness;
  70008. targetRayMode: XRTargetRayMode;
  70009. targetRaySpace: XRSpace;
  70010. gripSpace: XRSpace | undefined;
  70011. gamepad: Gamepad | undefined;
  70012. profiles: Array<string>;
  70013. }
  70014. interface XRSessionInit {
  70015. optionalFeatures?: XRReferenceSpaceType[];
  70016. requiredFeatures?: XRReferenceSpaceType[];
  70017. }
  70018. interface XRSession extends XRAnchorCreator {
  70019. addEventListener: Function;
  70020. removeEventListener: Function;
  70021. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70022. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70023. requestAnimationFrame: Function;
  70024. end(): Promise<void>;
  70025. renderState: XRRenderState;
  70026. inputSources: Array<XRInputSource>;
  70027. // AR hit test
  70028. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70029. updateWorldTrackingState(options: {
  70030. planeDetectionState?: { enabled: boolean; }
  70031. }): void;
  70032. }
  70033. interface XRReferenceSpace extends XRSpace {
  70034. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70035. onreset: any;
  70036. }
  70037. type XRPlaneSet = Set<XRPlane>;
  70038. type XRAnchorSet = Set<XRAnchor>;
  70039. interface XRFrame {
  70040. session: XRSession;
  70041. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70042. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70043. // Anchors
  70044. trackedAnchors?: XRAnchorSet;
  70045. // Planes
  70046. worldInformation: {
  70047. detectedPlanes?: XRPlaneSet;
  70048. };
  70049. }
  70050. interface XRViewerPose extends XRPose {
  70051. views: Array<XRView>;
  70052. }
  70053. interface XRPose {
  70054. transform: XRRigidTransform;
  70055. emulatedPosition: boolean;
  70056. }
  70057. interface XRWebGLLayerOptions {
  70058. antialias?: boolean;
  70059. depth?: boolean;
  70060. stencil?: boolean;
  70061. alpha?: boolean;
  70062. multiview?: boolean;
  70063. framebufferScaleFactor?: number;
  70064. }
  70065. declare var XRWebGLLayer: {
  70066. prototype: XRWebGLLayer;
  70067. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70068. };
  70069. interface XRWebGLLayer {
  70070. framebuffer: WebGLFramebuffer;
  70071. framebufferWidth: number;
  70072. framebufferHeight: number;
  70073. getViewport: Function;
  70074. }
  70075. declare class XRRigidTransform {
  70076. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70077. position: DOMPointReadOnly;
  70078. orientation: DOMPointReadOnly;
  70079. matrix: Float32Array;
  70080. inverse: XRRigidTransform;
  70081. }
  70082. interface XRView {
  70083. eye: XREye;
  70084. projectionMatrix: Float32Array;
  70085. transform: XRRigidTransform;
  70086. }
  70087. interface XRInputSourceChangeEvent {
  70088. session: XRSession;
  70089. removed: Array<XRInputSource>;
  70090. added: Array<XRInputSource>;
  70091. }
  70092. interface XRInputSourceEvent extends Event {
  70093. readonly frame: XRFrame;
  70094. readonly inputSource: XRInputSource;
  70095. }
  70096. // Experimental(er) features
  70097. declare class XRRay {
  70098. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70099. origin: DOMPointReadOnly;
  70100. direction: DOMPointReadOnly;
  70101. matrix: Float32Array;
  70102. }
  70103. interface XRHitResult {
  70104. hitMatrix: Float32Array;
  70105. }
  70106. interface XRAnchor {
  70107. // remove?
  70108. id?: string;
  70109. anchorSpace: XRSpace;
  70110. lastChangedTime: number;
  70111. detach(): void;
  70112. }
  70113. interface XRPlane extends XRAnchorCreator {
  70114. orientation: "Horizontal" | "Vertical";
  70115. planeSpace: XRSpace;
  70116. polygon: Array<DOMPointReadOnly>;
  70117. lastChangedTime: number;
  70118. }
  70119. interface XRAnchorCreator {
  70120. // AR Anchors
  70121. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  70122. }
  70123. /**
  70124. * @ignore
  70125. */
  70126. declare module BABYLON.GLTF2.Exporter {
  70127. }
  70128. /**
  70129. * @ignore
  70130. */
  70131. declare module BABYLON.GLTF1 {
  70132. }
  70133. declare module BABYLON.GUI {
  70134. /**
  70135. * Class used to specific a value and its associated unit
  70136. */
  70137. export class ValueAndUnit {
  70138. /** defines the unit to store */
  70139. unit: number;
  70140. /** defines a boolean indicating if the value can be negative */
  70141. negativeValueAllowed: boolean;
  70142. private _value;
  70143. private _originalUnit;
  70144. /**
  70145. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70146. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70147. */
  70148. ignoreAdaptiveScaling: boolean;
  70149. /**
  70150. * Creates a new ValueAndUnit
  70151. * @param value defines the value to store
  70152. * @param unit defines the unit to store
  70153. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70154. */
  70155. constructor(value: number,
  70156. /** defines the unit to store */
  70157. unit?: number,
  70158. /** defines a boolean indicating if the value can be negative */
  70159. negativeValueAllowed?: boolean);
  70160. /** Gets a boolean indicating if the value is a percentage */
  70161. get isPercentage(): boolean;
  70162. /** Gets a boolean indicating if the value is store as pixel */
  70163. get isPixel(): boolean;
  70164. /** Gets direct internal value */
  70165. get internalValue(): number;
  70166. /**
  70167. * Gets value as pixel
  70168. * @param host defines the root host
  70169. * @param refValue defines the reference value for percentages
  70170. * @returns the value as pixel
  70171. */
  70172. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70173. /**
  70174. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70175. * @param value defines the value to store
  70176. * @param unit defines the unit to store
  70177. * @returns the current ValueAndUnit
  70178. */
  70179. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70180. /**
  70181. * Gets the value accordingly to its unit
  70182. * @param host defines the root host
  70183. * @returns the value
  70184. */
  70185. getValue(host: AdvancedDynamicTexture): number;
  70186. /**
  70187. * Gets a string representation of the value
  70188. * @param host defines the root host
  70189. * @param decimals defines an optional number of decimals to display
  70190. * @returns a string
  70191. */
  70192. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70193. /**
  70194. * Store a value parsed from a string
  70195. * @param source defines the source string
  70196. * @returns true if the value was successfully parsed
  70197. */
  70198. fromString(source: string | number): boolean;
  70199. private static _Regex;
  70200. private static _UNITMODE_PERCENTAGE;
  70201. private static _UNITMODE_PIXEL;
  70202. /** UNITMODE_PERCENTAGE */
  70203. static get UNITMODE_PERCENTAGE(): number;
  70204. /** UNITMODE_PIXEL */
  70205. static get UNITMODE_PIXEL(): number;
  70206. }
  70207. }
  70208. declare module BABYLON.GUI {
  70209. /**
  70210. * Define a style used by control to automatically setup properties based on a template.
  70211. * Only support font related properties so far
  70212. */
  70213. export class Style implements BABYLON.IDisposable {
  70214. private _fontFamily;
  70215. private _fontStyle;
  70216. private _fontWeight;
  70217. /** @hidden */
  70218. _host: AdvancedDynamicTexture;
  70219. /** @hidden */
  70220. _fontSize: ValueAndUnit;
  70221. /**
  70222. * BABYLON.Observable raised when the style values are changed
  70223. */
  70224. onChangedObservable: BABYLON.Observable<Style>;
  70225. /**
  70226. * Creates a new style object
  70227. * @param host defines the AdvancedDynamicTexture which hosts this style
  70228. */
  70229. constructor(host: AdvancedDynamicTexture);
  70230. /**
  70231. * Gets or sets the font size
  70232. */
  70233. get fontSize(): string | number;
  70234. set fontSize(value: string | number);
  70235. /**
  70236. * Gets or sets the font family
  70237. */
  70238. get fontFamily(): string;
  70239. set fontFamily(value: string);
  70240. /**
  70241. * Gets or sets the font style
  70242. */
  70243. get fontStyle(): string;
  70244. set fontStyle(value: string);
  70245. /** Gets or sets font weight */
  70246. get fontWeight(): string;
  70247. set fontWeight(value: string);
  70248. /** Dispose all associated resources */
  70249. dispose(): void;
  70250. }
  70251. }
  70252. declare module BABYLON.GUI {
  70253. /**
  70254. * Class used to transport BABYLON.Vector2 information for pointer events
  70255. */
  70256. export class Vector2WithInfo extends BABYLON.Vector2 {
  70257. /** defines the current mouse button index */
  70258. buttonIndex: number;
  70259. /**
  70260. * Creates a new Vector2WithInfo
  70261. * @param source defines the vector2 data to transport
  70262. * @param buttonIndex defines the current mouse button index
  70263. */
  70264. constructor(source: BABYLON.Vector2,
  70265. /** defines the current mouse button index */
  70266. buttonIndex?: number);
  70267. }
  70268. /** Class used to provide 2D matrix features */
  70269. export class Matrix2D {
  70270. /** Gets the internal array of 6 floats used to store matrix data */
  70271. m: Float32Array;
  70272. /**
  70273. * Creates a new matrix
  70274. * @param m00 defines value for (0, 0)
  70275. * @param m01 defines value for (0, 1)
  70276. * @param m10 defines value for (1, 0)
  70277. * @param m11 defines value for (1, 1)
  70278. * @param m20 defines value for (2, 0)
  70279. * @param m21 defines value for (2, 1)
  70280. */
  70281. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70282. /**
  70283. * Fills the matrix from direct values
  70284. * @param m00 defines value for (0, 0)
  70285. * @param m01 defines value for (0, 1)
  70286. * @param m10 defines value for (1, 0)
  70287. * @param m11 defines value for (1, 1)
  70288. * @param m20 defines value for (2, 0)
  70289. * @param m21 defines value for (2, 1)
  70290. * @returns the current modified matrix
  70291. */
  70292. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70293. /**
  70294. * Gets matrix determinant
  70295. * @returns the determinant
  70296. */
  70297. determinant(): number;
  70298. /**
  70299. * Inverses the matrix and stores it in a target matrix
  70300. * @param result defines the target matrix
  70301. * @returns the current matrix
  70302. */
  70303. invertToRef(result: Matrix2D): Matrix2D;
  70304. /**
  70305. * Multiplies the current matrix with another one
  70306. * @param other defines the second operand
  70307. * @param result defines the target matrix
  70308. * @returns the current matrix
  70309. */
  70310. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70311. /**
  70312. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70313. * @param x defines the x coordinate to transform
  70314. * @param y defines the x coordinate to transform
  70315. * @param result defines the target vector2
  70316. * @returns the current matrix
  70317. */
  70318. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70319. /**
  70320. * Creates an identity matrix
  70321. * @returns a new matrix
  70322. */
  70323. static Identity(): Matrix2D;
  70324. /**
  70325. * Creates a translation matrix and stores it in a target matrix
  70326. * @param x defines the x coordinate of the translation
  70327. * @param y defines the y coordinate of the translation
  70328. * @param result defines the target matrix
  70329. */
  70330. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70331. /**
  70332. * Creates a scaling matrix and stores it in a target matrix
  70333. * @param x defines the x coordinate of the scaling
  70334. * @param y defines the y coordinate of the scaling
  70335. * @param result defines the target matrix
  70336. */
  70337. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70338. /**
  70339. * Creates a rotation matrix and stores it in a target matrix
  70340. * @param angle defines the rotation angle
  70341. * @param result defines the target matrix
  70342. */
  70343. static RotationToRef(angle: number, result: Matrix2D): void;
  70344. private static _TempPreTranslationMatrix;
  70345. private static _TempPostTranslationMatrix;
  70346. private static _TempRotationMatrix;
  70347. private static _TempScalingMatrix;
  70348. private static _TempCompose0;
  70349. private static _TempCompose1;
  70350. private static _TempCompose2;
  70351. /**
  70352. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70353. * @param tx defines the x coordinate of the translation
  70354. * @param ty defines the y coordinate of the translation
  70355. * @param angle defines the rotation angle
  70356. * @param scaleX defines the x coordinate of the scaling
  70357. * @param scaleY defines the y coordinate of the scaling
  70358. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70359. * @param result defines the target matrix
  70360. */
  70361. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70362. }
  70363. }
  70364. declare module BABYLON.GUI {
  70365. /**
  70366. * Class used to store 2D control sizes
  70367. */
  70368. export class Measure {
  70369. /** defines left coordinate */
  70370. left: number;
  70371. /** defines top coordinate */
  70372. top: number;
  70373. /** defines width dimension */
  70374. width: number;
  70375. /** defines height dimension */
  70376. height: number;
  70377. /**
  70378. * Creates a new measure
  70379. * @param left defines left coordinate
  70380. * @param top defines top coordinate
  70381. * @param width defines width dimension
  70382. * @param height defines height dimension
  70383. */
  70384. constructor(
  70385. /** defines left coordinate */
  70386. left: number,
  70387. /** defines top coordinate */
  70388. top: number,
  70389. /** defines width dimension */
  70390. width: number,
  70391. /** defines height dimension */
  70392. height: number);
  70393. /**
  70394. * Copy from another measure
  70395. * @param other defines the other measure to copy from
  70396. */
  70397. copyFrom(other: Measure): void;
  70398. /**
  70399. * Copy from a group of 4 floats
  70400. * @param left defines left coordinate
  70401. * @param top defines top coordinate
  70402. * @param width defines width dimension
  70403. * @param height defines height dimension
  70404. */
  70405. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70406. /**
  70407. * Computes the axis aligned bounding box measure for two given measures
  70408. * @param a Input measure
  70409. * @param b Input measure
  70410. * @param result the resulting bounding measure
  70411. */
  70412. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70413. /**
  70414. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  70415. * @param transform the matrix to transform the measure before computing the AABB
  70416. * @param result the resulting AABB
  70417. */
  70418. transformToRef(transform: Matrix2D, result: Measure): void;
  70419. /**
  70420. * Check equality between this measure and another one
  70421. * @param other defines the other measures
  70422. * @returns true if both measures are equals
  70423. */
  70424. isEqualsTo(other: Measure): boolean;
  70425. /**
  70426. * Creates an empty measure
  70427. * @returns a new measure
  70428. */
  70429. static Empty(): Measure;
  70430. }
  70431. }
  70432. declare module BABYLON.GUI {
  70433. /**
  70434. * Interface used to define a control that can receive focus
  70435. */
  70436. export interface IFocusableControl {
  70437. /**
  70438. * Function called when the control receives the focus
  70439. */
  70440. onFocus(): void;
  70441. /**
  70442. * Function called when the control loses the focus
  70443. */
  70444. onBlur(): void;
  70445. /**
  70446. * Function called to let the control handle keyboard events
  70447. * @param evt defines the current keyboard event
  70448. */
  70449. processKeyboard(evt: KeyboardEvent): void;
  70450. /**
  70451. * Function called to get the list of controls that should not steal the focus from this control
  70452. * @returns an array of controls
  70453. */
  70454. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70455. }
  70456. /**
  70457. * Class used to create texture to support 2D GUI elements
  70458. * @see http://doc.babylonjs.com/how_to/gui
  70459. */
  70460. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70461. private _isDirty;
  70462. private _renderObserver;
  70463. private _resizeObserver;
  70464. private _preKeyboardObserver;
  70465. private _pointerMoveObserver;
  70466. private _pointerObserver;
  70467. private _canvasPointerOutObserver;
  70468. private _background;
  70469. /** @hidden */
  70470. _rootContainer: Container;
  70471. /** @hidden */
  70472. _lastPickedControl: Control;
  70473. /** @hidden */
  70474. _lastControlOver: {
  70475. [pointerId: number]: Control;
  70476. };
  70477. /** @hidden */
  70478. _lastControlDown: {
  70479. [pointerId: number]: Control;
  70480. };
  70481. /** @hidden */
  70482. _capturingControl: {
  70483. [pointerId: number]: Control;
  70484. };
  70485. /** @hidden */
  70486. _shouldBlockPointer: boolean;
  70487. /** @hidden */
  70488. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70489. /** @hidden */
  70490. _linkedControls: Control[];
  70491. private _isFullscreen;
  70492. private _fullscreenViewport;
  70493. private _idealWidth;
  70494. private _idealHeight;
  70495. private _useSmallestIdeal;
  70496. private _renderAtIdealSize;
  70497. private _focusedControl;
  70498. private _blockNextFocusCheck;
  70499. private _renderScale;
  70500. private _rootElement;
  70501. private _cursorChanged;
  70502. private _defaultMousePointerId;
  70503. /** @hidden */
  70504. _numLayoutCalls: number;
  70505. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70506. get numLayoutCalls(): number;
  70507. /** @hidden */
  70508. _numRenderCalls: number;
  70509. /** Gets the number of render calls made the last time the ADT has been rendered */
  70510. get numRenderCalls(): number;
  70511. /**
  70512. * Define type to string to ensure compatibility across browsers
  70513. * Safari doesn't support DataTransfer constructor
  70514. */
  70515. private _clipboardData;
  70516. /**
  70517. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70518. */
  70519. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70520. /**
  70521. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70522. */
  70523. onControlPickedObservable: BABYLON.Observable<Control>;
  70524. /**
  70525. * BABYLON.Observable event triggered before layout is evaluated
  70526. */
  70527. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70528. /**
  70529. * BABYLON.Observable event triggered after the layout was evaluated
  70530. */
  70531. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70532. /**
  70533. * BABYLON.Observable event triggered before the texture is rendered
  70534. */
  70535. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70536. /**
  70537. * BABYLON.Observable event triggered after the texture was rendered
  70538. */
  70539. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70540. /**
  70541. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70542. */
  70543. premulAlpha: boolean;
  70544. /**
  70545. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70546. * Useful when you want more antialiasing
  70547. */
  70548. get renderScale(): number;
  70549. set renderScale(value: number);
  70550. /** Gets or sets the background color */
  70551. get background(): string;
  70552. set background(value: string);
  70553. /**
  70554. * Gets or sets the ideal width used to design controls.
  70555. * The GUI will then rescale everything accordingly
  70556. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70557. */
  70558. get idealWidth(): number;
  70559. set idealWidth(value: number);
  70560. /**
  70561. * Gets or sets the ideal height used to design controls.
  70562. * The GUI will then rescale everything accordingly
  70563. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70564. */
  70565. get idealHeight(): number;
  70566. set idealHeight(value: number);
  70567. /**
  70568. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70569. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70570. */
  70571. get useSmallestIdeal(): boolean;
  70572. set useSmallestIdeal(value: boolean);
  70573. /**
  70574. * Gets or sets a boolean indicating if adaptive scaling must be used
  70575. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70576. */
  70577. get renderAtIdealSize(): boolean;
  70578. set renderAtIdealSize(value: boolean);
  70579. /**
  70580. * Gets the ratio used when in "ideal mode"
  70581. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70582. * */
  70583. get idealRatio(): number;
  70584. /**
  70585. * Gets the underlying layer used to render the texture when in fullscreen mode
  70586. */
  70587. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70588. /**
  70589. * Gets the root container control
  70590. */
  70591. get rootContainer(): Container;
  70592. /**
  70593. * Returns an array containing the root container.
  70594. * This is mostly used to let the Inspector introspects the ADT
  70595. * @returns an array containing the rootContainer
  70596. */
  70597. getChildren(): Array<Container>;
  70598. /**
  70599. * Will return all controls that are inside this texture
  70600. * @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
  70601. * @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
  70602. * @return all child controls
  70603. */
  70604. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70605. /**
  70606. * Gets or sets the current focused control
  70607. */
  70608. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70609. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70610. /**
  70611. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70612. */
  70613. get isForeground(): boolean;
  70614. set isForeground(value: boolean);
  70615. /**
  70616. * Gets or set information about clipboardData
  70617. */
  70618. get clipboardData(): string;
  70619. set clipboardData(value: string);
  70620. /**
  70621. * Creates a new AdvancedDynamicTexture
  70622. * @param name defines the name of the texture
  70623. * @param width defines the width of the texture
  70624. * @param height defines the height of the texture
  70625. * @param scene defines the hosting scene
  70626. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  70627. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  70628. */
  70629. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  70630. /**
  70631. * Get the current class name of the texture useful for serialization or dynamic coding.
  70632. * @returns "AdvancedDynamicTexture"
  70633. */
  70634. getClassName(): string;
  70635. /**
  70636. * Function used to execute a function on all controls
  70637. * @param func defines the function to execute
  70638. * @param container defines the container where controls belong. If null the root container will be used
  70639. */
  70640. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  70641. private _useInvalidateRectOptimization;
  70642. /**
  70643. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  70644. */
  70645. get useInvalidateRectOptimization(): boolean;
  70646. set useInvalidateRectOptimization(value: boolean);
  70647. private _invalidatedRectangle;
  70648. /**
  70649. * Invalidates a rectangle area on the gui texture
  70650. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  70651. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  70652. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  70653. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  70654. */
  70655. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  70656. /**
  70657. * Marks the texture as dirty forcing a complete update
  70658. */
  70659. markAsDirty(): void;
  70660. /**
  70661. * Helper function used to create a new style
  70662. * @returns a new style
  70663. * @see http://doc.babylonjs.com/how_to/gui#styles
  70664. */
  70665. createStyle(): Style;
  70666. /**
  70667. * Adds a new control to the root container
  70668. * @param control defines the control to add
  70669. * @returns the current texture
  70670. */
  70671. addControl(control: Control): AdvancedDynamicTexture;
  70672. /**
  70673. * Removes a control from the root container
  70674. * @param control defines the control to remove
  70675. * @returns the current texture
  70676. */
  70677. removeControl(control: Control): AdvancedDynamicTexture;
  70678. /**
  70679. * Release all resources
  70680. */
  70681. dispose(): void;
  70682. private _onResize;
  70683. /** @hidden */
  70684. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70685. /**
  70686. * Get screen coordinates for a vector3
  70687. * @param position defines the position to project
  70688. * @param worldMatrix defines the world matrix to use
  70689. * @returns the projected position
  70690. */
  70691. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70692. private _checkUpdate;
  70693. private _clearMeasure;
  70694. private _render;
  70695. /** @hidden */
  70696. _changeCursor(cursor: string): void;
  70697. /** @hidden */
  70698. _registerLastControlDown(control: Control, pointerId: number): void;
  70699. private _doPicking;
  70700. /** @hidden */
  70701. _cleanControlAfterRemovalFromList(list: {
  70702. [pointerId: number]: Control;
  70703. }, control: Control): void;
  70704. /** @hidden */
  70705. _cleanControlAfterRemoval(control: Control): void;
  70706. /** Attach to all scene events required to support pointer events */
  70707. attach(): void;
  70708. /** @hidden */
  70709. private onClipboardCopy;
  70710. /** @hidden */
  70711. private onClipboardCut;
  70712. /** @hidden */
  70713. private onClipboardPaste;
  70714. /**
  70715. * Register the clipboard Events onto the canvas
  70716. */
  70717. registerClipboardEvents(): void;
  70718. /**
  70719. * Unregister the clipboard Events from the canvas
  70720. */
  70721. unRegisterClipboardEvents(): void;
  70722. /**
  70723. * Connect the texture to a hosting mesh to enable interactions
  70724. * @param mesh defines the mesh to attach to
  70725. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70726. */
  70727. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70728. /**
  70729. * Move the focus to a specific control
  70730. * @param control defines the control which will receive the focus
  70731. */
  70732. moveFocusToControl(control: IFocusableControl): void;
  70733. private _manageFocus;
  70734. private _attachToOnPointerOut;
  70735. /**
  70736. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70737. * @param mesh defines the mesh which will receive the texture
  70738. * @param width defines the texture width (1024 by default)
  70739. * @param height defines the texture height (1024 by default)
  70740. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70741. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70742. * @returns a new AdvancedDynamicTexture
  70743. */
  70744. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70745. /**
  70746. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70747. * In this mode the texture will rely on a layer for its rendering.
  70748. * This allows it to be treated like any other layer.
  70749. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70750. * LayerMask is set through advancedTexture.layer.layerMask
  70751. * @param name defines name for the texture
  70752. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70753. * @param scene defines the hsoting scene
  70754. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70755. * @returns a new AdvancedDynamicTexture
  70756. */
  70757. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70758. }
  70759. }
  70760. declare module BABYLON.GUI {
  70761. /**
  70762. * Root class used for all 2D controls
  70763. * @see http://doc.babylonjs.com/how_to/gui#controls
  70764. */
  70765. export class Control {
  70766. /** defines the name of the control */
  70767. name?: string | undefined;
  70768. /**
  70769. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70770. */
  70771. static AllowAlphaInheritance: boolean;
  70772. private _alpha;
  70773. private _alphaSet;
  70774. private _zIndex;
  70775. /** @hidden */
  70776. _host: AdvancedDynamicTexture;
  70777. /** Gets or sets the control parent */
  70778. parent: BABYLON.Nullable<Container>;
  70779. /** @hidden */
  70780. _currentMeasure: Measure;
  70781. private _fontFamily;
  70782. private _fontStyle;
  70783. private _fontWeight;
  70784. private _fontSize;
  70785. private _font;
  70786. /** @hidden */
  70787. _width: ValueAndUnit;
  70788. /** @hidden */
  70789. _height: ValueAndUnit;
  70790. /** @hidden */
  70791. protected _fontOffset: {
  70792. ascent: number;
  70793. height: number;
  70794. descent: number;
  70795. };
  70796. private _color;
  70797. private _style;
  70798. private _styleObserver;
  70799. /** @hidden */
  70800. protected _horizontalAlignment: number;
  70801. /** @hidden */
  70802. protected _verticalAlignment: number;
  70803. /** @hidden */
  70804. protected _isDirty: boolean;
  70805. /** @hidden */
  70806. protected _wasDirty: boolean;
  70807. /** @hidden */
  70808. _tempParentMeasure: Measure;
  70809. /** @hidden */
  70810. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70811. /** @hidden */
  70812. protected _cachedParentMeasure: Measure;
  70813. private _paddingLeft;
  70814. private _paddingRight;
  70815. private _paddingTop;
  70816. private _paddingBottom;
  70817. /** @hidden */
  70818. _left: ValueAndUnit;
  70819. /** @hidden */
  70820. _top: ValueAndUnit;
  70821. private _scaleX;
  70822. private _scaleY;
  70823. private _rotation;
  70824. private _transformCenterX;
  70825. private _transformCenterY;
  70826. /** @hidden */
  70827. _transformMatrix: Matrix2D;
  70828. /** @hidden */
  70829. protected _invertTransformMatrix: Matrix2D;
  70830. /** @hidden */
  70831. protected _transformedPosition: BABYLON.Vector2;
  70832. private _isMatrixDirty;
  70833. private _cachedOffsetX;
  70834. private _cachedOffsetY;
  70835. private _isVisible;
  70836. private _isHighlighted;
  70837. /** @hidden */
  70838. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70839. private _fontSet;
  70840. private _dummyVector2;
  70841. private _downCount;
  70842. private _enterCount;
  70843. private _doNotRender;
  70844. private _downPointerIds;
  70845. protected _isEnabled: boolean;
  70846. protected _disabledColor: string;
  70847. protected _disabledColorItem: string;
  70848. /** @hidden */
  70849. protected _rebuildLayout: boolean;
  70850. /** @hidden */
  70851. _customData: any;
  70852. /** @hidden */
  70853. _isClipped: boolean;
  70854. /** @hidden */
  70855. _automaticSize: boolean;
  70856. /** @hidden */
  70857. _tag: any;
  70858. /**
  70859. * 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
  70860. */
  70861. uniqueId: number;
  70862. /**
  70863. * Gets or sets an object used to store user defined information for the node
  70864. */
  70865. metadata: any;
  70866. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70867. isHitTestVisible: boolean;
  70868. /** Gets or sets a boolean indicating if the control can block pointer events */
  70869. isPointerBlocker: boolean;
  70870. /** Gets or sets a boolean indicating if the control can be focusable */
  70871. isFocusInvisible: boolean;
  70872. /**
  70873. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70874. * 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
  70875. */
  70876. clipChildren: boolean;
  70877. /**
  70878. * Gets or sets a boolean indicating that control content must be clipped
  70879. * 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
  70880. */
  70881. clipContent: boolean;
  70882. /**
  70883. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70884. */
  70885. useBitmapCache: boolean;
  70886. private _cacheData;
  70887. private _shadowOffsetX;
  70888. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70889. get shadowOffsetX(): number;
  70890. set shadowOffsetX(value: number);
  70891. private _shadowOffsetY;
  70892. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70893. get shadowOffsetY(): number;
  70894. set shadowOffsetY(value: number);
  70895. private _shadowBlur;
  70896. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70897. get shadowBlur(): number;
  70898. set shadowBlur(value: number);
  70899. private _shadowColor;
  70900. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70901. get shadowColor(): string;
  70902. set shadowColor(value: string);
  70903. /** Gets or sets the cursor to use when the control is hovered */
  70904. hoverCursor: string;
  70905. /** @hidden */
  70906. protected _linkOffsetX: ValueAndUnit;
  70907. /** @hidden */
  70908. protected _linkOffsetY: ValueAndUnit;
  70909. /** Gets the control type name */
  70910. get typeName(): string;
  70911. /**
  70912. * Get the current class name of the control.
  70913. * @returns current class name
  70914. */
  70915. getClassName(): string;
  70916. /**
  70917. * An event triggered when pointer wheel is scrolled
  70918. */
  70919. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  70920. /**
  70921. * An event triggered when the pointer move over the control.
  70922. */
  70923. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70924. /**
  70925. * An event triggered when the pointer move out of the control.
  70926. */
  70927. onPointerOutObservable: BABYLON.Observable<Control>;
  70928. /**
  70929. * An event triggered when the pointer taps the control
  70930. */
  70931. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70932. /**
  70933. * An event triggered when pointer up
  70934. */
  70935. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70936. /**
  70937. * An event triggered when a control is clicked on
  70938. */
  70939. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70940. /**
  70941. * An event triggered when pointer enters the control
  70942. */
  70943. onPointerEnterObservable: BABYLON.Observable<Control>;
  70944. /**
  70945. * An event triggered when the control is marked as dirty
  70946. */
  70947. onDirtyObservable: BABYLON.Observable<Control>;
  70948. /**
  70949. * An event triggered before drawing the control
  70950. */
  70951. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70952. /**
  70953. * An event triggered after the control was drawn
  70954. */
  70955. onAfterDrawObservable: BABYLON.Observable<Control>;
  70956. /**
  70957. * Get the hosting AdvancedDynamicTexture
  70958. */
  70959. get host(): AdvancedDynamicTexture;
  70960. /** Gets or set information about font offsets (used to render and align text) */
  70961. get fontOffset(): {
  70962. ascent: number;
  70963. height: number;
  70964. descent: number;
  70965. };
  70966. set fontOffset(offset: {
  70967. ascent: number;
  70968. height: number;
  70969. descent: number;
  70970. });
  70971. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70972. get alpha(): number;
  70973. set alpha(value: number);
  70974. /**
  70975. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70976. */
  70977. get isHighlighted(): boolean;
  70978. set isHighlighted(value: boolean);
  70979. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70980. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70981. */
  70982. get scaleX(): number;
  70983. set scaleX(value: number);
  70984. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70985. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70986. */
  70987. get scaleY(): number;
  70988. set scaleY(value: number);
  70989. /** Gets or sets the rotation angle (0 by default)
  70990. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70991. */
  70992. get rotation(): number;
  70993. set rotation(value: number);
  70994. /** Gets or sets the transformation center on Y axis (0 by default)
  70995. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70996. */
  70997. get transformCenterY(): number;
  70998. set transformCenterY(value: number);
  70999. /** Gets or sets the transformation center on X axis (0 by default)
  71000. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71001. */
  71002. get transformCenterX(): number;
  71003. set transformCenterX(value: number);
  71004. /**
  71005. * Gets or sets the horizontal alignment
  71006. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71007. */
  71008. get horizontalAlignment(): number;
  71009. set horizontalAlignment(value: number);
  71010. /**
  71011. * Gets or sets the vertical alignment
  71012. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71013. */
  71014. get verticalAlignment(): number;
  71015. set verticalAlignment(value: number);
  71016. /**
  71017. * Gets or sets control width
  71018. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71019. */
  71020. get width(): string | number;
  71021. set width(value: string | number);
  71022. /**
  71023. * Gets or sets the control width in pixel
  71024. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71025. */
  71026. get widthInPixels(): number;
  71027. set widthInPixels(value: number);
  71028. /**
  71029. * Gets or sets control height
  71030. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71031. */
  71032. get height(): string | number;
  71033. set height(value: string | number);
  71034. /**
  71035. * Gets or sets control height in pixel
  71036. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71037. */
  71038. get heightInPixels(): number;
  71039. set heightInPixels(value: number);
  71040. /** Gets or set font family */
  71041. get fontFamily(): string;
  71042. set fontFamily(value: string);
  71043. /** Gets or sets font style */
  71044. get fontStyle(): string;
  71045. set fontStyle(value: string);
  71046. /** Gets or sets font weight */
  71047. get fontWeight(): string;
  71048. set fontWeight(value: string);
  71049. /**
  71050. * Gets or sets style
  71051. * @see http://doc.babylonjs.com/how_to/gui#styles
  71052. */
  71053. get style(): BABYLON.Nullable<Style>;
  71054. set style(value: BABYLON.Nullable<Style>);
  71055. /** @hidden */
  71056. get _isFontSizeInPercentage(): boolean;
  71057. /** Gets or sets font size in pixels */
  71058. get fontSizeInPixels(): number;
  71059. set fontSizeInPixels(value: number);
  71060. /** Gets or sets font size */
  71061. get fontSize(): string | number;
  71062. set fontSize(value: string | number);
  71063. /** Gets or sets foreground color */
  71064. get color(): string;
  71065. set color(value: string);
  71066. /** Gets or sets z index which is used to reorder controls on the z axis */
  71067. get zIndex(): number;
  71068. set zIndex(value: number);
  71069. /** Gets or sets a boolean indicating if the control can be rendered */
  71070. get notRenderable(): boolean;
  71071. set notRenderable(value: boolean);
  71072. /** Gets or sets a boolean indicating if the control is visible */
  71073. get isVisible(): boolean;
  71074. set isVisible(value: boolean);
  71075. /** Gets a boolean indicating that the control needs to update its rendering */
  71076. get isDirty(): boolean;
  71077. /**
  71078. * Gets the current linked mesh (or null if none)
  71079. */
  71080. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71081. /**
  71082. * Gets or sets a value indicating the padding to use on the left of the control
  71083. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71084. */
  71085. get paddingLeft(): string | number;
  71086. set paddingLeft(value: string | number);
  71087. /**
  71088. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71089. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71090. */
  71091. get paddingLeftInPixels(): number;
  71092. set paddingLeftInPixels(value: number);
  71093. /**
  71094. * Gets or sets a value indicating the padding to use on the right of the control
  71095. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71096. */
  71097. get paddingRight(): string | number;
  71098. set paddingRight(value: string | number);
  71099. /**
  71100. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71101. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71102. */
  71103. get paddingRightInPixels(): number;
  71104. set paddingRightInPixels(value: number);
  71105. /**
  71106. * Gets or sets a value indicating the padding to use on the top of the control
  71107. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71108. */
  71109. get paddingTop(): string | number;
  71110. set paddingTop(value: string | number);
  71111. /**
  71112. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71113. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71114. */
  71115. get paddingTopInPixels(): number;
  71116. set paddingTopInPixels(value: number);
  71117. /**
  71118. * Gets or sets a value indicating the padding to use on the bottom of the control
  71119. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71120. */
  71121. get paddingBottom(): string | number;
  71122. set paddingBottom(value: string | number);
  71123. /**
  71124. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  71125. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71126. */
  71127. get paddingBottomInPixels(): number;
  71128. set paddingBottomInPixels(value: number);
  71129. /**
  71130. * Gets or sets a value indicating the left coordinate of the control
  71131. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71132. */
  71133. get left(): string | number;
  71134. set left(value: string | number);
  71135. /**
  71136. * Gets or sets a value indicating the left coordinate in pixels of the control
  71137. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71138. */
  71139. get leftInPixels(): number;
  71140. set leftInPixels(value: number);
  71141. /**
  71142. * Gets or sets a value indicating the top coordinate of the control
  71143. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71144. */
  71145. get top(): string | number;
  71146. set top(value: string | number);
  71147. /**
  71148. * Gets or sets a value indicating the top coordinate in pixels of the control
  71149. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71150. */
  71151. get topInPixels(): number;
  71152. set topInPixels(value: number);
  71153. /**
  71154. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71155. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71156. */
  71157. get linkOffsetX(): string | number;
  71158. set linkOffsetX(value: string | number);
  71159. /**
  71160. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71161. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71162. */
  71163. get linkOffsetXInPixels(): number;
  71164. set linkOffsetXInPixels(value: number);
  71165. /**
  71166. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71167. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71168. */
  71169. get linkOffsetY(): string | number;
  71170. set linkOffsetY(value: string | number);
  71171. /**
  71172. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71173. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71174. */
  71175. get linkOffsetYInPixels(): number;
  71176. set linkOffsetYInPixels(value: number);
  71177. /** Gets the center coordinate on X axis */
  71178. get centerX(): number;
  71179. /** Gets the center coordinate on Y axis */
  71180. get centerY(): number;
  71181. /** Gets or sets if control is Enabled*/
  71182. get isEnabled(): boolean;
  71183. set isEnabled(value: boolean);
  71184. /** Gets or sets background color of control if it's disabled*/
  71185. get disabledColor(): string;
  71186. set disabledColor(value: string);
  71187. /** Gets or sets front color of control if it's disabled*/
  71188. get disabledColorItem(): string;
  71189. set disabledColorItem(value: string);
  71190. /**
  71191. * Creates a new control
  71192. * @param name defines the name of the control
  71193. */
  71194. constructor(
  71195. /** defines the name of the control */
  71196. name?: string | undefined);
  71197. /** @hidden */
  71198. protected _getTypeName(): string;
  71199. /**
  71200. * Gets the first ascendant in the hierarchy of the given type
  71201. * @param className defines the required type
  71202. * @returns the ascendant or null if not found
  71203. */
  71204. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71205. /** @hidden */
  71206. _resetFontCache(): void;
  71207. /**
  71208. * Determines if a container is an ascendant of the current control
  71209. * @param container defines the container to look for
  71210. * @returns true if the container is one of the ascendant of the control
  71211. */
  71212. isAscendant(container: Control): boolean;
  71213. /**
  71214. * Gets coordinates in local control space
  71215. * @param globalCoordinates defines the coordinates to transform
  71216. * @returns the new coordinates in local space
  71217. */
  71218. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71219. /**
  71220. * Gets coordinates in local control space
  71221. * @param globalCoordinates defines the coordinates to transform
  71222. * @param result defines the target vector2 where to store the result
  71223. * @returns the current control
  71224. */
  71225. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71226. /**
  71227. * Gets coordinates in parent local control space
  71228. * @param globalCoordinates defines the coordinates to transform
  71229. * @returns the new coordinates in parent local space
  71230. */
  71231. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71232. /**
  71233. * Move the current control to a vector3 position projected onto the screen.
  71234. * @param position defines the target position
  71235. * @param scene defines the hosting scene
  71236. */
  71237. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71238. /**
  71239. * Will store all controls that have this control as ascendant in a given array
  71240. * @param results defines the array where to store the descendants
  71241. * @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
  71242. * @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
  71243. */
  71244. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71245. /**
  71246. * Will return all controls that have this control as ascendant
  71247. * @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
  71248. * @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
  71249. * @return all child controls
  71250. */
  71251. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71252. /**
  71253. * Link current control with a target mesh
  71254. * @param mesh defines the mesh to link with
  71255. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71256. */
  71257. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71258. /** @hidden */
  71259. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71260. /** @hidden */
  71261. _offsetLeft(offset: number): void;
  71262. /** @hidden */
  71263. _offsetTop(offset: number): void;
  71264. /** @hidden */
  71265. _markMatrixAsDirty(): void;
  71266. /** @hidden */
  71267. _flagDescendantsAsMatrixDirty(): void;
  71268. /** @hidden */
  71269. _intersectsRect(rect: Measure): boolean;
  71270. /** @hidden */
  71271. protected invalidateRect(): void;
  71272. /** @hidden */
  71273. _markAsDirty(force?: boolean): void;
  71274. /** @hidden */
  71275. _markAllAsDirty(): void;
  71276. /** @hidden */
  71277. _link(host: AdvancedDynamicTexture): void;
  71278. /** @hidden */
  71279. protected _transform(context?: CanvasRenderingContext2D): void;
  71280. /** @hidden */
  71281. _renderHighlight(context: CanvasRenderingContext2D): void;
  71282. /** @hidden */
  71283. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71284. /** @hidden */
  71285. protected _applyStates(context: CanvasRenderingContext2D): void;
  71286. /** @hidden */
  71287. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71288. /** @hidden */
  71289. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71290. protected _evaluateClippingState(parentMeasure: Measure): void;
  71291. /** @hidden */
  71292. _measure(): void;
  71293. /** @hidden */
  71294. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71295. /** @hidden */
  71296. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71297. /** @hidden */
  71298. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71299. /** @hidden */
  71300. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71301. private static _ClipMeasure;
  71302. private _tmpMeasureA;
  71303. private _clip;
  71304. /** @hidden */
  71305. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71306. /** @hidden */
  71307. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71308. /**
  71309. * Tests if a given coordinates belong to the current control
  71310. * @param x defines x coordinate to test
  71311. * @param y defines y coordinate to test
  71312. * @returns true if the coordinates are inside the control
  71313. */
  71314. contains(x: number, y: number): boolean;
  71315. /** @hidden */
  71316. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71317. /** @hidden */
  71318. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71319. /** @hidden */
  71320. _onPointerEnter(target: Control): boolean;
  71321. /** @hidden */
  71322. _onPointerOut(target: Control, force?: boolean): void;
  71323. /** @hidden */
  71324. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71325. /** @hidden */
  71326. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71327. /** @hidden */
  71328. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71329. /** @hidden */
  71330. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  71331. /** @hidden */
  71332. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71333. private _prepareFont;
  71334. /** Releases associated resources */
  71335. dispose(): void;
  71336. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71337. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71338. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71339. private static _VERTICAL_ALIGNMENT_TOP;
  71340. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71341. private static _VERTICAL_ALIGNMENT_CENTER;
  71342. /** HORIZONTAL_ALIGNMENT_LEFT */
  71343. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71344. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71345. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71346. /** HORIZONTAL_ALIGNMENT_CENTER */
  71347. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71348. /** VERTICAL_ALIGNMENT_TOP */
  71349. static get VERTICAL_ALIGNMENT_TOP(): number;
  71350. /** VERTICAL_ALIGNMENT_BOTTOM */
  71351. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71352. /** VERTICAL_ALIGNMENT_CENTER */
  71353. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71354. private static _FontHeightSizes;
  71355. /** @hidden */
  71356. static _GetFontOffset(font: string): {
  71357. ascent: number;
  71358. height: number;
  71359. descent: number;
  71360. };
  71361. /**
  71362. * Creates a stack panel that can be used to render headers
  71363. * @param control defines the control to associate with the header
  71364. * @param text defines the text of the header
  71365. * @param size defines the size of the header
  71366. * @param options defines options used to configure the header
  71367. * @returns a new StackPanel
  71368. * @ignore
  71369. * @hidden
  71370. */
  71371. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71372. isHorizontal: boolean;
  71373. controlFirst: boolean;
  71374. }) => any;
  71375. /** @hidden */
  71376. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71377. }
  71378. }
  71379. declare module BABYLON.GUI {
  71380. /**
  71381. * Root class for 2D containers
  71382. * @see http://doc.babylonjs.com/how_to/gui#containers
  71383. */
  71384. export class Container extends Control {
  71385. name?: string | undefined;
  71386. /** @hidden */
  71387. _children: Control[];
  71388. /** @hidden */
  71389. protected _measureForChildren: Measure;
  71390. /** @hidden */
  71391. protected _background: string;
  71392. /** @hidden */
  71393. protected _adaptWidthToChildren: boolean;
  71394. /** @hidden */
  71395. protected _adaptHeightToChildren: boolean;
  71396. /**
  71397. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71398. */
  71399. logLayoutCycleErrors: boolean;
  71400. /**
  71401. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71402. */
  71403. maxLayoutCycle: number;
  71404. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71405. get adaptHeightToChildren(): boolean;
  71406. set adaptHeightToChildren(value: boolean);
  71407. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71408. get adaptWidthToChildren(): boolean;
  71409. set adaptWidthToChildren(value: boolean);
  71410. /** Gets or sets background color */
  71411. get background(): string;
  71412. set background(value: string);
  71413. /** Gets the list of children */
  71414. get children(): Control[];
  71415. /**
  71416. * Creates a new Container
  71417. * @param name defines the name of the container
  71418. */
  71419. constructor(name?: string | undefined);
  71420. protected _getTypeName(): string;
  71421. _flagDescendantsAsMatrixDirty(): void;
  71422. /**
  71423. * Gets a child using its name
  71424. * @param name defines the child name to look for
  71425. * @returns the child control if found
  71426. */
  71427. getChildByName(name: string): BABYLON.Nullable<Control>;
  71428. /**
  71429. * Gets a child using its type and its name
  71430. * @param name defines the child name to look for
  71431. * @param type defines the child type to look for
  71432. * @returns the child control if found
  71433. */
  71434. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  71435. /**
  71436. * Search for a specific control in children
  71437. * @param control defines the control to look for
  71438. * @returns true if the control is in child list
  71439. */
  71440. containsControl(control: Control): boolean;
  71441. /**
  71442. * Adds a new control to the current container
  71443. * @param control defines the control to add
  71444. * @returns the current container
  71445. */
  71446. addControl(control: BABYLON.Nullable<Control>): Container;
  71447. /**
  71448. * Removes all controls from the current container
  71449. * @returns the current container
  71450. */
  71451. clearControls(): Container;
  71452. /**
  71453. * Removes a control from the current container
  71454. * @param control defines the control to remove
  71455. * @returns the current container
  71456. */
  71457. removeControl(control: Control): Container;
  71458. /** @hidden */
  71459. _reOrderControl(control: Control): void;
  71460. /** @hidden */
  71461. _offsetLeft(offset: number): void;
  71462. /** @hidden */
  71463. _offsetTop(offset: number): void;
  71464. /** @hidden */
  71465. _markAllAsDirty(): void;
  71466. /** @hidden */
  71467. protected _localDraw(context: CanvasRenderingContext2D): void;
  71468. /** @hidden */
  71469. _link(host: AdvancedDynamicTexture): void;
  71470. /** @hidden */
  71471. protected _beforeLayout(): void;
  71472. /** @hidden */
  71473. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71474. /** @hidden */
  71475. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71476. protected _postMeasure(): void;
  71477. /** @hidden */
  71478. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71479. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71480. /** @hidden */
  71481. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71482. /** @hidden */
  71483. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71484. /** Releases associated resources */
  71485. dispose(): void;
  71486. }
  71487. }
  71488. declare module BABYLON.GUI {
  71489. /** Class used to create rectangle container */
  71490. export class Rectangle extends Container {
  71491. name?: string | undefined;
  71492. private _thickness;
  71493. private _cornerRadius;
  71494. /** Gets or sets border thickness */
  71495. get thickness(): number;
  71496. set thickness(value: number);
  71497. /** Gets or sets the corner radius angle */
  71498. get cornerRadius(): number;
  71499. set cornerRadius(value: number);
  71500. /**
  71501. * Creates a new Rectangle
  71502. * @param name defines the control name
  71503. */
  71504. constructor(name?: string | undefined);
  71505. protected _getTypeName(): string;
  71506. protected _localDraw(context: CanvasRenderingContext2D): void;
  71507. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71508. private _drawRoundedRect;
  71509. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71510. }
  71511. }
  71512. declare module BABYLON.GUI {
  71513. /**
  71514. * Enum that determines the text-wrapping mode to use.
  71515. */
  71516. export enum TextWrapping {
  71517. /**
  71518. * Clip the text when it's larger than Control.width; this is the default mode.
  71519. */
  71520. Clip = 0,
  71521. /**
  71522. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71523. */
  71524. WordWrap = 1,
  71525. /**
  71526. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71527. */
  71528. Ellipsis = 2
  71529. }
  71530. /**
  71531. * Class used to create text block control
  71532. */
  71533. export class TextBlock extends Control {
  71534. /**
  71535. * Defines the name of the control
  71536. */
  71537. name?: string | undefined;
  71538. private _text;
  71539. private _textWrapping;
  71540. private _textHorizontalAlignment;
  71541. private _textVerticalAlignment;
  71542. private _lines;
  71543. private _resizeToFit;
  71544. private _lineSpacing;
  71545. private _outlineWidth;
  71546. private _outlineColor;
  71547. /**
  71548. * An event triggered after the text is changed
  71549. */
  71550. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71551. /**
  71552. * An event triggered after the text was broken up into lines
  71553. */
  71554. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71555. /**
  71556. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71557. */
  71558. get lines(): any[];
  71559. /**
  71560. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71561. */
  71562. get resizeToFit(): boolean;
  71563. /**
  71564. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71565. */
  71566. set resizeToFit(value: boolean);
  71567. /**
  71568. * Gets or sets a boolean indicating if text must be wrapped
  71569. */
  71570. get textWrapping(): TextWrapping | boolean;
  71571. /**
  71572. * Gets or sets a boolean indicating if text must be wrapped
  71573. */
  71574. set textWrapping(value: TextWrapping | boolean);
  71575. /**
  71576. * Gets or sets text to display
  71577. */
  71578. get text(): string;
  71579. /**
  71580. * Gets or sets text to display
  71581. */
  71582. set text(value: string);
  71583. /**
  71584. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71585. */
  71586. get textHorizontalAlignment(): number;
  71587. /**
  71588. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71589. */
  71590. set textHorizontalAlignment(value: number);
  71591. /**
  71592. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71593. */
  71594. get textVerticalAlignment(): number;
  71595. /**
  71596. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71597. */
  71598. set textVerticalAlignment(value: number);
  71599. /**
  71600. * Gets or sets line spacing value
  71601. */
  71602. set lineSpacing(value: string | number);
  71603. /**
  71604. * Gets or sets line spacing value
  71605. */
  71606. get lineSpacing(): string | number;
  71607. /**
  71608. * Gets or sets outlineWidth of the text to display
  71609. */
  71610. get outlineWidth(): number;
  71611. /**
  71612. * Gets or sets outlineWidth of the text to display
  71613. */
  71614. set outlineWidth(value: number);
  71615. /**
  71616. * Gets or sets outlineColor of the text to display
  71617. */
  71618. get outlineColor(): string;
  71619. /**
  71620. * Gets or sets outlineColor of the text to display
  71621. */
  71622. set outlineColor(value: string);
  71623. /**
  71624. * Creates a new TextBlock object
  71625. * @param name defines the name of the control
  71626. * @param text defines the text to display (emptry string by default)
  71627. */
  71628. constructor(
  71629. /**
  71630. * Defines the name of the control
  71631. */
  71632. name?: string | undefined, text?: string);
  71633. protected _getTypeName(): string;
  71634. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71635. private _drawText;
  71636. /** @hidden */
  71637. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71638. protected _applyStates(context: CanvasRenderingContext2D): void;
  71639. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  71640. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  71641. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  71642. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  71643. protected _renderLines(context: CanvasRenderingContext2D): void;
  71644. /**
  71645. * Given a width constraint applied on the text block, find the expected height
  71646. * @returns expected height
  71647. */
  71648. computeExpectedHeight(): number;
  71649. dispose(): void;
  71650. }
  71651. }
  71652. declare module BABYLON.GUI {
  71653. /**
  71654. * Class used to create 2D images
  71655. */
  71656. export class Image extends Control {
  71657. name?: string | undefined;
  71658. private _workingCanvas;
  71659. private _domImage;
  71660. private _imageWidth;
  71661. private _imageHeight;
  71662. private _loaded;
  71663. private _stretch;
  71664. private _source;
  71665. private _autoScale;
  71666. private _sourceLeft;
  71667. private _sourceTop;
  71668. private _sourceWidth;
  71669. private _sourceHeight;
  71670. private _svgAttributesComputationCompleted;
  71671. private _isSVG;
  71672. private _cellWidth;
  71673. private _cellHeight;
  71674. private _cellId;
  71675. private _populateNinePatchSlicesFromImage;
  71676. private _sliceLeft;
  71677. private _sliceRight;
  71678. private _sliceTop;
  71679. private _sliceBottom;
  71680. private _detectPointerOnOpaqueOnly;
  71681. /**
  71682. * BABYLON.Observable notified when the content is loaded
  71683. */
  71684. onImageLoadedObservable: BABYLON.Observable<Image>;
  71685. /**
  71686. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  71687. */
  71688. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  71689. /**
  71690. * Gets a boolean indicating that the content is loaded
  71691. */
  71692. get isLoaded(): boolean;
  71693. /**
  71694. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71695. */
  71696. get populateNinePatchSlicesFromImage(): boolean;
  71697. set populateNinePatchSlicesFromImage(value: boolean);
  71698. /**
  71699. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71700. * Beware using this as this will comsume more memory as the image has to be stored twice
  71701. */
  71702. get detectPointerOnOpaqueOnly(): boolean;
  71703. set detectPointerOnOpaqueOnly(value: boolean);
  71704. /**
  71705. * Gets or sets the left value for slicing (9-patch)
  71706. */
  71707. get sliceLeft(): number;
  71708. set sliceLeft(value: number);
  71709. /**
  71710. * Gets or sets the right value for slicing (9-patch)
  71711. */
  71712. get sliceRight(): number;
  71713. set sliceRight(value: number);
  71714. /**
  71715. * Gets or sets the top value for slicing (9-patch)
  71716. */
  71717. get sliceTop(): number;
  71718. set sliceTop(value: number);
  71719. /**
  71720. * Gets or sets the bottom value for slicing (9-patch)
  71721. */
  71722. get sliceBottom(): number;
  71723. set sliceBottom(value: number);
  71724. /**
  71725. * Gets or sets the left coordinate in the source image
  71726. */
  71727. get sourceLeft(): number;
  71728. set sourceLeft(value: number);
  71729. /**
  71730. * Gets or sets the top coordinate in the source image
  71731. */
  71732. get sourceTop(): number;
  71733. set sourceTop(value: number);
  71734. /**
  71735. * Gets or sets the width to capture in the source image
  71736. */
  71737. get sourceWidth(): number;
  71738. set sourceWidth(value: number);
  71739. /**
  71740. * Gets or sets the height to capture in the source image
  71741. */
  71742. get sourceHeight(): number;
  71743. set sourceHeight(value: number);
  71744. /** Indicates if the format of the image is SVG */
  71745. get isSVG(): boolean;
  71746. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  71747. get svgAttributesComputationCompleted(): boolean;
  71748. /**
  71749. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71750. * @see http://doc.babylonjs.com/how_to/gui#image
  71751. */
  71752. get autoScale(): boolean;
  71753. set autoScale(value: boolean);
  71754. /** Gets or sets the streching mode used by the image */
  71755. get stretch(): number;
  71756. set stretch(value: number);
  71757. /** @hidden */
  71758. _rotate90(n: number, preserveProperties?: boolean): Image;
  71759. private _handleRotationForSVGImage;
  71760. private _rotate90SourceProperties;
  71761. /**
  71762. * Gets or sets the internal DOM image used to render the control
  71763. */
  71764. set domImage(value: HTMLImageElement);
  71765. get domImage(): HTMLImageElement;
  71766. private _onImageLoaded;
  71767. private _extractNinePatchSliceDataFromImage;
  71768. /**
  71769. * Gets or sets image source url
  71770. */
  71771. set source(value: BABYLON.Nullable<string>);
  71772. /**
  71773. * Checks for svg document with icon id present
  71774. */
  71775. private _svgCheck;
  71776. /**
  71777. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71778. * given external svg file and icon id
  71779. */
  71780. private _getSVGAttribs;
  71781. /**
  71782. * Gets or sets the cell width to use when animation sheet is enabled
  71783. * @see http://doc.babylonjs.com/how_to/gui#image
  71784. */
  71785. get cellWidth(): number;
  71786. set cellWidth(value: number);
  71787. /**
  71788. * Gets or sets the cell height to use when animation sheet is enabled
  71789. * @see http://doc.babylonjs.com/how_to/gui#image
  71790. */
  71791. get cellHeight(): number;
  71792. set cellHeight(value: number);
  71793. /**
  71794. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71795. * @see http://doc.babylonjs.com/how_to/gui#image
  71796. */
  71797. get cellId(): number;
  71798. set cellId(value: number);
  71799. /**
  71800. * Creates a new Image
  71801. * @param name defines the control name
  71802. * @param url defines the image url
  71803. */
  71804. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71805. /**
  71806. * Tests if a given coordinates belong to the current control
  71807. * @param x defines x coordinate to test
  71808. * @param y defines y coordinate to test
  71809. * @returns true if the coordinates are inside the control
  71810. */
  71811. contains(x: number, y: number): boolean;
  71812. protected _getTypeName(): string;
  71813. /** Force the control to synchronize with its content */
  71814. synchronizeSizeWithContent(): void;
  71815. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71816. private _prepareWorkingCanvasForOpaqueDetection;
  71817. private _drawImage;
  71818. _draw(context: CanvasRenderingContext2D): void;
  71819. private _renderCornerPatch;
  71820. private _renderNinePatch;
  71821. dispose(): void;
  71822. /** STRETCH_NONE */
  71823. static readonly STRETCH_NONE: number;
  71824. /** STRETCH_FILL */
  71825. static readonly STRETCH_FILL: number;
  71826. /** STRETCH_UNIFORM */
  71827. static readonly STRETCH_UNIFORM: number;
  71828. /** STRETCH_EXTEND */
  71829. static readonly STRETCH_EXTEND: number;
  71830. /** NINE_PATCH */
  71831. static readonly STRETCH_NINE_PATCH: number;
  71832. }
  71833. }
  71834. declare module BABYLON.GUI {
  71835. /**
  71836. * Class used to create 2D buttons
  71837. */
  71838. export class Button extends Rectangle {
  71839. name?: string | undefined;
  71840. /**
  71841. * Function called to generate a pointer enter animation
  71842. */
  71843. pointerEnterAnimation: () => void;
  71844. /**
  71845. * Function called to generate a pointer out animation
  71846. */
  71847. pointerOutAnimation: () => void;
  71848. /**
  71849. * Function called to generate a pointer down animation
  71850. */
  71851. pointerDownAnimation: () => void;
  71852. /**
  71853. * Function called to generate a pointer up animation
  71854. */
  71855. pointerUpAnimation: () => void;
  71856. /**
  71857. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71858. */
  71859. delegatePickingToChildren: boolean;
  71860. private _image;
  71861. /**
  71862. * Returns the image part of the button (if any)
  71863. */
  71864. get image(): BABYLON.Nullable<Image>;
  71865. private _textBlock;
  71866. /**
  71867. * Returns the image part of the button (if any)
  71868. */
  71869. get textBlock(): BABYLON.Nullable<TextBlock>;
  71870. /**
  71871. * Creates a new Button
  71872. * @param name defines the name of the button
  71873. */
  71874. constructor(name?: string | undefined);
  71875. protected _getTypeName(): string;
  71876. /** @hidden */
  71877. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71878. /** @hidden */
  71879. _onPointerEnter(target: Control): boolean;
  71880. /** @hidden */
  71881. _onPointerOut(target: Control, force?: boolean): void;
  71882. /** @hidden */
  71883. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71884. /** @hidden */
  71885. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71886. /**
  71887. * Creates a new button made with an image and a text
  71888. * @param name defines the name of the button
  71889. * @param text defines the text of the button
  71890. * @param imageUrl defines the url of the image
  71891. * @returns a new Button
  71892. */
  71893. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71894. /**
  71895. * Creates a new button made with an image
  71896. * @param name defines the name of the button
  71897. * @param imageUrl defines the url of the image
  71898. * @returns a new Button
  71899. */
  71900. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71901. /**
  71902. * Creates a new button made with a text
  71903. * @param name defines the name of the button
  71904. * @param text defines the text of the button
  71905. * @returns a new Button
  71906. */
  71907. static CreateSimpleButton(name: string, text: string): Button;
  71908. /**
  71909. * Creates a new button made with an image and a centered text
  71910. * @param name defines the name of the button
  71911. * @param text defines the text of the button
  71912. * @param imageUrl defines the url of the image
  71913. * @returns a new Button
  71914. */
  71915. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71916. }
  71917. }
  71918. declare module BABYLON.GUI {
  71919. /**
  71920. * Class used to create a 2D stack panel container
  71921. */
  71922. export class StackPanel extends Container {
  71923. name?: string | undefined;
  71924. private _isVertical;
  71925. private _manualWidth;
  71926. private _manualHeight;
  71927. private _doNotTrackManualChanges;
  71928. /**
  71929. * Gets or sets a boolean indicating that layou warnings should be ignored
  71930. */
  71931. ignoreLayoutWarnings: boolean;
  71932. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71933. get isVertical(): boolean;
  71934. set isVertical(value: boolean);
  71935. /**
  71936. * Gets or sets panel width.
  71937. * This value should not be set when in horizontal mode as it will be computed automatically
  71938. */
  71939. set width(value: string | number);
  71940. get width(): string | number;
  71941. /**
  71942. * Gets or sets panel height.
  71943. * This value should not be set when in vertical mode as it will be computed automatically
  71944. */
  71945. set height(value: string | number);
  71946. get height(): string | number;
  71947. /**
  71948. * Creates a new StackPanel
  71949. * @param name defines control name
  71950. */
  71951. constructor(name?: string | undefined);
  71952. protected _getTypeName(): string;
  71953. /** @hidden */
  71954. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71955. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71956. protected _postMeasure(): void;
  71957. }
  71958. }
  71959. declare module BABYLON.GUI {
  71960. /**
  71961. * Class used to represent a 2D checkbox
  71962. */
  71963. export class Checkbox extends Control {
  71964. name?: string | undefined;
  71965. private _isChecked;
  71966. private _background;
  71967. private _checkSizeRatio;
  71968. private _thickness;
  71969. /** Gets or sets border thickness */
  71970. get thickness(): number;
  71971. set thickness(value: number);
  71972. /**
  71973. * BABYLON.Observable raised when isChecked property changes
  71974. */
  71975. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71976. /** Gets or sets a value indicating the ratio between overall size and check size */
  71977. get checkSizeRatio(): number;
  71978. set checkSizeRatio(value: number);
  71979. /** Gets or sets background color */
  71980. get background(): string;
  71981. set background(value: string);
  71982. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71983. get isChecked(): boolean;
  71984. set isChecked(value: boolean);
  71985. /**
  71986. * Creates a new CheckBox
  71987. * @param name defines the control name
  71988. */
  71989. constructor(name?: string | undefined);
  71990. protected _getTypeName(): string;
  71991. /** @hidden */
  71992. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71993. /** @hidden */
  71994. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71995. /**
  71996. * Utility function to easily create a checkbox with a header
  71997. * @param title defines the label to use for the header
  71998. * @param onValueChanged defines the callback to call when value changes
  71999. * @returns a StackPanel containing the checkbox and a textBlock
  72000. */
  72001. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72002. }
  72003. }
  72004. declare module BABYLON.GUI {
  72005. /**
  72006. * Class used to store key control properties
  72007. */
  72008. export class KeyPropertySet {
  72009. /** Width */
  72010. width?: string;
  72011. /** Height */
  72012. height?: string;
  72013. /** Left padding */
  72014. paddingLeft?: string;
  72015. /** Right padding */
  72016. paddingRight?: string;
  72017. /** Top padding */
  72018. paddingTop?: string;
  72019. /** Bottom padding */
  72020. paddingBottom?: string;
  72021. /** Foreground color */
  72022. color?: string;
  72023. /** Background color */
  72024. background?: string;
  72025. }
  72026. /**
  72027. * Class used to create virtual keyboard
  72028. */
  72029. export class VirtualKeyboard extends StackPanel {
  72030. /** BABYLON.Observable raised when a key is pressed */
  72031. onKeyPressObservable: BABYLON.Observable<string>;
  72032. /** Gets or sets default key button width */
  72033. defaultButtonWidth: string;
  72034. /** Gets or sets default key button height */
  72035. defaultButtonHeight: string;
  72036. /** Gets or sets default key button left padding */
  72037. defaultButtonPaddingLeft: string;
  72038. /** Gets or sets default key button right padding */
  72039. defaultButtonPaddingRight: string;
  72040. /** Gets or sets default key button top padding */
  72041. defaultButtonPaddingTop: string;
  72042. /** Gets or sets default key button bottom padding */
  72043. defaultButtonPaddingBottom: string;
  72044. /** Gets or sets default key button foreground color */
  72045. defaultButtonColor: string;
  72046. /** Gets or sets default key button background color */
  72047. defaultButtonBackground: string;
  72048. /** Gets or sets shift button foreground color */
  72049. shiftButtonColor: string;
  72050. /** Gets or sets shift button thickness*/
  72051. selectedShiftThickness: number;
  72052. /** Gets shift key state */
  72053. shiftState: number;
  72054. protected _getTypeName(): string;
  72055. private _createKey;
  72056. /**
  72057. * Adds a new row of keys
  72058. * @param keys defines the list of keys to add
  72059. * @param propertySets defines the associated property sets
  72060. */
  72061. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72062. /**
  72063. * Set the shift key to a specific state
  72064. * @param shiftState defines the new shift state
  72065. */
  72066. applyShiftState(shiftState: number): void;
  72067. private _currentlyConnectedInputText;
  72068. private _connectedInputTexts;
  72069. private _onKeyPressObserver;
  72070. /** Gets the input text control currently attached to the keyboard */
  72071. get connectedInputText(): BABYLON.Nullable<InputText>;
  72072. /**
  72073. * Connects the keyboard with an input text control
  72074. *
  72075. * @param input defines the target control
  72076. */
  72077. connect(input: InputText): void;
  72078. /**
  72079. * Disconnects the keyboard from connected InputText controls
  72080. *
  72081. * @param input optionally defines a target control, otherwise all are disconnected
  72082. */
  72083. disconnect(input?: InputText): void;
  72084. private _removeConnectedInputObservables;
  72085. /**
  72086. * Release all resources
  72087. */
  72088. dispose(): void;
  72089. /**
  72090. * Creates a new keyboard using a default layout
  72091. *
  72092. * @param name defines control name
  72093. * @returns a new VirtualKeyboard
  72094. */
  72095. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72096. }
  72097. }
  72098. declare module BABYLON.GUI {
  72099. /**
  72100. * Class used to create input text control
  72101. */
  72102. export class InputText extends Control implements IFocusableControl {
  72103. name?: string | undefined;
  72104. private _text;
  72105. private _placeholderText;
  72106. private _background;
  72107. private _focusedBackground;
  72108. private _focusedColor;
  72109. private _placeholderColor;
  72110. private _thickness;
  72111. private _margin;
  72112. private _autoStretchWidth;
  72113. private _maxWidth;
  72114. private _isFocused;
  72115. private _blinkTimeout;
  72116. private _blinkIsEven;
  72117. private _cursorOffset;
  72118. private _scrollLeft;
  72119. private _textWidth;
  72120. private _clickedCoordinate;
  72121. private _deadKey;
  72122. private _addKey;
  72123. private _currentKey;
  72124. private _isTextHighlightOn;
  72125. private _textHighlightColor;
  72126. private _highligherOpacity;
  72127. private _highlightedText;
  72128. private _startHighlightIndex;
  72129. private _endHighlightIndex;
  72130. private _cursorIndex;
  72131. private _onFocusSelectAll;
  72132. private _isPointerDown;
  72133. private _onClipboardObserver;
  72134. private _onPointerDblTapObserver;
  72135. /** @hidden */
  72136. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72137. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72138. promptMessage: string;
  72139. /** Force disable prompt on mobile device */
  72140. disableMobilePrompt: boolean;
  72141. /** BABYLON.Observable raised when the text changes */
  72142. onTextChangedObservable: BABYLON.Observable<InputText>;
  72143. /** BABYLON.Observable raised just before an entered character is to be added */
  72144. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72145. /** BABYLON.Observable raised when the control gets the focus */
  72146. onFocusObservable: BABYLON.Observable<InputText>;
  72147. /** BABYLON.Observable raised when the control loses the focus */
  72148. onBlurObservable: BABYLON.Observable<InputText>;
  72149. /**Observable raised when the text is highlighted */
  72150. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72151. /**Observable raised when copy event is triggered */
  72152. onTextCopyObservable: BABYLON.Observable<InputText>;
  72153. /** BABYLON.Observable raised when cut event is triggered */
  72154. onTextCutObservable: BABYLON.Observable<InputText>;
  72155. /** BABYLON.Observable raised when paste event is triggered */
  72156. onTextPasteObservable: BABYLON.Observable<InputText>;
  72157. /** BABYLON.Observable raised when a key event was processed */
  72158. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72159. /** Gets or sets the maximum width allowed by the control */
  72160. get maxWidth(): string | number;
  72161. /** Gets the maximum width allowed by the control in pixels */
  72162. get maxWidthInPixels(): number;
  72163. set maxWidth(value: string | number);
  72164. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72165. get highligherOpacity(): number;
  72166. set highligherOpacity(value: number);
  72167. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72168. get onFocusSelectAll(): boolean;
  72169. set onFocusSelectAll(value: boolean);
  72170. /** Gets or sets the text hightlight color */
  72171. get textHighlightColor(): string;
  72172. set textHighlightColor(value: string);
  72173. /** Gets or sets control margin */
  72174. get margin(): string;
  72175. /** Gets control margin in pixels */
  72176. get marginInPixels(): number;
  72177. set margin(value: string);
  72178. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72179. get autoStretchWidth(): boolean;
  72180. set autoStretchWidth(value: boolean);
  72181. /** Gets or sets border thickness */
  72182. get thickness(): number;
  72183. set thickness(value: number);
  72184. /** Gets or sets the background color when focused */
  72185. get focusedBackground(): string;
  72186. set focusedBackground(value: string);
  72187. /** Gets or sets the background color when focused */
  72188. get focusedColor(): string;
  72189. set focusedColor(value: string);
  72190. /** Gets or sets the background color */
  72191. get background(): string;
  72192. set background(value: string);
  72193. /** Gets or sets the placeholder color */
  72194. get placeholderColor(): string;
  72195. set placeholderColor(value: string);
  72196. /** Gets or sets the text displayed when the control is empty */
  72197. get placeholderText(): string;
  72198. set placeholderText(value: string);
  72199. /** Gets or sets the dead key flag */
  72200. get deadKey(): boolean;
  72201. set deadKey(flag: boolean);
  72202. /** Gets or sets the highlight text */
  72203. get highlightedText(): string;
  72204. set highlightedText(text: string);
  72205. /** Gets or sets if the current key should be added */
  72206. get addKey(): boolean;
  72207. set addKey(flag: boolean);
  72208. /** Gets or sets the value of the current key being entered */
  72209. get currentKey(): string;
  72210. set currentKey(key: string);
  72211. /** Gets or sets the text displayed in the control */
  72212. get text(): string;
  72213. set text(value: string);
  72214. /** Gets or sets control width */
  72215. get width(): string | number;
  72216. set width(value: string | number);
  72217. /**
  72218. * Creates a new InputText
  72219. * @param name defines the control name
  72220. * @param text defines the text of the control
  72221. */
  72222. constructor(name?: string | undefined, text?: string);
  72223. /** @hidden */
  72224. onBlur(): void;
  72225. /** @hidden */
  72226. onFocus(): void;
  72227. protected _getTypeName(): string;
  72228. /**
  72229. * Function called to get the list of controls that should not steal the focus from this control
  72230. * @returns an array of controls
  72231. */
  72232. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72233. /** @hidden */
  72234. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72235. /** @hidden */
  72236. private _updateValueFromCursorIndex;
  72237. /** @hidden */
  72238. private _processDblClick;
  72239. /** @hidden */
  72240. private _selectAllText;
  72241. /**
  72242. * Handles the keyboard event
  72243. * @param evt Defines the KeyboardEvent
  72244. */
  72245. processKeyboard(evt: KeyboardEvent): void;
  72246. /** @hidden */
  72247. private _onCopyText;
  72248. /** @hidden */
  72249. private _onCutText;
  72250. /** @hidden */
  72251. private _onPasteText;
  72252. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72253. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72254. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72255. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72256. protected _beforeRenderText(text: string): string;
  72257. dispose(): void;
  72258. }
  72259. }
  72260. declare module BABYLON.GUI {
  72261. /**
  72262. * Class used to create a 2D grid container
  72263. */
  72264. export class Grid extends Container {
  72265. name?: string | undefined;
  72266. private _rowDefinitions;
  72267. private _columnDefinitions;
  72268. private _cells;
  72269. private _childControls;
  72270. /**
  72271. * Gets the number of columns
  72272. */
  72273. get columnCount(): number;
  72274. /**
  72275. * Gets the number of rows
  72276. */
  72277. get rowCount(): number;
  72278. /** Gets the list of children */
  72279. get children(): Control[];
  72280. /** Gets the list of cells (e.g. the containers) */
  72281. get cells(): {
  72282. [key: string]: Container;
  72283. };
  72284. /**
  72285. * Gets the definition of a specific row
  72286. * @param index defines the index of the row
  72287. * @returns the row definition
  72288. */
  72289. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72290. /**
  72291. * Gets the definition of a specific column
  72292. * @param index defines the index of the column
  72293. * @returns the column definition
  72294. */
  72295. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72296. /**
  72297. * Adds a new row to the grid
  72298. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72299. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72300. * @returns the current grid
  72301. */
  72302. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72303. /**
  72304. * Adds a new column to the grid
  72305. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72306. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72307. * @returns the current grid
  72308. */
  72309. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72310. /**
  72311. * Update a row definition
  72312. * @param index defines the index of the row to update
  72313. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72314. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72315. * @returns the current grid
  72316. */
  72317. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72318. /**
  72319. * Update a column definition
  72320. * @param index defines the index of the column to update
  72321. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72322. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72323. * @returns the current grid
  72324. */
  72325. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72326. /**
  72327. * Gets the list of children stored in a specific cell
  72328. * @param row defines the row to check
  72329. * @param column defines the column to check
  72330. * @returns the list of controls
  72331. */
  72332. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72333. /**
  72334. * Gets a string representing the child cell info (row x column)
  72335. * @param child defines the control to get info from
  72336. * @returns a string containing the child cell info (row x column)
  72337. */
  72338. getChildCellInfo(child: Control): string;
  72339. private _removeCell;
  72340. private _offsetCell;
  72341. /**
  72342. * Remove a column definition at specified index
  72343. * @param index defines the index of the column to remove
  72344. * @returns the current grid
  72345. */
  72346. removeColumnDefinition(index: number): Grid;
  72347. /**
  72348. * Remove a row definition at specified index
  72349. * @param index defines the index of the row to remove
  72350. * @returns the current grid
  72351. */
  72352. removeRowDefinition(index: number): Grid;
  72353. /**
  72354. * Adds a new control to the current grid
  72355. * @param control defines the control to add
  72356. * @param row defines the row where to add the control (0 by default)
  72357. * @param column defines the column where to add the control (0 by default)
  72358. * @returns the current grid
  72359. */
  72360. addControl(control: Control, row?: number, column?: number): Grid;
  72361. /**
  72362. * Removes a control from the current container
  72363. * @param control defines the control to remove
  72364. * @returns the current container
  72365. */
  72366. removeControl(control: Control): Container;
  72367. /**
  72368. * Creates a new Grid
  72369. * @param name defines control name
  72370. */
  72371. constructor(name?: string | undefined);
  72372. protected _getTypeName(): string;
  72373. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72374. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72375. _flagDescendantsAsMatrixDirty(): void;
  72376. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72377. /** Releases associated resources */
  72378. dispose(): void;
  72379. }
  72380. }
  72381. declare module BABYLON.GUI {
  72382. /** Class used to create color pickers */
  72383. export class ColorPicker extends Control {
  72384. name?: string | undefined;
  72385. private static _Epsilon;
  72386. private _colorWheelCanvas;
  72387. private _value;
  72388. private _tmpColor;
  72389. private _pointerStartedOnSquare;
  72390. private _pointerStartedOnWheel;
  72391. private _squareLeft;
  72392. private _squareTop;
  72393. private _squareSize;
  72394. private _h;
  72395. private _s;
  72396. private _v;
  72397. private _lastPointerDownID;
  72398. /**
  72399. * BABYLON.Observable raised when the value changes
  72400. */
  72401. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72402. /** Gets or sets the color of the color picker */
  72403. get value(): BABYLON.Color3;
  72404. set value(value: BABYLON.Color3);
  72405. /**
  72406. * Gets or sets control width
  72407. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72408. */
  72409. get width(): string | number;
  72410. set width(value: string | number);
  72411. /**
  72412. * Gets or sets control height
  72413. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72414. */
  72415. get height(): string | number;
  72416. /** Gets or sets control height */
  72417. set height(value: string | number);
  72418. /** Gets or sets control size */
  72419. get size(): string | number;
  72420. set size(value: string | number);
  72421. /**
  72422. * Creates a new ColorPicker
  72423. * @param name defines the control name
  72424. */
  72425. constructor(name?: string | undefined);
  72426. protected _getTypeName(): string;
  72427. /** @hidden */
  72428. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72429. private _updateSquareProps;
  72430. private _drawGradientSquare;
  72431. private _drawCircle;
  72432. private _createColorWheelCanvas;
  72433. /** @hidden */
  72434. _draw(context: CanvasRenderingContext2D): void;
  72435. private _pointerIsDown;
  72436. private _updateValueFromPointer;
  72437. private _isPointOnSquare;
  72438. private _isPointOnWheel;
  72439. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72440. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72441. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72442. /**
  72443. * This function expands the color picker by creating a color picker dialog with manual
  72444. * color value input and the ability to save colors into an array to be used later in
  72445. * subsequent launches of the dialogue.
  72446. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72447. * @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.
  72448. * @returns picked color as a hex string and the saved colors array as hex strings.
  72449. */
  72450. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72451. pickerWidth?: string;
  72452. pickerHeight?: string;
  72453. headerHeight?: string;
  72454. lastColor?: string;
  72455. swatchLimit?: number;
  72456. numSwatchesPerLine?: number;
  72457. savedColors?: Array<string>;
  72458. }): Promise<{
  72459. savedColors?: string[];
  72460. pickedColor: string;
  72461. }>;
  72462. }
  72463. }
  72464. declare module BABYLON.GUI {
  72465. /** Class used to create 2D ellipse containers */
  72466. export class Ellipse extends Container {
  72467. name?: string | undefined;
  72468. private _thickness;
  72469. /** Gets or sets border thickness */
  72470. get thickness(): number;
  72471. set thickness(value: number);
  72472. /**
  72473. * Creates a new Ellipse
  72474. * @param name defines the control name
  72475. */
  72476. constructor(name?: string | undefined);
  72477. protected _getTypeName(): string;
  72478. protected _localDraw(context: CanvasRenderingContext2D): void;
  72479. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72480. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72481. }
  72482. }
  72483. declare module BABYLON.GUI {
  72484. /**
  72485. * Class used to create a password control
  72486. */
  72487. export class InputPassword extends InputText {
  72488. protected _beforeRenderText(text: string): string;
  72489. }
  72490. }
  72491. declare module BABYLON.GUI {
  72492. /** Class used to render 2D lines */
  72493. export class Line extends Control {
  72494. name?: string | undefined;
  72495. private _lineWidth;
  72496. private _x1;
  72497. private _y1;
  72498. private _x2;
  72499. private _y2;
  72500. private _dash;
  72501. private _connectedControl;
  72502. private _connectedControlDirtyObserver;
  72503. /** Gets or sets the dash pattern */
  72504. get dash(): Array<number>;
  72505. set dash(value: Array<number>);
  72506. /** Gets or sets the control connected with the line end */
  72507. get connectedControl(): Control;
  72508. set connectedControl(value: Control);
  72509. /** Gets or sets start coordinates on X axis */
  72510. get x1(): string | number;
  72511. set x1(value: string | number);
  72512. /** Gets or sets start coordinates on Y axis */
  72513. get y1(): string | number;
  72514. set y1(value: string | number);
  72515. /** Gets or sets end coordinates on X axis */
  72516. get x2(): string | number;
  72517. set x2(value: string | number);
  72518. /** Gets or sets end coordinates on Y axis */
  72519. get y2(): string | number;
  72520. set y2(value: string | number);
  72521. /** Gets or sets line width */
  72522. get lineWidth(): number;
  72523. set lineWidth(value: number);
  72524. /** Gets or sets horizontal alignment */
  72525. set horizontalAlignment(value: number);
  72526. /** Gets or sets vertical alignment */
  72527. set verticalAlignment(value: number);
  72528. private get _effectiveX2();
  72529. private get _effectiveY2();
  72530. /**
  72531. * Creates a new Line
  72532. * @param name defines the control name
  72533. */
  72534. constructor(name?: string | undefined);
  72535. protected _getTypeName(): string;
  72536. _draw(context: CanvasRenderingContext2D): void;
  72537. _measure(): void;
  72538. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72539. /**
  72540. * Move one end of the line given 3D cartesian coordinates.
  72541. * @param position Targeted world position
  72542. * @param scene BABYLON.Scene
  72543. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72544. */
  72545. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72546. /**
  72547. * Move one end of the line to a position in screen absolute space.
  72548. * @param projectedPosition Position in screen absolute space (X, Y)
  72549. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72550. */
  72551. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72552. }
  72553. }
  72554. declare module BABYLON.GUI {
  72555. /**
  72556. * Class used to store a point for a MultiLine object.
  72557. * The point can be pure 2D coordinates, a mesh or a control
  72558. */
  72559. export class MultiLinePoint {
  72560. private _multiLine;
  72561. private _x;
  72562. private _y;
  72563. private _control;
  72564. private _mesh;
  72565. private _controlObserver;
  72566. private _meshObserver;
  72567. /** @hidden */
  72568. _point: BABYLON.Vector2;
  72569. /**
  72570. * Creates a new MultiLinePoint
  72571. * @param multiLine defines the source MultiLine object
  72572. */
  72573. constructor(multiLine: MultiLine);
  72574. /** Gets or sets x coordinate */
  72575. get x(): string | number;
  72576. set x(value: string | number);
  72577. /** Gets or sets y coordinate */
  72578. get y(): string | number;
  72579. set y(value: string | number);
  72580. /** Gets or sets the control associated with this point */
  72581. get control(): BABYLON.Nullable<Control>;
  72582. set control(value: BABYLON.Nullable<Control>);
  72583. /** Gets or sets the mesh associated with this point */
  72584. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72585. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72586. /** Resets links */
  72587. resetLinks(): void;
  72588. /**
  72589. * Gets a translation vector
  72590. * @returns the translation vector
  72591. */
  72592. translate(): BABYLON.Vector2;
  72593. private _translatePoint;
  72594. /** Release associated resources */
  72595. dispose(): void;
  72596. }
  72597. }
  72598. declare module BABYLON.GUI {
  72599. /**
  72600. * Class used to create multi line control
  72601. */
  72602. export class MultiLine extends Control {
  72603. name?: string | undefined;
  72604. private _lineWidth;
  72605. private _dash;
  72606. private _points;
  72607. private _minX;
  72608. private _minY;
  72609. private _maxX;
  72610. private _maxY;
  72611. /**
  72612. * Creates a new MultiLine
  72613. * @param name defines the control name
  72614. */
  72615. constructor(name?: string | undefined);
  72616. /** Gets or sets dash pattern */
  72617. get dash(): Array<number>;
  72618. set dash(value: Array<number>);
  72619. /**
  72620. * Gets point stored at specified index
  72621. * @param index defines the index to look for
  72622. * @returns the requested point if found
  72623. */
  72624. getAt(index: number): MultiLinePoint;
  72625. /** Function called when a point is updated */
  72626. onPointUpdate: () => void;
  72627. /**
  72628. * Adds new points to the point collection
  72629. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  72630. * @returns the list of created MultiLinePoint
  72631. */
  72632. add(...items: (AbstractMesh | Control | {
  72633. x: string | number;
  72634. y: string | number;
  72635. })[]): MultiLinePoint[];
  72636. /**
  72637. * Adds a new point to the point collection
  72638. * @param item defines the item (mesh, control or 2d coordiantes) to add
  72639. * @returns the created MultiLinePoint
  72640. */
  72641. push(item?: (AbstractMesh | Control | {
  72642. x: string | number;
  72643. y: string | number;
  72644. })): MultiLinePoint;
  72645. /**
  72646. * Remove a specific value or point from the active point collection
  72647. * @param value defines the value or point to remove
  72648. */
  72649. remove(value: number | MultiLinePoint): void;
  72650. /**
  72651. * Resets this object to initial state (no point)
  72652. */
  72653. reset(): void;
  72654. /**
  72655. * Resets all links
  72656. */
  72657. resetLinks(): void;
  72658. /** Gets or sets line width */
  72659. get lineWidth(): number;
  72660. set lineWidth(value: number);
  72661. set horizontalAlignment(value: number);
  72662. set verticalAlignment(value: number);
  72663. protected _getTypeName(): string;
  72664. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72665. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72666. _measure(): void;
  72667. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72668. dispose(): void;
  72669. }
  72670. }
  72671. declare module BABYLON.GUI {
  72672. /**
  72673. * Class used to create radio button controls
  72674. */
  72675. export class RadioButton extends Control {
  72676. name?: string | undefined;
  72677. private _isChecked;
  72678. private _background;
  72679. private _checkSizeRatio;
  72680. private _thickness;
  72681. /** Gets or sets border thickness */
  72682. get thickness(): number;
  72683. set thickness(value: number);
  72684. /** Gets or sets group name */
  72685. group: string;
  72686. /** BABYLON.Observable raised when isChecked is changed */
  72687. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72688. /** Gets or sets a value indicating the ratio between overall size and check size */
  72689. get checkSizeRatio(): number;
  72690. set checkSizeRatio(value: number);
  72691. /** Gets or sets background color */
  72692. get background(): string;
  72693. set background(value: string);
  72694. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72695. get isChecked(): boolean;
  72696. set isChecked(value: boolean);
  72697. /**
  72698. * Creates a new RadioButton
  72699. * @param name defines the control name
  72700. */
  72701. constructor(name?: string | undefined);
  72702. protected _getTypeName(): string;
  72703. _draw(context: CanvasRenderingContext2D): void;
  72704. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72705. /**
  72706. * Utility function to easily create a radio button with a header
  72707. * @param title defines the label to use for the header
  72708. * @param group defines the group to use for the radio button
  72709. * @param isChecked defines the initial state of the radio button
  72710. * @param onValueChanged defines the callback to call when value changes
  72711. * @returns a StackPanel containing the radio button and a textBlock
  72712. */
  72713. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  72714. }
  72715. }
  72716. declare module BABYLON.GUI {
  72717. /**
  72718. * Class used to create slider controls
  72719. */
  72720. export class BaseSlider extends Control {
  72721. name?: string | undefined;
  72722. protected _thumbWidth: ValueAndUnit;
  72723. private _minimum;
  72724. private _maximum;
  72725. private _value;
  72726. private _isVertical;
  72727. protected _barOffset: ValueAndUnit;
  72728. private _isThumbClamped;
  72729. protected _displayThumb: boolean;
  72730. private _step;
  72731. private _lastPointerDownID;
  72732. protected _effectiveBarOffset: number;
  72733. protected _renderLeft: number;
  72734. protected _renderTop: number;
  72735. protected _renderWidth: number;
  72736. protected _renderHeight: number;
  72737. protected _backgroundBoxLength: number;
  72738. protected _backgroundBoxThickness: number;
  72739. protected _effectiveThumbThickness: number;
  72740. /** BABYLON.Observable raised when the sldier value changes */
  72741. onValueChangedObservable: BABYLON.Observable<number>;
  72742. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72743. get displayThumb(): boolean;
  72744. set displayThumb(value: boolean);
  72745. /** Gets or sets a step to apply to values (0 by default) */
  72746. get step(): number;
  72747. set step(value: number);
  72748. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72749. get barOffset(): string | number;
  72750. /** Gets main bar offset in pixels*/
  72751. get barOffsetInPixels(): number;
  72752. set barOffset(value: string | number);
  72753. /** Gets or sets thumb width */
  72754. get thumbWidth(): string | number;
  72755. /** Gets thumb width in pixels */
  72756. get thumbWidthInPixels(): number;
  72757. set thumbWidth(value: string | number);
  72758. /** Gets or sets minimum value */
  72759. get minimum(): number;
  72760. set minimum(value: number);
  72761. /** Gets or sets maximum value */
  72762. get maximum(): number;
  72763. set maximum(value: number);
  72764. /** Gets or sets current value */
  72765. get value(): number;
  72766. set value(value: number);
  72767. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72768. get isVertical(): boolean;
  72769. set isVertical(value: boolean);
  72770. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72771. get isThumbClamped(): boolean;
  72772. set isThumbClamped(value: boolean);
  72773. /**
  72774. * Creates a new BaseSlider
  72775. * @param name defines the control name
  72776. */
  72777. constructor(name?: string | undefined);
  72778. protected _getTypeName(): string;
  72779. protected _getThumbPosition(): number;
  72780. protected _getThumbThickness(type: string): number;
  72781. protected _prepareRenderingData(type: string): void;
  72782. private _pointerIsDown;
  72783. /** @hidden */
  72784. protected _updateValueFromPointer(x: number, y: number): void;
  72785. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72786. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72787. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72788. }
  72789. }
  72790. declare module BABYLON.GUI {
  72791. /**
  72792. * Class used to create slider controls
  72793. */
  72794. export class Slider extends BaseSlider {
  72795. name?: string | undefined;
  72796. private _background;
  72797. private _borderColor;
  72798. private _isThumbCircle;
  72799. protected _displayValueBar: boolean;
  72800. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72801. get displayValueBar(): boolean;
  72802. set displayValueBar(value: boolean);
  72803. /** Gets or sets border color */
  72804. get borderColor(): string;
  72805. set borderColor(value: string);
  72806. /** Gets or sets background color */
  72807. get background(): string;
  72808. set background(value: string);
  72809. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72810. get isThumbCircle(): boolean;
  72811. set isThumbCircle(value: boolean);
  72812. /**
  72813. * Creates a new Slider
  72814. * @param name defines the control name
  72815. */
  72816. constructor(name?: string | undefined);
  72817. protected _getTypeName(): string;
  72818. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72819. }
  72820. }
  72821. declare module BABYLON.GUI {
  72822. /** Class used to create a RadioGroup
  72823. * which contains groups of radio buttons
  72824. */
  72825. export class SelectorGroup {
  72826. /** name of SelectorGroup */
  72827. name: string;
  72828. private _groupPanel;
  72829. private _selectors;
  72830. private _groupHeader;
  72831. /**
  72832. * Creates a new SelectorGroup
  72833. * @param name of group, used as a group heading
  72834. */
  72835. constructor(
  72836. /** name of SelectorGroup */
  72837. name: string);
  72838. /** Gets the groupPanel of the SelectorGroup */
  72839. get groupPanel(): StackPanel;
  72840. /** Gets the selectors array */
  72841. get selectors(): StackPanel[];
  72842. /** Gets and sets the group header */
  72843. get header(): string;
  72844. set header(label: string);
  72845. /** @hidden */
  72846. private _addGroupHeader;
  72847. /** @hidden*/
  72848. _getSelector(selectorNb: number): StackPanel | undefined;
  72849. /** Removes the selector at the given position
  72850. * @param selectorNb the position of the selector within the group
  72851. */
  72852. removeSelector(selectorNb: number): void;
  72853. }
  72854. /** Class used to create a CheckboxGroup
  72855. * which contains groups of checkbox buttons
  72856. */
  72857. export class CheckboxGroup extends SelectorGroup {
  72858. /** Adds a checkbox as a control
  72859. * @param text is the label for the selector
  72860. * @param func is the function called when the Selector is checked
  72861. * @param checked is true when Selector is checked
  72862. */
  72863. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72864. /** @hidden */
  72865. _setSelectorLabel(selectorNb: number, label: string): void;
  72866. /** @hidden */
  72867. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72868. /** @hidden */
  72869. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72870. /** @hidden */
  72871. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72872. }
  72873. /** Class used to create a RadioGroup
  72874. * which contains groups of radio buttons
  72875. */
  72876. export class RadioGroup extends SelectorGroup {
  72877. private _selectNb;
  72878. /** Adds a radio button as a control
  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. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72884. /** @hidden */
  72885. _setSelectorLabel(selectorNb: number, label: string): void;
  72886. /** @hidden */
  72887. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72888. /** @hidden */
  72889. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72890. /** @hidden */
  72891. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72892. }
  72893. /** Class used to create a SliderGroup
  72894. * which contains groups of slider buttons
  72895. */
  72896. export class SliderGroup extends SelectorGroup {
  72897. /**
  72898. * Adds a slider to the SelectorGroup
  72899. * @param label is the label for the SliderBar
  72900. * @param func is the function called when the Slider moves
  72901. * @param unit is a string describing the units used, eg degrees or metres
  72902. * @param min is the minimum value for the Slider
  72903. * @param max is the maximum value for the Slider
  72904. * @param value is the start value for the Slider between min and max
  72905. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72906. */
  72907. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72908. /** @hidden */
  72909. _setSelectorLabel(selectorNb: number, label: string): void;
  72910. /** @hidden */
  72911. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72912. /** @hidden */
  72913. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72914. /** @hidden */
  72915. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72916. }
  72917. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72918. * @see http://doc.babylonjs.com/how_to/selector
  72919. */
  72920. export class SelectionPanel extends Rectangle {
  72921. /** name of SelectionPanel */
  72922. name: string;
  72923. /** an array of SelectionGroups */
  72924. groups: SelectorGroup[];
  72925. private _panel;
  72926. private _buttonColor;
  72927. private _buttonBackground;
  72928. private _headerColor;
  72929. private _barColor;
  72930. private _barHeight;
  72931. private _spacerHeight;
  72932. private _labelColor;
  72933. private _groups;
  72934. private _bars;
  72935. /**
  72936. * Creates a new SelectionPanel
  72937. * @param name of SelectionPanel
  72938. * @param groups is an array of SelectionGroups
  72939. */
  72940. constructor(
  72941. /** name of SelectionPanel */
  72942. name: string,
  72943. /** an array of SelectionGroups */
  72944. groups?: SelectorGroup[]);
  72945. protected _getTypeName(): string;
  72946. /** Gets or sets the headerColor */
  72947. get headerColor(): string;
  72948. set headerColor(color: string);
  72949. private _setHeaderColor;
  72950. /** Gets or sets the button color */
  72951. get buttonColor(): string;
  72952. set buttonColor(color: string);
  72953. private _setbuttonColor;
  72954. /** Gets or sets the label color */
  72955. get labelColor(): string;
  72956. set labelColor(color: string);
  72957. private _setLabelColor;
  72958. /** Gets or sets the button background */
  72959. get buttonBackground(): string;
  72960. set buttonBackground(color: string);
  72961. private _setButtonBackground;
  72962. /** Gets or sets the color of separator bar */
  72963. get barColor(): string;
  72964. set barColor(color: string);
  72965. private _setBarColor;
  72966. /** Gets or sets the height of separator bar */
  72967. get barHeight(): string;
  72968. set barHeight(value: string);
  72969. private _setBarHeight;
  72970. /** Gets or sets the height of spacers*/
  72971. get spacerHeight(): string;
  72972. set spacerHeight(value: string);
  72973. private _setSpacerHeight;
  72974. /** Adds a bar between groups */
  72975. private _addSpacer;
  72976. /** Add a group to the selection panel
  72977. * @param group is the selector group to add
  72978. */
  72979. addGroup(group: SelectorGroup): void;
  72980. /** Remove the group from the given position
  72981. * @param groupNb is the position of the group in the list
  72982. */
  72983. removeGroup(groupNb: number): void;
  72984. /** Change a group header label
  72985. * @param label is the new group header label
  72986. * @param groupNb is the number of the group to relabel
  72987. * */
  72988. setHeaderName(label: string, groupNb: number): void;
  72989. /** Change selector label to the one given
  72990. * @param label is the new selector label
  72991. * @param groupNb is the number of the groupcontaining the selector
  72992. * @param selectorNb is the number of the selector within a group to relabel
  72993. * */
  72994. relabel(label: string, groupNb: number, selectorNb: number): void;
  72995. /** For a given group position remove the selector at the given position
  72996. * @param groupNb is the number of the group to remove the selector from
  72997. * @param selectorNb is the number of the selector within the group
  72998. */
  72999. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73000. /** For a given group position of correct type add a checkbox button
  73001. * @param groupNb is the number of the group to remove the selector from
  73002. * @param label is the label for the selector
  73003. * @param func is the function called when the Selector is checked
  73004. * @param checked is true when Selector is checked
  73005. */
  73006. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73007. /** For a given group position of correct type add a radio button
  73008. * @param groupNb is the number of the group to remove the selector from
  73009. * @param label is the label for the selector
  73010. * @param func is the function called when the Selector is checked
  73011. * @param checked is true when Selector is checked
  73012. */
  73013. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73014. /**
  73015. * For a given slider group add a slider
  73016. * @param groupNb is the number of the group to add the slider to
  73017. * @param label is the label for the Slider
  73018. * @param func is the function called when the Slider moves
  73019. * @param unit is a string describing the units used, eg degrees or metres
  73020. * @param min is the minimum value for the Slider
  73021. * @param max is the maximum value for the Slider
  73022. * @param value is the start value for the Slider between min and max
  73023. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73024. */
  73025. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73026. }
  73027. }
  73028. declare module BABYLON.GUI {
  73029. /**
  73030. * Class used to hold a the container for ScrollViewer
  73031. * @hidden
  73032. */
  73033. export class _ScrollViewerWindow extends Container {
  73034. parentClientWidth: number;
  73035. parentClientHeight: number;
  73036. private _freezeControls;
  73037. private _parentMeasure;
  73038. private _oldLeft;
  73039. private _oldTop;
  73040. get freezeControls(): boolean;
  73041. set freezeControls(value: boolean);
  73042. private _bucketWidth;
  73043. private _bucketHeight;
  73044. private _buckets;
  73045. private _bucketLen;
  73046. get bucketWidth(): number;
  73047. get bucketHeight(): number;
  73048. setBucketSizes(width: number, height: number): void;
  73049. private _useBuckets;
  73050. private _makeBuckets;
  73051. private _dispatchInBuckets;
  73052. private _updateMeasures;
  73053. private _updateChildrenMeasures;
  73054. /**
  73055. * Creates a new ScrollViewerWindow
  73056. * @param name of ScrollViewerWindow
  73057. */
  73058. constructor(name?: string);
  73059. protected _getTypeName(): string;
  73060. /** @hidden */
  73061. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73062. /** @hidden */
  73063. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73064. private _scrollChildren;
  73065. private _scrollChildrenWithBuckets;
  73066. /** @hidden */
  73067. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73068. protected _postMeasure(): void;
  73069. }
  73070. }
  73071. declare module BABYLON.GUI {
  73072. /**
  73073. * Class used to create slider controls
  73074. */
  73075. export class ScrollBar extends BaseSlider {
  73076. name?: string | undefined;
  73077. private _background;
  73078. private _borderColor;
  73079. private _tempMeasure;
  73080. /** Gets or sets border color */
  73081. get borderColor(): string;
  73082. set borderColor(value: string);
  73083. /** Gets or sets background color */
  73084. get background(): string;
  73085. set background(value: string);
  73086. /**
  73087. * Creates a new Slider
  73088. * @param name defines the control name
  73089. */
  73090. constructor(name?: string | undefined);
  73091. protected _getTypeName(): string;
  73092. protected _getThumbThickness(): number;
  73093. _draw(context: CanvasRenderingContext2D): void;
  73094. private _first;
  73095. private _originX;
  73096. private _originY;
  73097. /** @hidden */
  73098. protected _updateValueFromPointer(x: number, y: number): void;
  73099. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73100. }
  73101. }
  73102. declare module BABYLON.GUI {
  73103. /**
  73104. * Class used to create slider controls
  73105. */
  73106. export class ImageScrollBar extends BaseSlider {
  73107. name?: string | undefined;
  73108. private _backgroundBaseImage;
  73109. private _backgroundImage;
  73110. private _thumbImage;
  73111. private _thumbBaseImage;
  73112. private _thumbLength;
  73113. private _thumbHeight;
  73114. private _barImageHeight;
  73115. private _tempMeasure;
  73116. /** Number of 90° rotation to apply on the images when in vertical mode */
  73117. num90RotationInVerticalMode: number;
  73118. /**
  73119. * Gets or sets the image used to render the background for horizontal bar
  73120. */
  73121. get backgroundImage(): Image;
  73122. set backgroundImage(value: Image);
  73123. /**
  73124. * Gets or sets the image used to render the thumb
  73125. */
  73126. get thumbImage(): Image;
  73127. set thumbImage(value: Image);
  73128. /**
  73129. * Gets or sets the length of the thumb
  73130. */
  73131. get thumbLength(): number;
  73132. set thumbLength(value: number);
  73133. /**
  73134. * Gets or sets the height of the thumb
  73135. */
  73136. get thumbHeight(): number;
  73137. set thumbHeight(value: number);
  73138. /**
  73139. * Gets or sets the height of the bar image
  73140. */
  73141. get barImageHeight(): number;
  73142. set barImageHeight(value: number);
  73143. /**
  73144. * Creates a new ImageScrollBar
  73145. * @param name defines the control name
  73146. */
  73147. constructor(name?: string | undefined);
  73148. protected _getTypeName(): string;
  73149. protected _getThumbThickness(): number;
  73150. _draw(context: CanvasRenderingContext2D): void;
  73151. private _first;
  73152. private _originX;
  73153. private _originY;
  73154. /** @hidden */
  73155. protected _updateValueFromPointer(x: number, y: number): void;
  73156. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73157. }
  73158. }
  73159. declare module BABYLON.GUI {
  73160. /**
  73161. * Class used to hold a viewer window and sliders in a grid
  73162. */
  73163. export class ScrollViewer extends Rectangle {
  73164. private _grid;
  73165. private _horizontalBarSpace;
  73166. private _verticalBarSpace;
  73167. private _dragSpace;
  73168. private _horizontalBar;
  73169. private _verticalBar;
  73170. private _barColor;
  73171. private _barBackground;
  73172. private _barImage;
  73173. private _horizontalBarImage;
  73174. private _verticalBarImage;
  73175. private _barBackgroundImage;
  73176. private _horizontalBarBackgroundImage;
  73177. private _verticalBarBackgroundImage;
  73178. private _barSize;
  73179. private _window;
  73180. private _pointerIsOver;
  73181. private _wheelPrecision;
  73182. private _onWheelObserver;
  73183. private _clientWidth;
  73184. private _clientHeight;
  73185. private _useImageBar;
  73186. private _thumbLength;
  73187. private _thumbHeight;
  73188. private _barImageHeight;
  73189. private _horizontalBarImageHeight;
  73190. private _verticalBarImageHeight;
  73191. /**
  73192. * Gets the horizontal scrollbar
  73193. */
  73194. get horizontalBar(): ScrollBar | ImageScrollBar;
  73195. /**
  73196. * Gets the vertical scrollbar
  73197. */
  73198. get verticalBar(): ScrollBar | ImageScrollBar;
  73199. /**
  73200. * Adds a new control to the current container
  73201. * @param control defines the control to add
  73202. * @returns the current container
  73203. */
  73204. addControl(control: BABYLON.Nullable<Control>): Container;
  73205. /**
  73206. * Removes a control from the current container
  73207. * @param control defines the control to remove
  73208. * @returns the current container
  73209. */
  73210. removeControl(control: Control): Container;
  73211. /** Gets the list of children */
  73212. get children(): Control[];
  73213. _flagDescendantsAsMatrixDirty(): void;
  73214. /**
  73215. * Freezes or unfreezes the controls in the window.
  73216. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73217. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73218. */
  73219. get freezeControls(): boolean;
  73220. set freezeControls(value: boolean);
  73221. /** Gets the bucket width */
  73222. get bucketWidth(): number;
  73223. /** Gets the bucket height */
  73224. get bucketHeight(): number;
  73225. /**
  73226. * Sets the bucket sizes.
  73227. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73228. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73229. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73230. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73231. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73232. * used), that's why it is not enabled by default.
  73233. * @param width width of the bucket
  73234. * @param height height of the bucket
  73235. */
  73236. setBucketSizes(width: number, height: number): void;
  73237. private _forceHorizontalBar;
  73238. private _forceVerticalBar;
  73239. /**
  73240. * Forces the horizontal scroll bar to be displayed
  73241. */
  73242. get forceHorizontalBar(): boolean;
  73243. set forceHorizontalBar(value: boolean);
  73244. /**
  73245. * Forces the vertical scroll bar to be displayed
  73246. */
  73247. get forceVerticalBar(): boolean;
  73248. set forceVerticalBar(value: boolean);
  73249. /**
  73250. * Creates a new ScrollViewer
  73251. * @param name of ScrollViewer
  73252. */
  73253. constructor(name?: string, isImageBased?: boolean);
  73254. /** Reset the scroll viewer window to initial size */
  73255. resetWindow(): void;
  73256. protected _getTypeName(): string;
  73257. private _buildClientSizes;
  73258. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73259. protected _postMeasure(): void;
  73260. /**
  73261. * Gets or sets the mouse wheel precision
  73262. * from 0 to 1 with a default value of 0.05
  73263. * */
  73264. get wheelPrecision(): number;
  73265. set wheelPrecision(value: number);
  73266. /** Gets or sets the scroll bar container background color */
  73267. get scrollBackground(): string;
  73268. set scrollBackground(color: string);
  73269. /** Gets or sets the bar color */
  73270. get barColor(): string;
  73271. set barColor(color: string);
  73272. /** Gets or sets the bar image */
  73273. get thumbImage(): Image;
  73274. set thumbImage(value: Image);
  73275. /** Gets or sets the horizontal bar image */
  73276. get horizontalThumbImage(): Image;
  73277. set horizontalThumbImage(value: Image);
  73278. /** Gets or sets the vertical bar image */
  73279. get verticalThumbImage(): Image;
  73280. set verticalThumbImage(value: Image);
  73281. /** Gets or sets the size of the bar */
  73282. get barSize(): number;
  73283. set barSize(value: number);
  73284. /** Gets or sets the length of the thumb */
  73285. get thumbLength(): number;
  73286. set thumbLength(value: number);
  73287. /** Gets or sets the height of the thumb */
  73288. get thumbHeight(): number;
  73289. set thumbHeight(value: number);
  73290. /** Gets or sets the height of the bar image */
  73291. get barImageHeight(): number;
  73292. set barImageHeight(value: number);
  73293. /** Gets or sets the height of the horizontal bar image */
  73294. get horizontalBarImageHeight(): number;
  73295. set horizontalBarImageHeight(value: number);
  73296. /** Gets or sets the height of the vertical bar image */
  73297. get verticalBarImageHeight(): number;
  73298. set verticalBarImageHeight(value: number);
  73299. /** Gets or sets the bar background */
  73300. get barBackground(): string;
  73301. set barBackground(color: string);
  73302. /** Gets or sets the bar background image */
  73303. get barImage(): Image;
  73304. set barImage(value: Image);
  73305. /** Gets or sets the horizontal bar background image */
  73306. get horizontalBarImage(): Image;
  73307. set horizontalBarImage(value: Image);
  73308. /** Gets or sets the vertical bar background image */
  73309. get verticalBarImage(): Image;
  73310. set verticalBarImage(value: Image);
  73311. private _setWindowPosition;
  73312. /** @hidden */
  73313. private _updateScroller;
  73314. _link(host: AdvancedDynamicTexture): void;
  73315. /** @hidden */
  73316. private _addBar;
  73317. /** @hidden */
  73318. private _attachWheel;
  73319. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73320. /** Releases associated resources */
  73321. dispose(): void;
  73322. }
  73323. }
  73324. declare module BABYLON.GUI {
  73325. /** Class used to render a grid */
  73326. export class DisplayGrid extends Control {
  73327. name?: string | undefined;
  73328. private _cellWidth;
  73329. private _cellHeight;
  73330. private _minorLineTickness;
  73331. private _minorLineColor;
  73332. private _majorLineTickness;
  73333. private _majorLineColor;
  73334. private _majorLineFrequency;
  73335. private _background;
  73336. private _displayMajorLines;
  73337. private _displayMinorLines;
  73338. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73339. get displayMinorLines(): boolean;
  73340. set displayMinorLines(value: boolean);
  73341. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73342. get displayMajorLines(): boolean;
  73343. set displayMajorLines(value: boolean);
  73344. /** Gets or sets background color (Black by default) */
  73345. get background(): string;
  73346. set background(value: string);
  73347. /** Gets or sets the width of each cell (20 by default) */
  73348. get cellWidth(): number;
  73349. set cellWidth(value: number);
  73350. /** Gets or sets the height of each cell (20 by default) */
  73351. get cellHeight(): number;
  73352. set cellHeight(value: number);
  73353. /** Gets or sets the tickness of minor lines (1 by default) */
  73354. get minorLineTickness(): number;
  73355. set minorLineTickness(value: number);
  73356. /** Gets or sets the color of minor lines (DarkGray by default) */
  73357. get minorLineColor(): string;
  73358. set minorLineColor(value: string);
  73359. /** Gets or sets the tickness of major lines (2 by default) */
  73360. get majorLineTickness(): number;
  73361. set majorLineTickness(value: number);
  73362. /** Gets or sets the color of major lines (White by default) */
  73363. get majorLineColor(): string;
  73364. set majorLineColor(value: string);
  73365. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73366. get majorLineFrequency(): number;
  73367. set majorLineFrequency(value: number);
  73368. /**
  73369. * Creates a new GridDisplayRectangle
  73370. * @param name defines the control name
  73371. */
  73372. constructor(name?: string | undefined);
  73373. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73374. protected _getTypeName(): string;
  73375. }
  73376. }
  73377. declare module BABYLON.GUI {
  73378. /**
  73379. * Class used to create slider controls based on images
  73380. */
  73381. export class ImageBasedSlider extends BaseSlider {
  73382. name?: string | undefined;
  73383. private _backgroundImage;
  73384. private _thumbImage;
  73385. private _valueBarImage;
  73386. private _tempMeasure;
  73387. get displayThumb(): boolean;
  73388. set displayThumb(value: boolean);
  73389. /**
  73390. * Gets or sets the image used to render the background
  73391. */
  73392. get backgroundImage(): Image;
  73393. set backgroundImage(value: Image);
  73394. /**
  73395. * Gets or sets the image used to render the value bar
  73396. */
  73397. get valueBarImage(): Image;
  73398. set valueBarImage(value: Image);
  73399. /**
  73400. * Gets or sets the image used to render the thumb
  73401. */
  73402. get thumbImage(): Image;
  73403. set thumbImage(value: Image);
  73404. /**
  73405. * Creates a new ImageBasedSlider
  73406. * @param name defines the control name
  73407. */
  73408. constructor(name?: string | undefined);
  73409. protected _getTypeName(): string;
  73410. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73411. }
  73412. }
  73413. declare module BABYLON.GUI {
  73414. /**
  73415. * Forcing an export so that this code will execute
  73416. * @hidden
  73417. */
  73418. const name = "Statics";
  73419. }
  73420. declare module BABYLON.GUI {
  73421. /**
  73422. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  73423. */
  73424. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  73425. /**
  73426. * Define the instrumented AdvancedDynamicTexture.
  73427. */
  73428. texture: AdvancedDynamicTexture;
  73429. private _captureRenderTime;
  73430. private _renderTime;
  73431. private _captureLayoutTime;
  73432. private _layoutTime;
  73433. private _onBeginRenderObserver;
  73434. private _onEndRenderObserver;
  73435. private _onBeginLayoutObserver;
  73436. private _onEndLayoutObserver;
  73437. /**
  73438. * Gets the perf counter used to capture render time
  73439. */
  73440. get renderTimeCounter(): BABYLON.PerfCounter;
  73441. /**
  73442. * Gets the perf counter used to capture layout time
  73443. */
  73444. get layoutTimeCounter(): BABYLON.PerfCounter;
  73445. /**
  73446. * Enable or disable the render time capture
  73447. */
  73448. get captureRenderTime(): boolean;
  73449. set captureRenderTime(value: boolean);
  73450. /**
  73451. * Enable or disable the layout time capture
  73452. */
  73453. get captureLayoutTime(): boolean;
  73454. set captureLayoutTime(value: boolean);
  73455. /**
  73456. * Instantiates a new advanced dynamic texture instrumentation.
  73457. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73458. * @param texture Defines the AdvancedDynamicTexture to instrument
  73459. */
  73460. constructor(
  73461. /**
  73462. * Define the instrumented AdvancedDynamicTexture.
  73463. */
  73464. texture: AdvancedDynamicTexture);
  73465. /**
  73466. * Dispose and release associated resources.
  73467. */
  73468. dispose(): void;
  73469. }
  73470. }
  73471. declare module BABYLON.GUI {
  73472. /**
  73473. * Class used to load GUI via XML.
  73474. */
  73475. export class XmlLoader {
  73476. private _nodes;
  73477. private _nodeTypes;
  73478. private _isLoaded;
  73479. private _objectAttributes;
  73480. private _parentClass;
  73481. /**
  73482. * Create a new xml loader
  73483. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73484. */
  73485. constructor(parentClass?: null);
  73486. private _getChainElement;
  73487. private _getClassAttribute;
  73488. private _createGuiElement;
  73489. private _parseGrid;
  73490. private _parseElement;
  73491. private _prepareSourceElement;
  73492. private _parseElementsFromSource;
  73493. private _parseXml;
  73494. /**
  73495. * Gets if the loading has finished.
  73496. * @returns whether the loading has finished or not
  73497. */
  73498. isLoaded(): boolean;
  73499. /**
  73500. * Gets a loaded node / control by id.
  73501. * @param id the Controls id set in the xml
  73502. * @returns element of type Control
  73503. */
  73504. getNodeById(id: string): any;
  73505. /**
  73506. * Gets all loaded nodes / controls
  73507. * @returns Array of controls
  73508. */
  73509. getNodes(): any;
  73510. /**
  73511. * Initiates the xml layout loading
  73512. * @param xmlFile defines the xml layout to load
  73513. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73514. * @param callback defines the callback called on layout load.
  73515. */
  73516. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73517. }
  73518. }
  73519. declare module BABYLON.GUI {
  73520. /**
  73521. * Class used to create containers for controls
  73522. */
  73523. export class Container3D extends Control3D {
  73524. private _blockLayout;
  73525. /**
  73526. * Gets the list of child controls
  73527. */
  73528. protected _children: Control3D[];
  73529. /**
  73530. * Gets the list of child controls
  73531. */
  73532. get children(): Array<Control3D>;
  73533. /**
  73534. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73535. * This is helpful to optimize layout operation when adding multiple children in a row
  73536. */
  73537. get blockLayout(): boolean;
  73538. set blockLayout(value: boolean);
  73539. /**
  73540. * Creates a new container
  73541. * @param name defines the container name
  73542. */
  73543. constructor(name?: string);
  73544. /**
  73545. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73546. * @returns the current container
  73547. */
  73548. updateLayout(): Container3D;
  73549. /**
  73550. * Gets a boolean indicating if the given control is in the children of this control
  73551. * @param control defines the control to check
  73552. * @returns true if the control is in the child list
  73553. */
  73554. containsControl(control: Control3D): boolean;
  73555. /**
  73556. * Adds a control to the children of this control
  73557. * @param control defines the control to add
  73558. * @returns the current container
  73559. */
  73560. addControl(control: Control3D): Container3D;
  73561. /**
  73562. * This function will be called everytime a new control is added
  73563. */
  73564. protected _arrangeChildren(): void;
  73565. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73566. /**
  73567. * Removes a control from the children of this control
  73568. * @param control defines the control to remove
  73569. * @returns the current container
  73570. */
  73571. removeControl(control: Control3D): Container3D;
  73572. protected _getTypeName(): string;
  73573. /**
  73574. * Releases all associated resources
  73575. */
  73576. dispose(): void;
  73577. /** Control rotation will remain unchanged */
  73578. static readonly UNSET_ORIENTATION: number;
  73579. /** Control will rotate to make it look at sphere central axis */
  73580. static readonly FACEORIGIN_ORIENTATION: number;
  73581. /** Control will rotate to make it look back at sphere central axis */
  73582. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73583. /** Control will rotate to look at z axis (0, 0, 1) */
  73584. static readonly FACEFORWARD_ORIENTATION: number;
  73585. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73586. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73587. }
  73588. }
  73589. declare module BABYLON.GUI {
  73590. /**
  73591. * Class used to manage 3D user interface
  73592. * @see http://doc.babylonjs.com/how_to/gui3d
  73593. */
  73594. export class GUI3DManager implements BABYLON.IDisposable {
  73595. private _scene;
  73596. private _sceneDisposeObserver;
  73597. private _utilityLayer;
  73598. private _rootContainer;
  73599. private _pointerObserver;
  73600. private _pointerOutObserver;
  73601. /** @hidden */
  73602. _lastPickedControl: Control3D;
  73603. /** @hidden */
  73604. _lastControlOver: {
  73605. [pointerId: number]: Control3D;
  73606. };
  73607. /** @hidden */
  73608. _lastControlDown: {
  73609. [pointerId: number]: Control3D;
  73610. };
  73611. /**
  73612. * BABYLON.Observable raised when the point picked by the pointer events changed
  73613. */
  73614. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73615. /** @hidden */
  73616. _sharedMaterials: {
  73617. [key: string]: BABYLON.Material;
  73618. };
  73619. /** Gets the hosting scene */
  73620. get scene(): BABYLON.Scene;
  73621. /** Gets associated utility layer */
  73622. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73623. /**
  73624. * Creates a new GUI3DManager
  73625. * @param scene
  73626. */
  73627. constructor(scene?: BABYLON.Scene);
  73628. private _handlePointerOut;
  73629. private _doPicking;
  73630. /**
  73631. * Gets the root container
  73632. */
  73633. get rootContainer(): Container3D;
  73634. /**
  73635. * Gets a boolean indicating if the given control is in the root child list
  73636. * @param control defines the control to check
  73637. * @returns true if the control is in the root child list
  73638. */
  73639. containsControl(control: Control3D): boolean;
  73640. /**
  73641. * Adds a control to the root child list
  73642. * @param control defines the control to add
  73643. * @returns the current manager
  73644. */
  73645. addControl(control: Control3D): GUI3DManager;
  73646. /**
  73647. * Removes a control from the root child list
  73648. * @param control defines the control to remove
  73649. * @returns the current container
  73650. */
  73651. removeControl(control: Control3D): GUI3DManager;
  73652. /**
  73653. * Releases all associated resources
  73654. */
  73655. dispose(): void;
  73656. }
  73657. }
  73658. declare module BABYLON.GUI {
  73659. /**
  73660. * Class used to transport BABYLON.Vector3 information for pointer events
  73661. */
  73662. export class Vector3WithInfo extends BABYLON.Vector3 {
  73663. /** defines the current mouse button index */
  73664. buttonIndex: number;
  73665. /**
  73666. * Creates a new Vector3WithInfo
  73667. * @param source defines the vector3 data to transport
  73668. * @param buttonIndex defines the current mouse button index
  73669. */
  73670. constructor(source: BABYLON.Vector3,
  73671. /** defines the current mouse button index */
  73672. buttonIndex?: number);
  73673. }
  73674. }
  73675. declare module BABYLON.GUI {
  73676. /**
  73677. * Class used as base class for controls
  73678. */
  73679. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  73680. /** Defines the control name */
  73681. name?: string | undefined;
  73682. /** @hidden */
  73683. _host: GUI3DManager;
  73684. private _node;
  73685. private _downCount;
  73686. private _enterCount;
  73687. private _downPointerIds;
  73688. private _isVisible;
  73689. /** Gets or sets the control position in world space */
  73690. get position(): BABYLON.Vector3;
  73691. set position(value: BABYLON.Vector3);
  73692. /** Gets or sets the control scaling in world space */
  73693. get scaling(): BABYLON.Vector3;
  73694. set scaling(value: BABYLON.Vector3);
  73695. /** Callback used to start pointer enter animation */
  73696. pointerEnterAnimation: () => void;
  73697. /** Callback used to start pointer out animation */
  73698. pointerOutAnimation: () => void;
  73699. /** Callback used to start pointer down animation */
  73700. pointerDownAnimation: () => void;
  73701. /** Callback used to start pointer up animation */
  73702. pointerUpAnimation: () => void;
  73703. /**
  73704. * An event triggered when the pointer move over the control
  73705. */
  73706. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  73707. /**
  73708. * An event triggered when the pointer move out of the control
  73709. */
  73710. onPointerOutObservable: BABYLON.Observable<Control3D>;
  73711. /**
  73712. * An event triggered when the pointer taps the control
  73713. */
  73714. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  73715. /**
  73716. * An event triggered when pointer is up
  73717. */
  73718. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  73719. /**
  73720. * An event triggered when a control is clicked on (with a mouse)
  73721. */
  73722. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  73723. /**
  73724. * An event triggered when pointer enters the control
  73725. */
  73726. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  73727. /**
  73728. * Gets or sets the parent container
  73729. */
  73730. parent: BABYLON.Nullable<Container3D>;
  73731. private _behaviors;
  73732. /**
  73733. * Gets the list of attached behaviors
  73734. * @see http://doc.babylonjs.com/features/behaviour
  73735. */
  73736. get behaviors(): BABYLON.Behavior<Control3D>[];
  73737. /**
  73738. * Attach a behavior to the control
  73739. * @see http://doc.babylonjs.com/features/behaviour
  73740. * @param behavior defines the behavior to attach
  73741. * @returns the current control
  73742. */
  73743. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73744. /**
  73745. * Remove an attached behavior
  73746. * @see http://doc.babylonjs.com/features/behaviour
  73747. * @param behavior defines the behavior to attach
  73748. * @returns the current control
  73749. */
  73750. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73751. /**
  73752. * Gets an attached behavior by name
  73753. * @param name defines the name of the behavior to look for
  73754. * @see http://doc.babylonjs.com/features/behaviour
  73755. * @returns null if behavior was not found else the requested behavior
  73756. */
  73757. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  73758. /** Gets or sets a boolean indicating if the control is visible */
  73759. get isVisible(): boolean;
  73760. set isVisible(value: boolean);
  73761. /**
  73762. * Creates a new control
  73763. * @param name defines the control name
  73764. */
  73765. constructor(
  73766. /** Defines the control name */
  73767. name?: string | undefined);
  73768. /**
  73769. * Gets a string representing the class name
  73770. */
  73771. get typeName(): string;
  73772. /**
  73773. * Get the current class name of the control.
  73774. * @returns current class name
  73775. */
  73776. getClassName(): string;
  73777. protected _getTypeName(): string;
  73778. /**
  73779. * Gets the transform node used by this control
  73780. */
  73781. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  73782. /**
  73783. * Gets the mesh used to render this control
  73784. */
  73785. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73786. /**
  73787. * Link the control as child of the given node
  73788. * @param node defines the node to link to. Use null to unlink the control
  73789. * @returns the current control
  73790. */
  73791. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  73792. /** @hidden **/
  73793. _prepareNode(scene: BABYLON.Scene): void;
  73794. /**
  73795. * Node creation.
  73796. * Can be overriden by children
  73797. * @param scene defines the scene where the node must be attached
  73798. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  73799. */
  73800. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73801. /**
  73802. * Affect a material to the given mesh
  73803. * @param mesh defines the mesh which will represent the control
  73804. */
  73805. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73806. /** @hidden */
  73807. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73808. /** @hidden */
  73809. _onPointerEnter(target: Control3D): boolean;
  73810. /** @hidden */
  73811. _onPointerOut(target: Control3D): void;
  73812. /** @hidden */
  73813. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73814. /** @hidden */
  73815. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73816. /** @hidden */
  73817. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73818. /** @hidden */
  73819. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73820. /** @hidden */
  73821. _disposeNode(): void;
  73822. /**
  73823. * Releases all associated resources
  73824. */
  73825. dispose(): void;
  73826. }
  73827. }
  73828. declare module BABYLON.GUI {
  73829. /**
  73830. * Class used as a root to all buttons
  73831. */
  73832. export class AbstractButton3D extends Control3D {
  73833. /**
  73834. * Creates a new button
  73835. * @param name defines the control name
  73836. */
  73837. constructor(name?: string);
  73838. protected _getTypeName(): string;
  73839. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73840. }
  73841. }
  73842. declare module BABYLON.GUI {
  73843. /**
  73844. * Class used to create a button in 3D
  73845. */
  73846. export class Button3D extends AbstractButton3D {
  73847. /** @hidden */
  73848. protected _currentMaterial: BABYLON.Material;
  73849. private _facadeTexture;
  73850. private _content;
  73851. private _contentResolution;
  73852. private _contentScaleRatio;
  73853. /**
  73854. * Gets or sets the texture resolution used to render content (512 by default)
  73855. */
  73856. get contentResolution(): BABYLON.int;
  73857. set contentResolution(value: BABYLON.int);
  73858. /**
  73859. * Gets or sets the texture scale ratio used to render content (2 by default)
  73860. */
  73861. get contentScaleRatio(): number;
  73862. set contentScaleRatio(value: number);
  73863. protected _disposeFacadeTexture(): void;
  73864. protected _resetContent(): void;
  73865. /**
  73866. * Creates a new button
  73867. * @param name defines the control name
  73868. */
  73869. constructor(name?: string);
  73870. /**
  73871. * Gets or sets the GUI 2D content used to display the button's facade
  73872. */
  73873. get content(): Control;
  73874. set content(value: Control);
  73875. /**
  73876. * Apply the facade texture (created from the content property).
  73877. * This function can be overloaded by child classes
  73878. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73879. */
  73880. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73881. protected _getTypeName(): string;
  73882. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73883. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73884. /**
  73885. * Releases all associated resources
  73886. */
  73887. dispose(): void;
  73888. }
  73889. }
  73890. declare module BABYLON.GUI {
  73891. /**
  73892. * Abstract class used to create a container panel deployed on the surface of a volume
  73893. */
  73894. export abstract class VolumeBasedPanel extends Container3D {
  73895. private _columns;
  73896. private _rows;
  73897. private _rowThenColum;
  73898. private _orientation;
  73899. protected _cellWidth: number;
  73900. protected _cellHeight: number;
  73901. /**
  73902. * Gets or sets the distance between elements
  73903. */
  73904. margin: number;
  73905. /**
  73906. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73907. * | Value | Type | Description |
  73908. * | ----- | ----------------------------------- | ----------- |
  73909. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73910. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73911. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73912. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73913. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73914. */
  73915. get orientation(): number;
  73916. set orientation(value: number);
  73917. /**
  73918. * Gets or sets the number of columns requested (10 by default).
  73919. * The panel will automatically compute the number of rows based on number of child controls.
  73920. */
  73921. get columns(): BABYLON.int;
  73922. set columns(value: BABYLON.int);
  73923. /**
  73924. * Gets or sets a the number of rows requested.
  73925. * The panel will automatically compute the number of columns based on number of child controls.
  73926. */
  73927. get rows(): BABYLON.int;
  73928. set rows(value: BABYLON.int);
  73929. /**
  73930. * Creates new VolumeBasedPanel
  73931. */
  73932. constructor();
  73933. protected _arrangeChildren(): void;
  73934. /** Child classes must implement this function to provide correct control positioning */
  73935. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73936. /** Child classes can implement this function to provide additional processing */
  73937. protected _finalProcessing(): void;
  73938. }
  73939. }
  73940. declare module BABYLON.GUI {
  73941. /**
  73942. * Class used to create a container panel deployed on the surface of a cylinder
  73943. */
  73944. export class CylinderPanel extends VolumeBasedPanel {
  73945. private _radius;
  73946. /**
  73947. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73948. */
  73949. get radius(): BABYLON.float;
  73950. set radius(value: BABYLON.float);
  73951. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73952. private _cylindricalMapping;
  73953. }
  73954. }
  73955. declare module BABYLON.GUI {
  73956. /** @hidden */
  73957. export var fluentVertexShader: {
  73958. name: string;
  73959. shader: string;
  73960. };
  73961. }
  73962. declare module BABYLON.GUI {
  73963. /** @hidden */
  73964. export var fluentPixelShader: {
  73965. name: string;
  73966. shader: string;
  73967. };
  73968. }
  73969. declare module BABYLON.GUI {
  73970. /** @hidden */
  73971. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73972. INNERGLOW: boolean;
  73973. BORDER: boolean;
  73974. HOVERLIGHT: boolean;
  73975. TEXTURE: boolean;
  73976. constructor();
  73977. }
  73978. /**
  73979. * Class used to render controls with fluent desgin
  73980. */
  73981. export class FluentMaterial extends BABYLON.PushMaterial {
  73982. /**
  73983. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73984. */
  73985. innerGlowColorIntensity: number;
  73986. /**
  73987. * Gets or sets the inner glow color (white by default)
  73988. */
  73989. innerGlowColor: BABYLON.Color3;
  73990. /**
  73991. * Gets or sets alpha value (default is 1.0)
  73992. */
  73993. alpha: number;
  73994. /**
  73995. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73996. */
  73997. albedoColor: BABYLON.Color3;
  73998. /**
  73999. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74000. */
  74001. renderBorders: boolean;
  74002. /**
  74003. * Gets or sets border width (default is 0.5)
  74004. */
  74005. borderWidth: number;
  74006. /**
  74007. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74008. */
  74009. edgeSmoothingValue: number;
  74010. /**
  74011. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74012. */
  74013. borderMinValue: number;
  74014. /**
  74015. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74016. */
  74017. renderHoverLight: boolean;
  74018. /**
  74019. * Gets or sets the radius used to render the hover light (default is 1.0)
  74020. */
  74021. hoverRadius: number;
  74022. /**
  74023. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74024. */
  74025. hoverColor: BABYLON.Color4;
  74026. /**
  74027. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74028. */
  74029. hoverPosition: BABYLON.Vector3;
  74030. private _albedoTexture;
  74031. /** Gets or sets the texture to use for albedo color */
  74032. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74033. /**
  74034. * Creates a new Fluent material
  74035. * @param name defines the name of the material
  74036. * @param scene defines the hosting scene
  74037. */
  74038. constructor(name: string, scene: BABYLON.Scene);
  74039. needAlphaBlending(): boolean;
  74040. needAlphaTesting(): boolean;
  74041. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74042. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74043. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74044. getActiveTextures(): BABYLON.BaseTexture[];
  74045. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74046. dispose(forceDisposeEffect?: boolean): void;
  74047. clone(name: string): FluentMaterial;
  74048. serialize(): any;
  74049. getClassName(): string;
  74050. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74051. }
  74052. }
  74053. declare module BABYLON.GUI {
  74054. /**
  74055. * Class used to create a holographic button in 3D
  74056. */
  74057. export class HolographicButton extends Button3D {
  74058. private _backPlate;
  74059. private _textPlate;
  74060. private _frontPlate;
  74061. private _text;
  74062. private _imageUrl;
  74063. private _shareMaterials;
  74064. private _frontMaterial;
  74065. private _backMaterial;
  74066. private _plateMaterial;
  74067. private _pickedPointObserver;
  74068. private _tooltipFade;
  74069. private _tooltipTextBlock;
  74070. private _tooltipTexture;
  74071. private _tooltipMesh;
  74072. private _tooltipHoverObserver;
  74073. private _tooltipOutObserver;
  74074. private _disposeTooltip;
  74075. /**
  74076. * Rendering ground id of all the mesh in the button
  74077. */
  74078. set renderingGroupId(id: number);
  74079. get renderingGroupId(): number;
  74080. /**
  74081. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74082. */
  74083. set tooltipText(text: BABYLON.Nullable<string>);
  74084. get tooltipText(): BABYLON.Nullable<string>;
  74085. /**
  74086. * Gets or sets text for the button
  74087. */
  74088. get text(): string;
  74089. set text(value: string);
  74090. /**
  74091. * Gets or sets the image url for the button
  74092. */
  74093. get imageUrl(): string;
  74094. set imageUrl(value: string);
  74095. /**
  74096. * Gets the back material used by this button
  74097. */
  74098. get backMaterial(): FluentMaterial;
  74099. /**
  74100. * Gets the front material used by this button
  74101. */
  74102. get frontMaterial(): FluentMaterial;
  74103. /**
  74104. * Gets the plate material used by this button
  74105. */
  74106. get plateMaterial(): BABYLON.StandardMaterial;
  74107. /**
  74108. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74109. */
  74110. get shareMaterials(): boolean;
  74111. /**
  74112. * Creates a new button
  74113. * @param name defines the control name
  74114. */
  74115. constructor(name?: string, shareMaterials?: boolean);
  74116. protected _getTypeName(): string;
  74117. private _rebuildContent;
  74118. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74119. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74120. private _createBackMaterial;
  74121. private _createFrontMaterial;
  74122. private _createPlateMaterial;
  74123. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  74124. /**
  74125. * Releases all associated resources
  74126. */
  74127. dispose(): void;
  74128. }
  74129. }
  74130. declare module BABYLON.GUI {
  74131. /**
  74132. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  74133. */
  74134. export class MeshButton3D extends Button3D {
  74135. /** @hidden */
  74136. protected _currentMesh: BABYLON.Mesh;
  74137. /**
  74138. * Creates a new 3D button based on a mesh
  74139. * @param mesh mesh to become a 3D button
  74140. * @param name defines the control name
  74141. */
  74142. constructor(mesh: BABYLON.Mesh, name?: string);
  74143. protected _getTypeName(): string;
  74144. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74145. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74146. }
  74147. }
  74148. declare module BABYLON.GUI {
  74149. /**
  74150. * Class used to create a container panel deployed on the surface of a plane
  74151. */
  74152. export class PlanePanel extends VolumeBasedPanel {
  74153. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74154. }
  74155. }
  74156. declare module BABYLON.GUI {
  74157. /**
  74158. * Class used to create a container panel where items get randomized planar mapping
  74159. */
  74160. export class ScatterPanel extends VolumeBasedPanel {
  74161. private _iteration;
  74162. /**
  74163. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74164. */
  74165. get iteration(): BABYLON.float;
  74166. set iteration(value: BABYLON.float);
  74167. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74168. private _scatterMapping;
  74169. protected _finalProcessing(): void;
  74170. }
  74171. }
  74172. declare module BABYLON.GUI {
  74173. /**
  74174. * Class used to create a container panel deployed on the surface of a sphere
  74175. */
  74176. export class SpherePanel extends VolumeBasedPanel {
  74177. private _radius;
  74178. /**
  74179. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74180. */
  74181. get radius(): BABYLON.float;
  74182. set radius(value: BABYLON.float);
  74183. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74184. private _sphericalMapping;
  74185. }
  74186. }
  74187. declare module BABYLON.GUI {
  74188. /**
  74189. * Class used to create a stack panel in 3D on XY plane
  74190. */
  74191. export class StackPanel3D extends Container3D {
  74192. private _isVertical;
  74193. /**
  74194. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74195. */
  74196. get isVertical(): boolean;
  74197. set isVertical(value: boolean);
  74198. /**
  74199. * Gets or sets the distance between elements
  74200. */
  74201. margin: number;
  74202. /**
  74203. * Creates new StackPanel
  74204. * @param isVertical
  74205. */
  74206. constructor(isVertical?: boolean);
  74207. protected _arrangeChildren(): void;
  74208. }
  74209. }
  74210. declare module BABYLON {
  74211. /**
  74212. * Configuration for glTF validation
  74213. */
  74214. export interface IGLTFValidationConfiguration {
  74215. /**
  74216. * The url of the glTF validator.
  74217. */
  74218. url: string;
  74219. }
  74220. /**
  74221. * glTF validation
  74222. */
  74223. export class GLTFValidation {
  74224. /**
  74225. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74226. */
  74227. static Configuration: IGLTFValidationConfiguration;
  74228. private static _LoadScriptPromise;
  74229. /**
  74230. * Validate a glTF asset using the glTF-Validator.
  74231. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74232. * @param rootUrl The root url for the glTF
  74233. * @param fileName The file name for the glTF
  74234. * @param getExternalResource The callback to get external resources for the glTF validator
  74235. * @returns A promise that resolves with the glTF validation results once complete
  74236. */
  74237. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74238. }
  74239. }
  74240. declare module BABYLON {
  74241. /**
  74242. * Mode that determines the coordinate system to use.
  74243. */
  74244. export enum GLTFLoaderCoordinateSystemMode {
  74245. /**
  74246. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74247. */
  74248. AUTO = 0,
  74249. /**
  74250. * Sets the useRightHandedSystem flag on the scene.
  74251. */
  74252. FORCE_RIGHT_HANDED = 1
  74253. }
  74254. /**
  74255. * Mode that determines what animations will start.
  74256. */
  74257. export enum GLTFLoaderAnimationStartMode {
  74258. /**
  74259. * No animation will start.
  74260. */
  74261. NONE = 0,
  74262. /**
  74263. * The first animation will start.
  74264. */
  74265. FIRST = 1,
  74266. /**
  74267. * All animations will start.
  74268. */
  74269. ALL = 2
  74270. }
  74271. /**
  74272. * Interface that contains the data for the glTF asset.
  74273. */
  74274. export interface IGLTFLoaderData {
  74275. /**
  74276. * The object that represents the glTF JSON.
  74277. */
  74278. json: Object;
  74279. /**
  74280. * The BIN chunk of a binary glTF.
  74281. */
  74282. bin: Nullable<IDataBuffer>;
  74283. }
  74284. /**
  74285. * Interface for extending the loader.
  74286. */
  74287. export interface IGLTFLoaderExtension {
  74288. /**
  74289. * The name of this extension.
  74290. */
  74291. readonly name: string;
  74292. /**
  74293. * Defines whether this extension is enabled.
  74294. */
  74295. enabled: boolean;
  74296. /**
  74297. * Defines the order of this extension.
  74298. * The loader sorts the extensions using these values when loading.
  74299. */
  74300. order?: number;
  74301. }
  74302. /**
  74303. * Loader state.
  74304. */
  74305. export enum GLTFLoaderState {
  74306. /**
  74307. * The asset is loading.
  74308. */
  74309. LOADING = 0,
  74310. /**
  74311. * The asset is ready for rendering.
  74312. */
  74313. READY = 1,
  74314. /**
  74315. * The asset is completely loaded.
  74316. */
  74317. COMPLETE = 2
  74318. }
  74319. /** @hidden */
  74320. export interface IImportMeshAsyncOutput {
  74321. meshes: AbstractMesh[];
  74322. particleSystems: IParticleSystem[];
  74323. skeletons: Skeleton[];
  74324. animationGroups: AnimationGroup[];
  74325. lights: Light[];
  74326. transformNodes: TransformNode[];
  74327. }
  74328. /** @hidden */
  74329. export interface IGLTFLoader extends IDisposable {
  74330. readonly state: Nullable<GLTFLoaderState>;
  74331. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  74332. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74333. }
  74334. /**
  74335. * File loader for loading glTF files into a scene.
  74336. */
  74337. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74338. /** @hidden */
  74339. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74340. /** @hidden */
  74341. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74342. /**
  74343. * Raised when the asset has been parsed
  74344. */
  74345. onParsedObservable: Observable<IGLTFLoaderData>;
  74346. private _onParsedObserver;
  74347. /**
  74348. * Raised when the asset has been parsed
  74349. */
  74350. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74351. /**
  74352. * 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.
  74353. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74354. * Defaults to true.
  74355. * @hidden
  74356. */
  74357. static IncrementalLoading: boolean;
  74358. /**
  74359. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74360. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74361. * @hidden
  74362. */
  74363. static HomogeneousCoordinates: boolean;
  74364. /**
  74365. * The coordinate system mode. Defaults to AUTO.
  74366. */
  74367. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74368. /**
  74369. * The animation start mode. Defaults to FIRST.
  74370. */
  74371. animationStartMode: GLTFLoaderAnimationStartMode;
  74372. /**
  74373. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74374. */
  74375. compileMaterials: boolean;
  74376. /**
  74377. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74378. */
  74379. useClipPlane: boolean;
  74380. /**
  74381. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74382. */
  74383. compileShadowGenerators: boolean;
  74384. /**
  74385. * Defines if the Alpha blended materials are only applied as coverage.
  74386. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74387. * If true, no extra effects are applied to transparent pixels.
  74388. */
  74389. transparencyAsCoverage: boolean;
  74390. /**
  74391. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74392. * Enabling will disable offline support and glTF validator.
  74393. * Defaults to false.
  74394. */
  74395. useRangeRequests: boolean;
  74396. /**
  74397. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74398. */
  74399. createInstances: boolean;
  74400. /**
  74401. * Function called before loading a url referenced by the asset.
  74402. */
  74403. preprocessUrlAsync: (url: string) => Promise<string>;
  74404. /**
  74405. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74406. */
  74407. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74408. private _onMeshLoadedObserver;
  74409. /**
  74410. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74411. */
  74412. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  74413. /**
  74414. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  74415. */
  74416. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  74417. private _onTextureLoadedObserver;
  74418. /**
  74419. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  74420. */
  74421. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  74422. /**
  74423. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  74424. */
  74425. readonly onMaterialLoadedObservable: Observable<Material>;
  74426. private _onMaterialLoadedObserver;
  74427. /**
  74428. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  74429. */
  74430. set onMaterialLoaded(callback: (material: Material) => void);
  74431. /**
  74432. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  74433. */
  74434. readonly onCameraLoadedObservable: Observable<Camera>;
  74435. private _onCameraLoadedObserver;
  74436. /**
  74437. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  74438. */
  74439. set onCameraLoaded(callback: (camera: Camera) => void);
  74440. /**
  74441. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  74442. * For assets with LODs, raised when all of the LODs are complete.
  74443. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74444. */
  74445. readonly onCompleteObservable: Observable<void>;
  74446. private _onCompleteObserver;
  74447. /**
  74448. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74449. * For assets with LODs, raised when all of the LODs are complete.
  74450. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74451. */
  74452. set onComplete(callback: () => void);
  74453. /**
  74454. * Observable raised when an error occurs.
  74455. */
  74456. readonly onErrorObservable: Observable<any>;
  74457. private _onErrorObserver;
  74458. /**
  74459. * Callback raised when an error occurs.
  74460. */
  74461. set onError(callback: (reason: any) => void);
  74462. /**
  74463. * Observable raised after the loader is disposed.
  74464. */
  74465. readonly onDisposeObservable: Observable<void>;
  74466. private _onDisposeObserver;
  74467. /**
  74468. * Callback raised after the loader is disposed.
  74469. */
  74470. set onDispose(callback: () => void);
  74471. /**
  74472. * Observable raised after a loader extension is created.
  74473. * Set additional options for a loader extension in this event.
  74474. */
  74475. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74476. private _onExtensionLoadedObserver;
  74477. /**
  74478. * Callback raised after a loader extension is created.
  74479. */
  74480. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74481. /**
  74482. * Defines if the loader logging is enabled.
  74483. */
  74484. get loggingEnabled(): boolean;
  74485. set loggingEnabled(value: boolean);
  74486. /**
  74487. * Defines if the loader should capture performance counters.
  74488. */
  74489. get capturePerformanceCounters(): boolean;
  74490. set capturePerformanceCounters(value: boolean);
  74491. /**
  74492. * Defines if the loader should validate the asset.
  74493. */
  74494. validate: boolean;
  74495. /**
  74496. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74497. */
  74498. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74499. private _onValidatedObserver;
  74500. /**
  74501. * Callback raised after a loader extension is created.
  74502. */
  74503. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74504. private _loader;
  74505. /**
  74506. * Name of the loader ("gltf")
  74507. */
  74508. name: string;
  74509. /** @hidden */
  74510. extensions: ISceneLoaderPluginExtensions;
  74511. /**
  74512. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74513. */
  74514. dispose(): void;
  74515. /** @hidden */
  74516. _clear(): void;
  74517. /** @hidden */
  74518. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74519. /** @hidden */
  74520. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74521. /** @hidden */
  74522. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74523. meshes: AbstractMesh[];
  74524. particleSystems: IParticleSystem[];
  74525. skeletons: Skeleton[];
  74526. animationGroups: AnimationGroup[];
  74527. }>;
  74528. /** @hidden */
  74529. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74530. /** @hidden */
  74531. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74532. /** @hidden */
  74533. canDirectLoad(data: string): boolean;
  74534. /** @hidden */
  74535. directLoad(scene: Scene, data: string): any;
  74536. /**
  74537. * The callback that allows custom handling of the root url based on the response url.
  74538. * @param rootUrl the original root url
  74539. * @param responseURL the response url if available
  74540. * @returns the new root url
  74541. */
  74542. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74543. /** @hidden */
  74544. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74545. /**
  74546. * The loader state or null if the loader is not active.
  74547. */
  74548. get loaderState(): Nullable<GLTFLoaderState>;
  74549. /**
  74550. * Returns a promise that resolves when the asset is completely loaded.
  74551. * @returns a promise that resolves when the asset is completely loaded.
  74552. */
  74553. whenCompleteAsync(): Promise<void>;
  74554. private _validate;
  74555. private _getLoader;
  74556. private _parseJson;
  74557. private _unpackBinaryAsync;
  74558. private _unpackBinaryV1Async;
  74559. private _unpackBinaryV2Async;
  74560. private static _parseVersion;
  74561. private static _compareVersion;
  74562. private static readonly _logSpaces;
  74563. private _logIndentLevel;
  74564. private _loggingEnabled;
  74565. /** @hidden */
  74566. _log: (message: string) => void;
  74567. /** @hidden */
  74568. _logOpen(message: string): void;
  74569. /** @hidden */
  74570. _logClose(): void;
  74571. private _logEnabled;
  74572. private _logDisabled;
  74573. private _capturePerformanceCounters;
  74574. /** @hidden */
  74575. _startPerformanceCounter: (counterName: string) => void;
  74576. /** @hidden */
  74577. _endPerformanceCounter: (counterName: string) => void;
  74578. private _startPerformanceCounterEnabled;
  74579. private _startPerformanceCounterDisabled;
  74580. private _endPerformanceCounterEnabled;
  74581. private _endPerformanceCounterDisabled;
  74582. }
  74583. }
  74584. declare module BABYLON.GLTF1 {
  74585. /**
  74586. * Enums
  74587. * @hidden
  74588. */
  74589. export enum EComponentType {
  74590. BYTE = 5120,
  74591. UNSIGNED_BYTE = 5121,
  74592. SHORT = 5122,
  74593. UNSIGNED_SHORT = 5123,
  74594. FLOAT = 5126
  74595. }
  74596. /** @hidden */
  74597. export enum EShaderType {
  74598. FRAGMENT = 35632,
  74599. VERTEX = 35633
  74600. }
  74601. /** @hidden */
  74602. export enum EParameterType {
  74603. BYTE = 5120,
  74604. UNSIGNED_BYTE = 5121,
  74605. SHORT = 5122,
  74606. UNSIGNED_SHORT = 5123,
  74607. INT = 5124,
  74608. UNSIGNED_INT = 5125,
  74609. FLOAT = 5126,
  74610. FLOAT_VEC2 = 35664,
  74611. FLOAT_VEC3 = 35665,
  74612. FLOAT_VEC4 = 35666,
  74613. INT_VEC2 = 35667,
  74614. INT_VEC3 = 35668,
  74615. INT_VEC4 = 35669,
  74616. BOOL = 35670,
  74617. BOOL_VEC2 = 35671,
  74618. BOOL_VEC3 = 35672,
  74619. BOOL_VEC4 = 35673,
  74620. FLOAT_MAT2 = 35674,
  74621. FLOAT_MAT3 = 35675,
  74622. FLOAT_MAT4 = 35676,
  74623. SAMPLER_2D = 35678
  74624. }
  74625. /** @hidden */
  74626. export enum ETextureWrapMode {
  74627. CLAMP_TO_EDGE = 33071,
  74628. MIRRORED_REPEAT = 33648,
  74629. REPEAT = 10497
  74630. }
  74631. /** @hidden */
  74632. export enum ETextureFilterType {
  74633. NEAREST = 9728,
  74634. LINEAR = 9728,
  74635. NEAREST_MIPMAP_NEAREST = 9984,
  74636. LINEAR_MIPMAP_NEAREST = 9985,
  74637. NEAREST_MIPMAP_LINEAR = 9986,
  74638. LINEAR_MIPMAP_LINEAR = 9987
  74639. }
  74640. /** @hidden */
  74641. export enum ETextureFormat {
  74642. ALPHA = 6406,
  74643. RGB = 6407,
  74644. RGBA = 6408,
  74645. LUMINANCE = 6409,
  74646. LUMINANCE_ALPHA = 6410
  74647. }
  74648. /** @hidden */
  74649. export enum ECullingType {
  74650. FRONT = 1028,
  74651. BACK = 1029,
  74652. FRONT_AND_BACK = 1032
  74653. }
  74654. /** @hidden */
  74655. export enum EBlendingFunction {
  74656. ZERO = 0,
  74657. ONE = 1,
  74658. SRC_COLOR = 768,
  74659. ONE_MINUS_SRC_COLOR = 769,
  74660. DST_COLOR = 774,
  74661. ONE_MINUS_DST_COLOR = 775,
  74662. SRC_ALPHA = 770,
  74663. ONE_MINUS_SRC_ALPHA = 771,
  74664. DST_ALPHA = 772,
  74665. ONE_MINUS_DST_ALPHA = 773,
  74666. CONSTANT_COLOR = 32769,
  74667. ONE_MINUS_CONSTANT_COLOR = 32770,
  74668. CONSTANT_ALPHA = 32771,
  74669. ONE_MINUS_CONSTANT_ALPHA = 32772,
  74670. SRC_ALPHA_SATURATE = 776
  74671. }
  74672. /** @hidden */
  74673. export interface IGLTFProperty {
  74674. extensions?: {
  74675. [key: string]: any;
  74676. };
  74677. extras?: Object;
  74678. }
  74679. /** @hidden */
  74680. export interface IGLTFChildRootProperty extends IGLTFProperty {
  74681. name?: string;
  74682. }
  74683. /** @hidden */
  74684. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  74685. bufferView: string;
  74686. byteOffset: number;
  74687. byteStride: number;
  74688. count: number;
  74689. type: string;
  74690. componentType: EComponentType;
  74691. max?: number[];
  74692. min?: number[];
  74693. name?: string;
  74694. }
  74695. /** @hidden */
  74696. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  74697. buffer: string;
  74698. byteOffset: number;
  74699. byteLength: number;
  74700. byteStride: number;
  74701. target?: number;
  74702. }
  74703. /** @hidden */
  74704. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  74705. uri: string;
  74706. byteLength?: number;
  74707. type?: string;
  74708. }
  74709. /** @hidden */
  74710. export interface IGLTFShader extends IGLTFChildRootProperty {
  74711. uri: string;
  74712. type: EShaderType;
  74713. }
  74714. /** @hidden */
  74715. export interface IGLTFProgram extends IGLTFChildRootProperty {
  74716. attributes: string[];
  74717. fragmentShader: string;
  74718. vertexShader: string;
  74719. }
  74720. /** @hidden */
  74721. export interface IGLTFTechniqueParameter {
  74722. type: number;
  74723. count?: number;
  74724. semantic?: string;
  74725. node?: string;
  74726. value?: number | boolean | string | Array<any>;
  74727. source?: string;
  74728. babylonValue?: any;
  74729. }
  74730. /** @hidden */
  74731. export interface IGLTFTechniqueCommonProfile {
  74732. lightingModel: string;
  74733. texcoordBindings: Object;
  74734. parameters?: Array<any>;
  74735. }
  74736. /** @hidden */
  74737. export interface IGLTFTechniqueStatesFunctions {
  74738. blendColor?: number[];
  74739. blendEquationSeparate?: number[];
  74740. blendFuncSeparate?: number[];
  74741. colorMask: boolean[];
  74742. cullFace: number[];
  74743. }
  74744. /** @hidden */
  74745. export interface IGLTFTechniqueStates {
  74746. enable: number[];
  74747. functions: IGLTFTechniqueStatesFunctions;
  74748. }
  74749. /** @hidden */
  74750. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  74751. parameters: {
  74752. [key: string]: IGLTFTechniqueParameter;
  74753. };
  74754. program: string;
  74755. attributes: {
  74756. [key: string]: string;
  74757. };
  74758. uniforms: {
  74759. [key: string]: string;
  74760. };
  74761. states: IGLTFTechniqueStates;
  74762. }
  74763. /** @hidden */
  74764. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  74765. technique?: string;
  74766. values: string[];
  74767. }
  74768. /** @hidden */
  74769. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  74770. attributes: {
  74771. [key: string]: string;
  74772. };
  74773. indices: string;
  74774. material: string;
  74775. mode?: number;
  74776. }
  74777. /** @hidden */
  74778. export interface IGLTFMesh extends IGLTFChildRootProperty {
  74779. primitives: IGLTFMeshPrimitive[];
  74780. }
  74781. /** @hidden */
  74782. export interface IGLTFImage extends IGLTFChildRootProperty {
  74783. uri: string;
  74784. }
  74785. /** @hidden */
  74786. export interface IGLTFSampler extends IGLTFChildRootProperty {
  74787. magFilter?: number;
  74788. minFilter?: number;
  74789. wrapS?: number;
  74790. wrapT?: number;
  74791. }
  74792. /** @hidden */
  74793. export interface IGLTFTexture extends IGLTFChildRootProperty {
  74794. sampler: string;
  74795. source: string;
  74796. format?: ETextureFormat;
  74797. internalFormat?: ETextureFormat;
  74798. target?: number;
  74799. type?: number;
  74800. babylonTexture?: Texture;
  74801. }
  74802. /** @hidden */
  74803. export interface IGLTFAmbienLight {
  74804. color?: number[];
  74805. }
  74806. /** @hidden */
  74807. export interface IGLTFDirectionalLight {
  74808. color?: number[];
  74809. }
  74810. /** @hidden */
  74811. export interface IGLTFPointLight {
  74812. color?: number[];
  74813. constantAttenuation?: number;
  74814. linearAttenuation?: number;
  74815. quadraticAttenuation?: number;
  74816. }
  74817. /** @hidden */
  74818. export interface IGLTFSpotLight {
  74819. color?: number[];
  74820. constantAttenuation?: number;
  74821. fallOfAngle?: number;
  74822. fallOffExponent?: number;
  74823. linearAttenuation?: number;
  74824. quadraticAttenuation?: number;
  74825. }
  74826. /** @hidden */
  74827. export interface IGLTFLight extends IGLTFChildRootProperty {
  74828. type: string;
  74829. }
  74830. /** @hidden */
  74831. export interface IGLTFCameraOrthographic {
  74832. xmag: number;
  74833. ymag: number;
  74834. zfar: number;
  74835. znear: number;
  74836. }
  74837. /** @hidden */
  74838. export interface IGLTFCameraPerspective {
  74839. aspectRatio: number;
  74840. yfov: number;
  74841. zfar: number;
  74842. znear: number;
  74843. }
  74844. /** @hidden */
  74845. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74846. type: string;
  74847. }
  74848. /** @hidden */
  74849. export interface IGLTFAnimationChannelTarget {
  74850. id: string;
  74851. path: string;
  74852. }
  74853. /** @hidden */
  74854. export interface IGLTFAnimationChannel {
  74855. sampler: string;
  74856. target: IGLTFAnimationChannelTarget;
  74857. }
  74858. /** @hidden */
  74859. export interface IGLTFAnimationSampler {
  74860. input: string;
  74861. output: string;
  74862. interpolation?: string;
  74863. }
  74864. /** @hidden */
  74865. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74866. channels?: IGLTFAnimationChannel[];
  74867. parameters?: {
  74868. [key: string]: string;
  74869. };
  74870. samplers?: {
  74871. [key: string]: IGLTFAnimationSampler;
  74872. };
  74873. }
  74874. /** @hidden */
  74875. export interface IGLTFNodeInstanceSkin {
  74876. skeletons: string[];
  74877. skin: string;
  74878. meshes: string[];
  74879. }
  74880. /** @hidden */
  74881. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74882. bindShapeMatrix: number[];
  74883. inverseBindMatrices: string;
  74884. jointNames: string[];
  74885. babylonSkeleton?: Skeleton;
  74886. }
  74887. /** @hidden */
  74888. export interface IGLTFNode extends IGLTFChildRootProperty {
  74889. camera?: string;
  74890. children: string[];
  74891. skin?: string;
  74892. jointName?: string;
  74893. light?: string;
  74894. matrix: number[];
  74895. mesh?: string;
  74896. meshes?: string[];
  74897. rotation?: number[];
  74898. scale?: number[];
  74899. translation?: number[];
  74900. babylonNode?: Node;
  74901. }
  74902. /** @hidden */
  74903. export interface IGLTFScene extends IGLTFChildRootProperty {
  74904. nodes: string[];
  74905. }
  74906. /** @hidden */
  74907. export interface IGLTFRuntime {
  74908. extensions: {
  74909. [key: string]: any;
  74910. };
  74911. accessors: {
  74912. [key: string]: IGLTFAccessor;
  74913. };
  74914. buffers: {
  74915. [key: string]: IGLTFBuffer;
  74916. };
  74917. bufferViews: {
  74918. [key: string]: IGLTFBufferView;
  74919. };
  74920. meshes: {
  74921. [key: string]: IGLTFMesh;
  74922. };
  74923. lights: {
  74924. [key: string]: IGLTFLight;
  74925. };
  74926. cameras: {
  74927. [key: string]: IGLTFCamera;
  74928. };
  74929. nodes: {
  74930. [key: string]: IGLTFNode;
  74931. };
  74932. images: {
  74933. [key: string]: IGLTFImage;
  74934. };
  74935. textures: {
  74936. [key: string]: IGLTFTexture;
  74937. };
  74938. shaders: {
  74939. [key: string]: IGLTFShader;
  74940. };
  74941. programs: {
  74942. [key: string]: IGLTFProgram;
  74943. };
  74944. samplers: {
  74945. [key: string]: IGLTFSampler;
  74946. };
  74947. techniques: {
  74948. [key: string]: IGLTFTechnique;
  74949. };
  74950. materials: {
  74951. [key: string]: IGLTFMaterial;
  74952. };
  74953. animations: {
  74954. [key: string]: IGLTFAnimation;
  74955. };
  74956. skins: {
  74957. [key: string]: IGLTFSkins;
  74958. };
  74959. currentScene?: Object;
  74960. scenes: {
  74961. [key: string]: IGLTFScene;
  74962. };
  74963. extensionsUsed: string[];
  74964. extensionsRequired?: string[];
  74965. buffersCount: number;
  74966. shaderscount: number;
  74967. scene: Scene;
  74968. rootUrl: string;
  74969. loadedBufferCount: number;
  74970. loadedBufferViews: {
  74971. [name: string]: ArrayBufferView;
  74972. };
  74973. loadedShaderCount: number;
  74974. importOnlyMeshes: boolean;
  74975. importMeshesNames?: string[];
  74976. dummyNodes: Node[];
  74977. forAssetContainer: boolean;
  74978. }
  74979. /** @hidden */
  74980. export interface INodeToRoot {
  74981. bone: Bone;
  74982. node: IGLTFNode;
  74983. id: string;
  74984. }
  74985. /** @hidden */
  74986. export interface IJointNode {
  74987. node: IGLTFNode;
  74988. id: string;
  74989. }
  74990. }
  74991. declare module BABYLON.GLTF1 {
  74992. /**
  74993. * Utils functions for GLTF
  74994. * @hidden
  74995. */
  74996. export class GLTFUtils {
  74997. /**
  74998. * Sets the given "parameter" matrix
  74999. * @param scene: the Scene object
  75000. * @param source: the source node where to pick the matrix
  75001. * @param parameter: the GLTF technique parameter
  75002. * @param uniformName: the name of the shader's uniform
  75003. * @param shaderMaterial: the shader material
  75004. */
  75005. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75006. /**
  75007. * Sets the given "parameter" matrix
  75008. * @param shaderMaterial: the shader material
  75009. * @param uniform: the name of the shader's uniform
  75010. * @param value: the value of the uniform
  75011. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75012. */
  75013. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75014. /**
  75015. * Returns the wrap mode of the texture
  75016. * @param mode: the mode value
  75017. */
  75018. static GetWrapMode(mode: number): number;
  75019. /**
  75020. * Returns the byte stride giving an accessor
  75021. * @param accessor: the GLTF accessor objet
  75022. */
  75023. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75024. /**
  75025. * Returns the texture filter mode giving a mode value
  75026. * @param mode: the filter mode value
  75027. */
  75028. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75029. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75030. /**
  75031. * Returns a buffer from its accessor
  75032. * @param gltfRuntime: the GLTF runtime
  75033. * @param accessor: the GLTF accessor
  75034. */
  75035. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75036. /**
  75037. * Decodes a buffer view into a string
  75038. * @param view: the buffer view
  75039. */
  75040. static DecodeBufferToText(view: ArrayBufferView): string;
  75041. /**
  75042. * Returns the default material of gltf. Related to
  75043. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75044. * @param scene: the Babylon.js scene
  75045. */
  75046. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75047. private static _DefaultMaterial;
  75048. }
  75049. }
  75050. declare module BABYLON.GLTF1 {
  75051. /**
  75052. * Implementation of the base glTF spec
  75053. * @hidden
  75054. */
  75055. export class GLTFLoaderBase {
  75056. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75057. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75058. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75059. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75060. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75061. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75062. }
  75063. /**
  75064. * glTF V1 Loader
  75065. * @hidden
  75066. */
  75067. export class GLTFLoader implements IGLTFLoader {
  75068. static Extensions: {
  75069. [name: string]: GLTFLoaderExtension;
  75070. };
  75071. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75072. state: Nullable<GLTFLoaderState>;
  75073. dispose(): void;
  75074. private _importMeshAsync;
  75075. /**
  75076. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75077. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75078. * @param scene the scene the meshes should be added to
  75079. * @param forAssetContainer defines if the entities must be stored in the scene
  75080. * @param data gltf data containing information of the meshes in a loaded file
  75081. * @param rootUrl root url to load from
  75082. * @param onProgress event that fires when loading progress has occured
  75083. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75084. */
  75085. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75086. private _loadAsync;
  75087. /**
  75088. * Imports all objects from a loaded gltf file and adds them to the scene
  75089. * @param scene the scene the objects should be added to
  75090. * @param data gltf data containing information of the meshes in a loaded file
  75091. * @param rootUrl root url to load from
  75092. * @param onProgress event that fires when loading progress has occured
  75093. * @returns a promise which completes when objects have been loaded to the scene
  75094. */
  75095. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75096. private _loadShadersAsync;
  75097. private _loadBuffersAsync;
  75098. private _createNodes;
  75099. }
  75100. /** @hidden */
  75101. export abstract class GLTFLoaderExtension {
  75102. private _name;
  75103. constructor(name: string);
  75104. get name(): string;
  75105. /**
  75106. * Defines an override for loading the runtime
  75107. * Return true to stop further extensions from loading the runtime
  75108. */
  75109. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75110. /**
  75111. * Defines an onverride for creating gltf runtime
  75112. * Return true to stop further extensions from creating the runtime
  75113. */
  75114. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75115. /**
  75116. * Defines an override for loading buffers
  75117. * Return true to stop further extensions from loading this buffer
  75118. */
  75119. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  75120. /**
  75121. * Defines an override for loading texture buffers
  75122. * Return true to stop further extensions from loading this texture data
  75123. */
  75124. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75125. /**
  75126. * Defines an override for creating textures
  75127. * Return true to stop further extensions from loading this texture
  75128. */
  75129. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  75130. /**
  75131. * Defines an override for loading shader strings
  75132. * Return true to stop further extensions from loading this shader data
  75133. */
  75134. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75135. /**
  75136. * Defines an override for loading materials
  75137. * Return true to stop further extensions from loading this material
  75138. */
  75139. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75140. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75141. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75142. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75143. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75144. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75145. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75146. private static LoadTextureBufferAsync;
  75147. private static CreateTextureAsync;
  75148. private static ApplyExtensions;
  75149. }
  75150. }
  75151. declare module BABYLON.GLTF1 {
  75152. /** @hidden */
  75153. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75154. private _bin;
  75155. constructor();
  75156. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75157. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75158. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75159. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75160. }
  75161. }
  75162. declare module BABYLON.GLTF1 {
  75163. /** @hidden */
  75164. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75165. constructor();
  75166. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75167. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75168. private _loadTexture;
  75169. }
  75170. }
  75171. declare module BABYLON.GLTF2.Loader {
  75172. /**
  75173. * Loader interface with an index field.
  75174. */
  75175. export interface IArrayItem {
  75176. /**
  75177. * The index of this item in the array.
  75178. */
  75179. index: number;
  75180. }
  75181. /**
  75182. * Loader interface with additional members.
  75183. */
  75184. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75185. /** @hidden */
  75186. _data?: Promise<ArrayBufferView>;
  75187. /** @hidden */
  75188. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75189. }
  75190. /**
  75191. * Loader interface with additional members.
  75192. */
  75193. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75194. }
  75195. /** @hidden */
  75196. export interface _IAnimationSamplerData {
  75197. input: Float32Array;
  75198. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75199. output: Float32Array;
  75200. }
  75201. /**
  75202. * Loader interface with additional members.
  75203. */
  75204. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75205. /** @hidden */
  75206. _data?: Promise<_IAnimationSamplerData>;
  75207. }
  75208. /**
  75209. * Loader interface with additional members.
  75210. */
  75211. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75212. channels: IAnimationChannel[];
  75213. samplers: IAnimationSampler[];
  75214. /** @hidden */
  75215. _babylonAnimationGroup?: AnimationGroup;
  75216. }
  75217. /**
  75218. * Loader interface with additional members.
  75219. */
  75220. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75221. /** @hidden */
  75222. _data?: Promise<ArrayBufferView>;
  75223. }
  75224. /**
  75225. * Loader interface with additional members.
  75226. */
  75227. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75228. /** @hidden */
  75229. _data?: Promise<ArrayBufferView>;
  75230. /** @hidden */
  75231. _babylonBuffer?: Promise<Buffer>;
  75232. }
  75233. /**
  75234. * Loader interface with additional members.
  75235. */
  75236. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75237. }
  75238. /**
  75239. * Loader interface with additional members.
  75240. */
  75241. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75242. /** @hidden */
  75243. _data?: Promise<ArrayBufferView>;
  75244. }
  75245. /**
  75246. * Loader interface with additional members.
  75247. */
  75248. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75249. }
  75250. /**
  75251. * Loader interface with additional members.
  75252. */
  75253. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75254. }
  75255. /**
  75256. * Loader interface with additional members.
  75257. */
  75258. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75259. baseColorTexture?: ITextureInfo;
  75260. metallicRoughnessTexture?: ITextureInfo;
  75261. }
  75262. /**
  75263. * Loader interface with additional members.
  75264. */
  75265. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75266. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75267. normalTexture?: IMaterialNormalTextureInfo;
  75268. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75269. emissiveTexture?: ITextureInfo;
  75270. /** @hidden */
  75271. _data?: {
  75272. [babylonDrawMode: number]: {
  75273. babylonMaterial: Material;
  75274. babylonMeshes: AbstractMesh[];
  75275. promise: Promise<void>;
  75276. };
  75277. };
  75278. }
  75279. /**
  75280. * Loader interface with additional members.
  75281. */
  75282. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75283. primitives: IMeshPrimitive[];
  75284. }
  75285. /**
  75286. * Loader interface with additional members.
  75287. */
  75288. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75289. /** @hidden */
  75290. _instanceData?: {
  75291. babylonSourceMesh: Mesh;
  75292. promise: Promise<any>;
  75293. };
  75294. }
  75295. /**
  75296. * Loader interface with additional members.
  75297. */
  75298. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75299. /**
  75300. * The parent glTF node.
  75301. */
  75302. parent?: INode;
  75303. /** @hidden */
  75304. _babylonTransformNode?: TransformNode;
  75305. /** @hidden */
  75306. _primitiveBabylonMeshes?: AbstractMesh[];
  75307. /** @hidden */
  75308. _babylonBones?: Bone[];
  75309. /** @hidden */
  75310. _numMorphTargets?: number;
  75311. }
  75312. /** @hidden */
  75313. export interface _ISamplerData {
  75314. noMipMaps: boolean;
  75315. samplingMode: number;
  75316. wrapU: number;
  75317. wrapV: number;
  75318. }
  75319. /**
  75320. * Loader interface with additional members.
  75321. */
  75322. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75323. /** @hidden */
  75324. _data?: _ISamplerData;
  75325. }
  75326. /**
  75327. * Loader interface with additional members.
  75328. */
  75329. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75330. }
  75331. /**
  75332. * Loader interface with additional members.
  75333. */
  75334. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75335. /** @hidden */
  75336. _data?: {
  75337. babylonSkeleton: Skeleton;
  75338. promise: Promise<void>;
  75339. };
  75340. }
  75341. /**
  75342. * Loader interface with additional members.
  75343. */
  75344. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75345. }
  75346. /**
  75347. * Loader interface with additional members.
  75348. */
  75349. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75350. }
  75351. /**
  75352. * Loader interface with additional members.
  75353. */
  75354. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75355. accessors?: IAccessor[];
  75356. animations?: IAnimation[];
  75357. buffers?: IBuffer[];
  75358. bufferViews?: IBufferView[];
  75359. cameras?: ICamera[];
  75360. images?: IImage[];
  75361. materials?: IMaterial[];
  75362. meshes?: IMesh[];
  75363. nodes?: INode[];
  75364. samplers?: ISampler[];
  75365. scenes?: IScene[];
  75366. skins?: ISkin[];
  75367. textures?: ITexture[];
  75368. }
  75369. }
  75370. declare module BABYLON.GLTF2 {
  75371. /**
  75372. * Interface for a glTF loader extension.
  75373. */
  75374. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75375. /**
  75376. * Called after the loader state changes to LOADING.
  75377. */
  75378. onLoading?(): void;
  75379. /**
  75380. * Called after the loader state changes to READY.
  75381. */
  75382. onReady?(): void;
  75383. /**
  75384. * Define this method to modify the default behavior when loading scenes.
  75385. * @param context The context when loading the asset
  75386. * @param scene The glTF scene property
  75387. * @returns A promise that resolves when the load is complete or null if not handled
  75388. */
  75389. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75390. /**
  75391. * Define this method to modify the default behavior when loading nodes.
  75392. * @param context The context when loading the asset
  75393. * @param node The glTF node property
  75394. * @param assign A function called synchronously after parsing the glTF properties
  75395. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75396. */
  75397. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75398. /**
  75399. * Define this method to modify the default behavior when loading cameras.
  75400. * @param context The context when loading the asset
  75401. * @param camera The glTF camera property
  75402. * @param assign A function called synchronously after parsing the glTF properties
  75403. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75404. */
  75405. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75406. /**
  75407. * @hidden
  75408. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75409. * @param context The context when loading the asset
  75410. * @param primitive The glTF mesh primitive property
  75411. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75412. */
  75413. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75414. /**
  75415. * @hidden
  75416. * Define this method to modify the default behavior when loading data for mesh primitives.
  75417. * @param context The context when loading the asset
  75418. * @param name The mesh name when loading the asset
  75419. * @param node The glTF node when loading the asset
  75420. * @param mesh The glTF mesh when loading the asset
  75421. * @param primitive The glTF mesh primitive property
  75422. * @param assign A function called synchronously after parsing the glTF properties
  75423. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75424. */
  75425. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75426. /**
  75427. * @hidden
  75428. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  75429. * @param context The context when loading the asset
  75430. * @param material The glTF material property
  75431. * @param assign A function called synchronously after parsing the glTF properties
  75432. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  75433. */
  75434. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75435. /**
  75436. * Define this method to modify the default behavior when creating materials.
  75437. * @param context The context when loading the asset
  75438. * @param material The glTF material property
  75439. * @param babylonDrawMode The draw mode for the Babylon material
  75440. * @returns The Babylon material or null if not handled
  75441. */
  75442. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75443. /**
  75444. * Define this method to modify the default behavior when loading material properties.
  75445. * @param context The context when loading the asset
  75446. * @param material The glTF material property
  75447. * @param babylonMaterial The Babylon material
  75448. * @returns A promise that resolves when the load is complete or null if not handled
  75449. */
  75450. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75451. /**
  75452. * Define this method to modify the default behavior when loading texture infos.
  75453. * @param context The context when loading the asset
  75454. * @param textureInfo The glTF texture info property
  75455. * @param assign A function called synchronously after parsing the glTF properties
  75456. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75457. */
  75458. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75459. /**
  75460. * @hidden
  75461. * Define this method to modify the default behavior when loading textures.
  75462. * @param context The context when loading the asset
  75463. * @param texture The glTF texture property
  75464. * @param assign A function called synchronously after parsing the glTF properties
  75465. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75466. */
  75467. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75468. /**
  75469. * Define this method to modify the default behavior when loading animations.
  75470. * @param context The context when loading the asset
  75471. * @param animation The glTF animation property
  75472. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75473. */
  75474. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75475. /**
  75476. * @hidden
  75477. * Define this method to modify the default behavior when loading skins.
  75478. * @param context The context when loading the asset
  75479. * @param node The glTF node property
  75480. * @param skin The glTF skin property
  75481. * @returns A promise that resolves when the load is complete or null if not handled
  75482. */
  75483. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75484. /**
  75485. * @hidden
  75486. * Define this method to modify the default behavior when loading uris.
  75487. * @param context The context when loading the asset
  75488. * @param property The glTF property associated with the uri
  75489. * @param uri The uri to load
  75490. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75491. */
  75492. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75493. /**
  75494. * Define this method to modify the default behavior when loading buffer views.
  75495. * @param context The context when loading the asset
  75496. * @param bufferView The glTF buffer view property
  75497. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75498. */
  75499. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75500. /**
  75501. * Define this method to modify the default behavior when loading buffers.
  75502. * @param context The context when loading the asset
  75503. * @param buffer The glTF buffer property
  75504. * @param byteOffset The byte offset to load
  75505. * @param byteLength The byte length to load
  75506. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75507. */
  75508. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75509. }
  75510. }
  75511. declare module BABYLON.GLTF2 {
  75512. /**
  75513. * Helper class for working with arrays when loading the glTF asset
  75514. */
  75515. export class ArrayItem {
  75516. /**
  75517. * Gets an item from the given array.
  75518. * @param context The context when loading the asset
  75519. * @param array The array to get the item from
  75520. * @param index The index to the array
  75521. * @returns The array item
  75522. */
  75523. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75524. /**
  75525. * Assign an `index` field to each item of the given array.
  75526. * @param array The array of items
  75527. */
  75528. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75529. }
  75530. /**
  75531. * The glTF 2.0 loader
  75532. */
  75533. export class GLTFLoader implements IGLTFLoader {
  75534. /** @hidden */
  75535. _completePromises: Promise<any>[];
  75536. /** @hidden */
  75537. _forAssetContainer: boolean;
  75538. /** Storage */
  75539. _babylonLights: Light[];
  75540. private _disposed;
  75541. private _parent;
  75542. private _state;
  75543. private _extensions;
  75544. private _rootUrl;
  75545. private _fileName;
  75546. private _uniqueRootUrl;
  75547. private _gltf;
  75548. private _bin;
  75549. private _babylonScene;
  75550. private _rootBabylonMesh;
  75551. private _defaultBabylonMaterialData;
  75552. private _progressCallback?;
  75553. private _requests;
  75554. private static _RegisteredExtensions;
  75555. /**
  75556. * The default glTF sampler.
  75557. */
  75558. static readonly DefaultSampler: ISampler;
  75559. /**
  75560. * Registers a loader extension.
  75561. * @param name The name of the loader extension.
  75562. * @param factory The factory function that creates the loader extension.
  75563. */
  75564. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75565. /**
  75566. * Unregisters a loader extension.
  75567. * @param name The name of the loader extension.
  75568. * @returns A boolean indicating whether the extension has been unregistered
  75569. */
  75570. static UnregisterExtension(name: string): boolean;
  75571. /**
  75572. * The loader state.
  75573. */
  75574. get state(): Nullable<GLTFLoaderState>;
  75575. /**
  75576. * The object that represents the glTF JSON.
  75577. */
  75578. get gltf(): IGLTF;
  75579. /**
  75580. * The BIN chunk of a binary glTF.
  75581. */
  75582. get bin(): Nullable<IDataBuffer>;
  75583. /**
  75584. * The parent file loader.
  75585. */
  75586. get parent(): GLTFFileLoader;
  75587. /**
  75588. * The Babylon scene when loading the asset.
  75589. */
  75590. get babylonScene(): Scene;
  75591. /**
  75592. * The root Babylon mesh when loading the asset.
  75593. */
  75594. get rootBabylonMesh(): Mesh;
  75595. /** @hidden */
  75596. constructor(parent: GLTFFileLoader);
  75597. /** @hidden */
  75598. dispose(): void;
  75599. /** @hidden */
  75600. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  75601. /** @hidden */
  75602. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75603. private _loadAsync;
  75604. private _loadData;
  75605. private _setupData;
  75606. private _loadExtensions;
  75607. private _checkExtensions;
  75608. private _setState;
  75609. private _createRootNode;
  75610. /**
  75611. * Loads a glTF scene.
  75612. * @param context The context when loading the asset
  75613. * @param scene The glTF scene property
  75614. * @returns A promise that resolves when the load is complete
  75615. */
  75616. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75617. private _forEachPrimitive;
  75618. private _getMeshes;
  75619. private _getTransformNodes;
  75620. private _getSkeletons;
  75621. private _getAnimationGroups;
  75622. private _startAnimations;
  75623. /**
  75624. * Loads a glTF node.
  75625. * @param context The context when loading the asset
  75626. * @param node The glTF node property
  75627. * @param assign A function called synchronously after parsing the glTF properties
  75628. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  75629. */
  75630. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  75631. private _loadMeshAsync;
  75632. /**
  75633. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75634. * @param context The context when loading the asset
  75635. * @param name The mesh name when loading the asset
  75636. * @param node The glTF node when loading the asset
  75637. * @param mesh The glTF mesh when loading the asset
  75638. * @param primitive The glTF mesh primitive property
  75639. * @param assign A function called synchronously after parsing the glTF properties
  75640. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75641. */
  75642. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75643. private _loadVertexDataAsync;
  75644. private _createMorphTargets;
  75645. private _loadMorphTargetsAsync;
  75646. private _loadMorphTargetVertexDataAsync;
  75647. private static _LoadTransform;
  75648. private _loadSkinAsync;
  75649. private _loadBones;
  75650. private _loadBone;
  75651. private _loadSkinInverseBindMatricesDataAsync;
  75652. private _updateBoneMatrices;
  75653. private _getNodeMatrix;
  75654. /**
  75655. * Loads a glTF camera.
  75656. * @param context The context when loading the asset
  75657. * @param camera The glTF camera property
  75658. * @param assign A function called synchronously after parsing the glTF properties
  75659. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  75660. */
  75661. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  75662. private _loadAnimationsAsync;
  75663. /**
  75664. * Loads a glTF animation.
  75665. * @param context The context when loading the asset
  75666. * @param animation The glTF animation property
  75667. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  75668. */
  75669. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  75670. /**
  75671. * @hidden Loads a glTF animation channel.
  75672. * @param context The context when loading the asset
  75673. * @param animationContext The context of the animation when loading the asset
  75674. * @param animation The glTF animation property
  75675. * @param channel The glTF animation channel property
  75676. * @param babylonAnimationGroup The babylon animation group property
  75677. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  75678. * @returns A void promise when the channel load is complete
  75679. */
  75680. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  75681. private _loadAnimationSamplerAsync;
  75682. private _loadBufferAsync;
  75683. /**
  75684. * Loads a glTF buffer view.
  75685. * @param context The context when loading the asset
  75686. * @param bufferView The glTF buffer view property
  75687. * @returns A promise that resolves with the loaded data when the load is complete
  75688. */
  75689. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  75690. private _loadAccessorAsync;
  75691. private _loadFloatAccessorAsync;
  75692. private _loadIndicesAccessorAsync;
  75693. private _loadVertexBufferViewAsync;
  75694. private _loadVertexAccessorAsync;
  75695. private _loadMaterialMetallicRoughnessPropertiesAsync;
  75696. /** @hidden */
  75697. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  75698. private _createDefaultMaterial;
  75699. /**
  75700. * Creates a Babylon material from a glTF material.
  75701. * @param context The context when loading the asset
  75702. * @param material The glTF material property
  75703. * @param babylonDrawMode The draw mode for the Babylon material
  75704. * @returns The Babylon material
  75705. */
  75706. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  75707. /**
  75708. * Loads properties from a glTF material into a Babylon material.
  75709. * @param context The context when loading the asset
  75710. * @param material The glTF material property
  75711. * @param babylonMaterial The Babylon material
  75712. * @returns A promise that resolves when the load is complete
  75713. */
  75714. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75715. /**
  75716. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  75717. * @param context The context when loading the asset
  75718. * @param material The glTF material property
  75719. * @param babylonMaterial The Babylon material
  75720. * @returns A promise that resolves when the load is complete
  75721. */
  75722. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75723. /**
  75724. * Loads the alpha properties from a glTF material into a Babylon material.
  75725. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  75726. * @param context The context when loading the asset
  75727. * @param material The glTF material property
  75728. * @param babylonMaterial The Babylon material
  75729. */
  75730. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  75731. /**
  75732. * Loads a glTF texture info.
  75733. * @param context The context when loading the asset
  75734. * @param textureInfo The glTF texture info property
  75735. * @param assign A function called synchronously after parsing the glTF properties
  75736. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  75737. */
  75738. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75739. /** @hidden */
  75740. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75741. /** @hidden */
  75742. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75743. private _loadSampler;
  75744. /**
  75745. * Loads a glTF image.
  75746. * @param context The context when loading the asset
  75747. * @param image The glTF image property
  75748. * @returns A promise that resolves with the loaded data when the load is complete
  75749. */
  75750. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  75751. /**
  75752. * Loads a glTF uri.
  75753. * @param context The context when loading the asset
  75754. * @param property The glTF property associated with the uri
  75755. * @param uri The base64 or relative uri
  75756. * @returns A promise that resolves with the loaded data when the load is complete
  75757. */
  75758. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  75759. private _onProgress;
  75760. /**
  75761. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  75762. * @param babylonObject the Babylon object with metadata
  75763. * @param pointer the JSON pointer
  75764. */
  75765. static AddPointerMetadata(babylonObject: {
  75766. metadata: any;
  75767. }, pointer: string): void;
  75768. private static _GetTextureWrapMode;
  75769. private static _GetTextureSamplingMode;
  75770. private static _GetTypedArrayConstructor;
  75771. private static _GetTypedArray;
  75772. private static _GetNumComponents;
  75773. private static _ValidateUri;
  75774. private static _GetDrawMode;
  75775. private _compileMaterialsAsync;
  75776. private _compileShadowGeneratorsAsync;
  75777. private _forEachExtensions;
  75778. private _applyExtensions;
  75779. private _extensionsOnLoading;
  75780. private _extensionsOnReady;
  75781. private _extensionsLoadSceneAsync;
  75782. private _extensionsLoadNodeAsync;
  75783. private _extensionsLoadCameraAsync;
  75784. private _extensionsLoadVertexDataAsync;
  75785. private _extensionsLoadMeshPrimitiveAsync;
  75786. private _extensionsLoadMaterialAsync;
  75787. private _extensionsCreateMaterial;
  75788. private _extensionsLoadMaterialPropertiesAsync;
  75789. private _extensionsLoadTextureInfoAsync;
  75790. private _extensionsLoadTextureAsync;
  75791. private _extensionsLoadAnimationAsync;
  75792. private _extensionsLoadSkinAsync;
  75793. private _extensionsLoadUriAsync;
  75794. private _extensionsLoadBufferViewAsync;
  75795. private _extensionsLoadBufferAsync;
  75796. /**
  75797. * Helper method called by a loader extension to load an glTF extension.
  75798. * @param context The context when loading the asset
  75799. * @param property The glTF property to load the extension from
  75800. * @param extensionName The name of the extension to load
  75801. * @param actionAsync The action to run
  75802. * @returns The promise returned by actionAsync or null if the extension does not exist
  75803. */
  75804. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75805. /**
  75806. * Helper method called by a loader extension to load a glTF extra.
  75807. * @param context The context when loading the asset
  75808. * @param property The glTF property to load the extra from
  75809. * @param extensionName The name of the extension to load
  75810. * @param actionAsync The action to run
  75811. * @returns The promise returned by actionAsync or null if the extra does not exist
  75812. */
  75813. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75814. /**
  75815. * Checks for presence of an extension.
  75816. * @param name The name of the extension to check
  75817. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  75818. */
  75819. isExtensionUsed(name: string): boolean;
  75820. /**
  75821. * Increments the indentation level and logs a message.
  75822. * @param message The message to log
  75823. */
  75824. logOpen(message: string): void;
  75825. /**
  75826. * Decrements the indentation level.
  75827. */
  75828. logClose(): void;
  75829. /**
  75830. * Logs a message
  75831. * @param message The message to log
  75832. */
  75833. log(message: string): void;
  75834. /**
  75835. * Starts a performance counter.
  75836. * @param counterName The name of the performance counter
  75837. */
  75838. startPerformanceCounter(counterName: string): void;
  75839. /**
  75840. * Ends a performance counter.
  75841. * @param counterName The name of the performance counter
  75842. */
  75843. endPerformanceCounter(counterName: string): void;
  75844. }
  75845. }
  75846. declare module BABYLON.GLTF2.Loader.Extensions {
  75847. /**
  75848. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75849. */
  75850. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75851. /**
  75852. * The name of this extension.
  75853. */
  75854. readonly name: string;
  75855. /**
  75856. * Defines whether this extension is enabled.
  75857. */
  75858. enabled: boolean;
  75859. private _loader;
  75860. private _lights?;
  75861. /** @hidden */
  75862. constructor(loader: GLTFLoader);
  75863. /** @hidden */
  75864. dispose(): void;
  75865. /** @hidden */
  75866. onLoading(): void;
  75867. /** @hidden */
  75868. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75869. private _loadLightAsync;
  75870. }
  75871. }
  75872. declare module BABYLON.GLTF2.Loader.Extensions {
  75873. /**
  75874. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75875. */
  75876. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75877. /**
  75878. * The name of this extension.
  75879. */
  75880. readonly name: string;
  75881. /**
  75882. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75883. */
  75884. dracoCompression?: DracoCompression;
  75885. /**
  75886. * Defines whether this extension is enabled.
  75887. */
  75888. enabled: boolean;
  75889. private _loader;
  75890. /** @hidden */
  75891. constructor(loader: GLTFLoader);
  75892. /** @hidden */
  75893. dispose(): void;
  75894. /** @hidden */
  75895. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75896. }
  75897. }
  75898. declare module BABYLON.GLTF2.Loader.Extensions {
  75899. /**
  75900. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  75901. */
  75902. export class KHR_lights implements IGLTFLoaderExtension {
  75903. /**
  75904. * The name of this extension.
  75905. */
  75906. readonly name: string;
  75907. /**
  75908. * Defines whether this extension is enabled.
  75909. */
  75910. enabled: boolean;
  75911. private _loader;
  75912. private _lights?;
  75913. /** @hidden */
  75914. constructor(loader: GLTFLoader);
  75915. /** @hidden */
  75916. dispose(): void;
  75917. /** @hidden */
  75918. onLoading(): void;
  75919. /** @hidden */
  75920. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75921. }
  75922. }
  75923. declare module BABYLON.GLTF2.Loader.Extensions {
  75924. /**
  75925. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75926. */
  75927. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75928. /**
  75929. * The name of this extension.
  75930. */
  75931. readonly name: string;
  75932. /**
  75933. * Defines whether this extension is enabled.
  75934. */
  75935. enabled: boolean;
  75936. /**
  75937. * Defines a number that determines the order the extensions are applied.
  75938. */
  75939. order: number;
  75940. private _loader;
  75941. /** @hidden */
  75942. constructor(loader: GLTFLoader);
  75943. /** @hidden */
  75944. dispose(): void;
  75945. /** @hidden */
  75946. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75947. private _loadSpecularGlossinessPropertiesAsync;
  75948. }
  75949. }
  75950. declare module BABYLON.GLTF2.Loader.Extensions {
  75951. /**
  75952. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75953. */
  75954. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75955. /**
  75956. * The name of this extension.
  75957. */
  75958. readonly name: string;
  75959. /**
  75960. * Defines whether this extension is enabled.
  75961. */
  75962. enabled: boolean;
  75963. /**
  75964. * Defines a number that determines the order the extensions are applied.
  75965. */
  75966. order: number;
  75967. private _loader;
  75968. /** @hidden */
  75969. constructor(loader: GLTFLoader);
  75970. /** @hidden */
  75971. dispose(): void;
  75972. /** @hidden */
  75973. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75974. private _loadUnlitPropertiesAsync;
  75975. }
  75976. }
  75977. declare module BABYLON.GLTF2.Loader.Extensions {
  75978. /**
  75979. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75980. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75981. * !!! Experimental Extension Subject to Changes !!!
  75982. */
  75983. export class KHR_materials_clearcoat 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. /**
  75993. * Defines a number that determines the order the extensions are applied.
  75994. */
  75995. order: number;
  75996. private _loader;
  75997. /** @hidden */
  75998. constructor(loader: GLTFLoader);
  75999. /** @hidden */
  76000. dispose(): void;
  76001. /** @hidden */
  76002. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76003. private _loadClearCoatPropertiesAsync;
  76004. }
  76005. }
  76006. declare module BABYLON.GLTF2.Loader.Extensions {
  76007. /**
  76008. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76009. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76010. * !!! Experimental Extension Subject to Changes !!!
  76011. */
  76012. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76013. /**
  76014. * The name of this extension.
  76015. */
  76016. readonly name: string;
  76017. /**
  76018. * Defines whether this extension is enabled.
  76019. */
  76020. enabled: boolean;
  76021. /**
  76022. * Defines a number that determines the order the extensions are applied.
  76023. */
  76024. order: number;
  76025. private _loader;
  76026. /** @hidden */
  76027. constructor(loader: GLTFLoader);
  76028. /** @hidden */
  76029. dispose(): void;
  76030. /** @hidden */
  76031. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76032. private _loadSheenPropertiesAsync;
  76033. }
  76034. }
  76035. declare module BABYLON.GLTF2.Loader.Extensions {
  76036. /**
  76037. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76038. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76039. * !!! Experimental Extension Subject to Changes !!!
  76040. */
  76041. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76042. /**
  76043. * The name of this extension.
  76044. */
  76045. readonly name: string;
  76046. /**
  76047. * Defines whether this extension is enabled.
  76048. */
  76049. enabled: boolean;
  76050. /**
  76051. * Defines a number that determines the order the extensions are applied.
  76052. */
  76053. order: number;
  76054. private _loader;
  76055. /** @hidden */
  76056. constructor(loader: GLTFLoader);
  76057. /** @hidden */
  76058. dispose(): void;
  76059. /** @hidden */
  76060. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76061. private _loadSpecularPropertiesAsync;
  76062. }
  76063. }
  76064. declare module BABYLON.GLTF2.Loader.Extensions {
  76065. /**
  76066. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76067. */
  76068. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76069. /**
  76070. * The name of this extension.
  76071. */
  76072. readonly name: string;
  76073. /**
  76074. * Defines whether this extension is enabled.
  76075. */
  76076. enabled: boolean;
  76077. /** @hidden */
  76078. constructor(loader: GLTFLoader);
  76079. /** @hidden */
  76080. dispose(): void;
  76081. }
  76082. }
  76083. declare module BABYLON.GLTF2.Loader.Extensions {
  76084. /**
  76085. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76086. * !!! Experimental Extension Subject to Changes !!!
  76087. */
  76088. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  76089. /** The name of this extension. */
  76090. readonly name: string;
  76091. /** Defines whether this extension is enabled. */
  76092. enabled: boolean;
  76093. private _loader;
  76094. /** @hidden */
  76095. constructor(loader: GLTFLoader);
  76096. /** @hidden */
  76097. dispose(): void;
  76098. /** @hidden */
  76099. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76100. }
  76101. }
  76102. declare module BABYLON.GLTF2.Loader.Extensions {
  76103. /**
  76104. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  76105. */
  76106. export class KHR_texture_transform implements IGLTFLoaderExtension {
  76107. /**
  76108. * The name of this extension.
  76109. */
  76110. readonly name: string;
  76111. /**
  76112. * Defines whether this extension is enabled.
  76113. */
  76114. enabled: boolean;
  76115. private _loader;
  76116. /** @hidden */
  76117. constructor(loader: GLTFLoader);
  76118. /** @hidden */
  76119. dispose(): void;
  76120. /** @hidden */
  76121. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76122. }
  76123. }
  76124. declare module BABYLON.GLTF2.Loader.Extensions {
  76125. /**
  76126. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  76127. */
  76128. export class MSFT_audio_emitter 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 _clips;
  76139. private _emitters;
  76140. /** @hidden */
  76141. constructor(loader: GLTFLoader);
  76142. /** @hidden */
  76143. dispose(): void;
  76144. /** @hidden */
  76145. onLoading(): void;
  76146. /** @hidden */
  76147. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76148. /** @hidden */
  76149. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76150. /** @hidden */
  76151. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76152. private _loadClipAsync;
  76153. private _loadEmitterAsync;
  76154. private _getEventAction;
  76155. private _loadAnimationEventAsync;
  76156. }
  76157. }
  76158. declare module BABYLON.GLTF2.Loader.Extensions {
  76159. /**
  76160. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76161. */
  76162. export class MSFT_lod implements IGLTFLoaderExtension {
  76163. /**
  76164. * The name of this extension.
  76165. */
  76166. readonly name: string;
  76167. /**
  76168. * Defines whether this extension is enabled.
  76169. */
  76170. enabled: boolean;
  76171. /**
  76172. * Defines a number that determines the order the extensions are applied.
  76173. */
  76174. order: number;
  76175. /**
  76176. * Maximum number of LODs to load, starting from the lowest LOD.
  76177. */
  76178. maxLODsToLoad: number;
  76179. /**
  76180. * Observable raised when all node LODs of one level are loaded.
  76181. * The event data is the index of the loaded LOD starting from zero.
  76182. * Dispose the loader to cancel the loading of the next level of LODs.
  76183. */
  76184. onNodeLODsLoadedObservable: Observable<number>;
  76185. /**
  76186. * Observable raised when all material LODs of one level are loaded.
  76187. * The event data is the index of the loaded LOD starting from zero.
  76188. * Dispose the loader to cancel the loading of the next level of LODs.
  76189. */
  76190. onMaterialLODsLoadedObservable: Observable<number>;
  76191. private _loader;
  76192. private _nodeIndexLOD;
  76193. private _nodeSignalLODs;
  76194. private _nodePromiseLODs;
  76195. private _materialIndexLOD;
  76196. private _materialSignalLODs;
  76197. private _materialPromiseLODs;
  76198. private _indexLOD;
  76199. private _bufferLODs;
  76200. /** @hidden */
  76201. constructor(loader: GLTFLoader);
  76202. /** @hidden */
  76203. dispose(): void;
  76204. /** @hidden */
  76205. onReady(): void;
  76206. /** @hidden */
  76207. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76208. /** @hidden */
  76209. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76210. /** @hidden */
  76211. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76212. /** @hidden */
  76213. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76214. /** @hidden */
  76215. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76216. private _loadBufferLOD;
  76217. /**
  76218. * Gets an array of LOD properties from lowest to highest.
  76219. */
  76220. private _getLODs;
  76221. private _disposeTransformNode;
  76222. private _disposeMaterials;
  76223. }
  76224. }
  76225. declare module BABYLON.GLTF2.Loader.Extensions {
  76226. /** @hidden */
  76227. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76228. readonly name: string;
  76229. enabled: boolean;
  76230. private _loader;
  76231. constructor(loader: GLTFLoader);
  76232. dispose(): void;
  76233. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76234. }
  76235. }
  76236. declare module BABYLON.GLTF2.Loader.Extensions {
  76237. /** @hidden */
  76238. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76239. readonly name: string;
  76240. enabled: boolean;
  76241. private _loader;
  76242. constructor(loader: GLTFLoader);
  76243. dispose(): void;
  76244. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76245. }
  76246. }
  76247. declare module BABYLON.GLTF2.Loader.Extensions {
  76248. /**
  76249. * Store glTF extras (if present) in BJS objects' metadata
  76250. */
  76251. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76252. /**
  76253. * The name of this extension.
  76254. */
  76255. readonly name: string;
  76256. /**
  76257. * Defines whether this extension is enabled.
  76258. */
  76259. enabled: boolean;
  76260. private _loader;
  76261. private _assignExtras;
  76262. /** @hidden */
  76263. constructor(loader: GLTFLoader);
  76264. /** @hidden */
  76265. dispose(): void;
  76266. /** @hidden */
  76267. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76268. /** @hidden */
  76269. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76270. /** @hidden */
  76271. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76272. }
  76273. }
  76274. declare module BABYLON {
  76275. /**
  76276. * Class reading and parsing the MTL file bundled with the obj file.
  76277. */
  76278. export class MTLFileLoader {
  76279. /**
  76280. * Invert Y-Axis of referenced textures on load
  76281. */
  76282. static INVERT_TEXTURE_Y: boolean;
  76283. /**
  76284. * All material loaded from the mtl will be set here
  76285. */
  76286. materials: StandardMaterial[];
  76287. /**
  76288. * This function will read the mtl file and create each material described inside
  76289. * This function could be improve by adding :
  76290. * -some component missing (Ni, Tf...)
  76291. * -including the specific options available
  76292. *
  76293. * @param scene defines the scene the material will be created in
  76294. * @param data defines the mtl data to parse
  76295. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76296. * @param forAssetContainer defines if the material should be registered in the scene
  76297. */
  76298. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  76299. /**
  76300. * Gets the texture for the material.
  76301. *
  76302. * If the material is imported from input file,
  76303. * We sanitize the url to ensure it takes the textre from aside the material.
  76304. *
  76305. * @param rootUrl The root url to load from
  76306. * @param value The value stored in the mtl
  76307. * @return The Texture
  76308. */
  76309. private static _getTexture;
  76310. }
  76311. }
  76312. declare module BABYLON {
  76313. /**
  76314. * Options for loading OBJ/MTL files
  76315. */
  76316. type MeshLoadOptions = {
  76317. /**
  76318. * Defines if UVs are optimized by default during load.
  76319. */
  76320. OptimizeWithUV: boolean;
  76321. /**
  76322. * Defines custom scaling of UV coordinates of loaded meshes.
  76323. */
  76324. UVScaling: Vector2;
  76325. /**
  76326. * Invert model on y-axis (does a model scaling inversion)
  76327. */
  76328. InvertY: boolean;
  76329. /**
  76330. * Invert Y-Axis of referenced textures on load
  76331. */
  76332. InvertTextureY: boolean;
  76333. /**
  76334. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76335. */
  76336. ImportVertexColors: boolean;
  76337. /**
  76338. * Compute the normals for the model, even if normals are present in the file.
  76339. */
  76340. ComputeNormals: boolean;
  76341. /**
  76342. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76343. */
  76344. SkipMaterials: boolean;
  76345. /**
  76346. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76347. */
  76348. MaterialLoadingFailsSilently: boolean;
  76349. };
  76350. /**
  76351. * OBJ file type loader.
  76352. * This is a babylon scene loader plugin.
  76353. */
  76354. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76355. /**
  76356. * Defines if UVs are optimized by default during load.
  76357. */
  76358. static OPTIMIZE_WITH_UV: boolean;
  76359. /**
  76360. * Invert model on y-axis (does a model scaling inversion)
  76361. */
  76362. static INVERT_Y: boolean;
  76363. /**
  76364. * Invert Y-Axis of referenced textures on load
  76365. */
  76366. static get INVERT_TEXTURE_Y(): boolean;
  76367. static set INVERT_TEXTURE_Y(value: boolean);
  76368. /**
  76369. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76370. */
  76371. static IMPORT_VERTEX_COLORS: boolean;
  76372. /**
  76373. * Compute the normals for the model, even if normals are present in the file.
  76374. */
  76375. static COMPUTE_NORMALS: boolean;
  76376. /**
  76377. * Defines custom scaling of UV coordinates of loaded meshes.
  76378. */
  76379. static UV_SCALING: Vector2;
  76380. /**
  76381. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76382. */
  76383. static SKIP_MATERIALS: boolean;
  76384. /**
  76385. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76386. *
  76387. * Defaults to true for backwards compatibility.
  76388. */
  76389. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  76390. /**
  76391. * Defines the name of the plugin.
  76392. */
  76393. name: string;
  76394. /**
  76395. * Defines the extension the plugin is able to load.
  76396. */
  76397. extensions: string;
  76398. /** @hidden */
  76399. obj: RegExp;
  76400. /** @hidden */
  76401. group: RegExp;
  76402. /** @hidden */
  76403. mtllib: RegExp;
  76404. /** @hidden */
  76405. usemtl: RegExp;
  76406. /** @hidden */
  76407. smooth: RegExp;
  76408. /** @hidden */
  76409. vertexPattern: RegExp;
  76410. /** @hidden */
  76411. normalPattern: RegExp;
  76412. /** @hidden */
  76413. uvPattern: RegExp;
  76414. /** @hidden */
  76415. facePattern1: RegExp;
  76416. /** @hidden */
  76417. facePattern2: RegExp;
  76418. /** @hidden */
  76419. facePattern3: RegExp;
  76420. /** @hidden */
  76421. facePattern4: RegExp;
  76422. /** @hidden */
  76423. facePattern5: RegExp;
  76424. private _forAssetContainer;
  76425. private _meshLoadOptions;
  76426. /**
  76427. * Creates loader for .OBJ files
  76428. *
  76429. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  76430. */
  76431. constructor(meshLoadOptions?: MeshLoadOptions);
  76432. private static get currentMeshLoadOptions();
  76433. /**
  76434. * Calls synchronously the MTL file attached to this obj.
  76435. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  76436. * Without this function materials are not displayed in the first frame (but displayed after).
  76437. * In consequence it is impossible to get material information in your HTML file
  76438. *
  76439. * @param url The URL of the MTL file
  76440. * @param rootUrl
  76441. * @param onSuccess Callback function to be called when the MTL file is loaded
  76442. * @private
  76443. */
  76444. private _loadMTL;
  76445. /**
  76446. * Instantiates a OBJ file loader plugin.
  76447. * @returns the created plugin
  76448. */
  76449. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  76450. /**
  76451. * If the data string can be loaded directly.
  76452. *
  76453. * @param data string containing the file data
  76454. * @returns if the data can be loaded directly
  76455. */
  76456. canDirectLoad(data: string): boolean;
  76457. /**
  76458. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  76459. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76460. * @param scene the scene the meshes should be added to
  76461. * @param data the OBJ data to load
  76462. * @param rootUrl root url to load from
  76463. * @param onProgress event that fires when loading progress has occured
  76464. * @param fileName Defines the name of the file to load
  76465. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76466. */
  76467. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76468. meshes: AbstractMesh[];
  76469. particleSystems: IParticleSystem[];
  76470. skeletons: Skeleton[];
  76471. animationGroups: AnimationGroup[];
  76472. }>;
  76473. /**
  76474. * Imports all objects from the loaded OBJ data and adds them to the scene
  76475. * @param scene the scene the objects should be added to
  76476. * @param data the OBJ data to load
  76477. * @param rootUrl root url to load from
  76478. * @param onProgress event that fires when loading progress has occured
  76479. * @param fileName Defines the name of the file to load
  76480. * @returns a promise which completes when objects have been loaded to the scene
  76481. */
  76482. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76483. /**
  76484. * Load into an asset container.
  76485. * @param scene The scene to load into
  76486. * @param data The data to import
  76487. * @param rootUrl The root url for scene and resources
  76488. * @param onProgress The callback when the load progresses
  76489. * @param fileName Defines the name of the file to load
  76490. * @returns The loaded asset container
  76491. */
  76492. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76493. /**
  76494. * Read the OBJ file and create an Array of meshes.
  76495. * Each mesh contains all information given by the OBJ and the MTL file.
  76496. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76497. *
  76498. * @param meshesNames
  76499. * @param scene Scene The scene where are displayed the data
  76500. * @param data String The content of the obj file
  76501. * @param rootUrl String The path to the folder
  76502. * @returns Array<AbstractMesh>
  76503. * @private
  76504. */
  76505. private _parseSolid;
  76506. }
  76507. }
  76508. declare module BABYLON {
  76509. /**
  76510. * STL file type loader.
  76511. * This is a babylon scene loader plugin.
  76512. */
  76513. export class STLFileLoader implements ISceneLoaderPlugin {
  76514. /** @hidden */
  76515. solidPattern: RegExp;
  76516. /** @hidden */
  76517. facetsPattern: RegExp;
  76518. /** @hidden */
  76519. normalPattern: RegExp;
  76520. /** @hidden */
  76521. vertexPattern: RegExp;
  76522. /**
  76523. * Defines the name of the plugin.
  76524. */
  76525. name: string;
  76526. /**
  76527. * Defines the extensions the stl loader is able to load.
  76528. * force data to come in as an ArrayBuffer
  76529. * we'll convert to string if it looks like it's an ASCII .stl
  76530. */
  76531. extensions: ISceneLoaderPluginExtensions;
  76532. /**
  76533. * Import meshes into a scene.
  76534. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76535. * @param scene The scene to import into
  76536. * @param data The data to import
  76537. * @param rootUrl The root url for scene and resources
  76538. * @param meshes The meshes array to import into
  76539. * @param particleSystems The particle systems array to import into
  76540. * @param skeletons The skeletons array to import into
  76541. * @param onError The callback when import fails
  76542. * @returns True if successful or false otherwise
  76543. */
  76544. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76545. /**
  76546. * Load into a scene.
  76547. * @param scene The scene to load into
  76548. * @param data The data to import
  76549. * @param rootUrl The root url for scene and resources
  76550. * @param onError The callback when import fails
  76551. * @returns true if successful or false otherwise
  76552. */
  76553. load(scene: Scene, data: any, rootUrl: string): boolean;
  76554. /**
  76555. * Load into an asset container.
  76556. * @param scene The scene to load into
  76557. * @param data The data to import
  76558. * @param rootUrl The root url for scene and resources
  76559. * @param onError The callback when import fails
  76560. * @returns The loaded asset container
  76561. */
  76562. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76563. private _isBinary;
  76564. private _parseBinary;
  76565. private _parseASCII;
  76566. }
  76567. }
  76568. declare module BABYLON {
  76569. /**
  76570. * Class for generating OBJ data from a Babylon scene.
  76571. */
  76572. export class OBJExport {
  76573. /**
  76574. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76575. * @param mesh defines the list of meshes to serialize
  76576. * @param materials defines if materials should be exported
  76577. * @param matlibname defines the name of the associated mtl file
  76578. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76579. * @returns the OBJ content
  76580. */
  76581. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76582. /**
  76583. * Exports the material(s) of a mesh in .MTL file format (text)
  76584. * @param mesh defines the mesh to extract the material from
  76585. * @returns the mtl content
  76586. */
  76587. static MTL(mesh: Mesh): string;
  76588. }
  76589. }
  76590. declare module BABYLON {
  76591. /** @hidden */
  76592. export var __IGLTFExporterExtension: number;
  76593. /**
  76594. * Interface for extending the exporter
  76595. * @hidden
  76596. */
  76597. export interface IGLTFExporterExtension {
  76598. /**
  76599. * The name of this extension
  76600. */
  76601. readonly name: string;
  76602. /**
  76603. * Defines whether this extension is enabled
  76604. */
  76605. enabled: boolean;
  76606. /**
  76607. * Defines whether this extension is required
  76608. */
  76609. required: boolean;
  76610. }
  76611. }
  76612. declare module BABYLON.GLTF2.Exporter {
  76613. /** @hidden */
  76614. export var __IGLTFExporterExtensionV2: number;
  76615. /**
  76616. * Interface for a glTF exporter extension
  76617. * @hidden
  76618. */
  76619. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  76620. /**
  76621. * Define this method to modify the default behavior before exporting a texture
  76622. * @param context The context when loading the asset
  76623. * @param babylonTexture The Babylon.js texture
  76624. * @param mimeType The mime-type of the generated image
  76625. * @returns A promise that resolves with the exported texture
  76626. */
  76627. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  76628. /**
  76629. * Define this method to get notified when a texture info is created
  76630. * @param context The context when loading the asset
  76631. * @param textureInfo The glTF texture info
  76632. * @param babylonTexture The Babylon.js texture
  76633. */
  76634. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76635. /**
  76636. * Define this method to modify the default behavior when exporting texture info
  76637. * @param context The context when loading the asset
  76638. * @param meshPrimitive glTF mesh primitive
  76639. * @param babylonSubMesh Babylon submesh
  76640. * @param binaryWriter glTF serializer binary writer instance
  76641. * @returns nullable IMeshPrimitive promise
  76642. */
  76643. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  76644. /**
  76645. * Define this method to modify the default behavior when exporting a node
  76646. * @param context The context when exporting the node
  76647. * @param node glTF node
  76648. * @param babylonNode BabylonJS node
  76649. * @returns nullable INode promise
  76650. */
  76651. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  76652. [key: number]: number;
  76653. }): Promise<Nullable<INode>>;
  76654. /**
  76655. * Define this method to modify the default behavior when exporting a material
  76656. * @param material glTF material
  76657. * @param babylonMaterial BabylonJS material
  76658. * @returns nullable IMaterial promise
  76659. */
  76660. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  76661. /**
  76662. * Define this method to return additional textures to export from a material
  76663. * @param material glTF material
  76664. * @param babylonMaterial BabylonJS material
  76665. * @returns List of textures
  76666. */
  76667. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76668. /** Gets a boolean indicating that this extension was used */
  76669. wasUsed: boolean;
  76670. /** Gets a boolean indicating that this extension is required for the file to work */
  76671. required: boolean;
  76672. /**
  76673. * Called after the exporter state changes to EXPORTING
  76674. */
  76675. onExporting?(): void;
  76676. }
  76677. }
  76678. declare module BABYLON.GLTF2.Exporter {
  76679. /**
  76680. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  76681. * @hidden
  76682. */
  76683. export class _GLTFMaterialExporter {
  76684. /**
  76685. * Represents the dielectric specular values for R, G and B
  76686. */
  76687. private static readonly _DielectricSpecular;
  76688. /**
  76689. * Allows the maximum specular power to be defined for material calculations
  76690. */
  76691. private static readonly _MaxSpecularPower;
  76692. /**
  76693. * Mapping to store textures
  76694. */
  76695. private _textureMap;
  76696. /**
  76697. * Numeric tolerance value
  76698. */
  76699. private static readonly _Epsilon;
  76700. /**
  76701. * Reference to the glTF Exporter
  76702. */
  76703. private _exporter;
  76704. constructor(exporter: _Exporter);
  76705. /**
  76706. * Specifies if two colors are approximately equal in value
  76707. * @param color1 first color to compare to
  76708. * @param color2 second color to compare to
  76709. * @param epsilon threshold value
  76710. */
  76711. private static FuzzyEquals;
  76712. /**
  76713. * Gets the materials from a Babylon scene and converts them to glTF materials
  76714. * @param scene babylonjs scene
  76715. * @param mimeType texture mime type
  76716. * @param images array of images
  76717. * @param textures array of textures
  76718. * @param materials array of materials
  76719. * @param imageData mapping of texture names to base64 textures
  76720. * @param hasTextureCoords specifies if texture coordinates are present on the material
  76721. */
  76722. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  76723. /**
  76724. * Makes a copy of the glTF material without the texture parameters
  76725. * @param originalMaterial original glTF material
  76726. * @returns glTF material without texture parameters
  76727. */
  76728. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  76729. /**
  76730. * Specifies if the material has any texture parameters present
  76731. * @param material glTF Material
  76732. * @returns boolean specifying if texture parameters are present
  76733. */
  76734. _hasTexturesPresent(material: IMaterial): boolean;
  76735. /**
  76736. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  76737. * @param babylonStandardMaterial
  76738. * @returns glTF Metallic Roughness Material representation
  76739. */
  76740. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  76741. /**
  76742. * Computes the metallic factor
  76743. * @param diffuse diffused value
  76744. * @param specular specular value
  76745. * @param oneMinusSpecularStrength one minus the specular strength
  76746. * @returns metallic value
  76747. */
  76748. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  76749. /**
  76750. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  76751. * @param glTFMaterial glTF material
  76752. * @param babylonMaterial Babylon material
  76753. */
  76754. private static _SetAlphaMode;
  76755. /**
  76756. * Converts a Babylon Standard Material to a glTF Material
  76757. * @param babylonStandardMaterial BJS Standard Material
  76758. * @param mimeType mime type to use for the textures
  76759. * @param images array of glTF image interfaces
  76760. * @param textures array of glTF texture interfaces
  76761. * @param materials array of glTF material interfaces
  76762. * @param imageData map of image file name to data
  76763. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76764. */
  76765. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76766. private _finishMaterial;
  76767. /**
  76768. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76769. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  76770. * @param mimeType mime type to use for the textures
  76771. * @param images array of glTF image interfaces
  76772. * @param textures array of glTF texture interfaces
  76773. * @param materials array of glTF material interfaces
  76774. * @param imageData map of image file name to data
  76775. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76776. */
  76777. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76778. /**
  76779. * Converts an image typed array buffer to a base64 image
  76780. * @param buffer typed array buffer
  76781. * @param width width of the image
  76782. * @param height height of the image
  76783. * @param mimeType mimetype of the image
  76784. * @returns base64 image string
  76785. */
  76786. private _createBase64FromCanvasAsync;
  76787. /**
  76788. * Generates a white texture based on the specified width and height
  76789. * @param width width of the texture in pixels
  76790. * @param height height of the texture in pixels
  76791. * @param scene babylonjs scene
  76792. * @returns white texture
  76793. */
  76794. private _createWhiteTexture;
  76795. /**
  76796. * 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
  76797. * @param texture1 first texture to resize
  76798. * @param texture2 second texture to resize
  76799. * @param scene babylonjs scene
  76800. * @returns resized textures or null
  76801. */
  76802. private _resizeTexturesToSameDimensions;
  76803. /**
  76804. * Converts an array of pixels to a Float32Array
  76805. * Throws an error if the pixel format is not supported
  76806. * @param pixels - array buffer containing pixel values
  76807. * @returns Float32 of pixels
  76808. */
  76809. private _convertPixelArrayToFloat32;
  76810. /**
  76811. * Convert Specular Glossiness Textures to Metallic Roughness
  76812. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  76813. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  76814. * @param diffuseTexture texture used to store diffuse information
  76815. * @param specularGlossinessTexture texture used to store specular and glossiness information
  76816. * @param factors specular glossiness material factors
  76817. * @param mimeType the mime type to use for the texture
  76818. * @returns pbr metallic roughness interface or null
  76819. */
  76820. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  76821. /**
  76822. * Converts specular glossiness material properties to metallic roughness
  76823. * @param specularGlossiness interface with specular glossiness material properties
  76824. * @returns interface with metallic roughness material properties
  76825. */
  76826. private _convertSpecularGlossinessToMetallicRoughness;
  76827. /**
  76828. * Calculates the surface reflectance, independent of lighting conditions
  76829. * @param color Color source to calculate brightness from
  76830. * @returns number representing the perceived brightness, or zero if color is undefined
  76831. */
  76832. private _getPerceivedBrightness;
  76833. /**
  76834. * Returns the maximum color component value
  76835. * @param color
  76836. * @returns maximum color component value, or zero if color is null or undefined
  76837. */
  76838. private _getMaxComponent;
  76839. /**
  76840. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  76841. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76842. * @param mimeType mime type to use for the textures
  76843. * @param images array of glTF image interfaces
  76844. * @param textures array of glTF texture interfaces
  76845. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76846. * @param imageData map of image file name to data
  76847. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76848. * @returns glTF PBR Metallic Roughness factors
  76849. */
  76850. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76851. private _getGLTFTextureSampler;
  76852. private _getGLTFTextureWrapMode;
  76853. private _getGLTFTextureWrapModesSampler;
  76854. /**
  76855. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76856. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76857. * @param mimeType mime type to use for the textures
  76858. * @param images array of glTF image interfaces
  76859. * @param textures array of glTF texture interfaces
  76860. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76861. * @param imageData map of image file name to data
  76862. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76863. * @returns glTF PBR Metallic Roughness factors
  76864. */
  76865. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76866. /**
  76867. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76868. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76869. * @param mimeType mime type to use for the textures
  76870. * @param images array of glTF image interfaces
  76871. * @param textures array of glTF texture interfaces
  76872. * @param materials array of glTF material interfaces
  76873. * @param imageData map of image file name to data
  76874. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76875. */
  76876. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76877. private setMetallicRoughnessPbrMaterial;
  76878. private getPixelsFromTexture;
  76879. /**
  76880. * Extracts a texture from a Babylon texture into file data and glTF data
  76881. * @param babylonTexture Babylon texture to extract
  76882. * @param mimeType Mime Type of the babylonTexture
  76883. * @return glTF texture info, or null if the texture format is not supported
  76884. */
  76885. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76886. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76887. /**
  76888. * Builds a texture from base64 string
  76889. * @param base64Texture base64 texture string
  76890. * @param baseTextureName Name to use for the texture
  76891. * @param mimeType image mime type for the texture
  76892. * @param images array of images
  76893. * @param textures array of textures
  76894. * @param imageData map of image data
  76895. * @returns glTF texture info, or null if the texture format is not supported
  76896. */
  76897. private _getTextureInfoFromBase64;
  76898. }
  76899. }
  76900. declare module BABYLON {
  76901. /**
  76902. * Class for holding and downloading glTF file data
  76903. */
  76904. export class GLTFData {
  76905. /**
  76906. * Object which contains the file name as the key and its data as the value
  76907. */
  76908. glTFFiles: {
  76909. [fileName: string]: string | Blob;
  76910. };
  76911. /**
  76912. * Initializes the glTF file object
  76913. */
  76914. constructor();
  76915. /**
  76916. * Downloads the glTF data as files based on their names and data
  76917. */
  76918. downloadFiles(): void;
  76919. }
  76920. }
  76921. declare module BABYLON {
  76922. /**
  76923. * Holds a collection of exporter options and parameters
  76924. */
  76925. export interface IExportOptions {
  76926. /**
  76927. * Function which indicates whether a babylon node should be exported or not
  76928. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76929. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76930. */
  76931. shouldExportNode?(node: Node): boolean;
  76932. /**
  76933. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76934. * @param metadata source metadata to read from
  76935. * @returns the data to store to glTF node extras
  76936. */
  76937. metadataSelector?(metadata: any): any;
  76938. /**
  76939. * The sample rate to bake animation curves
  76940. */
  76941. animationSampleRate?: number;
  76942. /**
  76943. * Begin serialization without waiting for the scene to be ready
  76944. */
  76945. exportWithoutWaitingForScene?: boolean;
  76946. /**
  76947. * Indicates if coordinate system swapping root nodes should be included in export
  76948. */
  76949. includeCoordinateSystemConversionNodes?: boolean;
  76950. }
  76951. /**
  76952. * Class for generating glTF data from a Babylon scene.
  76953. */
  76954. export class GLTF2Export {
  76955. /**
  76956. * Exports the geometry of the scene to .gltf file format asynchronously
  76957. * @param scene Babylon scene with scene hierarchy information
  76958. * @param filePrefix File prefix to use when generating the glTF file
  76959. * @param options Exporter options
  76960. * @returns Returns an object with a .gltf file and associates texture names
  76961. * as keys and their data and paths as values
  76962. */
  76963. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76964. private static _PreExportAsync;
  76965. private static _PostExportAsync;
  76966. /**
  76967. * Exports the geometry of the scene to .glb file format asychronously
  76968. * @param scene Babylon scene with scene hierarchy information
  76969. * @param filePrefix File prefix to use when generating glb file
  76970. * @param options Exporter options
  76971. * @returns Returns an object with a .glb filename as key and data as value
  76972. */
  76973. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76974. }
  76975. }
  76976. declare module BABYLON.GLTF2.Exporter {
  76977. /**
  76978. * @hidden
  76979. */
  76980. export class _GLTFUtilities {
  76981. /**
  76982. * Creates a buffer view based on the supplied arguments
  76983. * @param bufferIndex index value of the specified buffer
  76984. * @param byteOffset byte offset value
  76985. * @param byteLength byte length of the bufferView
  76986. * @param byteStride byte distance between conequential elements
  76987. * @param name name of the buffer view
  76988. * @returns bufferView for glTF
  76989. */
  76990. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76991. /**
  76992. * Creates an accessor based on the supplied arguments
  76993. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76994. * @param name The name of the accessor
  76995. * @param type The type of the accessor
  76996. * @param componentType The datatype of components in the attribute
  76997. * @param count The number of attributes referenced by this accessor
  76998. * @param byteOffset The offset relative to the start of the bufferView in bytes
  76999. * @param min Minimum value of each component in this attribute
  77000. * @param max Maximum value of each component in this attribute
  77001. * @returns accessor for glTF
  77002. */
  77003. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77004. /**
  77005. * Calculates the minimum and maximum values of an array of position floats
  77006. * @param positions Positions array of a mesh
  77007. * @param vertexStart Starting vertex offset to calculate min and max values
  77008. * @param vertexCount Number of vertices to check for min and max values
  77009. * @returns min number array and max number array
  77010. */
  77011. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77012. min: number[];
  77013. max: number[];
  77014. };
  77015. /**
  77016. * Converts a new right-handed Vector3
  77017. * @param vector vector3 array
  77018. * @returns right-handed Vector3
  77019. */
  77020. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77021. /**
  77022. * Converts a Vector3 to right-handed
  77023. * @param vector Vector3 to convert to right-handed
  77024. */
  77025. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77026. /**
  77027. * Converts a three element number array to right-handed
  77028. * @param vector number array to convert to right-handed
  77029. */
  77030. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77031. /**
  77032. * Converts a new right-handed Vector3
  77033. * @param vector vector3 array
  77034. * @returns right-handed Vector3
  77035. */
  77036. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77037. /**
  77038. * Converts a Vector3 to right-handed
  77039. * @param vector Vector3 to convert to right-handed
  77040. */
  77041. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77042. /**
  77043. * Converts a three element number array to right-handed
  77044. * @param vector number array to convert to right-handed
  77045. */
  77046. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77047. /**
  77048. * Converts a Vector4 to right-handed
  77049. * @param vector Vector4 to convert to right-handed
  77050. */
  77051. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77052. /**
  77053. * Converts a Vector4 to right-handed
  77054. * @param vector Vector4 to convert to right-handed
  77055. */
  77056. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77057. /**
  77058. * Converts a Quaternion to right-handed
  77059. * @param quaternion Source quaternion to convert to right-handed
  77060. */
  77061. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77062. /**
  77063. * Converts a Quaternion to right-handed
  77064. * @param quaternion Source quaternion to convert to right-handed
  77065. */
  77066. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77067. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77068. }
  77069. }
  77070. declare module BABYLON.GLTF2.Exporter {
  77071. /**
  77072. * Converts Babylon Scene into glTF 2.0.
  77073. * @hidden
  77074. */
  77075. export class _Exporter {
  77076. /**
  77077. * Stores the glTF to export
  77078. */
  77079. _glTF: IGLTF;
  77080. /**
  77081. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77082. */
  77083. _bufferViews: IBufferView[];
  77084. /**
  77085. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77086. */
  77087. _accessors: IAccessor[];
  77088. /**
  77089. * Stores all the generated nodes, which contains transform and/or mesh information per node
  77090. */
  77091. _nodes: INode[];
  77092. /**
  77093. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  77094. */
  77095. private _scenes;
  77096. /**
  77097. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  77098. */
  77099. private _meshes;
  77100. /**
  77101. * Stores all the generated material information, which represents the appearance of each primitive
  77102. */
  77103. _materials: IMaterial[];
  77104. _materialMap: {
  77105. [materialID: number]: number;
  77106. };
  77107. /**
  77108. * Stores all the generated texture information, which is referenced by glTF materials
  77109. */
  77110. _textures: ITexture[];
  77111. /**
  77112. * Stores all the generated image information, which is referenced by glTF textures
  77113. */
  77114. _images: IImage[];
  77115. /**
  77116. * Stores all the texture samplers
  77117. */
  77118. _samplers: ISampler[];
  77119. /**
  77120. * Stores all the generated animation samplers, which is referenced by glTF animations
  77121. */
  77122. /**
  77123. * Stores the animations for glTF models
  77124. */
  77125. private _animations;
  77126. /**
  77127. * Stores the total amount of bytes stored in the glTF buffer
  77128. */
  77129. private _totalByteLength;
  77130. /**
  77131. * Stores a reference to the Babylon scene containing the source geometry and material information
  77132. */
  77133. _babylonScene: Scene;
  77134. /**
  77135. * Stores a map of the image data, where the key is the file name and the value
  77136. * is the image data
  77137. */
  77138. _imageData: {
  77139. [fileName: string]: {
  77140. data: Uint8Array;
  77141. mimeType: ImageMimeType;
  77142. };
  77143. };
  77144. /**
  77145. * Stores a map of the unique id of a node to its index in the node array
  77146. */
  77147. _nodeMap: {
  77148. [key: number]: number;
  77149. };
  77150. /**
  77151. * Specifies if the source Babylon scene was left handed, and needed conversion.
  77152. */
  77153. _convertToRightHandedSystem: boolean;
  77154. /**
  77155. * Specifies if a Babylon node should be converted to right-handed on export
  77156. */
  77157. _convertToRightHandedSystemMap: {
  77158. [nodeId: number]: boolean;
  77159. };
  77160. _includeCoordinateSystemConversionNodes: boolean;
  77161. /**
  77162. * Baked animation sample rate
  77163. */
  77164. private _animationSampleRate;
  77165. private _options;
  77166. private _localEngine;
  77167. _glTFMaterialExporter: _GLTFMaterialExporter;
  77168. private _extensions;
  77169. private static _ExtensionNames;
  77170. private static _ExtensionFactories;
  77171. private _applyExtension;
  77172. private _applyExtensions;
  77173. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77174. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77175. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77176. [key: number]: number;
  77177. }): Promise<Nullable<INode>>;
  77178. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77179. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77180. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77181. private _forEachExtensions;
  77182. private _extensionsOnExporting;
  77183. /**
  77184. * Load glTF serializer extensions
  77185. */
  77186. private _loadExtensions;
  77187. /**
  77188. * Creates a glTF Exporter instance, which can accept optional exporter options
  77189. * @param babylonScene Babylon scene object
  77190. * @param options Options to modify the behavior of the exporter
  77191. */
  77192. constructor(babylonScene: Scene, options?: IExportOptions);
  77193. dispose(): void;
  77194. /**
  77195. * Registers a glTF exporter extension
  77196. * @param name Name of the extension to export
  77197. * @param factory The factory function that creates the exporter extension
  77198. */
  77199. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77200. /**
  77201. * Un-registers an exporter extension
  77202. * @param name The name fo the exporter extension
  77203. * @returns A boolean indicating whether the extension has been un-registered
  77204. */
  77205. static UnregisterExtension(name: string): boolean;
  77206. /**
  77207. * Lazy load a local engine
  77208. */
  77209. _getLocalEngine(): Engine;
  77210. private reorderIndicesBasedOnPrimitiveMode;
  77211. /**
  77212. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77213. * clock-wise during export to glTF
  77214. * @param submesh BabylonJS submesh
  77215. * @param primitiveMode Primitive mode of the mesh
  77216. * @param sideOrientation the winding order of the submesh
  77217. * @param vertexBufferKind The type of vertex attribute
  77218. * @param meshAttributeArray The vertex attribute data
  77219. * @param byteOffset The offset to the binary data
  77220. * @param binaryWriter The binary data for the glTF file
  77221. * @param convertToRightHandedSystem Converts the values to right-handed
  77222. */
  77223. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77224. /**
  77225. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77226. * clock-wise during export to glTF
  77227. * @param submesh BabylonJS submesh
  77228. * @param primitiveMode Primitive mode of the mesh
  77229. * @param sideOrientation the winding order of the submesh
  77230. * @param vertexBufferKind The type of vertex attribute
  77231. * @param meshAttributeArray The vertex attribute data
  77232. * @param byteOffset The offset to the binary data
  77233. * @param binaryWriter The binary data for the glTF file
  77234. * @param convertToRightHandedSystem Converts the values to right-handed
  77235. */
  77236. private reorderTriangleFillMode;
  77237. /**
  77238. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77239. * clock-wise during export to glTF
  77240. * @param submesh BabylonJS submesh
  77241. * @param primitiveMode Primitive mode of the mesh
  77242. * @param sideOrientation the winding order of the submesh
  77243. * @param vertexBufferKind The type of vertex attribute
  77244. * @param meshAttributeArray The vertex attribute data
  77245. * @param byteOffset The offset to the binary data
  77246. * @param binaryWriter The binary data for the glTF file
  77247. * @param convertToRightHandedSystem Converts the values to right-handed
  77248. */
  77249. private reorderTriangleStripDrawMode;
  77250. /**
  77251. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77252. * clock-wise during export to glTF
  77253. * @param submesh BabylonJS submesh
  77254. * @param primitiveMode Primitive mode of the mesh
  77255. * @param sideOrientation the winding order of the submesh
  77256. * @param vertexBufferKind The type of vertex attribute
  77257. * @param meshAttributeArray The vertex attribute data
  77258. * @param byteOffset The offset to the binary data
  77259. * @param binaryWriter The binary data for the glTF file
  77260. * @param convertToRightHandedSystem Converts the values to right-handed
  77261. */
  77262. private reorderTriangleFanMode;
  77263. /**
  77264. * Writes the vertex attribute data to binary
  77265. * @param vertices The vertices to write to the binary writer
  77266. * @param byteOffset The offset into the binary writer to overwrite binary data
  77267. * @param vertexAttributeKind The vertex attribute type
  77268. * @param meshAttributeArray The vertex attribute data
  77269. * @param binaryWriter The writer containing the binary data
  77270. * @param convertToRightHandedSystem Converts the values to right-handed
  77271. */
  77272. private writeVertexAttributeData;
  77273. /**
  77274. * Writes mesh attribute data to a data buffer
  77275. * Returns the bytelength of the data
  77276. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77277. * @param meshAttributeArray Array containing the attribute data
  77278. * @param binaryWriter The buffer to write the binary data to
  77279. * @param indices Used to specify the order of the vertex data
  77280. * @param convertToRightHandedSystem Converts the values to right-handed
  77281. */
  77282. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  77283. /**
  77284. * Generates glTF json data
  77285. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77286. * @param glTFPrefix Text to use when prefixing a glTF file
  77287. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77288. * @returns json data as string
  77289. */
  77290. private generateJSON;
  77291. /**
  77292. * Generates data for .gltf and .bin files based on the glTF prefix string
  77293. * @param glTFPrefix Text to use when prefixing a glTF file
  77294. * @param dispose Dispose the exporter
  77295. * @returns GLTFData with glTF file data
  77296. */
  77297. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77298. /**
  77299. * Creates a binary buffer for glTF
  77300. * @returns array buffer for binary data
  77301. */
  77302. private _generateBinaryAsync;
  77303. /**
  77304. * Pads the number to a multiple of 4
  77305. * @param num number to pad
  77306. * @returns padded number
  77307. */
  77308. private _getPadding;
  77309. /**
  77310. * @hidden
  77311. */
  77312. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77313. /**
  77314. * Sets the TRS for each node
  77315. * @param node glTF Node for storing the transformation data
  77316. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77317. * @param convertToRightHandedSystem Converts the values to right-handed
  77318. */
  77319. private setNodeTransformation;
  77320. private getVertexBufferFromMesh;
  77321. /**
  77322. * Creates a bufferview based on the vertices type for the Babylon mesh
  77323. * @param kind Indicates the type of vertices data
  77324. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77325. * @param binaryWriter The buffer to write the bufferview data to
  77326. * @param convertToRightHandedSystem Converts the values to right-handed
  77327. */
  77328. private createBufferViewKind;
  77329. /**
  77330. * The primitive mode of the Babylon mesh
  77331. * @param babylonMesh The BabylonJS mesh
  77332. */
  77333. private getMeshPrimitiveMode;
  77334. /**
  77335. * Sets the primitive mode of the glTF mesh primitive
  77336. * @param meshPrimitive glTF mesh primitive
  77337. * @param primitiveMode The primitive mode
  77338. */
  77339. private setPrimitiveMode;
  77340. /**
  77341. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77342. * @param meshPrimitive glTF mesh primitive
  77343. * @param attributeKind vertex attribute
  77344. * @returns boolean specifying if uv coordinates are present
  77345. */
  77346. private setAttributeKind;
  77347. /**
  77348. * Sets data for the primitive attributes of each submesh
  77349. * @param mesh glTF Mesh object to store the primitive attribute information
  77350. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77351. * @param binaryWriter Buffer to write the attribute data to
  77352. * @param convertToRightHandedSystem Converts the values to right-handed
  77353. */
  77354. private setPrimitiveAttributesAsync;
  77355. /**
  77356. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  77357. * @param node The node to check
  77358. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  77359. */
  77360. private isBabylonCoordinateSystemConvertingNode;
  77361. /**
  77362. * Creates a glTF scene based on the array of meshes
  77363. * Returns the the total byte offset
  77364. * @param babylonScene Babylon scene to get the mesh data from
  77365. * @param binaryWriter Buffer to write binary data to
  77366. */
  77367. private createSceneAsync;
  77368. /**
  77369. * Creates a mapping of Node unique id to node index and handles animations
  77370. * @param babylonScene Babylon Scene
  77371. * @param nodes Babylon transform nodes
  77372. * @param binaryWriter Buffer to write binary data to
  77373. * @returns Node mapping of unique id to index
  77374. */
  77375. private createNodeMapAndAnimationsAsync;
  77376. /**
  77377. * Creates a glTF node from a Babylon mesh
  77378. * @param babylonMesh Source Babylon mesh
  77379. * @param binaryWriter Buffer for storing geometry data
  77380. * @param convertToRightHandedSystem Converts the values to right-handed
  77381. * @param nodeMap Node mapping of unique id to glTF node index
  77382. * @returns glTF node
  77383. */
  77384. private createNodeAsync;
  77385. }
  77386. /**
  77387. * @hidden
  77388. *
  77389. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  77390. */
  77391. export class _BinaryWriter {
  77392. /**
  77393. * Array buffer which stores all binary data
  77394. */
  77395. private _arrayBuffer;
  77396. /**
  77397. * View of the array buffer
  77398. */
  77399. private _dataView;
  77400. /**
  77401. * byte offset of data in array buffer
  77402. */
  77403. private _byteOffset;
  77404. /**
  77405. * Initialize binary writer with an initial byte length
  77406. * @param byteLength Initial byte length of the array buffer
  77407. */
  77408. constructor(byteLength: number);
  77409. /**
  77410. * Resize the array buffer to the specified byte length
  77411. * @param byteLength
  77412. */
  77413. private resizeBuffer;
  77414. /**
  77415. * Get an array buffer with the length of the byte offset
  77416. * @returns ArrayBuffer resized to the byte offset
  77417. */
  77418. getArrayBuffer(): ArrayBuffer;
  77419. /**
  77420. * Get the byte offset of the array buffer
  77421. * @returns byte offset
  77422. */
  77423. getByteOffset(): number;
  77424. /**
  77425. * Stores an UInt8 in the array buffer
  77426. * @param entry
  77427. * @param byteOffset If defined, specifies where to set the value as an offset.
  77428. */
  77429. setUInt8(entry: number, byteOffset?: number): void;
  77430. /**
  77431. * Gets an UInt32 in the array buffer
  77432. * @param entry
  77433. * @param byteOffset If defined, specifies where to set the value as an offset.
  77434. */
  77435. getUInt32(byteOffset: number): number;
  77436. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77437. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77438. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77439. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77440. /**
  77441. * Stores a Float32 in the array buffer
  77442. * @param entry
  77443. */
  77444. setFloat32(entry: number, byteOffset?: number): void;
  77445. /**
  77446. * Stores an UInt32 in the array buffer
  77447. * @param entry
  77448. * @param byteOffset If defined, specifies where to set the value as an offset.
  77449. */
  77450. setUInt32(entry: number, byteOffset?: number): void;
  77451. }
  77452. }
  77453. declare module BABYLON.GLTF2.Exporter {
  77454. /**
  77455. * @hidden
  77456. * Interface to store animation data.
  77457. */
  77458. export interface _IAnimationData {
  77459. /**
  77460. * Keyframe data.
  77461. */
  77462. inputs: number[];
  77463. /**
  77464. * Value data.
  77465. */
  77466. outputs: number[][];
  77467. /**
  77468. * Animation interpolation data.
  77469. */
  77470. samplerInterpolation: AnimationSamplerInterpolation;
  77471. /**
  77472. * Minimum keyframe value.
  77473. */
  77474. inputsMin: number;
  77475. /**
  77476. * Maximum keyframe value.
  77477. */
  77478. inputsMax: number;
  77479. }
  77480. /**
  77481. * @hidden
  77482. */
  77483. export interface _IAnimationInfo {
  77484. /**
  77485. * The target channel for the animation
  77486. */
  77487. animationChannelTargetPath: AnimationChannelTargetPath;
  77488. /**
  77489. * The glTF accessor type for the data.
  77490. */
  77491. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  77492. /**
  77493. * Specifies if quaternions should be used.
  77494. */
  77495. useQuaternion: boolean;
  77496. }
  77497. /**
  77498. * @hidden
  77499. * Utility class for generating glTF animation data from BabylonJS.
  77500. */
  77501. export class _GLTFAnimation {
  77502. /**
  77503. * @ignore
  77504. *
  77505. * Creates glTF channel animation from BabylonJS animation.
  77506. * @param babylonTransformNode - BabylonJS mesh.
  77507. * @param animation - animation.
  77508. * @param animationChannelTargetPath - The target animation channel.
  77509. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  77510. * @param useQuaternion - Specifies if quaternions are used.
  77511. * @returns nullable IAnimationData
  77512. */
  77513. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  77514. private static _DeduceAnimationInfo;
  77515. /**
  77516. * @ignore
  77517. * Create node animations from the transform node animations
  77518. * @param babylonNode
  77519. * @param runtimeGLTFAnimation
  77520. * @param idleGLTFAnimations
  77521. * @param nodeMap
  77522. * @param nodes
  77523. * @param binaryWriter
  77524. * @param bufferViews
  77525. * @param accessors
  77526. * @param convertToRightHandedSystem
  77527. * @param animationSampleRate
  77528. */
  77529. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77530. [key: number]: number;
  77531. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77532. /**
  77533. * @ignore
  77534. * Create node animations from the animation groups
  77535. * @param babylonScene
  77536. * @param glTFAnimations
  77537. * @param nodeMap
  77538. * @param nodes
  77539. * @param binaryWriter
  77540. * @param bufferViews
  77541. * @param accessors
  77542. * @param convertToRightHandedSystemMap
  77543. * @param animationSampleRate
  77544. */
  77545. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77546. [key: number]: number;
  77547. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  77548. [nodeId: number]: boolean;
  77549. }, animationSampleRate: number): void;
  77550. private static AddAnimation;
  77551. /**
  77552. * Create a baked animation
  77553. * @param babylonTransformNode BabylonJS mesh
  77554. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77555. * @param animationChannelTargetPath animation target channel
  77556. * @param minFrame minimum animation frame
  77557. * @param maxFrame maximum animation frame
  77558. * @param fps frames per second of the animation
  77559. * @param inputs input key frames of the animation
  77560. * @param outputs output key frame data of the animation
  77561. * @param convertToRightHandedSystem converts the values to right-handed
  77562. * @param useQuaternion specifies if quaternions should be used
  77563. */
  77564. private static _CreateBakedAnimation;
  77565. private static _ConvertFactorToVector3OrQuaternion;
  77566. private static _SetInterpolatedValue;
  77567. /**
  77568. * Creates linear animation from the animation key frames
  77569. * @param babylonTransformNode BabylonJS mesh
  77570. * @param animation BabylonJS animation
  77571. * @param animationChannelTargetPath The target animation channel
  77572. * @param frameDelta The difference between the last and first frame of the animation
  77573. * @param inputs Array to store the key frame times
  77574. * @param outputs Array to store the key frame data
  77575. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77576. * @param useQuaternion Specifies if quaternions are used in the animation
  77577. */
  77578. private static _CreateLinearOrStepAnimation;
  77579. /**
  77580. * Creates cubic spline animation from the animation key frames
  77581. * @param babylonTransformNode BabylonJS mesh
  77582. * @param animation BabylonJS animation
  77583. * @param animationChannelTargetPath The target animation channel
  77584. * @param frameDelta The difference between the last and first frame of the animation
  77585. * @param inputs Array to store the key frame times
  77586. * @param outputs Array to store the key frame data
  77587. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77588. * @param useQuaternion Specifies if quaternions are used in the animation
  77589. */
  77590. private static _CreateCubicSplineAnimation;
  77591. private static _GetBasePositionRotationOrScale;
  77592. /**
  77593. * Adds a key frame value
  77594. * @param keyFrame
  77595. * @param animation
  77596. * @param outputs
  77597. * @param animationChannelTargetPath
  77598. * @param basePositionRotationOrScale
  77599. * @param convertToRightHandedSystem
  77600. * @param useQuaternion
  77601. */
  77602. private static _AddKeyframeValue;
  77603. /**
  77604. * Determine the interpolation based on the key frames
  77605. * @param keyFrames
  77606. * @param animationChannelTargetPath
  77607. * @param useQuaternion
  77608. */
  77609. private static _DeduceInterpolation;
  77610. /**
  77611. * Adds an input tangent or output tangent to the output data
  77612. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  77613. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  77614. * @param outputs The animation data by keyframe
  77615. * @param animationChannelTargetPath The target animation channel
  77616. * @param interpolation The interpolation type
  77617. * @param keyFrame The key frame with the animation data
  77618. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  77619. * @param useQuaternion Specifies if quaternions are used
  77620. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  77621. */
  77622. private static AddSplineTangent;
  77623. /**
  77624. * Get the minimum and maximum key frames' frame values
  77625. * @param keyFrames animation key frames
  77626. * @returns the minimum and maximum key frame value
  77627. */
  77628. private static calculateMinMaxKeyFrames;
  77629. }
  77630. }
  77631. declare module BABYLON.GLTF2.Exporter {
  77632. /** @hidden */
  77633. export var textureTransformPixelShader: {
  77634. name: string;
  77635. shader: string;
  77636. };
  77637. }
  77638. declare module BABYLON.GLTF2.Exporter.Extensions {
  77639. /**
  77640. * @hidden
  77641. */
  77642. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  77643. private _recordedTextures;
  77644. /** Name of this extension */
  77645. readonly name: string;
  77646. /** Defines whether this extension is enabled */
  77647. enabled: boolean;
  77648. /** Defines whether this extension is required */
  77649. required: boolean;
  77650. /** Reference to the glTF exporter */
  77651. private _wasUsed;
  77652. constructor(exporter: _Exporter);
  77653. dispose(): void;
  77654. /** @hidden */
  77655. get wasUsed(): boolean;
  77656. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77657. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  77658. /**
  77659. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  77660. * @param babylonTexture
  77661. * @param offset
  77662. * @param rotation
  77663. * @param scale
  77664. * @param scene
  77665. */
  77666. private _textureTransformTextureAsync;
  77667. }
  77668. }
  77669. declare module BABYLON.GLTF2.Exporter.Extensions {
  77670. /**
  77671. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  77672. */
  77673. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  77674. /** The name of this extension. */
  77675. readonly name: string;
  77676. /** Defines whether this extension is enabled. */
  77677. enabled: boolean;
  77678. /** Defines whether this extension is required */
  77679. required: boolean;
  77680. /** Reference to the glTF exporter */
  77681. private _exporter;
  77682. private _lights;
  77683. /** @hidden */
  77684. constructor(exporter: _Exporter);
  77685. /** @hidden */
  77686. dispose(): void;
  77687. /** @hidden */
  77688. get wasUsed(): boolean;
  77689. /** @hidden */
  77690. onExporting(): void;
  77691. /**
  77692. * Define this method to modify the default behavior when exporting a node
  77693. * @param context The context when exporting the node
  77694. * @param node glTF node
  77695. * @param babylonNode BabylonJS node
  77696. * @param nodeMap Node mapping of unique id to glTF node index
  77697. * @returns nullable INode promise
  77698. */
  77699. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77700. [key: number]: number;
  77701. }): Promise<Nullable<INode>>;
  77702. }
  77703. }
  77704. declare module BABYLON.GLTF2.Exporter.Extensions {
  77705. /**
  77706. * @hidden
  77707. */
  77708. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  77709. /** Name of this extension */
  77710. readonly name: string;
  77711. /** Defines whether this extension is enabled */
  77712. enabled: boolean;
  77713. /** Defines whether this extension is required */
  77714. required: boolean;
  77715. /** Reference to the glTF exporter */
  77716. private _textureInfos;
  77717. private _exportedTextures;
  77718. private _wasUsed;
  77719. constructor(exporter: _Exporter);
  77720. dispose(): void;
  77721. /** @hidden */
  77722. get wasUsed(): boolean;
  77723. private _getTextureIndex;
  77724. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77725. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77726. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  77727. }
  77728. }
  77729. declare module BABYLON {
  77730. /**
  77731. * Class for generating STL data from a Babylon scene.
  77732. */
  77733. export class STLExport {
  77734. /**
  77735. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  77736. * @param meshes list defines the mesh to serialize
  77737. * @param download triggers the automatic download of the file.
  77738. * @param fileName changes the downloads fileName.
  77739. * @param binary changes the STL to a binary type.
  77740. * @param isLittleEndian toggle for binary type exporter.
  77741. * @returns the STL as UTF8 string
  77742. */
  77743. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  77744. }
  77745. }
  77746. declare module "babylonjs-gltf2interface" {
  77747. export = BABYLON.GLTF2;
  77748. }
  77749. /**
  77750. * Module for glTF 2.0 Interface
  77751. */
  77752. declare module BABYLON.GLTF2 {
  77753. /**
  77754. * The datatype of the components in the attribute
  77755. */
  77756. const enum AccessorComponentType {
  77757. /**
  77758. * Byte
  77759. */
  77760. BYTE = 5120,
  77761. /**
  77762. * Unsigned Byte
  77763. */
  77764. UNSIGNED_BYTE = 5121,
  77765. /**
  77766. * Short
  77767. */
  77768. SHORT = 5122,
  77769. /**
  77770. * Unsigned Short
  77771. */
  77772. UNSIGNED_SHORT = 5123,
  77773. /**
  77774. * Unsigned Int
  77775. */
  77776. UNSIGNED_INT = 5125,
  77777. /**
  77778. * Float
  77779. */
  77780. FLOAT = 5126,
  77781. }
  77782. /**
  77783. * Specifies if the attirbute is a scalar, vector, or matrix
  77784. */
  77785. const enum AccessorType {
  77786. /**
  77787. * Scalar
  77788. */
  77789. SCALAR = "SCALAR",
  77790. /**
  77791. * Vector2
  77792. */
  77793. VEC2 = "VEC2",
  77794. /**
  77795. * Vector3
  77796. */
  77797. VEC3 = "VEC3",
  77798. /**
  77799. * Vector4
  77800. */
  77801. VEC4 = "VEC4",
  77802. /**
  77803. * Matrix2x2
  77804. */
  77805. MAT2 = "MAT2",
  77806. /**
  77807. * Matrix3x3
  77808. */
  77809. MAT3 = "MAT3",
  77810. /**
  77811. * Matrix4x4
  77812. */
  77813. MAT4 = "MAT4",
  77814. }
  77815. /**
  77816. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77817. */
  77818. const enum AnimationChannelTargetPath {
  77819. /**
  77820. * Translation
  77821. */
  77822. TRANSLATION = "translation",
  77823. /**
  77824. * Rotation
  77825. */
  77826. ROTATION = "rotation",
  77827. /**
  77828. * Scale
  77829. */
  77830. SCALE = "scale",
  77831. /**
  77832. * Weights
  77833. */
  77834. WEIGHTS = "weights",
  77835. }
  77836. /**
  77837. * Interpolation algorithm
  77838. */
  77839. const enum AnimationSamplerInterpolation {
  77840. /**
  77841. * The animated values are linearly interpolated between keyframes
  77842. */
  77843. LINEAR = "LINEAR",
  77844. /**
  77845. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  77846. */
  77847. STEP = "STEP",
  77848. /**
  77849. * The animation's interpolation is computed using a cubic spline with specified tangents
  77850. */
  77851. CUBICSPLINE = "CUBICSPLINE",
  77852. }
  77853. /**
  77854. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77855. */
  77856. const enum CameraType {
  77857. /**
  77858. * A perspective camera containing properties to create a perspective projection matrix
  77859. */
  77860. PERSPECTIVE = "perspective",
  77861. /**
  77862. * An orthographic camera containing properties to create an orthographic projection matrix
  77863. */
  77864. ORTHOGRAPHIC = "orthographic",
  77865. }
  77866. /**
  77867. * The mime-type of the image
  77868. */
  77869. const enum ImageMimeType {
  77870. /**
  77871. * JPEG Mime-type
  77872. */
  77873. JPEG = "image/jpeg",
  77874. /**
  77875. * PNG Mime-type
  77876. */
  77877. PNG = "image/png",
  77878. }
  77879. /**
  77880. * The alpha rendering mode of the material
  77881. */
  77882. const enum MaterialAlphaMode {
  77883. /**
  77884. * The alpha value is ignored and the rendered output is fully opaque
  77885. */
  77886. OPAQUE = "OPAQUE",
  77887. /**
  77888. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77889. */
  77890. MASK = "MASK",
  77891. /**
  77892. * 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)
  77893. */
  77894. BLEND = "BLEND",
  77895. }
  77896. /**
  77897. * The type of the primitives to render
  77898. */
  77899. const enum MeshPrimitiveMode {
  77900. /**
  77901. * Points
  77902. */
  77903. POINTS = 0,
  77904. /**
  77905. * Lines
  77906. */
  77907. LINES = 1,
  77908. /**
  77909. * Line Loop
  77910. */
  77911. LINE_LOOP = 2,
  77912. /**
  77913. * Line Strip
  77914. */
  77915. LINE_STRIP = 3,
  77916. /**
  77917. * Triangles
  77918. */
  77919. TRIANGLES = 4,
  77920. /**
  77921. * Triangle Strip
  77922. */
  77923. TRIANGLE_STRIP = 5,
  77924. /**
  77925. * Triangle Fan
  77926. */
  77927. TRIANGLE_FAN = 6,
  77928. }
  77929. /**
  77930. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77931. */
  77932. const enum TextureMagFilter {
  77933. /**
  77934. * Nearest
  77935. */
  77936. NEAREST = 9728,
  77937. /**
  77938. * Linear
  77939. */
  77940. LINEAR = 9729,
  77941. }
  77942. /**
  77943. * Minification filter. All valid values correspond to WebGL enums
  77944. */
  77945. const enum TextureMinFilter {
  77946. /**
  77947. * Nearest
  77948. */
  77949. NEAREST = 9728,
  77950. /**
  77951. * Linear
  77952. */
  77953. LINEAR = 9729,
  77954. /**
  77955. * Nearest Mip-Map Nearest
  77956. */
  77957. NEAREST_MIPMAP_NEAREST = 9984,
  77958. /**
  77959. * Linear Mipmap Nearest
  77960. */
  77961. LINEAR_MIPMAP_NEAREST = 9985,
  77962. /**
  77963. * Nearest Mipmap Linear
  77964. */
  77965. NEAREST_MIPMAP_LINEAR = 9986,
  77966. /**
  77967. * Linear Mipmap Linear
  77968. */
  77969. LINEAR_MIPMAP_LINEAR = 9987,
  77970. }
  77971. /**
  77972. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77973. */
  77974. const enum TextureWrapMode {
  77975. /**
  77976. * Clamp to Edge
  77977. */
  77978. CLAMP_TO_EDGE = 33071,
  77979. /**
  77980. * Mirrored Repeat
  77981. */
  77982. MIRRORED_REPEAT = 33648,
  77983. /**
  77984. * Repeat
  77985. */
  77986. REPEAT = 10497,
  77987. }
  77988. /**
  77989. * glTF Property
  77990. */
  77991. interface IProperty {
  77992. /**
  77993. * Dictionary object with extension-specific objects
  77994. */
  77995. extensions?: {
  77996. [key: string]: any;
  77997. };
  77998. /**
  77999. * Application-Specific data
  78000. */
  78001. extras?: any;
  78002. }
  78003. /**
  78004. * glTF Child of Root Property
  78005. */
  78006. interface IChildRootProperty extends IProperty {
  78007. /**
  78008. * The user-defined name of this object
  78009. */
  78010. name?: string;
  78011. }
  78012. /**
  78013. * Indices of those attributes that deviate from their initialization value
  78014. */
  78015. interface IAccessorSparseIndices extends IProperty {
  78016. /**
  78017. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78018. */
  78019. bufferView: number;
  78020. /**
  78021. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78022. */
  78023. byteOffset?: number;
  78024. /**
  78025. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78026. */
  78027. componentType: AccessorComponentType;
  78028. }
  78029. /**
  78030. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78031. */
  78032. interface IAccessorSparseValues extends IProperty {
  78033. /**
  78034. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78035. */
  78036. bufferView: number;
  78037. /**
  78038. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78039. */
  78040. byteOffset?: number;
  78041. }
  78042. /**
  78043. * Sparse storage of attributes that deviate from their initialization value
  78044. */
  78045. interface IAccessorSparse extends IProperty {
  78046. /**
  78047. * The number of attributes encoded in this sparse accessor
  78048. */
  78049. count: number;
  78050. /**
  78051. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78052. */
  78053. indices: IAccessorSparseIndices;
  78054. /**
  78055. * 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
  78056. */
  78057. values: IAccessorSparseValues;
  78058. }
  78059. /**
  78060. * 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
  78061. */
  78062. interface IAccessor extends IChildRootProperty {
  78063. /**
  78064. * The index of the bufferview
  78065. */
  78066. bufferView?: number;
  78067. /**
  78068. * The offset relative to the start of the bufferView in bytes
  78069. */
  78070. byteOffset?: number;
  78071. /**
  78072. * The datatype of components in the attribute
  78073. */
  78074. componentType: AccessorComponentType;
  78075. /**
  78076. * Specifies whether integer data values should be normalized
  78077. */
  78078. normalized?: boolean;
  78079. /**
  78080. * The number of attributes referenced by this accessor
  78081. */
  78082. count: number;
  78083. /**
  78084. * Specifies if the attribute is a scalar, vector, or matrix
  78085. */
  78086. type: AccessorType;
  78087. /**
  78088. * Maximum value of each component in this attribute
  78089. */
  78090. max?: number[];
  78091. /**
  78092. * Minimum value of each component in this attribute
  78093. */
  78094. min?: number[];
  78095. /**
  78096. * Sparse storage of attributes that deviate from their initialization value
  78097. */
  78098. sparse?: IAccessorSparse;
  78099. }
  78100. /**
  78101. * Targets an animation's sampler at a node's property
  78102. */
  78103. interface IAnimationChannel extends IProperty {
  78104. /**
  78105. * The index of a sampler in this animation used to compute the value for the target
  78106. */
  78107. sampler: number;
  78108. /**
  78109. * The index of the node and TRS property to target
  78110. */
  78111. target: IAnimationChannelTarget;
  78112. }
  78113. /**
  78114. * The index of the node and TRS property that an animation channel targets
  78115. */
  78116. interface IAnimationChannelTarget extends IProperty {
  78117. /**
  78118. * The index of the node to target
  78119. */
  78120. node: number;
  78121. /**
  78122. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78123. */
  78124. path: AnimationChannelTargetPath;
  78125. }
  78126. /**
  78127. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78128. */
  78129. interface IAnimationSampler extends IProperty {
  78130. /**
  78131. * The index of an accessor containing keyframe input values, e.g., time
  78132. */
  78133. input: number;
  78134. /**
  78135. * Interpolation algorithm
  78136. */
  78137. interpolation?: AnimationSamplerInterpolation;
  78138. /**
  78139. * The index of an accessor, containing keyframe output values
  78140. */
  78141. output: number;
  78142. }
  78143. /**
  78144. * A keyframe animation
  78145. */
  78146. interface IAnimation extends IChildRootProperty {
  78147. /**
  78148. * An array of channels, each of which targets an animation's sampler at a node's property
  78149. */
  78150. channels: IAnimationChannel[];
  78151. /**
  78152. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78153. */
  78154. samplers: IAnimationSampler[];
  78155. }
  78156. /**
  78157. * Metadata about the glTF asset
  78158. */
  78159. interface IAsset extends IChildRootProperty {
  78160. /**
  78161. * A copyright message suitable for display to credit the content creator
  78162. */
  78163. copyright?: string;
  78164. /**
  78165. * Tool that generated this glTF model. Useful for debugging
  78166. */
  78167. generator?: string;
  78168. /**
  78169. * The glTF version that this asset targets
  78170. */
  78171. version: string;
  78172. /**
  78173. * The minimum glTF version that this asset targets
  78174. */
  78175. minVersion?: string;
  78176. }
  78177. /**
  78178. * A buffer points to binary geometry, animation, or skins
  78179. */
  78180. interface IBuffer extends IChildRootProperty {
  78181. /**
  78182. * 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
  78183. */
  78184. uri?: string;
  78185. /**
  78186. * The length of the buffer in bytes
  78187. */
  78188. byteLength: number;
  78189. }
  78190. /**
  78191. * A view into a buffer generally representing a subset of the buffer
  78192. */
  78193. interface IBufferView extends IChildRootProperty {
  78194. /**
  78195. * The index of the buffer
  78196. */
  78197. buffer: number;
  78198. /**
  78199. * The offset into the buffer in bytes
  78200. */
  78201. byteOffset?: number;
  78202. /**
  78203. * The lenth of the bufferView in bytes
  78204. */
  78205. byteLength: number;
  78206. /**
  78207. * The stride, in bytes
  78208. */
  78209. byteStride?: number;
  78210. }
  78211. /**
  78212. * An orthographic camera containing properties to create an orthographic projection matrix
  78213. */
  78214. interface ICameraOrthographic extends IProperty {
  78215. /**
  78216. * The floating-point horizontal magnification of the view. Must not be zero
  78217. */
  78218. xmag: number;
  78219. /**
  78220. * The floating-point vertical magnification of the view. Must not be zero
  78221. */
  78222. ymag: number;
  78223. /**
  78224. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78225. */
  78226. zfar: number;
  78227. /**
  78228. * The floating-point distance to the near clipping plane
  78229. */
  78230. znear: number;
  78231. }
  78232. /**
  78233. * A perspective camera containing properties to create a perspective projection matrix
  78234. */
  78235. interface ICameraPerspective extends IProperty {
  78236. /**
  78237. * The floating-point aspect ratio of the field of view
  78238. */
  78239. aspectRatio?: number;
  78240. /**
  78241. * The floating-point vertical field of view in radians
  78242. */
  78243. yfov: number;
  78244. /**
  78245. * The floating-point distance to the far clipping plane
  78246. */
  78247. zfar?: number;
  78248. /**
  78249. * The floating-point distance to the near clipping plane
  78250. */
  78251. znear: number;
  78252. }
  78253. /**
  78254. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78255. */
  78256. interface ICamera extends IChildRootProperty {
  78257. /**
  78258. * An orthographic camera containing properties to create an orthographic projection matrix
  78259. */
  78260. orthographic?: ICameraOrthographic;
  78261. /**
  78262. * A perspective camera containing properties to create a perspective projection matrix
  78263. */
  78264. perspective?: ICameraPerspective;
  78265. /**
  78266. * Specifies if the camera uses a perspective or orthographic projection
  78267. */
  78268. type: CameraType;
  78269. }
  78270. /**
  78271. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78272. */
  78273. interface IImage extends IChildRootProperty {
  78274. /**
  78275. * 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
  78276. */
  78277. uri?: string;
  78278. /**
  78279. * The image's MIME type
  78280. */
  78281. mimeType?: ImageMimeType;
  78282. /**
  78283. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78284. */
  78285. bufferView?: number;
  78286. }
  78287. /**
  78288. * Material Normal Texture Info
  78289. */
  78290. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78291. /**
  78292. * The scalar multiplier applied to each normal vector of the normal texture
  78293. */
  78294. scale?: number;
  78295. }
  78296. /**
  78297. * Material Occlusion Texture Info
  78298. */
  78299. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78300. /**
  78301. * A scalar multiplier controlling the amount of occlusion applied
  78302. */
  78303. strength?: number;
  78304. }
  78305. /**
  78306. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78307. */
  78308. interface IMaterialPbrMetallicRoughness {
  78309. /**
  78310. * The material's base color factor
  78311. */
  78312. baseColorFactor?: number[];
  78313. /**
  78314. * The base color texture
  78315. */
  78316. baseColorTexture?: ITextureInfo;
  78317. /**
  78318. * The metalness of the material
  78319. */
  78320. metallicFactor?: number;
  78321. /**
  78322. * The roughness of the material
  78323. */
  78324. roughnessFactor?: number;
  78325. /**
  78326. * The metallic-roughness texture
  78327. */
  78328. metallicRoughnessTexture?: ITextureInfo;
  78329. }
  78330. /**
  78331. * The material appearance of a primitive
  78332. */
  78333. interface IMaterial extends IChildRootProperty {
  78334. /**
  78335. * 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
  78336. */
  78337. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78338. /**
  78339. * The normal map texture
  78340. */
  78341. normalTexture?: IMaterialNormalTextureInfo;
  78342. /**
  78343. * The occlusion map texture
  78344. */
  78345. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78346. /**
  78347. * The emissive map texture
  78348. */
  78349. emissiveTexture?: ITextureInfo;
  78350. /**
  78351. * 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
  78352. */
  78353. emissiveFactor?: number[];
  78354. /**
  78355. * The alpha rendering mode of the material
  78356. */
  78357. alphaMode?: MaterialAlphaMode;
  78358. /**
  78359. * The alpha cutoff value of the material
  78360. */
  78361. alphaCutoff?: number;
  78362. /**
  78363. * Specifies whether the material is double sided
  78364. */
  78365. doubleSided?: boolean;
  78366. }
  78367. /**
  78368. * Geometry to be rendered with the given material
  78369. */
  78370. interface IMeshPrimitive extends IProperty {
  78371. /**
  78372. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78373. */
  78374. attributes: {
  78375. [name: string]: number;
  78376. };
  78377. /**
  78378. * The index of the accessor that contains the indices
  78379. */
  78380. indices?: number;
  78381. /**
  78382. * The index of the material to apply to this primitive when rendering
  78383. */
  78384. material?: number;
  78385. /**
  78386. * The type of primitives to render. All valid values correspond to WebGL enums
  78387. */
  78388. mode?: MeshPrimitiveMode;
  78389. /**
  78390. * 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
  78391. */
  78392. targets?: {
  78393. [name: string]: number;
  78394. }[];
  78395. }
  78396. /**
  78397. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  78398. */
  78399. interface IMesh extends IChildRootProperty {
  78400. /**
  78401. * An array of primitives, each defining geometry to be rendered with a material
  78402. */
  78403. primitives: IMeshPrimitive[];
  78404. /**
  78405. * Array of weights to be applied to the Morph Targets
  78406. */
  78407. weights?: number[];
  78408. }
  78409. /**
  78410. * A node in the node hierarchy
  78411. */
  78412. interface INode extends IChildRootProperty {
  78413. /**
  78414. * The index of the camera referenced by this node
  78415. */
  78416. camera?: number;
  78417. /**
  78418. * The indices of this node's children
  78419. */
  78420. children?: number[];
  78421. /**
  78422. * The index of the skin referenced by this node
  78423. */
  78424. skin?: number;
  78425. /**
  78426. * A floating-point 4x4 transformation matrix stored in column-major order
  78427. */
  78428. matrix?: number[];
  78429. /**
  78430. * The index of the mesh in this node
  78431. */
  78432. mesh?: number;
  78433. /**
  78434. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  78435. */
  78436. rotation?: number[];
  78437. /**
  78438. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  78439. */
  78440. scale?: number[];
  78441. /**
  78442. * The node's translation along the x, y, and z axes
  78443. */
  78444. translation?: number[];
  78445. /**
  78446. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  78447. */
  78448. weights?: number[];
  78449. }
  78450. /**
  78451. * Texture sampler properties for filtering and wrapping modes
  78452. */
  78453. interface ISampler extends IChildRootProperty {
  78454. /**
  78455. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78456. */
  78457. magFilter?: TextureMagFilter;
  78458. /**
  78459. * Minification filter. All valid values correspond to WebGL enums
  78460. */
  78461. minFilter?: TextureMinFilter;
  78462. /**
  78463. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78464. */
  78465. wrapS?: TextureWrapMode;
  78466. /**
  78467. * T (V) wrapping mode. All valid values correspond to WebGL enums
  78468. */
  78469. wrapT?: TextureWrapMode;
  78470. }
  78471. /**
  78472. * The root nodes of a scene
  78473. */
  78474. interface IScene extends IChildRootProperty {
  78475. /**
  78476. * The indices of each root node
  78477. */
  78478. nodes: number[];
  78479. }
  78480. /**
  78481. * Joints and matrices defining a skin
  78482. */
  78483. interface ISkin extends IChildRootProperty {
  78484. /**
  78485. * 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
  78486. */
  78487. inverseBindMatrices?: number;
  78488. /**
  78489. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  78490. */
  78491. skeleton?: number;
  78492. /**
  78493. * 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)
  78494. */
  78495. joints: number[];
  78496. }
  78497. /**
  78498. * A texture and its sampler
  78499. */
  78500. interface ITexture extends IChildRootProperty {
  78501. /**
  78502. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  78503. */
  78504. sampler?: number;
  78505. /**
  78506. * The index of the image used by this texture
  78507. */
  78508. source: number;
  78509. }
  78510. /**
  78511. * Reference to a texture
  78512. */
  78513. interface ITextureInfo extends IProperty {
  78514. /**
  78515. * The index of the texture
  78516. */
  78517. index: number;
  78518. /**
  78519. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  78520. */
  78521. texCoord?: number;
  78522. }
  78523. /**
  78524. * The root object for a glTF asset
  78525. */
  78526. interface IGLTF extends IProperty {
  78527. /**
  78528. * An array of accessors. An accessor is a typed view into a bufferView
  78529. */
  78530. accessors?: IAccessor[];
  78531. /**
  78532. * An array of keyframe animations
  78533. */
  78534. animations?: IAnimation[];
  78535. /**
  78536. * Metadata about the glTF asset
  78537. */
  78538. asset: IAsset;
  78539. /**
  78540. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78541. */
  78542. buffers?: IBuffer[];
  78543. /**
  78544. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78545. */
  78546. bufferViews?: IBufferView[];
  78547. /**
  78548. * An array of cameras
  78549. */
  78550. cameras?: ICamera[];
  78551. /**
  78552. * Names of glTF extensions used somewhere in this asset
  78553. */
  78554. extensionsUsed?: string[];
  78555. /**
  78556. * Names of glTF extensions required to properly load this asset
  78557. */
  78558. extensionsRequired?: string[];
  78559. /**
  78560. * An array of images. An image defines data used to create a texture
  78561. */
  78562. images?: IImage[];
  78563. /**
  78564. * An array of materials. A material defines the appearance of a primitive
  78565. */
  78566. materials?: IMaterial[];
  78567. /**
  78568. * An array of meshes. A mesh is a set of primitives to be rendered
  78569. */
  78570. meshes?: IMesh[];
  78571. /**
  78572. * An array of nodes
  78573. */
  78574. nodes?: INode[];
  78575. /**
  78576. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78577. */
  78578. samplers?: ISampler[];
  78579. /**
  78580. * The index of the default scene
  78581. */
  78582. scene?: number;
  78583. /**
  78584. * An array of scenes
  78585. */
  78586. scenes?: IScene[];
  78587. /**
  78588. * An array of skins. A skin is defined by joints and matrices
  78589. */
  78590. skins?: ISkin[];
  78591. /**
  78592. * An array of textures
  78593. */
  78594. textures?: ITexture[];
  78595. }
  78596. /**
  78597. * The glTF validation results
  78598. * @ignore
  78599. */
  78600. interface IGLTFValidationResults {
  78601. info: {
  78602. generator: string;
  78603. hasAnimations: boolean;
  78604. hasDefaultScene: boolean;
  78605. hasMaterials: boolean;
  78606. hasMorphTargets: boolean;
  78607. hasSkins: boolean;
  78608. hasTextures: boolean;
  78609. maxAttributesUsed: number;
  78610. primitivesCount: number
  78611. };
  78612. issues: {
  78613. messages: Array<string>;
  78614. numErrors: number;
  78615. numHints: number;
  78616. numInfos: number;
  78617. numWarnings: number;
  78618. truncated: boolean
  78619. };
  78620. mimeType: string;
  78621. uri: string;
  78622. validatedAt: string;
  78623. validatorVersion: string;
  78624. }
  78625. /**
  78626. * The glTF validation options
  78627. */
  78628. interface IGLTFValidationOptions {
  78629. /** Uri to use */
  78630. uri?: string;
  78631. /** Function used to load external resources */
  78632. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  78633. /** Boolean indicating that we need to validate accessor data */
  78634. validateAccessorData?: boolean;
  78635. /** max number of issues allowed */
  78636. maxIssues?: number;
  78637. /** Ignored issues */
  78638. ignoredIssues?: Array<string>;
  78639. /** Value to override severy settings */
  78640. severityOverrides?: Object;
  78641. }
  78642. /**
  78643. * The glTF validator object
  78644. * @ignore
  78645. */
  78646. interface IGLTFValidator {
  78647. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78648. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78649. }
  78650. }
  78651. declare module BABYLON {
  78652. /** @hidden */
  78653. export var cellPixelShader: {
  78654. name: string;
  78655. shader: string;
  78656. };
  78657. }
  78658. declare module BABYLON {
  78659. /** @hidden */
  78660. export var cellVertexShader: {
  78661. name: string;
  78662. shader: string;
  78663. };
  78664. }
  78665. declare module BABYLON {
  78666. export class CellMaterial extends BABYLON.PushMaterial {
  78667. private _diffuseTexture;
  78668. diffuseTexture: BABYLON.BaseTexture;
  78669. diffuseColor: BABYLON.Color3;
  78670. _computeHighLevel: boolean;
  78671. computeHighLevel: boolean;
  78672. private _disableLighting;
  78673. disableLighting: boolean;
  78674. private _maxSimultaneousLights;
  78675. maxSimultaneousLights: number;
  78676. private _renderId;
  78677. constructor(name: string, scene: BABYLON.Scene);
  78678. needAlphaBlending(): boolean;
  78679. needAlphaTesting(): boolean;
  78680. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78681. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78682. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78683. getAnimatables(): BABYLON.IAnimatable[];
  78684. getActiveTextures(): BABYLON.BaseTexture[];
  78685. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78686. dispose(forceDisposeEffect?: boolean): void;
  78687. getClassName(): string;
  78688. clone(name: string): CellMaterial;
  78689. serialize(): any;
  78690. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  78691. }
  78692. }
  78693. declare module BABYLON {
  78694. export class CustomShaderStructure {
  78695. FragmentStore: string;
  78696. VertexStore: string;
  78697. constructor();
  78698. }
  78699. export class ShaderSpecialParts {
  78700. constructor();
  78701. Fragment_Begin: string;
  78702. Fragment_Definitions: string;
  78703. Fragment_MainBegin: string;
  78704. Fragment_Custom_Diffuse: string;
  78705. Fragment_Before_Lights: string;
  78706. Fragment_Before_Fog: string;
  78707. Fragment_Custom_Alpha: string;
  78708. Fragment_Before_FragColor: string;
  78709. Vertex_Begin: string;
  78710. Vertex_Definitions: string;
  78711. Vertex_MainBegin: string;
  78712. Vertex_Before_PositionUpdated: string;
  78713. Vertex_Before_NormalUpdated: string;
  78714. Vertex_MainEnd: string;
  78715. }
  78716. export class CustomMaterial extends BABYLON.StandardMaterial {
  78717. static ShaderIndexer: number;
  78718. CustomParts: ShaderSpecialParts;
  78719. _isCreatedShader: boolean;
  78720. _createdShaderName: string;
  78721. _customUniform: string[];
  78722. _newUniforms: string[];
  78723. _newUniformInstances: any[];
  78724. _newSamplerInstances: BABYLON.Texture[];
  78725. FragmentShader: string;
  78726. VertexShader: string;
  78727. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78728. ReviewUniform(name: string, arr: string[]): string[];
  78729. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  78730. constructor(name: string, scene: BABYLON.Scene);
  78731. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  78732. Fragment_Begin(shaderPart: string): CustomMaterial;
  78733. Fragment_Definitions(shaderPart: string): CustomMaterial;
  78734. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  78735. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  78736. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  78737. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  78738. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  78739. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  78740. Vertex_Begin(shaderPart: string): CustomMaterial;
  78741. Vertex_Definitions(shaderPart: string): CustomMaterial;
  78742. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  78743. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  78744. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  78745. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  78746. }
  78747. }
  78748. declare module BABYLON {
  78749. export class ShaderAlebdoParts {
  78750. constructor();
  78751. Fragment_Begin: string;
  78752. Fragment_Definitions: string;
  78753. Fragment_MainBegin: string;
  78754. Fragment_Custom_Albedo: string;
  78755. Fragment_Before_Lights: string;
  78756. Fragment_Custom_MetallicRoughness: string;
  78757. Fragment_Custom_MicroSurface: string;
  78758. Fragment_Before_Fog: string;
  78759. Fragment_Custom_Alpha: string;
  78760. Fragment_Before_FragColor: string;
  78761. Vertex_Begin: string;
  78762. Vertex_Definitions: string;
  78763. Vertex_MainBegin: string;
  78764. Vertex_Before_PositionUpdated: string;
  78765. Vertex_Before_NormalUpdated: string;
  78766. Vertex_MainEnd: string;
  78767. }
  78768. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  78769. static ShaderIndexer: number;
  78770. CustomParts: ShaderAlebdoParts;
  78771. _isCreatedShader: boolean;
  78772. _createdShaderName: string;
  78773. _customUniform: string[];
  78774. _newUniforms: string[];
  78775. _newUniformInstances: any[];
  78776. _newSamplerInstances: BABYLON.Texture[];
  78777. FragmentShader: string;
  78778. VertexShader: string;
  78779. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78780. ReviewUniform(name: string, arr: string[]): string[];
  78781. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  78782. constructor(name: string, scene: BABYLON.Scene);
  78783. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  78784. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  78785. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  78786. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  78787. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  78788. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  78789. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  78790. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  78791. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  78792. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  78793. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  78794. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  78795. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  78796. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  78797. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  78798. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  78799. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  78800. }
  78801. }
  78802. declare module BABYLON {
  78803. /** @hidden */
  78804. export var firePixelShader: {
  78805. name: string;
  78806. shader: string;
  78807. };
  78808. }
  78809. declare module BABYLON {
  78810. /** @hidden */
  78811. export var fireVertexShader: {
  78812. name: string;
  78813. shader: string;
  78814. };
  78815. }
  78816. declare module BABYLON {
  78817. export class FireMaterial extends BABYLON.PushMaterial {
  78818. private _diffuseTexture;
  78819. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78820. private _distortionTexture;
  78821. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78822. private _opacityTexture;
  78823. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78824. diffuseColor: BABYLON.Color3;
  78825. speed: number;
  78826. private _scaledDiffuse;
  78827. private _renderId;
  78828. private _lastTime;
  78829. constructor(name: string, scene: BABYLON.Scene);
  78830. needAlphaBlending(): boolean;
  78831. needAlphaTesting(): boolean;
  78832. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78833. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78834. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78835. getAnimatables(): BABYLON.IAnimatable[];
  78836. getActiveTextures(): BABYLON.BaseTexture[];
  78837. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78838. getClassName(): string;
  78839. dispose(forceDisposeEffect?: boolean): void;
  78840. clone(name: string): FireMaterial;
  78841. serialize(): any;
  78842. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  78843. }
  78844. }
  78845. declare module BABYLON {
  78846. /** @hidden */
  78847. export var furPixelShader: {
  78848. name: string;
  78849. shader: string;
  78850. };
  78851. }
  78852. declare module BABYLON {
  78853. /** @hidden */
  78854. export var furVertexShader: {
  78855. name: string;
  78856. shader: string;
  78857. };
  78858. }
  78859. declare module BABYLON {
  78860. export class FurMaterial extends BABYLON.PushMaterial {
  78861. private _diffuseTexture;
  78862. diffuseTexture: BABYLON.BaseTexture;
  78863. private _heightTexture;
  78864. heightTexture: BABYLON.BaseTexture;
  78865. diffuseColor: BABYLON.Color3;
  78866. furLength: number;
  78867. furAngle: number;
  78868. furColor: BABYLON.Color3;
  78869. furOffset: number;
  78870. furSpacing: number;
  78871. furGravity: BABYLON.Vector3;
  78872. furSpeed: number;
  78873. furDensity: number;
  78874. furOcclusion: number;
  78875. furTexture: BABYLON.DynamicTexture;
  78876. private _disableLighting;
  78877. disableLighting: boolean;
  78878. private _maxSimultaneousLights;
  78879. maxSimultaneousLights: number;
  78880. highLevelFur: boolean;
  78881. _meshes: BABYLON.AbstractMesh[];
  78882. private _renderId;
  78883. private _furTime;
  78884. constructor(name: string, scene: BABYLON.Scene);
  78885. get furTime(): number;
  78886. set furTime(furTime: number);
  78887. needAlphaBlending(): boolean;
  78888. needAlphaTesting(): boolean;
  78889. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78890. updateFur(): void;
  78891. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78892. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78893. getAnimatables(): BABYLON.IAnimatable[];
  78894. getActiveTextures(): BABYLON.BaseTexture[];
  78895. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78896. dispose(forceDisposeEffect?: boolean): void;
  78897. clone(name: string): FurMaterial;
  78898. serialize(): any;
  78899. getClassName(): string;
  78900. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78901. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78902. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78903. }
  78904. }
  78905. declare module BABYLON {
  78906. /** @hidden */
  78907. export var gradientPixelShader: {
  78908. name: string;
  78909. shader: string;
  78910. };
  78911. }
  78912. declare module BABYLON {
  78913. /** @hidden */
  78914. export var gradientVertexShader: {
  78915. name: string;
  78916. shader: string;
  78917. };
  78918. }
  78919. declare module BABYLON {
  78920. export class GradientMaterial extends BABYLON.PushMaterial {
  78921. private _maxSimultaneousLights;
  78922. maxSimultaneousLights: number;
  78923. topColor: BABYLON.Color3;
  78924. topColorAlpha: number;
  78925. bottomColor: BABYLON.Color3;
  78926. bottomColorAlpha: number;
  78927. offset: number;
  78928. scale: number;
  78929. smoothness: number;
  78930. private _disableLighting;
  78931. disableLighting: boolean;
  78932. private _renderId;
  78933. constructor(name: string, scene: BABYLON.Scene);
  78934. needAlphaBlending(): boolean;
  78935. needAlphaTesting(): boolean;
  78936. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78937. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78938. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78939. getAnimatables(): BABYLON.IAnimatable[];
  78940. dispose(forceDisposeEffect?: boolean): void;
  78941. clone(name: string): GradientMaterial;
  78942. serialize(): any;
  78943. getClassName(): string;
  78944. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78945. }
  78946. }
  78947. declare module BABYLON {
  78948. /** @hidden */
  78949. export var gridPixelShader: {
  78950. name: string;
  78951. shader: string;
  78952. };
  78953. }
  78954. declare module BABYLON {
  78955. /** @hidden */
  78956. export var gridVertexShader: {
  78957. name: string;
  78958. shader: string;
  78959. };
  78960. }
  78961. declare module BABYLON {
  78962. /**
  78963. * The grid materials allows you to wrap any shape with a grid.
  78964. * Colors are customizable.
  78965. */
  78966. export class GridMaterial extends BABYLON.PushMaterial {
  78967. /**
  78968. * Main color of the grid (e.g. between lines)
  78969. */
  78970. mainColor: BABYLON.Color3;
  78971. /**
  78972. * Color of the grid lines.
  78973. */
  78974. lineColor: BABYLON.Color3;
  78975. /**
  78976. * The scale of the grid compared to unit.
  78977. */
  78978. gridRatio: number;
  78979. /**
  78980. * Allows setting an offset for the grid lines.
  78981. */
  78982. gridOffset: BABYLON.Vector3;
  78983. /**
  78984. * The frequency of thicker lines.
  78985. */
  78986. majorUnitFrequency: number;
  78987. /**
  78988. * The visibility of minor units in the grid.
  78989. */
  78990. minorUnitVisibility: number;
  78991. /**
  78992. * The grid opacity outside of the lines.
  78993. */
  78994. opacity: number;
  78995. /**
  78996. * Determine RBG output is premultiplied by alpha value.
  78997. */
  78998. preMultiplyAlpha: boolean;
  78999. private _opacityTexture;
  79000. opacityTexture: BABYLON.BaseTexture;
  79001. private _gridControl;
  79002. private _renderId;
  79003. /**
  79004. * constructor
  79005. * @param name The name given to the material in order to identify it afterwards.
  79006. * @param scene The scene the material is used in.
  79007. */
  79008. constructor(name: string, scene: BABYLON.Scene);
  79009. /**
  79010. * Returns wehter or not the grid requires alpha blending.
  79011. */
  79012. needAlphaBlending(): boolean;
  79013. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79014. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79015. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79016. /**
  79017. * Dispose the material and its associated resources.
  79018. * @param forceDisposeEffect will also dispose the used effect when true
  79019. */
  79020. dispose(forceDisposeEffect?: boolean): void;
  79021. clone(name: string): GridMaterial;
  79022. serialize(): any;
  79023. getClassName(): string;
  79024. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79025. }
  79026. }
  79027. declare module BABYLON {
  79028. /** @hidden */
  79029. export var lavaPixelShader: {
  79030. name: string;
  79031. shader: string;
  79032. };
  79033. }
  79034. declare module BABYLON {
  79035. /** @hidden */
  79036. export var lavaVertexShader: {
  79037. name: string;
  79038. shader: string;
  79039. };
  79040. }
  79041. declare module BABYLON {
  79042. export class LavaMaterial extends BABYLON.PushMaterial {
  79043. private _diffuseTexture;
  79044. diffuseTexture: BABYLON.BaseTexture;
  79045. noiseTexture: BABYLON.BaseTexture;
  79046. fogColor: BABYLON.Color3;
  79047. speed: number;
  79048. movingSpeed: number;
  79049. lowFrequencySpeed: number;
  79050. fogDensity: number;
  79051. private _lastTime;
  79052. diffuseColor: BABYLON.Color3;
  79053. private _disableLighting;
  79054. disableLighting: boolean;
  79055. private _unlit;
  79056. unlit: boolean;
  79057. private _maxSimultaneousLights;
  79058. maxSimultaneousLights: number;
  79059. private _scaledDiffuse;
  79060. private _renderId;
  79061. constructor(name: string, scene: BABYLON.Scene);
  79062. needAlphaBlending(): boolean;
  79063. needAlphaTesting(): boolean;
  79064. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79065. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79066. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79067. getAnimatables(): BABYLON.IAnimatable[];
  79068. getActiveTextures(): BABYLON.BaseTexture[];
  79069. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79070. dispose(forceDisposeEffect?: boolean): void;
  79071. clone(name: string): LavaMaterial;
  79072. serialize(): any;
  79073. getClassName(): string;
  79074. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79075. }
  79076. }
  79077. declare module BABYLON {
  79078. /** @hidden */
  79079. export var mixPixelShader: {
  79080. name: string;
  79081. shader: string;
  79082. };
  79083. }
  79084. declare module BABYLON {
  79085. /** @hidden */
  79086. export var mixVertexShader: {
  79087. name: string;
  79088. shader: string;
  79089. };
  79090. }
  79091. declare module BABYLON {
  79092. export class MixMaterial extends BABYLON.PushMaterial {
  79093. /**
  79094. * Mix textures
  79095. */
  79096. private _mixTexture1;
  79097. mixTexture1: BABYLON.BaseTexture;
  79098. private _mixTexture2;
  79099. mixTexture2: BABYLON.BaseTexture;
  79100. /**
  79101. * Diffuse textures
  79102. */
  79103. private _diffuseTexture1;
  79104. diffuseTexture1: BABYLON.Texture;
  79105. private _diffuseTexture2;
  79106. diffuseTexture2: BABYLON.Texture;
  79107. private _diffuseTexture3;
  79108. diffuseTexture3: BABYLON.Texture;
  79109. private _diffuseTexture4;
  79110. diffuseTexture4: BABYLON.Texture;
  79111. private _diffuseTexture5;
  79112. diffuseTexture5: BABYLON.Texture;
  79113. private _diffuseTexture6;
  79114. diffuseTexture6: BABYLON.Texture;
  79115. private _diffuseTexture7;
  79116. diffuseTexture7: BABYLON.Texture;
  79117. private _diffuseTexture8;
  79118. diffuseTexture8: BABYLON.Texture;
  79119. /**
  79120. * Uniforms
  79121. */
  79122. diffuseColor: BABYLON.Color3;
  79123. specularColor: BABYLON.Color3;
  79124. specularPower: number;
  79125. private _disableLighting;
  79126. disableLighting: boolean;
  79127. private _maxSimultaneousLights;
  79128. maxSimultaneousLights: number;
  79129. private _renderId;
  79130. constructor(name: string, scene: BABYLON.Scene);
  79131. needAlphaBlending(): boolean;
  79132. needAlphaTesting(): boolean;
  79133. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79134. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79135. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79136. getAnimatables(): BABYLON.IAnimatable[];
  79137. getActiveTextures(): BABYLON.BaseTexture[];
  79138. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79139. dispose(forceDisposeEffect?: boolean): void;
  79140. clone(name: string): MixMaterial;
  79141. serialize(): any;
  79142. getClassName(): string;
  79143. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  79144. }
  79145. }
  79146. declare module BABYLON {
  79147. /** @hidden */
  79148. export var normalPixelShader: {
  79149. name: string;
  79150. shader: string;
  79151. };
  79152. }
  79153. declare module BABYLON {
  79154. /** @hidden */
  79155. export var normalVertexShader: {
  79156. name: string;
  79157. shader: string;
  79158. };
  79159. }
  79160. declare module BABYLON {
  79161. export class NormalMaterial extends BABYLON.PushMaterial {
  79162. private _diffuseTexture;
  79163. diffuseTexture: BABYLON.BaseTexture;
  79164. diffuseColor: BABYLON.Color3;
  79165. private _disableLighting;
  79166. disableLighting: boolean;
  79167. private _maxSimultaneousLights;
  79168. maxSimultaneousLights: number;
  79169. private _renderId;
  79170. constructor(name: string, scene: BABYLON.Scene);
  79171. needAlphaBlending(): boolean;
  79172. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79173. needAlphaTesting(): boolean;
  79174. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79175. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79176. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79177. getAnimatables(): BABYLON.IAnimatable[];
  79178. getActiveTextures(): BABYLON.BaseTexture[];
  79179. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79180. dispose(forceDisposeEffect?: boolean): void;
  79181. clone(name: string): NormalMaterial;
  79182. serialize(): any;
  79183. getClassName(): string;
  79184. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79185. }
  79186. }
  79187. declare module BABYLON {
  79188. /** @hidden */
  79189. export var shadowOnlyPixelShader: {
  79190. name: string;
  79191. shader: string;
  79192. };
  79193. }
  79194. declare module BABYLON {
  79195. /** @hidden */
  79196. export var shadowOnlyVertexShader: {
  79197. name: string;
  79198. shader: string;
  79199. };
  79200. }
  79201. declare module BABYLON {
  79202. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79203. private _renderId;
  79204. private _activeLight;
  79205. constructor(name: string, scene: BABYLON.Scene);
  79206. shadowColor: BABYLON.Color3;
  79207. needAlphaBlending(): boolean;
  79208. needAlphaTesting(): boolean;
  79209. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79210. get activeLight(): BABYLON.IShadowLight;
  79211. set activeLight(light: BABYLON.IShadowLight);
  79212. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79213. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79214. clone(name: string): ShadowOnlyMaterial;
  79215. serialize(): any;
  79216. getClassName(): string;
  79217. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79218. }
  79219. }
  79220. declare module BABYLON {
  79221. /** @hidden */
  79222. export var simplePixelShader: {
  79223. name: string;
  79224. shader: string;
  79225. };
  79226. }
  79227. declare module BABYLON {
  79228. /** @hidden */
  79229. export var simpleVertexShader: {
  79230. name: string;
  79231. shader: string;
  79232. };
  79233. }
  79234. declare module BABYLON {
  79235. export class SimpleMaterial extends BABYLON.PushMaterial {
  79236. private _diffuseTexture;
  79237. diffuseTexture: BABYLON.BaseTexture;
  79238. diffuseColor: BABYLON.Color3;
  79239. private _disableLighting;
  79240. disableLighting: boolean;
  79241. private _maxSimultaneousLights;
  79242. maxSimultaneousLights: number;
  79243. private _renderId;
  79244. constructor(name: string, scene: BABYLON.Scene);
  79245. needAlphaBlending(): boolean;
  79246. needAlphaTesting(): boolean;
  79247. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79248. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79249. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79250. getAnimatables(): BABYLON.IAnimatable[];
  79251. getActiveTextures(): BABYLON.BaseTexture[];
  79252. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79253. dispose(forceDisposeEffect?: boolean): void;
  79254. clone(name: string): SimpleMaterial;
  79255. serialize(): any;
  79256. getClassName(): string;
  79257. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79258. }
  79259. }
  79260. declare module BABYLON {
  79261. /** @hidden */
  79262. export var skyPixelShader: {
  79263. name: string;
  79264. shader: string;
  79265. };
  79266. }
  79267. declare module BABYLON {
  79268. /** @hidden */
  79269. export var skyVertexShader: {
  79270. name: string;
  79271. shader: string;
  79272. };
  79273. }
  79274. declare module BABYLON {
  79275. /**
  79276. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79277. * @see https://doc.babylonjs.com/extensions/sky
  79278. */
  79279. export class SkyMaterial extends BABYLON.PushMaterial {
  79280. /**
  79281. * Defines the overall luminance of sky in interval ]0, 1[.
  79282. */
  79283. luminance: number;
  79284. /**
  79285. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79286. */
  79287. turbidity: number;
  79288. /**
  79289. * Defines the sky appearance (light intensity).
  79290. */
  79291. rayleigh: number;
  79292. /**
  79293. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79294. */
  79295. mieCoefficient: number;
  79296. /**
  79297. * Defines the amount of haze particles following the Mie scattering theory.
  79298. */
  79299. mieDirectionalG: number;
  79300. /**
  79301. * Defines the distance of the sun according to the active scene camera.
  79302. */
  79303. distance: number;
  79304. /**
  79305. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79306. * "inclined".
  79307. */
  79308. inclination: number;
  79309. /**
  79310. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79311. * an object direction and a reference direction.
  79312. */
  79313. azimuth: number;
  79314. /**
  79315. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79316. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79317. */
  79318. sunPosition: BABYLON.Vector3;
  79319. /**
  79320. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79321. * .sunPosition property.
  79322. */
  79323. useSunPosition: boolean;
  79324. /**
  79325. * Defines an offset vector used to get a horizon offset.
  79326. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79327. */
  79328. cameraOffset: BABYLON.Vector3;
  79329. private _cameraPosition;
  79330. private _renderId;
  79331. /**
  79332. * Instantiates a new sky material.
  79333. * This material allows to create dynamic and texture free
  79334. * effects for skyboxes by taking care of the atmosphere state.
  79335. * @see https://doc.babylonjs.com/extensions/sky
  79336. * @param name Define the name of the material in the scene
  79337. * @param scene Define the scene the material belong to
  79338. */
  79339. constructor(name: string, scene: BABYLON.Scene);
  79340. /**
  79341. * Specifies if the material will require alpha blending
  79342. * @returns a boolean specifying if alpha blending is needed
  79343. */
  79344. needAlphaBlending(): boolean;
  79345. /**
  79346. * Specifies if this material should be rendered in alpha test mode
  79347. * @returns false as the sky material doesn't need alpha testing.
  79348. */
  79349. needAlphaTesting(): boolean;
  79350. /**
  79351. * Get the texture used for alpha test purpose.
  79352. * @returns null as the sky material has no texture.
  79353. */
  79354. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79355. /**
  79356. * Get if the submesh is ready to be used and all its information available.
  79357. * Child classes can use it to update shaders
  79358. * @param mesh defines the mesh to check
  79359. * @param subMesh defines which submesh to check
  79360. * @param useInstances specifies that instances should be used
  79361. * @returns a boolean indicating that the submesh is ready or not
  79362. */
  79363. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79364. /**
  79365. * Binds the submesh to this material by preparing the effect and shader to draw
  79366. * @param world defines the world transformation matrix
  79367. * @param mesh defines the mesh containing the submesh
  79368. * @param subMesh defines the submesh to bind the material to
  79369. */
  79370. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79371. /**
  79372. * Get the list of animatables in the material.
  79373. * @returns the list of animatables object used in the material
  79374. */
  79375. getAnimatables(): BABYLON.IAnimatable[];
  79376. /**
  79377. * Disposes the material
  79378. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79379. */
  79380. dispose(forceDisposeEffect?: boolean): void;
  79381. /**
  79382. * Makes a duplicate of the material, and gives it a new name
  79383. * @param name defines the new name for the duplicated material
  79384. * @returns the cloned material
  79385. */
  79386. clone(name: string): SkyMaterial;
  79387. /**
  79388. * Serializes this material in a JSON representation
  79389. * @returns the serialized material object
  79390. */
  79391. serialize(): any;
  79392. /**
  79393. * Gets the current class name of the material e.g. "SkyMaterial"
  79394. * Mainly use in serialization.
  79395. * @returns the class name
  79396. */
  79397. getClassName(): string;
  79398. /**
  79399. * Creates a sky material from parsed material data
  79400. * @param source defines the JSON representation of the material
  79401. * @param scene defines the hosting scene
  79402. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79403. * @returns a new sky material
  79404. */
  79405. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  79406. }
  79407. }
  79408. declare module BABYLON {
  79409. /** @hidden */
  79410. export var terrainPixelShader: {
  79411. name: string;
  79412. shader: string;
  79413. };
  79414. }
  79415. declare module BABYLON {
  79416. /** @hidden */
  79417. export var terrainVertexShader: {
  79418. name: string;
  79419. shader: string;
  79420. };
  79421. }
  79422. declare module BABYLON {
  79423. export class TerrainMaterial extends BABYLON.PushMaterial {
  79424. private _mixTexture;
  79425. mixTexture: BABYLON.BaseTexture;
  79426. private _diffuseTexture1;
  79427. diffuseTexture1: BABYLON.Texture;
  79428. private _diffuseTexture2;
  79429. diffuseTexture2: BABYLON.Texture;
  79430. private _diffuseTexture3;
  79431. diffuseTexture3: BABYLON.Texture;
  79432. private _bumpTexture1;
  79433. bumpTexture1: BABYLON.Texture;
  79434. private _bumpTexture2;
  79435. bumpTexture2: BABYLON.Texture;
  79436. private _bumpTexture3;
  79437. bumpTexture3: BABYLON.Texture;
  79438. diffuseColor: BABYLON.Color3;
  79439. specularColor: BABYLON.Color3;
  79440. specularPower: number;
  79441. private _disableLighting;
  79442. disableLighting: boolean;
  79443. private _maxSimultaneousLights;
  79444. maxSimultaneousLights: number;
  79445. private _renderId;
  79446. constructor(name: string, scene: BABYLON.Scene);
  79447. needAlphaBlending(): boolean;
  79448. needAlphaTesting(): boolean;
  79449. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79450. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79451. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79452. getAnimatables(): BABYLON.IAnimatable[];
  79453. getActiveTextures(): BABYLON.BaseTexture[];
  79454. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79455. dispose(forceDisposeEffect?: boolean): void;
  79456. clone(name: string): TerrainMaterial;
  79457. serialize(): any;
  79458. getClassName(): string;
  79459. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  79460. }
  79461. }
  79462. declare module BABYLON {
  79463. /** @hidden */
  79464. export var triplanarPixelShader: {
  79465. name: string;
  79466. shader: string;
  79467. };
  79468. }
  79469. declare module BABYLON {
  79470. /** @hidden */
  79471. export var triplanarVertexShader: {
  79472. name: string;
  79473. shader: string;
  79474. };
  79475. }
  79476. declare module BABYLON {
  79477. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  79478. mixTexture: BABYLON.BaseTexture;
  79479. private _diffuseTextureX;
  79480. diffuseTextureX: BABYLON.BaseTexture;
  79481. private _diffuseTextureY;
  79482. diffuseTextureY: BABYLON.BaseTexture;
  79483. private _diffuseTextureZ;
  79484. diffuseTextureZ: BABYLON.BaseTexture;
  79485. private _normalTextureX;
  79486. normalTextureX: BABYLON.BaseTexture;
  79487. private _normalTextureY;
  79488. normalTextureY: BABYLON.BaseTexture;
  79489. private _normalTextureZ;
  79490. normalTextureZ: BABYLON.BaseTexture;
  79491. tileSize: number;
  79492. diffuseColor: BABYLON.Color3;
  79493. specularColor: BABYLON.Color3;
  79494. specularPower: number;
  79495. private _disableLighting;
  79496. disableLighting: boolean;
  79497. private _maxSimultaneousLights;
  79498. maxSimultaneousLights: number;
  79499. private _renderId;
  79500. constructor(name: string, scene: BABYLON.Scene);
  79501. needAlphaBlending(): boolean;
  79502. needAlphaTesting(): boolean;
  79503. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79504. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79505. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79506. getAnimatables(): BABYLON.IAnimatable[];
  79507. getActiveTextures(): BABYLON.BaseTexture[];
  79508. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79509. dispose(forceDisposeEffect?: boolean): void;
  79510. clone(name: string): TriPlanarMaterial;
  79511. serialize(): any;
  79512. getClassName(): string;
  79513. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  79514. }
  79515. }
  79516. declare module BABYLON {
  79517. /** @hidden */
  79518. export var waterPixelShader: {
  79519. name: string;
  79520. shader: string;
  79521. };
  79522. }
  79523. declare module BABYLON {
  79524. /** @hidden */
  79525. export var waterVertexShader: {
  79526. name: string;
  79527. shader: string;
  79528. };
  79529. }
  79530. declare module BABYLON {
  79531. export class WaterMaterial extends BABYLON.PushMaterial {
  79532. renderTargetSize: BABYLON.Vector2;
  79533. private _bumpTexture;
  79534. bumpTexture: BABYLON.BaseTexture;
  79535. diffuseColor: BABYLON.Color3;
  79536. specularColor: BABYLON.Color3;
  79537. specularPower: number;
  79538. private _disableLighting;
  79539. disableLighting: boolean;
  79540. private _maxSimultaneousLights;
  79541. maxSimultaneousLights: number;
  79542. /**
  79543. * @param {number}: Represents the wind force
  79544. */
  79545. windForce: number;
  79546. /**
  79547. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79548. */
  79549. windDirection: BABYLON.Vector2;
  79550. /**
  79551. * @param {number}: Wave height, represents the height of the waves
  79552. */
  79553. waveHeight: number;
  79554. /**
  79555. * @param {number}: Bump height, represents the bump height related to the bump map
  79556. */
  79557. bumpHeight: number;
  79558. /**
  79559. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79560. */
  79561. private _bumpSuperimpose;
  79562. bumpSuperimpose: boolean;
  79563. /**
  79564. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79565. */
  79566. private _fresnelSeparate;
  79567. fresnelSeparate: boolean;
  79568. /**
  79569. * @param {boolean}: bump Waves modify the reflection.
  79570. */
  79571. private _bumpAffectsReflection;
  79572. bumpAffectsReflection: boolean;
  79573. /**
  79574. * @param {number}: The water color blended with the refraction (near)
  79575. */
  79576. waterColor: BABYLON.Color3;
  79577. /**
  79578. * @param {number}: The blend factor related to the water color
  79579. */
  79580. colorBlendFactor: number;
  79581. /**
  79582. * @param {number}: The water color blended with the reflection (far)
  79583. */
  79584. waterColor2: BABYLON.Color3;
  79585. /**
  79586. * @param {number}: The blend factor related to the water color (reflection, far)
  79587. */
  79588. colorBlendFactor2: number;
  79589. /**
  79590. * @param {number}: Represents the maximum length of a wave
  79591. */
  79592. waveLength: number;
  79593. /**
  79594. * @param {number}: Defines the waves speed
  79595. */
  79596. waveSpeed: number;
  79597. /**
  79598. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79599. * will avoid calculating useless pixels in the pixel shader of the water material.
  79600. */
  79601. disableClipPlane: boolean;
  79602. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  79603. private _mesh;
  79604. private _refractionRTT;
  79605. private _reflectionRTT;
  79606. private _reflectionTransform;
  79607. private _lastTime;
  79608. private _lastDeltaTime;
  79609. private _renderId;
  79610. private _useLogarithmicDepth;
  79611. private _waitingRenderList;
  79612. private _imageProcessingConfiguration;
  79613. private _imageProcessingObserver;
  79614. /**
  79615. * Gets a boolean indicating that current material needs to register RTT
  79616. */
  79617. get hasRenderTargetTextures(): boolean;
  79618. /**
  79619. * Constructor
  79620. */
  79621. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  79622. get useLogarithmicDepth(): boolean;
  79623. set useLogarithmicDepth(value: boolean);
  79624. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79625. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79626. addToRenderList(node: any): void;
  79627. enableRenderTargets(enable: boolean): void;
  79628. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  79629. get renderTargetsEnabled(): boolean;
  79630. needAlphaBlending(): boolean;
  79631. needAlphaTesting(): boolean;
  79632. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79633. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79634. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79635. private _createRenderTargets;
  79636. getAnimatables(): BABYLON.IAnimatable[];
  79637. getActiveTextures(): BABYLON.BaseTexture[];
  79638. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79639. dispose(forceDisposeEffect?: boolean): void;
  79640. clone(name: string): WaterMaterial;
  79641. serialize(): any;
  79642. getClassName(): string;
  79643. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  79644. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  79645. }
  79646. }
  79647. declare module BABYLON {
  79648. /** @hidden */
  79649. export var asciiartPixelShader: {
  79650. name: string;
  79651. shader: string;
  79652. };
  79653. }
  79654. declare module BABYLON {
  79655. /**
  79656. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  79657. *
  79658. * It basically takes care rendering the font front the given font size to a texture.
  79659. * This is used later on in the postprocess.
  79660. */
  79661. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  79662. private _font;
  79663. private _text;
  79664. private _charSize;
  79665. /**
  79666. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79667. */
  79668. get charSize(): number;
  79669. /**
  79670. * Create a new instance of the Ascii Art FontTexture class
  79671. * @param name the name of the texture
  79672. * @param font the font to use, use the W3C CSS notation
  79673. * @param text the caracter set to use in the rendering.
  79674. * @param scene the scene that owns the texture
  79675. */
  79676. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79677. /**
  79678. * Gets the max char width of a font.
  79679. * @param font the font to use, use the W3C CSS notation
  79680. * @return the max char width
  79681. */
  79682. private getFontWidth;
  79683. /**
  79684. * Gets the max char height of a font.
  79685. * @param font the font to use, use the W3C CSS notation
  79686. * @return the max char height
  79687. */
  79688. private getFontHeight;
  79689. /**
  79690. * Clones the current AsciiArtTexture.
  79691. * @return the clone of the texture.
  79692. */
  79693. clone(): AsciiArtFontTexture;
  79694. /**
  79695. * Parses a json object representing the texture and returns an instance of it.
  79696. * @param source the source JSON representation
  79697. * @param scene the scene to create the texture for
  79698. * @return the parsed texture
  79699. */
  79700. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  79701. }
  79702. /**
  79703. * Option available in the Ascii Art Post Process.
  79704. */
  79705. export interface IAsciiArtPostProcessOptions {
  79706. /**
  79707. * The font to use following the w3c font definition.
  79708. */
  79709. font?: string;
  79710. /**
  79711. * The character set to use in the postprocess.
  79712. */
  79713. characterSet?: string;
  79714. /**
  79715. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79716. * This number is defined between 0 and 1;
  79717. */
  79718. mixToTile?: number;
  79719. /**
  79720. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79721. * This number is defined between 0 and 1;
  79722. */
  79723. mixToNormal?: number;
  79724. }
  79725. /**
  79726. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  79727. *
  79728. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79729. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  79730. */
  79731. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  79732. /**
  79733. * The font texture used to render the char in the post process.
  79734. */
  79735. private _asciiArtFontTexture;
  79736. /**
  79737. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79738. * This number is defined between 0 and 1;
  79739. */
  79740. mixToTile: number;
  79741. /**
  79742. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79743. * This number is defined between 0 and 1;
  79744. */
  79745. mixToNormal: number;
  79746. /**
  79747. * Instantiates a new Ascii Art Post Process.
  79748. * @param name the name to give to the postprocess
  79749. * @camera the camera to apply the post process to.
  79750. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  79751. */
  79752. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  79753. }
  79754. }
  79755. declare module BABYLON {
  79756. /** @hidden */
  79757. export var digitalrainPixelShader: {
  79758. name: string;
  79759. shader: string;
  79760. };
  79761. }
  79762. declare module BABYLON {
  79763. /**
  79764. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  79765. *
  79766. * It basically takes care rendering the font front the given font size to a texture.
  79767. * This is used later on in the postprocess.
  79768. */
  79769. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  79770. private _font;
  79771. private _text;
  79772. private _charSize;
  79773. /**
  79774. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79775. */
  79776. get charSize(): number;
  79777. /**
  79778. * Create a new instance of the Digital Rain FontTexture class
  79779. * @param name the name of the texture
  79780. * @param font the font to use, use the W3C CSS notation
  79781. * @param text the caracter set to use in the rendering.
  79782. * @param scene the scene that owns the texture
  79783. */
  79784. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79785. /**
  79786. * Gets the max char width of a font.
  79787. * @param font the font to use, use the W3C CSS notation
  79788. * @return the max char width
  79789. */
  79790. private getFontWidth;
  79791. /**
  79792. * Gets the max char height of a font.
  79793. * @param font the font to use, use the W3C CSS notation
  79794. * @return the max char height
  79795. */
  79796. private getFontHeight;
  79797. /**
  79798. * Clones the current DigitalRainFontTexture.
  79799. * @return the clone of the texture.
  79800. */
  79801. clone(): DigitalRainFontTexture;
  79802. /**
  79803. * Parses a json object representing the texture and returns an instance of it.
  79804. * @param source the source JSON representation
  79805. * @param scene the scene to create the texture for
  79806. * @return the parsed texture
  79807. */
  79808. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  79809. }
  79810. /**
  79811. * Option available in the Digital Rain Post Process.
  79812. */
  79813. export interface IDigitalRainPostProcessOptions {
  79814. /**
  79815. * The font to use following the w3c font definition.
  79816. */
  79817. font?: string;
  79818. /**
  79819. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79820. * This number is defined between 0 and 1;
  79821. */
  79822. mixToTile?: number;
  79823. /**
  79824. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79825. * This number is defined between 0 and 1;
  79826. */
  79827. mixToNormal?: number;
  79828. }
  79829. /**
  79830. * DigitalRainPostProcess helps rendering everithing in digital rain.
  79831. *
  79832. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79833. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  79834. */
  79835. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  79836. /**
  79837. * The font texture used to render the char in the post process.
  79838. */
  79839. private _digitalRainFontTexture;
  79840. /**
  79841. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79842. * This number is defined between 0 and 1;
  79843. */
  79844. mixToTile: number;
  79845. /**
  79846. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79847. * This number is defined between 0 and 1;
  79848. */
  79849. mixToNormal: number;
  79850. /**
  79851. * Instantiates a new Digital Rain Post Process.
  79852. * @param name the name to give to the postprocess
  79853. * @camera the camera to apply the post process to.
  79854. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  79855. */
  79856. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  79857. }
  79858. }
  79859. declare module BABYLON {
  79860. /** @hidden */
  79861. export var brickProceduralTexturePixelShader: {
  79862. name: string;
  79863. shader: string;
  79864. };
  79865. }
  79866. declare module BABYLON {
  79867. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  79868. private _numberOfBricksHeight;
  79869. private _numberOfBricksWidth;
  79870. private _jointColor;
  79871. private _brickColor;
  79872. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79873. updateShaderUniforms(): void;
  79874. get numberOfBricksHeight(): number;
  79875. set numberOfBricksHeight(value: number);
  79876. get numberOfBricksWidth(): number;
  79877. set numberOfBricksWidth(value: number);
  79878. get jointColor(): BABYLON.Color3;
  79879. set jointColor(value: BABYLON.Color3);
  79880. get brickColor(): BABYLON.Color3;
  79881. set brickColor(value: BABYLON.Color3);
  79882. /**
  79883. * Serializes this brick procedural texture
  79884. * @returns a serialized brick procedural texture object
  79885. */
  79886. serialize(): any;
  79887. /**
  79888. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79889. * @param parsedTexture defines parsed texture data
  79890. * @param scene defines the current scene
  79891. * @param rootUrl defines the root URL containing brick procedural texture information
  79892. * @returns a parsed Brick Procedural BABYLON.Texture
  79893. */
  79894. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79895. }
  79896. }
  79897. declare module BABYLON {
  79898. /** @hidden */
  79899. export var cloudProceduralTexturePixelShader: {
  79900. name: string;
  79901. shader: string;
  79902. };
  79903. }
  79904. declare module BABYLON {
  79905. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79906. private _skyColor;
  79907. private _cloudColor;
  79908. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79909. updateShaderUniforms(): void;
  79910. get skyColor(): BABYLON.Color4;
  79911. set skyColor(value: BABYLON.Color4);
  79912. get cloudColor(): BABYLON.Color4;
  79913. set cloudColor(value: BABYLON.Color4);
  79914. /**
  79915. * Serializes this cloud procedural texture
  79916. * @returns a serialized cloud procedural texture object
  79917. */
  79918. serialize(): any;
  79919. /**
  79920. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79921. * @param parsedTexture defines parsed texture data
  79922. * @param scene defines the current scene
  79923. * @param rootUrl defines the root URL containing cloud procedural texture information
  79924. * @returns a parsed Cloud Procedural BABYLON.Texture
  79925. */
  79926. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79927. }
  79928. }
  79929. declare module BABYLON {
  79930. /** @hidden */
  79931. export var fireProceduralTexturePixelShader: {
  79932. name: string;
  79933. shader: string;
  79934. };
  79935. }
  79936. declare module BABYLON {
  79937. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79938. private _time;
  79939. private _speed;
  79940. private _autoGenerateTime;
  79941. private _fireColors;
  79942. private _alphaThreshold;
  79943. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79944. updateShaderUniforms(): void;
  79945. render(useCameraPostProcess?: boolean): void;
  79946. static get PurpleFireColors(): BABYLON.Color3[];
  79947. static get GreenFireColors(): BABYLON.Color3[];
  79948. static get RedFireColors(): BABYLON.Color3[];
  79949. static get BlueFireColors(): BABYLON.Color3[];
  79950. get autoGenerateTime(): boolean;
  79951. set autoGenerateTime(value: boolean);
  79952. get fireColors(): BABYLON.Color3[];
  79953. set fireColors(value: BABYLON.Color3[]);
  79954. get time(): number;
  79955. set time(value: number);
  79956. get speed(): BABYLON.Vector2;
  79957. set speed(value: BABYLON.Vector2);
  79958. get alphaThreshold(): number;
  79959. set alphaThreshold(value: number);
  79960. /**
  79961. * Serializes this fire procedural texture
  79962. * @returns a serialized fire procedural texture object
  79963. */
  79964. serialize(): any;
  79965. /**
  79966. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79967. * @param parsedTexture defines parsed texture data
  79968. * @param scene defines the current scene
  79969. * @param rootUrl defines the root URL containing fire procedural texture information
  79970. * @returns a parsed Fire Procedural BABYLON.Texture
  79971. */
  79972. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79973. }
  79974. }
  79975. declare module BABYLON {
  79976. /** @hidden */
  79977. export var grassProceduralTexturePixelShader: {
  79978. name: string;
  79979. shader: string;
  79980. };
  79981. }
  79982. declare module BABYLON {
  79983. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79984. private _grassColors;
  79985. private _groundColor;
  79986. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79987. updateShaderUniforms(): void;
  79988. get grassColors(): BABYLON.Color3[];
  79989. set grassColors(value: BABYLON.Color3[]);
  79990. get groundColor(): BABYLON.Color3;
  79991. set groundColor(value: BABYLON.Color3);
  79992. /**
  79993. * Serializes this grass procedural texture
  79994. * @returns a serialized grass procedural texture object
  79995. */
  79996. serialize(): any;
  79997. /**
  79998. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79999. * @param parsedTexture defines parsed texture data
  80000. * @param scene defines the current scene
  80001. * @param rootUrl defines the root URL containing grass procedural texture information
  80002. * @returns a parsed Grass Procedural BABYLON.Texture
  80003. */
  80004. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80005. }
  80006. }
  80007. declare module BABYLON {
  80008. /** @hidden */
  80009. export var marbleProceduralTexturePixelShader: {
  80010. name: string;
  80011. shader: string;
  80012. };
  80013. }
  80014. declare module BABYLON {
  80015. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80016. private _numberOfTilesHeight;
  80017. private _numberOfTilesWidth;
  80018. private _amplitude;
  80019. private _jointColor;
  80020. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80021. updateShaderUniforms(): void;
  80022. get numberOfTilesHeight(): number;
  80023. set numberOfTilesHeight(value: number);
  80024. get amplitude(): number;
  80025. set amplitude(value: number);
  80026. get numberOfTilesWidth(): number;
  80027. set numberOfTilesWidth(value: number);
  80028. get jointColor(): BABYLON.Color3;
  80029. set jointColor(value: BABYLON.Color3);
  80030. /**
  80031. * Serializes this marble procedural texture
  80032. * @returns a serialized marble procedural texture object
  80033. */
  80034. serialize(): any;
  80035. /**
  80036. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80037. * @param parsedTexture defines parsed texture data
  80038. * @param scene defines the current scene
  80039. * @param rootUrl defines the root URL containing marble procedural texture information
  80040. * @returns a parsed Marble Procedural BABYLON.Texture
  80041. */
  80042. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80043. }
  80044. }
  80045. declare module BABYLON {
  80046. /** @hidden */
  80047. export var normalMapProceduralTexturePixelShader: {
  80048. name: string;
  80049. shader: string;
  80050. };
  80051. }
  80052. declare module BABYLON {
  80053. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80054. private _baseTexture;
  80055. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80056. updateShaderUniforms(): void;
  80057. render(useCameraPostProcess?: boolean): void;
  80058. resize(size: any, generateMipMaps: any): void;
  80059. get baseTexture(): BABYLON.Texture;
  80060. set baseTexture(texture: BABYLON.Texture);
  80061. /**
  80062. * Serializes this normal map procedural texture
  80063. * @returns a serialized normal map procedural texture object
  80064. */
  80065. serialize(): any;
  80066. /**
  80067. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80068. * @param parsedTexture defines parsed texture data
  80069. * @param scene defines the current scene
  80070. * @param rootUrl defines the root URL containing normal map procedural texture information
  80071. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80072. */
  80073. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80074. }
  80075. }
  80076. declare module BABYLON {
  80077. /** @hidden */
  80078. export var perlinNoiseProceduralTexturePixelShader: {
  80079. name: string;
  80080. shader: string;
  80081. };
  80082. }
  80083. declare module BABYLON {
  80084. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  80085. time: number;
  80086. timeScale: number;
  80087. translationSpeed: number;
  80088. private _currentTranslation;
  80089. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80090. updateShaderUniforms(): void;
  80091. render(useCameraPostProcess?: boolean): void;
  80092. resize(size: any, generateMipMaps: any): void;
  80093. /**
  80094. * Serializes this perlin noise procedural texture
  80095. * @returns a serialized perlin noise procedural texture object
  80096. */
  80097. serialize(): any;
  80098. /**
  80099. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  80100. * @param parsedTexture defines parsed texture data
  80101. * @param scene defines the current scene
  80102. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  80103. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  80104. */
  80105. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  80106. }
  80107. }
  80108. declare module BABYLON {
  80109. /** @hidden */
  80110. export var roadProceduralTexturePixelShader: {
  80111. name: string;
  80112. shader: string;
  80113. };
  80114. }
  80115. declare module BABYLON {
  80116. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  80117. private _roadColor;
  80118. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80119. updateShaderUniforms(): void;
  80120. get roadColor(): BABYLON.Color3;
  80121. set roadColor(value: BABYLON.Color3);
  80122. /**
  80123. * Serializes this road procedural texture
  80124. * @returns a serialized road procedural texture object
  80125. */
  80126. serialize(): any;
  80127. /**
  80128. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  80129. * @param parsedTexture defines parsed texture data
  80130. * @param scene defines the current scene
  80131. * @param rootUrl defines the root URL containing road procedural texture information
  80132. * @returns a parsed Road Procedural BABYLON.Texture
  80133. */
  80134. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  80135. }
  80136. }
  80137. declare module BABYLON {
  80138. /** @hidden */
  80139. export var starfieldProceduralTexturePixelShader: {
  80140. name: string;
  80141. shader: string;
  80142. };
  80143. }
  80144. declare module BABYLON {
  80145. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  80146. private _time;
  80147. private _alpha;
  80148. private _beta;
  80149. private _zoom;
  80150. private _formuparam;
  80151. private _stepsize;
  80152. private _tile;
  80153. private _brightness;
  80154. private _darkmatter;
  80155. private _distfading;
  80156. private _saturation;
  80157. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80158. updateShaderUniforms(): void;
  80159. get time(): number;
  80160. set time(value: number);
  80161. get alpha(): number;
  80162. set alpha(value: number);
  80163. get beta(): number;
  80164. set beta(value: number);
  80165. get formuparam(): number;
  80166. set formuparam(value: number);
  80167. get stepsize(): number;
  80168. set stepsize(value: number);
  80169. get zoom(): number;
  80170. set zoom(value: number);
  80171. get tile(): number;
  80172. set tile(value: number);
  80173. get brightness(): number;
  80174. set brightness(value: number);
  80175. get darkmatter(): number;
  80176. set darkmatter(value: number);
  80177. get distfading(): number;
  80178. set distfading(value: number);
  80179. get saturation(): number;
  80180. set saturation(value: number);
  80181. /**
  80182. * Serializes this starfield procedural texture
  80183. * @returns a serialized starfield procedural texture object
  80184. */
  80185. serialize(): any;
  80186. /**
  80187. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80188. * @param parsedTexture defines parsed texture data
  80189. * @param scene defines the current scene
  80190. * @param rootUrl defines the root URL containing startfield procedural texture information
  80191. * @returns a parsed Starfield Procedural BABYLON.Texture
  80192. */
  80193. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80194. }
  80195. }
  80196. declare module BABYLON {
  80197. /** @hidden */
  80198. export var woodProceduralTexturePixelShader: {
  80199. name: string;
  80200. shader: string;
  80201. };
  80202. }
  80203. declare module BABYLON {
  80204. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80205. private _ampScale;
  80206. private _woodColor;
  80207. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80208. updateShaderUniforms(): void;
  80209. get ampScale(): number;
  80210. set ampScale(value: number);
  80211. get woodColor(): BABYLON.Color3;
  80212. set woodColor(value: BABYLON.Color3);
  80213. /**
  80214. * Serializes this wood procedural texture
  80215. * @returns a serialized wood procedural texture object
  80216. */
  80217. serialize(): any;
  80218. /**
  80219. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80220. * @param parsedTexture defines parsed texture data
  80221. * @param scene defines the current scene
  80222. * @param rootUrl defines the root URL containing wood procedural texture information
  80223. * @returns a parsed Wood Procedural BABYLON.Texture
  80224. */
  80225. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80226. }
  80227. }