documentation.d.ts 3.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. /**
  408. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  409. * @param num the number to convert and pad
  410. * @param length the expected length of the string
  411. * @returns the padded string
  412. */
  413. static PadNumber(num: number, length: number): string;
  414. }
  415. }
  416. declare module BABYLON {
  417. /**
  418. * Class containing a set of static utilities functions for deep copy.
  419. */
  420. export class DeepCopier {
  421. /**
  422. * Tries to copy an object by duplicating every property
  423. * @param source defines the source object
  424. * @param destination defines the target object
  425. * @param doNotCopyList defines a list of properties to avoid
  426. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  427. */
  428. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  429. }
  430. }
  431. declare module BABYLON {
  432. /**
  433. * Class containing a set of static utilities functions for precision date
  434. */
  435. export class PrecisionDate {
  436. /**
  437. * Gets either window.performance.now() if supported or Date.now() else
  438. */
  439. static get Now(): number;
  440. }
  441. }
  442. declare module BABYLON {
  443. /** @hidden */
  444. export class _DevTools {
  445. static WarnImport(name: string): string;
  446. }
  447. }
  448. declare module BABYLON {
  449. /**
  450. * Interface used to define the mechanism to get data from the network
  451. */
  452. export interface IWebRequest {
  453. /**
  454. * Returns client's response url
  455. */
  456. responseURL: string;
  457. /**
  458. * Returns client's status
  459. */
  460. status: number;
  461. /**
  462. * Returns client's status as a text
  463. */
  464. statusText: string;
  465. }
  466. }
  467. declare module BABYLON {
  468. /**
  469. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  470. */
  471. export class WebRequest implements IWebRequest {
  472. private _xhr;
  473. /**
  474. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  475. * i.e. when loading files, where the server/service expects an Authorization header
  476. */
  477. static CustomRequestHeaders: {
  478. [key: string]: string;
  479. };
  480. /**
  481. * Add callback functions in this array to update all the requests before they get sent to the network
  482. */
  483. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  484. private _injectCustomRequestHeaders;
  485. /**
  486. * Gets or sets a function to be called when loading progress changes
  487. */
  488. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  489. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  490. /**
  491. * Returns client's state
  492. */
  493. get readyState(): number;
  494. /**
  495. * Returns client's status
  496. */
  497. get status(): number;
  498. /**
  499. * Returns client's status as a text
  500. */
  501. get statusText(): string;
  502. /**
  503. * Returns client's response
  504. */
  505. get response(): any;
  506. /**
  507. * Returns client's response url
  508. */
  509. get responseURL(): string;
  510. /**
  511. * Returns client's response as text
  512. */
  513. get responseText(): string;
  514. /**
  515. * Gets or sets the expected response type
  516. */
  517. get responseType(): XMLHttpRequestResponseType;
  518. set responseType(value: XMLHttpRequestResponseType);
  519. /** @hidden */
  520. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  521. /** @hidden */
  522. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  523. /**
  524. * Cancels any network activity
  525. */
  526. abort(): void;
  527. /**
  528. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  529. * @param body defines an optional request body
  530. */
  531. send(body?: Document | BodyInit | null): void;
  532. /**
  533. * Sets the request method, request URL
  534. * @param method defines the method to use (GET, POST, etc..)
  535. * @param url defines the url to connect with
  536. */
  537. open(method: string, url: string): void;
  538. /**
  539. * Sets the value of a request header.
  540. * @param name The name of the header whose value is to be set
  541. * @param value The value to set as the body of the header
  542. */
  543. setRequestHeader(name: string, value: string): void;
  544. /**
  545. * Get the string containing the text of a particular header's value.
  546. * @param name The name of the header
  547. * @returns The string containing the text of the given header name
  548. */
  549. getResponseHeader(name: string): Nullable<string>;
  550. }
  551. }
  552. declare module BABYLON {
  553. /**
  554. * File request interface
  555. */
  556. export interface IFileRequest {
  557. /**
  558. * Raised when the request is complete (success or error).
  559. */
  560. onCompleteObservable: Observable<IFileRequest>;
  561. /**
  562. * Aborts the request for a file.
  563. */
  564. abort: () => void;
  565. }
  566. }
  567. declare module BABYLON {
  568. /**
  569. * Define options used to create a render target texture
  570. */
  571. export class RenderTargetCreationOptions {
  572. /**
  573. * Specifies is mipmaps must be generated
  574. */
  575. generateMipMaps?: boolean;
  576. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  577. generateDepthBuffer?: boolean;
  578. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  579. generateStencilBuffer?: boolean;
  580. /** Defines texture type (int by default) */
  581. type?: number;
  582. /** Defines sampling mode (trilinear by default) */
  583. samplingMode?: number;
  584. /** Defines format (RGBA by default) */
  585. format?: number;
  586. }
  587. }
  588. declare module BABYLON {
  589. /** Defines the cross module used constants to avoid circular dependncies */
  590. export class Constants {
  591. /** Defines that alpha blending is disabled */
  592. static readonly ALPHA_DISABLE: number;
  593. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  594. static readonly ALPHA_ADD: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  596. static readonly ALPHA_COMBINE: number;
  597. /** Defines that alpha blending is DEST - SRC * DEST */
  598. static readonly ALPHA_SUBTRACT: number;
  599. /** Defines that alpha blending is SRC * DEST */
  600. static readonly ALPHA_MULTIPLY: number;
  601. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  602. static readonly ALPHA_MAXIMIZED: number;
  603. /** Defines that alpha blending is SRC + DEST */
  604. static readonly ALPHA_ONEONE: number;
  605. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  606. static readonly ALPHA_PREMULTIPLIED: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  609. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  612. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  613. static readonly ALPHA_INTERPOLATE: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  616. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_SCREENMODE: number;
  619. /**
  620. * Defines that alpha blending is SRC + DST
  621. * Alpha will be set to SRC ALPHA + DST ALPHA
  622. */
  623. static readonly ALPHA_ONEONE_ONEONE: number;
  624. /**
  625. * Defines that alpha blending is SRC * DST ALPHA + DST
  626. * Alpha will be set to 0
  627. */
  628. static readonly ALPHA_ALPHATOCOLOR: number;
  629. /**
  630. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  631. */
  632. static readonly ALPHA_REVERSEONEMINUS: number;
  633. /**
  634. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  635. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  636. */
  637. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST
  640. * Alpha will be set to SRC ALPHA
  641. */
  642. static readonly ALPHA_ONEONE_ONEZERO: number;
  643. /**
  644. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  645. * Alpha will be set to DST ALPHA
  646. */
  647. static readonly ALPHA_EXCLUSION: number;
  648. /** Defines that alpha blending equation a SUM */
  649. static readonly ALPHA_EQUATION_ADD: number;
  650. /** Defines that alpha blending equation a SUBSTRACTION */
  651. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  652. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  654. /** Defines that alpha blending equation a MAX operation */
  655. static readonly ALPHA_EQUATION_MAX: number;
  656. /** Defines that alpha blending equation a MIN operation */
  657. static readonly ALPHA_EQUATION_MIN: number;
  658. /**
  659. * Defines that alpha blending equation a DARKEN operation:
  660. * It takes the min of the src and sums the alpha channels.
  661. */
  662. static readonly ALPHA_EQUATION_DARKEN: number;
  663. /** Defines that the ressource is not delayed*/
  664. static readonly DELAYLOADSTATE_NONE: number;
  665. /** Defines that the ressource was successfully delay loaded */
  666. static readonly DELAYLOADSTATE_LOADED: number;
  667. /** Defines that the ressource is currently delay loading */
  668. static readonly DELAYLOADSTATE_LOADING: number;
  669. /** Defines that the ressource is delayed and has not started loading */
  670. static readonly DELAYLOADSTATE_NOTLOADED: number;
  671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  672. static readonly NEVER: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  674. static readonly ALWAYS: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  676. static readonly LESS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  678. static readonly EQUAL: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  680. static readonly LEQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  682. static readonly GREATER: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  684. static readonly GEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  686. static readonly NOTEQUAL: number;
  687. /** Passed to stencilOperation to specify that stencil value must be kept */
  688. static readonly KEEP: number;
  689. /** Passed to stencilOperation to specify that stencil value must be replaced */
  690. static readonly REPLACE: number;
  691. /** Passed to stencilOperation to specify that stencil value must be incremented */
  692. static readonly INCR: number;
  693. /** Passed to stencilOperation to specify that stencil value must be decremented */
  694. static readonly DECR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be inverted */
  696. static readonly INVERT: number;
  697. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  698. static readonly INCR_WRAP: number;
  699. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  700. static readonly DECR_WRAP: number;
  701. /** Texture is not repeating outside of 0..1 UVs */
  702. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  703. /** Texture is repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  705. /** Texture is repeating and mirrored */
  706. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  707. /** ALPHA */
  708. static readonly TEXTUREFORMAT_ALPHA: number;
  709. /** LUMINANCE */
  710. static readonly TEXTUREFORMAT_LUMINANCE: number;
  711. /** LUMINANCE_ALPHA */
  712. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  713. /** RGB */
  714. static readonly TEXTUREFORMAT_RGB: number;
  715. /** RGBA */
  716. static readonly TEXTUREFORMAT_RGBA: number;
  717. /** RED */
  718. static readonly TEXTUREFORMAT_RED: number;
  719. /** RED (2nd reference) */
  720. static readonly TEXTUREFORMAT_R: number;
  721. /** RG */
  722. static readonly TEXTUREFORMAT_RG: number;
  723. /** RED_INTEGER */
  724. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  725. /** RED_INTEGER (2nd reference) */
  726. static readonly TEXTUREFORMAT_R_INTEGER: number;
  727. /** RG_INTEGER */
  728. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  729. /** RGB_INTEGER */
  730. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  731. /** RGBA_INTEGER */
  732. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  733. /** UNSIGNED_BYTE */
  734. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  735. /** UNSIGNED_BYTE (2nd reference) */
  736. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  737. /** FLOAT */
  738. static readonly TEXTURETYPE_FLOAT: number;
  739. /** HALF_FLOAT */
  740. static readonly TEXTURETYPE_HALF_FLOAT: number;
  741. /** BYTE */
  742. static readonly TEXTURETYPE_BYTE: number;
  743. /** SHORT */
  744. static readonly TEXTURETYPE_SHORT: number;
  745. /** UNSIGNED_SHORT */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  747. /** INT */
  748. static readonly TEXTURETYPE_INT: number;
  749. /** UNSIGNED_INT */
  750. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  751. /** UNSIGNED_SHORT_4_4_4_4 */
  752. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  753. /** UNSIGNED_SHORT_5_5_5_1 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  755. /** UNSIGNED_SHORT_5_6_5 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  757. /** UNSIGNED_INT_2_10_10_10_REV */
  758. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  759. /** UNSIGNED_INT_24_8 */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  761. /** UNSIGNED_INT_10F_11F_11F_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  763. /** UNSIGNED_INT_5_9_9_9_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  765. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  766. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  767. /** nearest is mag = nearest and min = nearest and no mip */
  768. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  769. /** mag = nearest and min = nearest and mip = none */
  770. static readonly TEXTURE_NEAREST_NEAREST: number;
  771. /** Bilinear is mag = linear and min = linear and no mip */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** mag = linear and min = linear and mip = none */
  774. static readonly TEXTURE_LINEAR_LINEAR: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** Trilinear is mag = linear and min = linear and mip = linear */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  779. /** mag = nearest and min = nearest and mip = nearest */
  780. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  781. /** mag = nearest and min = linear and mip = nearest */
  782. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = linear */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  785. /** mag = nearest and min = linear and mip = none */
  786. static readonly TEXTURE_NEAREST_LINEAR: number;
  787. /** nearest is mag = nearest and min = nearest and mip = linear */
  788. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  789. /** mag = linear and min = nearest and mip = nearest */
  790. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  791. /** mag = linear and min = nearest and mip = linear */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  794. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = none */
  796. static readonly TEXTURE_LINEAR_NEAREST: number;
  797. /** Explicit coordinates mode */
  798. static readonly TEXTURE_EXPLICIT_MODE: number;
  799. /** Spherical coordinates mode */
  800. static readonly TEXTURE_SPHERICAL_MODE: number;
  801. /** Planar coordinates mode */
  802. static readonly TEXTURE_PLANAR_MODE: number;
  803. /** Cubic coordinates mode */
  804. static readonly TEXTURE_CUBIC_MODE: number;
  805. /** Projection coordinates mode */
  806. static readonly TEXTURE_PROJECTION_MODE: number;
  807. /** Skybox coordinates mode */
  808. static readonly TEXTURE_SKYBOX_MODE: number;
  809. /** Inverse Cubic coordinates mode */
  810. static readonly TEXTURE_INVCUBIC_MODE: number;
  811. /** Equirectangular coordinates mode */
  812. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  813. /** Equirectangular Fixed coordinates mode */
  814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed Mirrored coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  817. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  818. static readonly SCALEMODE_FLOOR: number;
  819. /** Defines that texture rescaling will look for the nearest power of 2 size */
  820. static readonly SCALEMODE_NEAREST: number;
  821. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  822. static readonly SCALEMODE_CEILING: number;
  823. /**
  824. * The dirty texture flag value
  825. */
  826. static readonly MATERIAL_TextureDirtyFlag: number;
  827. /**
  828. * The dirty light flag value
  829. */
  830. static readonly MATERIAL_LightDirtyFlag: number;
  831. /**
  832. * The dirty fresnel flag value
  833. */
  834. static readonly MATERIAL_FresnelDirtyFlag: number;
  835. /**
  836. * The dirty attribute flag value
  837. */
  838. static readonly MATERIAL_AttributesDirtyFlag: number;
  839. /**
  840. * The dirty misc flag value
  841. */
  842. static readonly MATERIAL_MiscDirtyFlag: number;
  843. /**
  844. * The all dirty flag value
  845. */
  846. static readonly MATERIAL_AllDirtyFlag: number;
  847. /**
  848. * Returns the triangle fill mode
  849. */
  850. static readonly MATERIAL_TriangleFillMode: number;
  851. /**
  852. * Returns the wireframe mode
  853. */
  854. static readonly MATERIAL_WireFrameFillMode: number;
  855. /**
  856. * Returns the point fill mode
  857. */
  858. static readonly MATERIAL_PointFillMode: number;
  859. /**
  860. * Returns the point list draw mode
  861. */
  862. static readonly MATERIAL_PointListDrawMode: number;
  863. /**
  864. * Returns the line list draw mode
  865. */
  866. static readonly MATERIAL_LineListDrawMode: number;
  867. /**
  868. * Returns the line loop draw mode
  869. */
  870. static readonly MATERIAL_LineLoopDrawMode: number;
  871. /**
  872. * Returns the line strip draw mode
  873. */
  874. static readonly MATERIAL_LineStripDrawMode: number;
  875. /**
  876. * Returns the triangle strip draw mode
  877. */
  878. static readonly MATERIAL_TriangleStripDrawMode: number;
  879. /**
  880. * Returns the triangle fan draw mode
  881. */
  882. static readonly MATERIAL_TriangleFanDrawMode: number;
  883. /**
  884. * Stores the clock-wise side orientation
  885. */
  886. static readonly MATERIAL_ClockWiseSideOrientation: number;
  887. /**
  888. * Stores the counter clock-wise side orientation
  889. */
  890. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  891. /**
  892. * Nothing
  893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  894. */
  895. static readonly ACTION_NothingTrigger: number;
  896. /**
  897. * On pick
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickTrigger: number;
  901. /**
  902. * On left pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLeftPickTrigger: number;
  906. /**
  907. * On right pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnRightPickTrigger: number;
  911. /**
  912. * On center pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnCenterPickTrigger: number;
  916. /**
  917. * On pick down
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPickDownTrigger: number;
  921. /**
  922. * On double pick
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnDoublePickTrigger: number;
  926. /**
  927. * On pick up
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnPickUpTrigger: number;
  931. /**
  932. * On pick out.
  933. * This trigger will only be raised if you also declared a OnPickDown
  934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnPickOutTrigger: number;
  937. /**
  938. * On long press
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnLongPressTrigger: number;
  942. /**
  943. * On pointer over
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnPointerOverTrigger: number;
  947. /**
  948. * On pointer out
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOutTrigger: number;
  952. /**
  953. * On every frame
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnEveryFrameTrigger: number;
  957. /**
  958. * On intersection enter
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnIntersectionEnterTrigger: number;
  962. /**
  963. * On intersection exit
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionExitTrigger: number;
  967. /**
  968. * On key down
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnKeyDownTrigger: number;
  972. /**
  973. * On key up
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyUpTrigger: number;
  977. /**
  978. * Billboard mode will only apply to Y axis
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  981. /**
  982. * Billboard mode will apply to all axes
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  985. /**
  986. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  989. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  990. * Test order :
  991. * Is the bounding sphere outside the frustum ?
  992. * If not, are the bounding box vertices outside the frustum ?
  993. * It not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  996. /** Culling strategy : Bounding Sphere Only.
  997. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  998. * It's also less accurate than the standard because some not visible objects can still be selected.
  999. * Test : is the bounding sphere outside the frustum ?
  1000. * If not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1003. /** Culling strategy : Optimistic Inclusion.
  1004. * This in an inclusion test first, then the standard exclusion test.
  1005. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1006. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1007. * Anyway, it's as accurate as the standard strategy.
  1008. * Test :
  1009. * Is the cullable object bounding sphere center in the frustum ?
  1010. * If not, apply the default culling strategy.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1013. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1014. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1015. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1016. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1017. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1018. * Test :
  1019. * Is the cullable object bounding sphere center in the frustum ?
  1020. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1023. /**
  1024. * No logging while loading
  1025. */
  1026. static readonly SCENELOADER_NO_LOGGING: number;
  1027. /**
  1028. * Minimal logging while loading
  1029. */
  1030. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1031. /**
  1032. * Summary logging while loading
  1033. */
  1034. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1035. /**
  1036. * Detailled logging while loading
  1037. */
  1038. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1039. }
  1040. }
  1041. declare module BABYLON {
  1042. /**
  1043. * This represents the required contract to create a new type of texture loader.
  1044. */
  1045. export interface IInternalTextureLoader {
  1046. /**
  1047. * Defines wether the loader supports cascade loading the different faces.
  1048. */
  1049. supportCascades: boolean;
  1050. /**
  1051. * This returns if the loader support the current file information.
  1052. * @param extension defines the file extension of the file being loaded
  1053. * @returns true if the loader can load the specified file
  1054. */
  1055. canLoad(extension: string): boolean;
  1056. /**
  1057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1058. * @param data contains the texture data
  1059. * @param texture defines the BabylonJS internal texture
  1060. * @param createPolynomials will be true if polynomials have been requested
  1061. * @param onLoad defines the callback to trigger once the texture is ready
  1062. * @param onError defines the callback to trigger in case of error
  1063. */
  1064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1065. /**
  1066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1067. * @param data contains the texture data
  1068. * @param texture defines the BabylonJS internal texture
  1069. * @param callback defines the method to call once ready to upload
  1070. */
  1071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1072. }
  1073. }
  1074. declare module BABYLON {
  1075. /**
  1076. * Class used to store and describe the pipeline context associated with an effect
  1077. */
  1078. export interface IPipelineContext {
  1079. /**
  1080. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1081. */
  1082. isAsync: boolean;
  1083. /**
  1084. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1085. */
  1086. isReady: boolean;
  1087. /** @hidden */
  1088. _getVertexShaderCode(): string | null;
  1089. /** @hidden */
  1090. _getFragmentShaderCode(): string | null;
  1091. /** @hidden */
  1092. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /**
  1097. * Class used to store gfx data (like WebGLBuffer)
  1098. */
  1099. export class DataBuffer {
  1100. /**
  1101. * Gets or sets the number of objects referencing this buffer
  1102. */
  1103. references: number;
  1104. /** Gets or sets the size of the underlying buffer */
  1105. capacity: number;
  1106. /**
  1107. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1108. */
  1109. is32Bits: boolean;
  1110. /**
  1111. * Gets the underlying buffer
  1112. */
  1113. get underlyingResource(): any;
  1114. }
  1115. }
  1116. declare module BABYLON {
  1117. /** @hidden */
  1118. export interface IShaderProcessor {
  1119. attributeProcessor?: (attribute: string) => string;
  1120. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1121. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1122. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1123. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1124. lineProcessor?: (line: string, isFragment: boolean) => string;
  1125. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export class ShaderCodeNode {
  1150. line: string;
  1151. children: ShaderCodeNode[];
  1152. additionalDefineKey?: string;
  1153. additionalDefineValue?: string;
  1154. isValid(preprocessors: {
  1155. [key: string]: string;
  1156. }): boolean;
  1157. process(preprocessors: {
  1158. [key: string]: string;
  1159. }, options: ProcessingOptions): string;
  1160. }
  1161. }
  1162. declare module BABYLON {
  1163. /** @hidden */
  1164. export class ShaderCodeCursor {
  1165. private _lines;
  1166. lineIndex: number;
  1167. get currentLine(): string;
  1168. get canRead(): boolean;
  1169. set lines(value: string[]);
  1170. }
  1171. }
  1172. declare module BABYLON {
  1173. /** @hidden */
  1174. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderDefineExpression {
  1183. isTrue(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderCodeTestNode extends ShaderCodeNode {
  1191. testExpression: ShaderDefineExpression;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1200. define: string;
  1201. not: boolean;
  1202. constructor(define: string, not?: boolean);
  1203. isTrue(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1211. leftOperand: ShaderDefineExpression;
  1212. rightOperand: ShaderDefineExpression;
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module BABYLON {
  1219. /** @hidden */
  1220. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1221. leftOperand: ShaderDefineExpression;
  1222. rightOperand: ShaderDefineExpression;
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module BABYLON {
  1229. /** @hidden */
  1230. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1231. define: string;
  1232. operand: string;
  1233. testValue: string;
  1234. constructor(define: string, operand: string, testValue: string);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module BABYLON {
  1241. /**
  1242. * Class used to enable access to offline support
  1243. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1244. */
  1245. export interface IOfflineProvider {
  1246. /**
  1247. * Gets a boolean indicating if scene must be saved in the database
  1248. */
  1249. enableSceneOffline: boolean;
  1250. /**
  1251. * Gets a boolean indicating if textures must be saved in the database
  1252. */
  1253. enableTexturesOffline: boolean;
  1254. /**
  1255. * Open the offline support and make it available
  1256. * @param successCallback defines the callback to call on success
  1257. * @param errorCallback defines the callback to call on error
  1258. */
  1259. open(successCallback: () => void, errorCallback: () => void): void;
  1260. /**
  1261. * Loads an image from the offline support
  1262. * @param url defines the url to load from
  1263. * @param image defines the target DOM image
  1264. */
  1265. loadImage(url: string, image: HTMLImageElement): void;
  1266. /**
  1267. * Loads a file from offline support
  1268. * @param url defines the URL to load from
  1269. * @param sceneLoaded defines a callback to call on success
  1270. * @param progressCallBack defines a callback to call when progress changed
  1271. * @param errorCallback defines a callback to call on error
  1272. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1273. */
  1274. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1275. }
  1276. }
  1277. declare module BABYLON {
  1278. /**
  1279. * Class used to help managing file picking and drag'n'drop
  1280. * File Storage
  1281. */
  1282. export class FilesInputStore {
  1283. /**
  1284. * List of files ready to be loaded
  1285. */
  1286. static FilesToLoad: {
  1287. [key: string]: File;
  1288. };
  1289. }
  1290. }
  1291. declare module BABYLON {
  1292. /**
  1293. * Class used to define a retry strategy when error happens while loading assets
  1294. */
  1295. export class RetryStrategy {
  1296. /**
  1297. * Function used to defines an exponential back off strategy
  1298. * @param maxRetries defines the maximum number of retries (3 by default)
  1299. * @param baseInterval defines the interval between retries
  1300. * @returns the strategy function to use
  1301. */
  1302. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * @ignore
  1308. * Application error to support additional information when loading a file
  1309. */
  1310. export abstract class BaseError extends Error {
  1311. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /** @ignore */
  1316. export class LoadFileError extends BaseError {
  1317. request?: WebRequest;
  1318. file?: File;
  1319. /**
  1320. * Creates a new LoadFileError
  1321. * @param message defines the message of the error
  1322. * @param request defines the optional web request
  1323. * @param file defines the optional file
  1324. */
  1325. constructor(message: string, object?: WebRequest | File);
  1326. }
  1327. /** @ignore */
  1328. export class RequestFileError extends BaseError {
  1329. request: WebRequest;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. */
  1335. constructor(message: string, request: WebRequest);
  1336. }
  1337. /** @ignore */
  1338. export class ReadFileError extends BaseError {
  1339. file: File;
  1340. /**
  1341. * Creates a new ReadFileError
  1342. * @param message defines the message of the error
  1343. * @param file defines the optional file
  1344. */
  1345. constructor(message: string, file: File);
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export class FileTools {
  1351. /**
  1352. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1353. */
  1354. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1355. /**
  1356. * Gets or sets the base URL to use to load assets
  1357. */
  1358. static BaseUrl: string;
  1359. /**
  1360. * Default behaviour for cors in the application.
  1361. * It can be a string if the expected behavior is identical in the entire app.
  1362. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1363. */
  1364. static CorsBehavior: string | ((url: string | string[]) => string);
  1365. /**
  1366. * Gets or sets a function used to pre-process url before using them to load assets
  1367. */
  1368. static PreprocessUrl: (url: string) => string;
  1369. /**
  1370. * Removes unwanted characters from an url
  1371. * @param url defines the url to clean
  1372. * @returns the cleaned url
  1373. */
  1374. private static _CleanUrl;
  1375. /**
  1376. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1377. * @param url define the url we are trying
  1378. * @param element define the dom element where to configure the cors policy
  1379. */
  1380. static SetCorsBehavior(url: string | string[], element: {
  1381. crossOrigin: string | null;
  1382. }): void;
  1383. /**
  1384. * Loads an image as an HTMLImageElement.
  1385. * @param input url string, ArrayBuffer, or Blob to load
  1386. * @param onLoad callback called when the image successfully loads
  1387. * @param onError callback called when the image fails to load
  1388. * @param offlineProvider offline provider for caching
  1389. * @param mimeType optional mime type
  1390. * @returns the HTMLImageElement of the loaded image
  1391. */
  1392. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1393. /**
  1394. * Reads a file from a File object
  1395. * @param file defines the file to load
  1396. * @param onSuccess defines the callback to call when data is loaded
  1397. * @param onProgress defines the callback to call during loading process
  1398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1399. * @param onError defines the callback to call when an error occurs
  1400. * @returns a file request object
  1401. */
  1402. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1403. /**
  1404. * Loads a file from a url
  1405. * @param url url to load
  1406. * @param onSuccess callback called when the file successfully loads
  1407. * @param onProgress callback called while file is loading (if the server supports this mode)
  1408. * @param offlineProvider defines the offline provider for caching
  1409. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1410. * @param onError callback called when the file fails to load
  1411. * @returns a file request object
  1412. */
  1413. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1420. * @param onError callback called when the file fails to load
  1421. * @param onOpened callback called when the web request is opened
  1422. * @returns a file request object
  1423. */
  1424. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1425. /**
  1426. * Checks if the loaded document was accessed via `file:`-Protocol.
  1427. * @returns boolean
  1428. */
  1429. static IsFileURL(): boolean;
  1430. }
  1431. }
  1432. declare module BABYLON {
  1433. /** @hidden */
  1434. export class ShaderProcessor {
  1435. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1436. private static _ProcessPrecision;
  1437. private static _ExtractOperation;
  1438. private static _BuildSubExpression;
  1439. private static _BuildExpression;
  1440. private static _MoveCursorWithinIf;
  1441. private static _MoveCursor;
  1442. private static _EvaluatePreProcessors;
  1443. private static _PreparePreProcessors;
  1444. private static _ProcessShaderConversion;
  1445. private static _ProcessIncludes;
  1446. /**
  1447. * Loads a file from a url
  1448. * @param url url to load
  1449. * @param onSuccess callback called when the file successfully loads
  1450. * @param onProgress callback called while file is loading (if the server supports this mode)
  1451. * @param offlineProvider defines the offline provider for caching
  1452. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1453. * @param onError callback called when the file fails to load
  1454. * @returns a file request object
  1455. * @hidden
  1456. */
  1457. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1458. }
  1459. }
  1460. declare module BABYLON {
  1461. /**
  1462. * @hidden
  1463. */
  1464. export interface IColor4Like {
  1465. r: float;
  1466. g: float;
  1467. b: float;
  1468. a: float;
  1469. }
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor3Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. }
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IVector4Like {
  1482. x: float;
  1483. y: float;
  1484. z: float;
  1485. w: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector3Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector2Like {
  1499. x: float;
  1500. y: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IMatrixLike {
  1506. toArray(): DeepImmutable<Float32Array>;
  1507. updateFlag: int;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IViewportLike {
  1513. x: float;
  1514. y: float;
  1515. width: float;
  1516. height: float;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IPlaneLike {
  1522. normal: IVector3Like;
  1523. d: float;
  1524. normalize(): void;
  1525. }
  1526. }
  1527. declare module BABYLON {
  1528. /**
  1529. * Interface used to define common properties for effect fallbacks
  1530. */
  1531. export interface IEffectFallbacks {
  1532. /**
  1533. * Removes the defines that should be removed when falling back.
  1534. * @param currentDefines defines the current define statements for the shader.
  1535. * @param effect defines the current effect we try to compile
  1536. * @returns The resulting defines with defines of the current rank removed.
  1537. */
  1538. reduce(currentDefines: string, effect: Effect): string;
  1539. /**
  1540. * Removes the fallback from the bound mesh.
  1541. */
  1542. unBindMesh(): void;
  1543. /**
  1544. * Checks to see if more fallbacks are still availible.
  1545. */
  1546. hasMoreFallbacks: boolean;
  1547. }
  1548. }
  1549. declare module BABYLON {
  1550. /**
  1551. * Class used to evalaute queries containing `and` and `or` operators
  1552. */
  1553. export class AndOrNotEvaluator {
  1554. /**
  1555. * Evaluate a query
  1556. * @param query defines the query to evaluate
  1557. * @param evaluateCallback defines the callback used to filter result
  1558. * @returns true if the query matches
  1559. */
  1560. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1561. private static _HandleParenthesisContent;
  1562. private static _SimplifyNegation;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /**
  1567. * Class used to store custom tags
  1568. */
  1569. export class Tags {
  1570. /**
  1571. * Adds support for tags on the given object
  1572. * @param obj defines the object to use
  1573. */
  1574. static EnableFor(obj: any): void;
  1575. /**
  1576. * Removes tags support
  1577. * @param obj defines the object to use
  1578. */
  1579. static DisableFor(obj: any): void;
  1580. /**
  1581. * Gets a boolean indicating if the given object has tags
  1582. * @param obj defines the object to use
  1583. * @returns a boolean
  1584. */
  1585. static HasTags(obj: any): boolean;
  1586. /**
  1587. * Gets the tags available on a given object
  1588. * @param obj defines the object to use
  1589. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1590. * @returns the tags
  1591. */
  1592. static GetTags(obj: any, asString?: boolean): any;
  1593. /**
  1594. * Adds tags to an object
  1595. * @param obj defines the object to use
  1596. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1597. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1598. */
  1599. static AddTagsTo(obj: any, tagsString: string): void;
  1600. /**
  1601. * @hidden
  1602. */
  1603. static _AddTagTo(obj: any, tag: string): void;
  1604. /**
  1605. * Removes specific tags from a specific object
  1606. * @param obj defines the object to use
  1607. * @param tagsString defines the tags to remove
  1608. */
  1609. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1610. /**
  1611. * @hidden
  1612. */
  1613. static _RemoveTagFrom(obj: any, tag: string): void;
  1614. /**
  1615. * Defines if tags hosted on an object match a given query
  1616. * @param obj defines the object to use
  1617. * @param tagsQuery defines the tag query
  1618. * @returns a boolean
  1619. */
  1620. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1621. }
  1622. }
  1623. declare module BABYLON {
  1624. /**
  1625. * Scalar computation library
  1626. */
  1627. export class Scalar {
  1628. /**
  1629. * Two pi constants convenient for computation.
  1630. */
  1631. static TwoPi: number;
  1632. /**
  1633. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1634. * @param a number
  1635. * @param b number
  1636. * @param epsilon (default = 1.401298E-45)
  1637. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. */
  1639. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1640. /**
  1641. * Returns a string : the upper case translation of the number i to hexadecimal.
  1642. * @param i number
  1643. * @returns the upper case translation of the number i to hexadecimal.
  1644. */
  1645. static ToHex(i: number): string;
  1646. /**
  1647. * Returns -1 if value is negative and +1 is value is positive.
  1648. * @param value the value
  1649. * @returns the value itself if it's equal to zero.
  1650. */
  1651. static Sign(value: number): number;
  1652. /**
  1653. * Returns the value itself if it's between min and max.
  1654. * Returns min if the value is lower than min.
  1655. * Returns max if the value is greater than max.
  1656. * @param value the value to clmap
  1657. * @param min the min value to clamp to (default: 0)
  1658. * @param max the max value to clamp to (default: 1)
  1659. * @returns the clamped value
  1660. */
  1661. static Clamp(value: number, min?: number, max?: number): number;
  1662. /**
  1663. * the log2 of value.
  1664. * @param value the value to compute log2 of
  1665. * @returns the log2 of value.
  1666. */
  1667. static Log2(value: number): number;
  1668. /**
  1669. * Loops the value, so that it is never larger than length and never smaller than 0.
  1670. *
  1671. * This is similar to the modulo operator but it works with floating point numbers.
  1672. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1673. * With t = 5 and length = 2.5, the result would be 0.0.
  1674. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1675. * @param value the value
  1676. * @param length the length
  1677. * @returns the looped value
  1678. */
  1679. static Repeat(value: number, length: number): number;
  1680. /**
  1681. * Normalize the value between 0.0 and 1.0 using min and max values
  1682. * @param value value to normalize
  1683. * @param min max to normalize between
  1684. * @param max min to normalize between
  1685. * @returns the normalized value
  1686. */
  1687. static Normalize(value: number, min: number, max: number): number;
  1688. /**
  1689. * Denormalize the value from 0.0 and 1.0 using min and max values
  1690. * @param normalized value to denormalize
  1691. * @param min max to denormalize between
  1692. * @param max min to denormalize between
  1693. * @returns the denormalized value
  1694. */
  1695. static Denormalize(normalized: number, min: number, max: number): number;
  1696. /**
  1697. * Calculates the shortest difference between two given angles given in degrees.
  1698. * @param current current angle in degrees
  1699. * @param target target angle in degrees
  1700. * @returns the delta
  1701. */
  1702. static DeltaAngle(current: number, target: number): number;
  1703. /**
  1704. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1705. * @param tx value
  1706. * @param length length
  1707. * @returns The returned value will move back and forth between 0 and length
  1708. */
  1709. static PingPong(tx: number, length: number): number;
  1710. /**
  1711. * Interpolates between min and max with smoothing at the limits.
  1712. *
  1713. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1714. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1715. * @param from from
  1716. * @param to to
  1717. * @param tx value
  1718. * @returns the smooth stepped value
  1719. */
  1720. static SmoothStep(from: number, to: number, tx: number): number;
  1721. /**
  1722. * Moves a value current towards target.
  1723. *
  1724. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1725. * Negative values of maxDelta pushes the value away from target.
  1726. * @param current current value
  1727. * @param target target value
  1728. * @param maxDelta max distance to move
  1729. * @returns resulting value
  1730. */
  1731. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1732. /**
  1733. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1734. *
  1735. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1736. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1737. * @param current current value
  1738. * @param target target value
  1739. * @param maxDelta max distance to move
  1740. * @returns resulting angle
  1741. */
  1742. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1743. /**
  1744. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1745. * @param start start value
  1746. * @param end target value
  1747. * @param amount amount to lerp between
  1748. * @returns the lerped value
  1749. */
  1750. static Lerp(start: number, end: number, amount: number): number;
  1751. /**
  1752. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1753. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static LerpAngle(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1762. * @param a start value
  1763. * @param b target value
  1764. * @param value value between a and b
  1765. * @returns the inverseLerp value
  1766. */
  1767. static InverseLerp(a: number, b: number, value: number): number;
  1768. /**
  1769. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1770. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1771. * @param value1 spline value
  1772. * @param tangent1 spline value
  1773. * @param value2 spline value
  1774. * @param tangent2 spline value
  1775. * @param amount input value
  1776. * @returns hermite result
  1777. */
  1778. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1779. /**
  1780. * Returns a random float number between and min and max values
  1781. * @param min min value of random
  1782. * @param max max value of random
  1783. * @returns random value
  1784. */
  1785. static RandomRange(min: number, max: number): number;
  1786. /**
  1787. * This function returns percentage of a number in a given range.
  1788. *
  1789. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1790. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1791. * @param number to convert to percentage
  1792. * @param min min range
  1793. * @param max max range
  1794. * @returns the percentage
  1795. */
  1796. static RangeToPercent(number: number, min: number, max: number): number;
  1797. /**
  1798. * This function returns number that corresponds to the percentage in a given range.
  1799. *
  1800. * PercentToRange(0.34,0,100) will return 34.
  1801. * @param percent to convert to number
  1802. * @param min min range
  1803. * @param max max range
  1804. * @returns the number
  1805. */
  1806. static PercentToRange(percent: number, min: number, max: number): number;
  1807. /**
  1808. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1809. * @param angle The angle to normalize in radian.
  1810. * @return The converted angle.
  1811. */
  1812. static NormalizeRadians(angle: number): number;
  1813. }
  1814. }
  1815. declare module BABYLON {
  1816. /**
  1817. * Constant used to convert a value to gamma space
  1818. * @ignorenaming
  1819. */
  1820. export const ToGammaSpace: number;
  1821. /**
  1822. * Constant used to convert a value to linear space
  1823. * @ignorenaming
  1824. */
  1825. export const ToLinearSpace = 2.2;
  1826. /**
  1827. * Constant used to define the minimal number value in Babylon.js
  1828. * @ignorenaming
  1829. */
  1830. let Epsilon: number;
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Class used to represent a viewport on screen
  1835. */
  1836. export class Viewport {
  1837. /** viewport left coordinate */
  1838. x: number;
  1839. /** viewport top coordinate */
  1840. y: number;
  1841. /**viewport width */
  1842. width: number;
  1843. /** viewport height */
  1844. height: number;
  1845. /**
  1846. * Creates a Viewport object located at (x, y) and sized (width, height)
  1847. * @param x defines viewport left coordinate
  1848. * @param y defines viewport top coordinate
  1849. * @param width defines the viewport width
  1850. * @param height defines the viewport height
  1851. */
  1852. constructor(
  1853. /** viewport left coordinate */
  1854. x: number,
  1855. /** viewport top coordinate */
  1856. y: number,
  1857. /**viewport width */
  1858. width: number,
  1859. /** viewport height */
  1860. height: number);
  1861. /**
  1862. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1863. * @param renderWidth defines the rendering width
  1864. * @param renderHeight defines the rendering height
  1865. * @returns a new Viewport
  1866. */
  1867. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1868. /**
  1869. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1870. * @param renderWidth defines the rendering width
  1871. * @param renderHeight defines the rendering height
  1872. * @param ref defines the target viewport
  1873. * @returns the current viewport
  1874. */
  1875. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1876. /**
  1877. * Returns a new Viewport copied from the current one
  1878. * @returns a new Viewport
  1879. */
  1880. clone(): Viewport;
  1881. }
  1882. }
  1883. declare module BABYLON {
  1884. /**
  1885. * Class containing a set of static utilities functions for arrays.
  1886. */
  1887. export class ArrayTools {
  1888. /**
  1889. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1890. * @param size the number of element to construct and put in the array
  1891. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1892. * @returns a new array filled with new objects
  1893. */
  1894. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1895. }
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class representing a vector containing 2 coordinates
  1900. */
  1901. export class Vector2 {
  1902. /** defines the first coordinate */
  1903. x: number;
  1904. /** defines the second coordinate */
  1905. y: number;
  1906. /**
  1907. * Creates a new Vector2 from the given x and y coordinates
  1908. * @param x defines the first coordinate
  1909. * @param y defines the second coordinate
  1910. */
  1911. constructor(
  1912. /** defines the first coordinate */
  1913. x?: number,
  1914. /** defines the second coordinate */
  1915. y?: number);
  1916. /**
  1917. * Gets a string with the Vector2 coordinates
  1918. * @returns a string with the Vector2 coordinates
  1919. */
  1920. toString(): string;
  1921. /**
  1922. * Gets class name
  1923. * @returns the string "Vector2"
  1924. */
  1925. getClassName(): string;
  1926. /**
  1927. * Gets current vector hash code
  1928. * @returns the Vector2 hash code as a number
  1929. */
  1930. getHashCode(): number;
  1931. /**
  1932. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1933. * @param array defines the source array
  1934. * @param index defines the offset in source array
  1935. * @returns the current Vector2
  1936. */
  1937. toArray(array: FloatArray, index?: number): Vector2;
  1938. /**
  1939. * Copy the current vector to an array
  1940. * @returns a new array with 2 elements: the Vector2 coordinates.
  1941. */
  1942. asArray(): number[];
  1943. /**
  1944. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1945. * @param source defines the source Vector2
  1946. * @returns the current updated Vector2
  1947. */
  1948. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1949. /**
  1950. * Sets the Vector2 coordinates with the given floats
  1951. * @param x defines the first coordinate
  1952. * @param y defines the second coordinate
  1953. * @returns the current updated Vector2
  1954. */
  1955. copyFromFloats(x: number, y: number): Vector2;
  1956. /**
  1957. * Sets the Vector2 coordinates with the given floats
  1958. * @param x defines the first coordinate
  1959. * @param y defines the second coordinate
  1960. * @returns the current updated Vector2
  1961. */
  1962. set(x: number, y: number): Vector2;
  1963. /**
  1964. * Add another vector with the current one
  1965. * @param otherVector defines the other vector
  1966. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1967. */
  1968. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1969. /**
  1970. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1971. * @param otherVector defines the other vector
  1972. * @param result defines the target vector
  1973. * @returns the unmodified current Vector2
  1974. */
  1975. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1976. /**
  1977. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1978. * @param otherVector defines the other vector
  1979. * @returns the current updated Vector2
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1984. * @param otherVector defines the other vector
  1985. * @returns a new Vector2
  1986. */
  1987. addVector3(otherVector: Vector3): Vector2;
  1988. /**
  1989. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. subtract(otherVector: Vector2): Vector2;
  1994. /**
  1995. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1996. * @param otherVector defines the other vector
  1997. * @param result defines the target vector
  1998. * @returns the unmodified current Vector2
  1999. */
  2000. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2001. /**
  2002. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2003. * @param otherVector defines the other vector
  2004. * @returns the current updated Vector2
  2005. */
  2006. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2007. /**
  2008. * Multiplies in place the current Vector2 coordinates by the given ones
  2009. * @param otherVector defines the other vector
  2010. * @returns the current updated Vector2
  2011. */
  2012. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2013. /**
  2014. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2015. * @param otherVector defines the other vector
  2016. * @returns a new Vector2
  2017. */
  2018. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @param result defines the target vector
  2023. * @returns the unmodified current Vector2
  2024. */
  2025. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2026. /**
  2027. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2028. * @param x defines the first coordinate
  2029. * @param y defines the second coordinate
  2030. * @returns a new Vector2
  2031. */
  2032. multiplyByFloats(x: number, y: number): Vector2;
  2033. /**
  2034. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2035. * @param otherVector defines the other vector
  2036. * @returns a new Vector2
  2037. */
  2038. divide(otherVector: Vector2): Vector2;
  2039. /**
  2040. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @param result defines the target vector
  2043. * @returns the unmodified current Vector2
  2044. */
  2045. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2046. /**
  2047. * Divides the current Vector2 coordinates by the given ones
  2048. * @param otherVector defines the other vector
  2049. * @returns the current updated Vector2
  2050. */
  2051. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Gets a new Vector2 with current Vector2 negated coordinates
  2054. * @returns a new Vector2
  2055. */
  2056. negate(): Vector2;
  2057. /**
  2058. * Negate this vector in place
  2059. * @returns this
  2060. */
  2061. negateInPlace(): Vector2;
  2062. /**
  2063. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2064. * @param result defines the Vector3 object where to store the result
  2065. * @returns the current Vector2
  2066. */
  2067. negateToRef(result: Vector2): Vector2;
  2068. /**
  2069. * Multiply the Vector2 coordinates by scale
  2070. * @param scale defines the scaling factor
  2071. * @returns the current updated Vector2
  2072. */
  2073. scaleInPlace(scale: number): Vector2;
  2074. /**
  2075. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2076. * @param scale defines the scaling factor
  2077. * @returns a new Vector2
  2078. */
  2079. scale(scale: number): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Gets a boolean if two vectors are equals
  2096. * @param otherVector defines the other vector
  2097. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2098. */
  2099. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2100. /**
  2101. * Gets a boolean if two vectors are equals (using an epsilon value)
  2102. * @param otherVector defines the other vector
  2103. * @param epsilon defines the minimal distance to consider equality
  2104. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2105. */
  2106. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2107. /**
  2108. * Gets a new Vector2 from current Vector2 floored values
  2109. * @returns a new Vector2
  2110. */
  2111. floor(): Vector2;
  2112. /**
  2113. * Gets a new Vector2 from current Vector2 floored values
  2114. * @returns a new Vector2
  2115. */
  2116. fract(): Vector2;
  2117. /**
  2118. * Gets the length of the vector
  2119. * @returns the vector length (float)
  2120. */
  2121. length(): number;
  2122. /**
  2123. * Gets the vector squared length
  2124. * @returns the vector squared length (float)
  2125. */
  2126. lengthSquared(): number;
  2127. /**
  2128. * Normalize the vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. normalize(): Vector2;
  2132. /**
  2133. * Gets a new Vector2 copied from the Vector2
  2134. * @returns a new Vector2
  2135. */
  2136. clone(): Vector2;
  2137. /**
  2138. * Gets a new Vector2(0, 0)
  2139. * @returns a new Vector2
  2140. */
  2141. static Zero(): Vector2;
  2142. /**
  2143. * Gets a new Vector2(1, 1)
  2144. * @returns a new Vector2
  2145. */
  2146. static One(): Vector2;
  2147. /**
  2148. * Gets a new Vector2 set from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @returns a new Vector2
  2152. */
  2153. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2154. /**
  2155. * Sets "result" from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @param result defines the target vector
  2159. */
  2160. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2161. /**
  2162. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2163. * @param value1 defines 1st point of control
  2164. * @param value2 defines 2nd point of control
  2165. * @param value3 defines 3rd point of control
  2166. * @param value4 defines 4th point of control
  2167. * @param amount defines the interpolation factor
  2168. * @returns a new Vector2
  2169. */
  2170. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2171. /**
  2172. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2173. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2174. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2175. * @param value defines the value to clamp
  2176. * @param min defines the lower limit
  2177. * @param max defines the upper limit
  2178. * @returns a new Vector2
  2179. */
  2180. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2183. * @param value1 defines the 1st control point
  2184. * @param tangent1 defines the outgoing tangent
  2185. * @param value2 defines the 2nd control point
  2186. * @param tangent2 defines the incoming tangent
  2187. * @param amount defines the interpolation factor
  2188. * @returns a new Vector2
  2189. */
  2190. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2193. * @param start defines the start vector
  2194. * @param end defines the end vector
  2195. * @param amount defines the interpolation factor
  2196. * @returns a new Vector2
  2197. */
  2198. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2199. /**
  2200. * Gets the dot product of the vector "left" and the vector "right"
  2201. * @param left defines first vector
  2202. * @param right defines second vector
  2203. * @returns the dot product (float)
  2204. */
  2205. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2206. /**
  2207. * Returns a new Vector2 equal to the normalized given vector
  2208. * @param vector defines the vector to normalize
  2209. * @returns a new Vector2
  2210. */
  2211. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @returns a new Vector2
  2231. */
  2232. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2233. /**
  2234. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @param result defines the target vector
  2238. */
  2239. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2240. /**
  2241. * Determines if a given vector is included in a triangle
  2242. * @param p defines the vector to test
  2243. * @param p0 defines 1st triangle point
  2244. * @param p1 defines 2nd triangle point
  2245. * @param p2 defines 3rd triangle point
  2246. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2247. */
  2248. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2249. /**
  2250. * Gets the distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the distance between vectors
  2254. */
  2255. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Returns the squared distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the squared distance between vectors
  2261. */
  2262. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns a new Vector2
  2268. */
  2269. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2270. /**
  2271. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2272. * @param p defines the middle point
  2273. * @param segA defines one point of the segment
  2274. * @param segB defines the other point of the segment
  2275. * @returns the shortest distance
  2276. */
  2277. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2278. }
  2279. /**
  2280. * Class used to store (x,y,z) vector representation
  2281. * A Vector3 is the main object used in 3D geometry
  2282. * It can represent etiher the coordinates of a point the space, either a direction
  2283. * Reminder: js uses a left handed forward facing system
  2284. */
  2285. export class Vector3 {
  2286. /**
  2287. * Defines the first coordinates (on X axis)
  2288. */
  2289. x: number;
  2290. /**
  2291. * Defines the second coordinates (on Y axis)
  2292. */
  2293. y: number;
  2294. /**
  2295. * Defines the third coordinates (on Z axis)
  2296. */
  2297. z: number;
  2298. private static _UpReadOnly;
  2299. private static _ZeroReadOnly;
  2300. /**
  2301. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2302. * @param x defines the first coordinates (on X axis)
  2303. * @param y defines the second coordinates (on Y axis)
  2304. * @param z defines the third coordinates (on Z axis)
  2305. */
  2306. constructor(
  2307. /**
  2308. * Defines the first coordinates (on X axis)
  2309. */
  2310. x?: number,
  2311. /**
  2312. * Defines the second coordinates (on Y axis)
  2313. */
  2314. y?: number,
  2315. /**
  2316. * Defines the third coordinates (on Z axis)
  2317. */
  2318. z?: number);
  2319. /**
  2320. * Creates a string representation of the Vector3
  2321. * @returns a string with the Vector3 coordinates.
  2322. */
  2323. toString(): string;
  2324. /**
  2325. * Gets the class name
  2326. * @returns the string "Vector3"
  2327. */
  2328. getClassName(): string;
  2329. /**
  2330. * Creates the Vector3 hash code
  2331. * @returns a number which tends to be unique between Vector3 instances
  2332. */
  2333. getHashCode(): number;
  2334. /**
  2335. * Creates an array containing three elements : the coordinates of the Vector3
  2336. * @returns a new array of numbers
  2337. */
  2338. asArray(): number[];
  2339. /**
  2340. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2341. * @param array defines the destination array
  2342. * @param index defines the offset in the destination array
  2343. * @returns the current Vector3
  2344. */
  2345. toArray(array: FloatArray, index?: number): Vector3;
  2346. /**
  2347. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2348. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2349. */
  2350. toQuaternion(): Quaternion;
  2351. /**
  2352. * Adds the given vector to the current Vector3
  2353. * @param otherVector defines the second operand
  2354. * @returns the current updated Vector3
  2355. */
  2356. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2357. /**
  2358. * Adds the given coordinates to the current Vector3
  2359. * @param x defines the x coordinate of the operand
  2360. * @param y defines the y coordinate of the operand
  2361. * @param z defines the z coordinate of the operand
  2362. * @returns the current updated Vector3
  2363. */
  2364. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2365. /**
  2366. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2367. * @param otherVector defines the second operand
  2368. * @returns the resulting Vector3
  2369. */
  2370. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2373. * @param otherVector defines the second operand
  2374. * @param result defines the Vector3 object where to store the result
  2375. * @returns the current Vector3
  2376. */
  2377. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2378. /**
  2379. * Subtract the given vector from the current Vector3
  2380. * @param otherVector defines the second operand
  2381. * @returns the current updated Vector3
  2382. */
  2383. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2384. /**
  2385. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the resulting Vector3
  2388. */
  2389. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2392. * @param otherVector defines the second operand
  2393. * @param result defines the Vector3 object where to store the result
  2394. * @returns the current Vector3
  2395. */
  2396. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2397. /**
  2398. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2399. * @param x defines the x coordinate of the operand
  2400. * @param y defines the y coordinate of the operand
  2401. * @param z defines the z coordinate of the operand
  2402. * @returns the resulting Vector3
  2403. */
  2404. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2405. /**
  2406. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2407. * @param x defines the x coordinate of the operand
  2408. * @param y defines the y coordinate of the operand
  2409. * @param z defines the z coordinate of the operand
  2410. * @param result defines the Vector3 object where to store the result
  2411. * @returns the current Vector3
  2412. */
  2413. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2414. /**
  2415. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2416. * @returns a new Vector3
  2417. */
  2418. negate(): Vector3;
  2419. /**
  2420. * Negate this vector in place
  2421. * @returns this
  2422. */
  2423. negateInPlace(): Vector3;
  2424. /**
  2425. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. negateToRef(result: Vector3): Vector3;
  2430. /**
  2431. * Multiplies the Vector3 coordinates by the float "scale"
  2432. * @param scale defines the multiplier factor
  2433. * @returns the current updated Vector3
  2434. */
  2435. scaleInPlace(scale: number): Vector3;
  2436. /**
  2437. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2438. * @param scale defines the multiplier factor
  2439. * @returns a new Vector3
  2440. */
  2441. scale(scale: number): Vector3;
  2442. /**
  2443. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2444. * @param scale defines the multiplier factor
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. scaleToRef(scale: number, result: Vector3): Vector3;
  2449. /**
  2450. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2451. * @param scale defines the scale factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the unmodified current Vector3
  2454. */
  2455. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2458. * @param otherVector defines the second operand
  2459. * @returns true if both vectors are equals
  2460. */
  2461. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2462. /**
  2463. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2464. * @param otherVector defines the second operand
  2465. * @param epsilon defines the minimal distance to define values as equals
  2466. * @returns true if both vectors are distant less than epsilon
  2467. */
  2468. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 coordinates equals the given floats
  2471. * @param x defines the x coordinate of the operand
  2472. * @param y defines the y coordinate of the operand
  2473. * @param z defines the z coordinate of the operand
  2474. * @returns true if both vectors are equals
  2475. */
  2476. equalsToFloats(x: number, y: number, z: number): boolean;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the given ones
  2479. * @param otherVector defines the second operand
  2480. * @returns the current updated Vector3
  2481. */
  2482. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2483. /**
  2484. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2485. * @param otherVector defines the second operand
  2486. * @returns the new Vector3
  2487. */
  2488. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2489. /**
  2490. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2491. * @param otherVector defines the second operand
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the current Vector3
  2494. */
  2495. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2496. /**
  2497. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2498. * @param x defines the x coordinate of the operand
  2499. * @param y defines the y coordinate of the operand
  2500. * @param z defines the z coordinate of the operand
  2501. * @returns the new Vector3
  2502. */
  2503. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2504. /**
  2505. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2506. * @param otherVector defines the second operand
  2507. * @returns the new Vector3
  2508. */
  2509. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2512. * @param otherVector defines the second operand
  2513. * @param result defines the Vector3 object where to store the result
  2514. * @returns the current Vector3
  2515. */
  2516. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones.
  2519. * @param otherVector defines the second operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. divideInPlace(otherVector: Vector3): Vector3;
  2523. /**
  2524. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2525. * @param other defines the second operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2529. /**
  2530. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2531. * @param other defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2537. * @param x defines the x coordinate of the operand
  2538. * @param y defines the y coordinate of the operand
  2539. * @param z defines the z coordinate of the operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2543. /**
  2544. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2545. * @param x defines the x coordinate of the operand
  2546. * @param y defines the y coordinate of the operand
  2547. * @param z defines the z coordinate of the operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2551. /**
  2552. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2553. * Check if is non uniform within a certain amount of decimal places to account for this
  2554. * @param epsilon the amount the values can differ
  2555. * @returns if the the vector is non uniform to a certain number of decimal places
  2556. */
  2557. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2558. /**
  2559. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2560. */
  2561. get isNonUniform(): boolean;
  2562. /**
  2563. * Gets a new Vector3 from current Vector3 floored values
  2564. * @returns a new Vector3
  2565. */
  2566. floor(): Vector3;
  2567. /**
  2568. * Gets a new Vector3 from current Vector3 floored values
  2569. * @returns a new Vector3
  2570. */
  2571. fract(): Vector3;
  2572. /**
  2573. * Gets the length of the Vector3
  2574. * @returns the length of the Vector3
  2575. */
  2576. length(): number;
  2577. /**
  2578. * Gets the squared length of the Vector3
  2579. * @returns squared length of the Vector3
  2580. */
  2581. lengthSquared(): number;
  2582. /**
  2583. * Normalize the current Vector3.
  2584. * Please note that this is an in place operation.
  2585. * @returns the current updated Vector3
  2586. */
  2587. normalize(): Vector3;
  2588. /**
  2589. * Reorders the x y z properties of the vector in place
  2590. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2591. * @returns the current updated vector
  2592. */
  2593. reorderInPlace(order: string): this;
  2594. /**
  2595. * Rotates the vector around 0,0,0 by a quaternion
  2596. * @param quaternion the rotation quaternion
  2597. * @param result vector to store the result
  2598. * @returns the resulting vector
  2599. */
  2600. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2601. /**
  2602. * Rotates a vector around a given point
  2603. * @param quaternion the rotation quaternion
  2604. * @param point the point to rotate around
  2605. * @param result vector to store the result
  2606. * @returns the resulting vector
  2607. */
  2608. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2609. /**
  2610. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2611. * The cross product is then orthogonal to both current and "other"
  2612. * @param other defines the right operand
  2613. * @returns the cross product
  2614. */
  2615. cross(other: Vector3): Vector3;
  2616. /**
  2617. * Normalize the current Vector3 with the given input length.
  2618. * Please note that this is an in place operation.
  2619. * @param len the length of the vector
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalizeFromLength(len: number): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 to a new vector
  2625. * @returns the new Vector3
  2626. */
  2627. normalizeToNew(): Vector3;
  2628. /**
  2629. * Normalize the current Vector3 to the reference
  2630. * @param reference define the Vector3 to update
  2631. * @returns the updated Vector3
  2632. */
  2633. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2634. /**
  2635. * Creates a new Vector3 copied from the current Vector3
  2636. * @returns the new Vector3
  2637. */
  2638. clone(): Vector3;
  2639. /**
  2640. * Copies the given vector coordinates to the current Vector3 ones
  2641. * @param source defines the source Vector3
  2642. * @returns the current updated Vector3
  2643. */
  2644. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2645. /**
  2646. * Copies the given floats to the current Vector3 coordinates
  2647. * @param x defines the x coordinate of the operand
  2648. * @param y defines the y coordinate of the operand
  2649. * @param z defines the z coordinate of the operand
  2650. * @returns the current updated Vector3
  2651. */
  2652. copyFromFloats(x: number, y: number, z: number): Vector3;
  2653. /**
  2654. * Copies the given floats to the current Vector3 coordinates
  2655. * @param x defines the x coordinate of the operand
  2656. * @param y defines the y coordinate of the operand
  2657. * @param z defines the z coordinate of the operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. set(x: number, y: number, z: number): Vector3;
  2661. /**
  2662. * Copies the given float to the current Vector3 coordinates
  2663. * @param v defines the x, y and z coordinates of the operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. setAll(v: number): Vector3;
  2667. /**
  2668. * Get the clip factor between two vectors
  2669. * @param vector0 defines the first operand
  2670. * @param vector1 defines the second operand
  2671. * @param axis defines the axis to use
  2672. * @param size defines the size along the axis
  2673. * @returns the clip factor
  2674. */
  2675. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2676. /**
  2677. * Get angle between two vectors
  2678. * @param vector0 angle between vector0 and vector1
  2679. * @param vector1 angle between vector0 and vector1
  2680. * @param normal direction of the normal
  2681. * @return the angle between vector0 and vector1
  2682. */
  2683. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2684. /**
  2685. * Returns a new Vector3 set from the index "offset" of the given array
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @returns the new Vector3
  2689. */
  2690. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. * @deprecated Please use FromArray instead.
  2697. */
  2698. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2699. /**
  2700. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @param result defines the Vector3 where to store the result
  2704. */
  2705. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. * @deprecated Please use FromArrayToRef instead.
  2712. */
  2713. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2714. /**
  2715. * Sets the given vector "result" with the given floats.
  2716. * @param x defines the x coordinate of the source
  2717. * @param y defines the y coordinate of the source
  2718. * @param z defines the z coordinate of the source
  2719. * @param result defines the Vector3 where to store the result
  2720. */
  2721. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2724. * @returns a new empty Vector3
  2725. */
  2726. static Zero(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2729. * @returns a new unit Vector3
  2730. */
  2731. static One(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2734. * @returns a new up Vector3
  2735. */
  2736. static Up(): Vector3;
  2737. /**
  2738. * Gets a up Vector3 that must not be updated
  2739. */
  2740. static get UpReadOnly(): DeepImmutable<Vector3>;
  2741. /**
  2742. * Gets a zero Vector3 that must not be updated
  2743. */
  2744. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2745. /**
  2746. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2747. * @returns a new down Vector3
  2748. */
  2749. static Down(): Vector3;
  2750. /**
  2751. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2752. * @returns a new forward Vector3
  2753. */
  2754. static Forward(): Vector3;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2757. * @returns a new forward Vector3
  2758. */
  2759. static Backward(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2762. * @returns a new right Vector3
  2763. */
  2764. static Right(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2767. * @returns a new left Vector3
  2768. */
  2769. static Left(): Vector3;
  2770. /**
  2771. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2772. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2773. * @param vector defines the Vector3 to transform
  2774. * @param transformation defines the transformation matrix
  2775. * @returns the transformed Vector3
  2776. */
  2777. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2778. /**
  2779. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2780. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2781. * @param vector defines the Vector3 to transform
  2782. * @param transformation defines the transformation matrix
  2783. * @param result defines the Vector3 where to store the result
  2784. */
  2785. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2786. /**
  2787. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2788. * This method computes tranformed coordinates only, not transformed direction vectors
  2789. * @param x define the x coordinate of the source vector
  2790. * @param y define the y coordinate of the source vector
  2791. * @param z define the z coordinate of the source vector
  2792. * @param transformation defines the transformation matrix
  2793. * @param result defines the Vector3 where to store the result
  2794. */
  2795. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2796. /**
  2797. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2798. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2799. * @param vector defines the Vector3 to transform
  2800. * @param transformation defines the transformation matrix
  2801. * @returns the new Vector3
  2802. */
  2803. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2804. /**
  2805. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2806. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2807. * @param vector defines the Vector3 to transform
  2808. * @param transformation defines the transformation matrix
  2809. * @param result defines the Vector3 where to store the result
  2810. */
  2811. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2812. /**
  2813. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2814. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2815. * @param x define the x coordinate of the source vector
  2816. * @param y define the y coordinate of the source vector
  2817. * @param z define the z coordinate of the source vector
  2818. * @param transformation defines the transformation matrix
  2819. * @param result defines the Vector3 where to store the result
  2820. */
  2821. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2822. /**
  2823. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2824. * @param value1 defines the first control point
  2825. * @param value2 defines the second control point
  2826. * @param value3 defines the third control point
  2827. * @param value4 defines the fourth control point
  2828. * @param amount defines the amount on the spline to use
  2829. * @returns the new Vector3
  2830. */
  2831. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2832. /**
  2833. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2834. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2835. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2836. * @param value defines the current value
  2837. * @param min defines the lower range value
  2838. * @param max defines the upper range value
  2839. * @returns the new Vector3
  2840. */
  2841. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2842. /**
  2843. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2844. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2845. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2846. * @param value defines the current value
  2847. * @param min defines the lower range value
  2848. * @param max defines the upper range value
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2852. /**
  2853. * Checks if a given vector is inside a specific range
  2854. * @param v defines the vector to test
  2855. * @param min defines the minimum range
  2856. * @param max defines the maximum range
  2857. */
  2858. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2861. * @param value1 defines the first control point
  2862. * @param tangent1 defines the first tangent vector
  2863. * @param value2 defines the second control point
  2864. * @param tangent2 defines the second tangent vector
  2865. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2866. * @returns the new Vector3
  2867. */
  2868. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2871. * @param start defines the start value
  2872. * @param end defines the end value
  2873. * @param amount max defines amount between both (between 0 and 1)
  2874. * @returns the new Vector3
  2875. */
  2876. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2879. * @param start defines the start value
  2880. * @param end defines the end value
  2881. * @param amount max defines amount between both (between 0 and 1)
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2885. /**
  2886. * Returns the dot product (float) between the vectors "left" and "right"
  2887. * @param left defines the left operand
  2888. * @param right defines the right operand
  2889. * @returns the dot product
  2890. */
  2891. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2892. /**
  2893. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2894. * The cross product is then orthogonal to both "left" and "right"
  2895. * @param left defines the left operand
  2896. * @param right defines the right operand
  2897. * @returns the cross product
  2898. */
  2899. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2900. /**
  2901. * Sets the given vector "result" with the cross product of "left" and "right"
  2902. * The cross product is then orthogonal to both "left" and "right"
  2903. * @param left defines the left operand
  2904. * @param right defines the right operand
  2905. * @param result defines the Vector3 where to store the result
  2906. */
  2907. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2908. /**
  2909. * Returns a new Vector3 as the normalization of the given vector
  2910. * @param vector defines the Vector3 to normalize
  2911. * @returns the new Vector3
  2912. */
  2913. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the normalization of the given first vector
  2916. * @param vector defines the Vector3 to normalize
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2920. /**
  2921. * Project a Vector3 onto screen space
  2922. * @param vector defines the Vector3 to project
  2923. * @param world defines the world matrix to use
  2924. * @param transform defines the transform (view x projection) matrix to use
  2925. * @param viewport defines the screen viewport to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2929. /** @hidden */
  2930. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2931. /**
  2932. * Unproject from screen space to object space
  2933. * @param source defines the screen space Vector3 to use
  2934. * @param viewportWidth defines the current width of the viewport
  2935. * @param viewportHeight defines the current height of the viewport
  2936. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2937. * @param transform defines the transform (view x projection) matrix to use
  2938. * @returns the new Vector3
  2939. */
  2940. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2941. /**
  2942. * Unproject from screen space to object space
  2943. * @param source defines the screen space Vector3 to use
  2944. * @param viewportWidth defines the current width of the viewport
  2945. * @param viewportHeight defines the current height of the viewport
  2946. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2947. * @param view defines the view matrix to use
  2948. * @param projection defines the projection matrix to use
  2949. * @returns the new Vector3
  2950. */
  2951. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2952. /**
  2953. * Unproject from screen space to object space
  2954. * @param source defines the screen space Vector3 to use
  2955. * @param viewportWidth defines the current width of the viewport
  2956. * @param viewportHeight defines the current height of the viewport
  2957. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2958. * @param view defines the view matrix to use
  2959. * @param projection defines the projection matrix to use
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param sourceX defines the screen space x coordinate to use
  2966. * @param sourceY defines the screen space y coordinate to use
  2967. * @param sourceZ defines the screen space z coordinate to use
  2968. * @param viewportWidth defines the current width of the viewport
  2969. * @param viewportHeight defines the current height of the viewport
  2970. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2971. * @param view defines the view matrix to use
  2972. * @param projection defines the projection matrix to use
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Gets the minimal coordinate values between two Vector3
  2978. * @param left defines the first operand
  2979. * @param right defines the second operand
  2980. * @returns the new Vector3
  2981. */
  2982. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Gets the maximal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Returns the distance between the vectors "value1" and "value2"
  2992. * @param value1 defines the first operand
  2993. * @param value2 defines the second operand
  2994. * @returns the distance
  2995. */
  2996. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2997. /**
  2998. * Returns the squared distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the squared distance
  3002. */
  3003. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns a new Vector3 located at the center between "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the new Vector3
  3009. */
  3010. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3013. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3014. * to something in order to rotate it from its local system to the given target system
  3015. * Note: axis1, axis2 and axis3 are normalized during this operation
  3016. * @param axis1 defines the first axis
  3017. * @param axis2 defines the second axis
  3018. * @param axis3 defines the third axis
  3019. * @returns a new Vector3
  3020. */
  3021. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3024. * @param axis1 defines the first axis
  3025. * @param axis2 defines the second axis
  3026. * @param axis3 defines the third axis
  3027. * @param ref defines the Vector3 where to store the result
  3028. */
  3029. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3030. }
  3031. /**
  3032. * Vector4 class created for EulerAngle class conversion to Quaternion
  3033. */
  3034. export class Vector4 {
  3035. /** x value of the vector */
  3036. x: number;
  3037. /** y value of the vector */
  3038. y: number;
  3039. /** z value of the vector */
  3040. z: number;
  3041. /** w value of the vector */
  3042. w: number;
  3043. /**
  3044. * Creates a Vector4 object from the given floats.
  3045. * @param x x value of the vector
  3046. * @param y y value of the vector
  3047. * @param z z value of the vector
  3048. * @param w w value of the vector
  3049. */
  3050. constructor(
  3051. /** x value of the vector */
  3052. x: number,
  3053. /** y value of the vector */
  3054. y: number,
  3055. /** z value of the vector */
  3056. z: number,
  3057. /** w value of the vector */
  3058. w: number);
  3059. /**
  3060. * Returns the string with the Vector4 coordinates.
  3061. * @returns a string containing all the vector values
  3062. */
  3063. toString(): string;
  3064. /**
  3065. * Returns the string "Vector4".
  3066. * @returns "Vector4"
  3067. */
  3068. getClassName(): string;
  3069. /**
  3070. * Returns the Vector4 hash code.
  3071. * @returns a unique hash code
  3072. */
  3073. getHashCode(): number;
  3074. /**
  3075. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3076. * @returns the resulting array
  3077. */
  3078. asArray(): number[];
  3079. /**
  3080. * Populates the given array from the given index with the Vector4 coordinates.
  3081. * @param array array to populate
  3082. * @param index index of the array to start at (default: 0)
  3083. * @returns the Vector4.
  3084. */
  3085. toArray(array: FloatArray, index?: number): Vector4;
  3086. /**
  3087. * Adds the given vector to the current Vector4.
  3088. * @param otherVector the vector to add
  3089. * @returns the updated Vector4.
  3090. */
  3091. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3092. /**
  3093. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3094. * @param otherVector the vector to add
  3095. * @returns the resulting vector
  3096. */
  3097. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3098. /**
  3099. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3100. * @param otherVector the vector to add
  3101. * @param result the vector to store the result
  3102. * @returns the current Vector4.
  3103. */
  3104. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3105. /**
  3106. * Subtract in place the given vector from the current Vector4.
  3107. * @param otherVector the vector to subtract
  3108. * @returns the updated Vector4.
  3109. */
  3110. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3111. /**
  3112. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3113. * @param otherVector the vector to add
  3114. * @returns the new vector with the result
  3115. */
  3116. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3117. /**
  3118. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3119. * @param otherVector the vector to subtract
  3120. * @param result the vector to store the result
  3121. * @returns the current Vector4.
  3122. */
  3123. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3124. /**
  3125. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3126. */
  3127. /**
  3128. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3129. * @param x value to subtract
  3130. * @param y value to subtract
  3131. * @param z value to subtract
  3132. * @param w value to subtract
  3133. * @returns new vector containing the result
  3134. */
  3135. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3136. /**
  3137. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @param result the vector to store the result in
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3148. * @returns a new vector with the negated values
  3149. */
  3150. negate(): Vector4;
  3151. /**
  3152. * Negate this vector in place
  3153. * @returns this
  3154. */
  3155. negateInPlace(): Vector4;
  3156. /**
  3157. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3158. * @param result defines the Vector3 object where to store the result
  3159. * @returns the current Vector4
  3160. */
  3161. negateToRef(result: Vector4): Vector4;
  3162. /**
  3163. * Multiplies the current Vector4 coordinates by scale (float).
  3164. * @param scale the number to scale with
  3165. * @returns the updated Vector4.
  3166. */
  3167. scaleInPlace(scale: number): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3170. * @param scale the number to scale with
  3171. * @returns a new vector with the result
  3172. */
  3173. scale(scale: number): Vector4;
  3174. /**
  3175. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3176. * @param scale the number to scale with
  3177. * @param result a vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. scaleToRef(scale: number, result: Vector4): Vector4;
  3181. /**
  3182. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3183. * @param scale defines the scale factor
  3184. * @param result defines the Vector4 object where to store the result
  3185. * @returns the unmodified current Vector4
  3186. */
  3187. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3188. /**
  3189. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3190. * @param otherVector the vector to compare against
  3191. * @returns true if they are equal
  3192. */
  3193. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3194. /**
  3195. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3196. * @param otherVector vector to compare against
  3197. * @param epsilon (Default: very small number)
  3198. * @returns true if they are equal
  3199. */
  3200. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3201. /**
  3202. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3203. * @param x x value to compare against
  3204. * @param y y value to compare against
  3205. * @param z z value to compare against
  3206. * @param w w value to compare against
  3207. * @returns true if equal
  3208. */
  3209. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3210. /**
  3211. * Multiplies in place the current Vector4 by the given one.
  3212. * @param otherVector vector to multiple with
  3213. * @returns the updated Vector4.
  3214. */
  3215. multiplyInPlace(otherVector: Vector4): Vector4;
  3216. /**
  3217. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3218. * @param otherVector vector to multiple with
  3219. * @returns resulting new vector
  3220. */
  3221. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3222. /**
  3223. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3224. * @param otherVector vector to multiple with
  3225. * @param result vector to store the result
  3226. * @returns the current Vector4.
  3227. */
  3228. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3229. /**
  3230. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3231. * @param x x value multiply with
  3232. * @param y y value multiply with
  3233. * @param z z value multiply with
  3234. * @param w w value multiply with
  3235. * @returns resulting new vector
  3236. */
  3237. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3240. * @param otherVector vector to devide with
  3241. * @returns resulting new vector
  3242. */
  3243. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3246. * @param otherVector vector to devide with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Divides the current Vector3 coordinates by the given ones.
  3253. * @param otherVector vector to devide with
  3254. * @returns the updated Vector3.
  3255. */
  3256. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3257. /**
  3258. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3259. * @param other defines the second operand
  3260. * @returns the current updated Vector4
  3261. */
  3262. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3265. * @param other defines the second operand
  3266. * @returns the current updated Vector4
  3267. */
  3268. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Gets a new Vector4 from current Vector4 floored values
  3271. * @returns a new Vector4
  3272. */
  3273. floor(): Vector4;
  3274. /**
  3275. * Gets a new Vector4 from current Vector3 floored values
  3276. * @returns a new Vector4
  3277. */
  3278. fract(): Vector4;
  3279. /**
  3280. * Returns the Vector4 length (float).
  3281. * @returns the length
  3282. */
  3283. length(): number;
  3284. /**
  3285. * Returns the Vector4 squared length (float).
  3286. * @returns the length squared
  3287. */
  3288. lengthSquared(): number;
  3289. /**
  3290. * Normalizes in place the Vector4.
  3291. * @returns the updated Vector4.
  3292. */
  3293. normalize(): Vector4;
  3294. /**
  3295. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3296. * @returns this converted to a new vector3
  3297. */
  3298. toVector3(): Vector3;
  3299. /**
  3300. * Returns a new Vector4 copied from the current one.
  3301. * @returns the new cloned vector
  3302. */
  3303. clone(): Vector4;
  3304. /**
  3305. * Updates the current Vector4 with the given one coordinates.
  3306. * @param source the source vector to copy from
  3307. * @returns the updated Vector4.
  3308. */
  3309. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3310. /**
  3311. * Updates the current Vector4 coordinates with the given floats.
  3312. * @param x float to copy from
  3313. * @param y float to copy from
  3314. * @param z float to copy from
  3315. * @param w float to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to set from
  3322. * @param y float to set from
  3323. * @param z float to set from
  3324. * @param w float to set from
  3325. * @returns the updated Vector4.
  3326. */
  3327. set(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Copies the given float to the current Vector3 coordinates
  3330. * @param v defines the x, y, z and w coordinates of the operand
  3331. * @returns the current updated Vector3
  3332. */
  3333. setAll(v: number): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set from the starting index of the given array.
  3336. * @param array the array to pull values from
  3337. * @param offset the offset into the array to start at
  3338. * @returns the new vector
  3339. */
  3340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3341. /**
  3342. * Updates the given vector "result" from the starting index of the given array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @param result the vector to store the result in
  3346. */
  3347. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3348. /**
  3349. * Updates the given vector "result" from the starting index of the given Float32Array.
  3350. * @param array the array to pull values from
  3351. * @param offset the offset into the array to start at
  3352. * @param result the vector to store the result in
  3353. */
  3354. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3355. /**
  3356. * Updates the given vector "result" coordinates from the given floats.
  3357. * @param x float to set from
  3358. * @param y float to set from
  3359. * @param z float to set from
  3360. * @param w float to set from
  3361. * @param result the vector to the floats in
  3362. */
  3363. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3364. /**
  3365. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3366. * @returns the new vector
  3367. */
  3368. static Zero(): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3371. * @returns the new vector
  3372. */
  3373. static One(): Vector4;
  3374. /**
  3375. * Returns a new normalized Vector4 from the given one.
  3376. * @param vector the vector to normalize
  3377. * @returns the vector
  3378. */
  3379. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3380. /**
  3381. * Updates the given vector "result" from the normalization of the given one.
  3382. * @param vector the vector to normalize
  3383. * @param result the vector to store the result in
  3384. */
  3385. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3386. /**
  3387. * Returns a vector with the minimum values from the left and right vectors
  3388. * @param left left vector to minimize
  3389. * @param right right vector to minimize
  3390. * @returns a new vector with the minimum of the left and right vector values
  3391. */
  3392. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Returns a vector with the maximum values from the left and right vectors
  3395. * @param left left vector to maximize
  3396. * @param right right vector to maximize
  3397. * @returns a new vector with the maximum of the left and right vector values
  3398. */
  3399. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3400. /**
  3401. * Returns the distance (float) between the vectors "value1" and "value2".
  3402. * @param value1 value to calulate the distance between
  3403. * @param value2 value to calulate the distance between
  3404. * @return the distance between the two vectors
  3405. */
  3406. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3407. /**
  3408. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the distance between
  3410. * @param value2 value to calulate the distance between
  3411. * @return the distance between the two vectors squared
  3412. */
  3413. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3414. /**
  3415. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3416. * @param value1 value to calulate the center between
  3417. * @param value2 value to calulate the center between
  3418. * @return the center between the two vectors
  3419. */
  3420. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3423. * This methods computes transformed normalized direction vectors only.
  3424. * @param vector the vector to transform
  3425. * @param transformation the transformation matrix to apply
  3426. * @returns the new vector
  3427. */
  3428. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3429. /**
  3430. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3431. * This methods computes transformed normalized direction vectors only.
  3432. * @param vector the vector to transform
  3433. * @param transformation the transformation matrix to apply
  3434. * @param result the vector to store the result in
  3435. */
  3436. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3437. /**
  3438. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3439. * This methods computes transformed normalized direction vectors only.
  3440. * @param x value to transform
  3441. * @param y value to transform
  3442. * @param z value to transform
  3443. * @param w value to transform
  3444. * @param transformation the transformation matrix to apply
  3445. * @param result the vector to store the results in
  3446. */
  3447. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3448. /**
  3449. * Creates a new Vector4 from a Vector3
  3450. * @param source defines the source data
  3451. * @param w defines the 4th component (default is 0)
  3452. * @returns a new Vector4
  3453. */
  3454. static FromVector3(source: Vector3, w?: number): Vector4;
  3455. }
  3456. /**
  3457. * Class used to store quaternion data
  3458. * @see https://en.wikipedia.org/wiki/Quaternion
  3459. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3460. */
  3461. export class Quaternion {
  3462. /** defines the first component (0 by default) */
  3463. x: number;
  3464. /** defines the second component (0 by default) */
  3465. y: number;
  3466. /** defines the third component (0 by default) */
  3467. z: number;
  3468. /** defines the fourth component (1.0 by default) */
  3469. w: number;
  3470. /**
  3471. * Creates a new Quaternion from the given floats
  3472. * @param x defines the first component (0 by default)
  3473. * @param y defines the second component (0 by default)
  3474. * @param z defines the third component (0 by default)
  3475. * @param w defines the fourth component (1.0 by default)
  3476. */
  3477. constructor(
  3478. /** defines the first component (0 by default) */
  3479. x?: number,
  3480. /** defines the second component (0 by default) */
  3481. y?: number,
  3482. /** defines the third component (0 by default) */
  3483. z?: number,
  3484. /** defines the fourth component (1.0 by default) */
  3485. w?: number);
  3486. /**
  3487. * Gets a string representation for the current quaternion
  3488. * @returns a string with the Quaternion coordinates
  3489. */
  3490. toString(): string;
  3491. /**
  3492. * Gets the class name of the quaternion
  3493. * @returns the string "Quaternion"
  3494. */
  3495. getClassName(): string;
  3496. /**
  3497. * Gets a hash code for this quaternion
  3498. * @returns the quaternion hash code
  3499. */
  3500. getHashCode(): number;
  3501. /**
  3502. * Copy the quaternion to an array
  3503. * @returns a new array populated with 4 elements from the quaternion coordinates
  3504. */
  3505. asArray(): number[];
  3506. /**
  3507. * Check if two quaternions are equals
  3508. * @param otherQuaternion defines the second operand
  3509. * @return true if the current quaternion and the given one coordinates are strictly equals
  3510. */
  3511. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3512. /**
  3513. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3514. * @param otherQuaternion defines the other quaternion
  3515. * @param epsilon defines the minimal distance to consider equality
  3516. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3517. */
  3518. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3519. /**
  3520. * Clone the current quaternion
  3521. * @returns a new quaternion copied from the current one
  3522. */
  3523. clone(): Quaternion;
  3524. /**
  3525. * Copy a quaternion to the current one
  3526. * @param other defines the other quaternion
  3527. * @returns the updated current quaternion
  3528. */
  3529. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3530. /**
  3531. * Updates the current quaternion with the given float coordinates
  3532. * @param x defines the x coordinate
  3533. * @param y defines the y coordinate
  3534. * @param z defines the z coordinate
  3535. * @param w defines the w coordinate
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3539. /**
  3540. * Updates the current quaternion from the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. set(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Adds two quaternions
  3550. * @param other defines the second operand
  3551. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3552. */
  3553. add(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Add a quaternion to the current one
  3556. * @param other defines the quaternion to add
  3557. * @returns the current quaternion
  3558. */
  3559. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3560. /**
  3561. * Subtract two quaternions
  3562. * @param other defines the second operand
  3563. * @returns a new quaternion as the subtraction result of the given one from the current one
  3564. */
  3565. subtract(other: Quaternion): Quaternion;
  3566. /**
  3567. * Multiplies the current quaternion by a scale factor
  3568. * @param value defines the scale factor
  3569. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3570. */
  3571. scale(value: number): Quaternion;
  3572. /**
  3573. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3574. * @param scale defines the scale factor
  3575. * @param result defines the Quaternion object where to store the result
  3576. * @returns the unmodified current quaternion
  3577. */
  3578. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3579. /**
  3580. * Multiplies in place the current quaternion by a scale factor
  3581. * @param value defines the scale factor
  3582. * @returns the current modified quaternion
  3583. */
  3584. scaleInPlace(value: number): Quaternion;
  3585. /**
  3586. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3587. * @param scale defines the scale factor
  3588. * @param result defines the Quaternion object where to store the result
  3589. * @returns the unmodified current quaternion
  3590. */
  3591. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3592. /**
  3593. * Multiplies two quaternions
  3594. * @param q1 defines the second operand
  3595. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3596. */
  3597. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3598. /**
  3599. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3600. * @param q1 defines the second operand
  3601. * @param result defines the target quaternion
  3602. * @returns the current quaternion
  3603. */
  3604. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3605. /**
  3606. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3607. * @param q1 defines the second operand
  3608. * @returns the currentupdated quaternion
  3609. */
  3610. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3611. /**
  3612. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3613. * @param ref defines the target quaternion
  3614. * @returns the current quaternion
  3615. */
  3616. conjugateToRef(ref: Quaternion): Quaternion;
  3617. /**
  3618. * Conjugates in place (1-q) the current quaternion
  3619. * @returns the current updated quaternion
  3620. */
  3621. conjugateInPlace(): Quaternion;
  3622. /**
  3623. * Conjugates in place (1-q) the current quaternion
  3624. * @returns a new quaternion
  3625. */
  3626. conjugate(): Quaternion;
  3627. /**
  3628. * Gets length of current quaternion
  3629. * @returns the quaternion length (float)
  3630. */
  3631. length(): number;
  3632. /**
  3633. * Normalize in place the current quaternion
  3634. * @returns the current updated quaternion
  3635. */
  3636. normalize(): Quaternion;
  3637. /**
  3638. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3639. * @param order is a reserved parameter and is ignore for now
  3640. * @returns a new Vector3 containing the Euler angles
  3641. */
  3642. toEulerAngles(order?: string): Vector3;
  3643. /**
  3644. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3645. * @param result defines the vector which will be filled with the Euler angles
  3646. * @param order is a reserved parameter and is ignore for now
  3647. * @returns the current unchanged quaternion
  3648. */
  3649. toEulerAnglesToRef(result: Vector3): Quaternion;
  3650. /**
  3651. * Updates the given rotation matrix with the current quaternion values
  3652. * @param result defines the target matrix
  3653. * @returns the current unchanged quaternion
  3654. */
  3655. toRotationMatrix(result: Matrix): Quaternion;
  3656. /**
  3657. * Updates the current quaternion from the given rotation matrix values
  3658. * @param matrix defines the source matrix
  3659. * @returns the current updated quaternion
  3660. */
  3661. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3662. /**
  3663. * Creates a new quaternion from a rotation matrix
  3664. * @param matrix defines the source matrix
  3665. * @returns a new quaternion created from the given rotation matrix values
  3666. */
  3667. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3668. /**
  3669. * Updates the given quaternion with the given rotation matrix values
  3670. * @param matrix defines the source matrix
  3671. * @param result defines the target quaternion
  3672. */
  3673. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3674. /**
  3675. * Returns the dot product (float) between the quaternions "left" and "right"
  3676. * @param left defines the left operand
  3677. * @param right defines the right operand
  3678. * @returns the dot product
  3679. */
  3680. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3681. /**
  3682. * Checks if the two quaternions are close to each other
  3683. * @param quat0 defines the first quaternion to check
  3684. * @param quat1 defines the second quaternion to check
  3685. * @returns true if the two quaternions are close to each other
  3686. */
  3687. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3688. /**
  3689. * Creates an empty quaternion
  3690. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3691. */
  3692. static Zero(): Quaternion;
  3693. /**
  3694. * Inverse a given quaternion
  3695. * @param q defines the source quaternion
  3696. * @returns a new quaternion as the inverted current quaternion
  3697. */
  3698. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Inverse a given quaternion
  3701. * @param q defines the source quaternion
  3702. * @param result the quaternion the result will be stored in
  3703. * @returns the result quaternion
  3704. */
  3705. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3706. /**
  3707. * Creates an identity quaternion
  3708. * @returns the identity quaternion
  3709. */
  3710. static Identity(): Quaternion;
  3711. /**
  3712. * Gets a boolean indicating if the given quaternion is identity
  3713. * @param quaternion defines the quaternion to check
  3714. * @returns true if the quaternion is identity
  3715. */
  3716. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3717. /**
  3718. * Creates a quaternion from a rotation around an axis
  3719. * @param axis defines the axis to use
  3720. * @param angle defines the angle to use
  3721. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3722. */
  3723. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3724. /**
  3725. * Creates a rotation around an axis and stores it into the given quaternion
  3726. * @param axis defines the axis to use
  3727. * @param angle defines the angle to use
  3728. * @param result defines the target quaternion
  3729. * @returns the target quaternion
  3730. */
  3731. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3732. /**
  3733. * Creates a new quaternion from data stored into an array
  3734. * @param array defines the data source
  3735. * @param offset defines the offset in the source array where the data starts
  3736. * @returns a new quaternion
  3737. */
  3738. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3739. /**
  3740. * Updates the given quaternion "result" from the starting index of the given array.
  3741. * @param array the array to pull values from
  3742. * @param offset the offset into the array to start at
  3743. * @param result the quaternion to store the result in
  3744. */
  3745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3746. /**
  3747. * Create a quaternion from Euler rotation angles
  3748. * @param x Pitch
  3749. * @param y Yaw
  3750. * @param z Roll
  3751. * @returns the new Quaternion
  3752. */
  3753. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3754. /**
  3755. * Updates a quaternion from Euler rotation angles
  3756. * @param x Pitch
  3757. * @param y Yaw
  3758. * @param z Roll
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation vector
  3765. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation vector
  3771. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3772. * @param result the quaternion to store the result
  3773. * @returns the updated quaternion
  3774. */
  3775. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3776. /**
  3777. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3778. * @param yaw defines the rotation around Y axis
  3779. * @param pitch defines the rotation around X axis
  3780. * @param roll defines the rotation around Z axis
  3781. * @returns the new quaternion
  3782. */
  3783. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3784. /**
  3785. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3786. * @param yaw defines the rotation around Y axis
  3787. * @param pitch defines the rotation around X axis
  3788. * @param roll defines the rotation around Z axis
  3789. * @param result defines the target quaternion
  3790. */
  3791. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3792. /**
  3793. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3794. * @param alpha defines the rotation around first axis
  3795. * @param beta defines the rotation around second axis
  3796. * @param gamma defines the rotation around third axis
  3797. * @returns the new quaternion
  3798. */
  3799. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3800. /**
  3801. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3802. * @param alpha defines the rotation around first axis
  3803. * @param beta defines the rotation around second axis
  3804. * @param gamma defines the rotation around third axis
  3805. * @param result defines the target quaternion
  3806. */
  3807. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3808. /**
  3809. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3810. * @param axis1 defines the first axis
  3811. * @param axis2 defines the second axis
  3812. * @param axis3 defines the third axis
  3813. * @returns the new quaternion
  3814. */
  3815. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3816. /**
  3817. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3818. * @param axis1 defines the first axis
  3819. * @param axis2 defines the second axis
  3820. * @param axis3 defines the third axis
  3821. * @param ref defines the target quaternion
  3822. */
  3823. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3824. /**
  3825. * Interpolates between two quaternions
  3826. * @param left defines first quaternion
  3827. * @param right defines second quaternion
  3828. * @param amount defines the gradient to use
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. /**
  3833. * Interpolates between two quaternions and stores it into a target quaternion
  3834. * @param left defines first quaternion
  3835. * @param right defines second quaternion
  3836. * @param amount defines the gradient to use
  3837. * @param result defines the target quaternion
  3838. */
  3839. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3840. /**
  3841. * Interpolate between two quaternions using Hermite interpolation
  3842. * @param value1 defines first quaternion
  3843. * @param tangent1 defines the incoming tangent
  3844. * @param value2 defines second quaternion
  3845. * @param tangent2 defines the outgoing tangent
  3846. * @param amount defines the target quaternion
  3847. * @returns the new interpolated quaternion
  3848. */
  3849. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3850. }
  3851. /**
  3852. * Class used to store matrix data (4x4)
  3853. */
  3854. export class Matrix {
  3855. private static _updateFlagSeed;
  3856. private static _identityReadOnly;
  3857. private _isIdentity;
  3858. private _isIdentityDirty;
  3859. private _isIdentity3x2;
  3860. private _isIdentity3x2Dirty;
  3861. /**
  3862. * Gets the update flag of the matrix which is an unique number for the matrix.
  3863. * It will be incremented every time the matrix data change.
  3864. * You can use it to speed the comparison between two versions of the same matrix.
  3865. */
  3866. updateFlag: number;
  3867. private readonly _m;
  3868. /**
  3869. * Gets the internal data of the matrix
  3870. */
  3871. get m(): DeepImmutable<Float32Array>;
  3872. /** @hidden */
  3873. _markAsUpdated(): void;
  3874. /** @hidden */
  3875. private _updateIdentityStatus;
  3876. /**
  3877. * Creates an empty matrix (filled with zeros)
  3878. */
  3879. constructor();
  3880. /**
  3881. * Check if the current matrix is identity
  3882. * @returns true is the matrix is the identity matrix
  3883. */
  3884. isIdentity(): boolean;
  3885. /**
  3886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3887. * @returns true is the matrix is the identity matrix
  3888. */
  3889. isIdentityAs3x2(): boolean;
  3890. /**
  3891. * Gets the determinant of the matrix
  3892. * @returns the matrix determinant
  3893. */
  3894. determinant(): number;
  3895. /**
  3896. * Returns the matrix as a Float32Array
  3897. * @returns the matrix underlying array
  3898. */
  3899. toArray(): DeepImmutable<Float32Array>;
  3900. /**
  3901. * Returns the matrix as a Float32Array
  3902. * @returns the matrix underlying array.
  3903. */
  3904. asArray(): DeepImmutable<Float32Array>;
  3905. /**
  3906. * Inverts the current matrix in place
  3907. * @returns the current inverted matrix
  3908. */
  3909. invert(): Matrix;
  3910. /**
  3911. * Sets all the matrix elements to zero
  3912. * @returns the current matrix
  3913. */
  3914. reset(): Matrix;
  3915. /**
  3916. * Adds the current matrix with a second one
  3917. * @param other defines the matrix to add
  3918. * @returns a new matrix as the addition of the current matrix and the given one
  3919. */
  3920. add(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3923. * @param other defines the matrix to add
  3924. * @param result defines the target matrix
  3925. * @returns the current matrix
  3926. */
  3927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3928. /**
  3929. * Adds in place the given matrix to the current matrix
  3930. * @param other defines the second operand
  3931. * @returns the current updated matrix
  3932. */
  3933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3934. /**
  3935. * Sets the given matrix to the current inverted Matrix
  3936. * @param other defines the target matrix
  3937. * @returns the unmodified current matrix
  3938. */
  3939. invertToRef(other: Matrix): Matrix;
  3940. /**
  3941. * add a value at the specified position in the current Matrix
  3942. * @param index the index of the value within the matrix. between 0 and 15.
  3943. * @param value the value to be added
  3944. * @returns the current updated matrix
  3945. */
  3946. addAtIndex(index: number, value: number): Matrix;
  3947. /**
  3948. * mutiply the specified position in the current Matrix by a value
  3949. * @param index the index of the value within the matrix. between 0 and 15.
  3950. * @param value the value to be added
  3951. * @returns the current updated matrix
  3952. */
  3953. multiplyAtIndex(index: number, value: number): Matrix;
  3954. /**
  3955. * Inserts the translation vector (using 3 floats) in the current matrix
  3956. * @param x defines the 1st component of the translation
  3957. * @param y defines the 2nd component of the translation
  3958. * @param z defines the 3rd component of the translation
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3962. /**
  3963. * Adds the translation vector (using 3 floats) in the current matrix
  3964. * @param x defines the 1st component of the translation
  3965. * @param y defines the 2nd component of the translation
  3966. * @param z defines the 3rd component of the translation
  3967. * @returns the current updated matrix
  3968. */
  3969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3970. /**
  3971. * Inserts the translation vector in the current matrix
  3972. * @param vector3 defines the translation to insert
  3973. * @returns the current updated matrix
  3974. */
  3975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3976. /**
  3977. * Gets the translation value of the current matrix
  3978. * @returns a new Vector3 as the extracted translation from the matrix
  3979. */
  3980. getTranslation(): Vector3;
  3981. /**
  3982. * Fill a Vector3 with the extracted translation from the matrix
  3983. * @param result defines the Vector3 where to store the translation
  3984. * @returns the current matrix
  3985. */
  3986. getTranslationToRef(result: Vector3): Matrix;
  3987. /**
  3988. * Remove rotation and scaling part from the matrix
  3989. * @returns the updated matrix
  3990. */
  3991. removeRotationAndScaling(): Matrix;
  3992. /**
  3993. * Multiply two matrices
  3994. * @param other defines the second operand
  3995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3996. */
  3997. multiply(other: DeepImmutable<Matrix>): Matrix;
  3998. /**
  3999. * Copy the current matrix from the given one
  4000. * @param other defines the source matrix
  4001. * @returns the current updated matrix
  4002. */
  4003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Populates the given array from the starting index with the current matrix values
  4006. * @param array defines the target array
  4007. * @param offset defines the offset in the target array where to start storing values
  4008. * @returns the current matrix
  4009. */
  4010. copyToArray(array: Float32Array, offset?: number): Matrix;
  4011. /**
  4012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4013. * @param other defines the second operand
  4014. * @param result defines the matrix where to store the multiplication
  4015. * @returns the current matrix
  4016. */
  4017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4018. /**
  4019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4020. * @param other defines the second operand
  4021. * @param result defines the array where to store the multiplication
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4026. /**
  4027. * Check equality between this matrix and a second one
  4028. * @param value defines the second matrix to compare
  4029. * @returns true is the current matrix and the given one values are strictly equal
  4030. */
  4031. equals(value: DeepImmutable<Matrix>): boolean;
  4032. /**
  4033. * Clone the current matrix
  4034. * @returns a new matrix from the current matrix
  4035. */
  4036. clone(): Matrix;
  4037. /**
  4038. * Returns the name of the current matrix class
  4039. * @returns the string "Matrix"
  4040. */
  4041. getClassName(): string;
  4042. /**
  4043. * Gets the hash code of the current matrix
  4044. * @returns the hash code
  4045. */
  4046. getHashCode(): number;
  4047. /**
  4048. * Decomposes the current Matrix into a translation, rotation and scaling components
  4049. * @param scale defines the scale vector3 given as a reference to update
  4050. * @param rotation defines the rotation quaternion given as a reference to update
  4051. * @param translation defines the translation vector3 given as a reference to update
  4052. * @returns true if operation was successful
  4053. */
  4054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4055. /**
  4056. * Gets specific row of the matrix
  4057. * @param index defines the number of the row to get
  4058. * @returns the index-th row of the current matrix as a new Vector4
  4059. */
  4060. getRow(index: number): Nullable<Vector4>;
  4061. /**
  4062. * Sets the index-th row of the current matrix to the vector4 values
  4063. * @param index defines the number of the row to set
  4064. * @param row defines the target vector4
  4065. * @returns the updated current matrix
  4066. */
  4067. setRow(index: number, row: Vector4): Matrix;
  4068. /**
  4069. * Compute the transpose of the matrix
  4070. * @returns the new transposed matrix
  4071. */
  4072. transpose(): Matrix;
  4073. /**
  4074. * Compute the transpose of the matrix and store it in a given matrix
  4075. * @param result defines the target matrix
  4076. * @returns the current matrix
  4077. */
  4078. transposeToRef(result: Matrix): Matrix;
  4079. /**
  4080. * Sets the index-th row of the current matrix with the given 4 x float values
  4081. * @param index defines the row index
  4082. * @param x defines the x component to set
  4083. * @param y defines the y component to set
  4084. * @param z defines the z component to set
  4085. * @param w defines the w component to set
  4086. * @returns the updated current matrix
  4087. */
  4088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4089. /**
  4090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4091. * @param scale defines the scale factor
  4092. * @returns a new matrix
  4093. */
  4094. scale(scale: number): Matrix;
  4095. /**
  4096. * Scale the current matrix values by a factor to a given result matrix
  4097. * @param scale defines the scale factor
  4098. * @param result defines the matrix to store the result
  4099. * @returns the current matrix
  4100. */
  4101. scaleToRef(scale: number, result: Matrix): Matrix;
  4102. /**
  4103. * Scale the current matrix values by a factor and add the result to a given matrix
  4104. * @param scale defines the scale factor
  4105. * @param result defines the Matrix to store the result
  4106. * @returns the current matrix
  4107. */
  4108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4109. /**
  4110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4111. * @param ref matrix to store the result
  4112. */
  4113. toNormalMatrix(ref: Matrix): void;
  4114. /**
  4115. * Gets only rotation part of the current matrix
  4116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4117. */
  4118. getRotationMatrix(): Matrix;
  4119. /**
  4120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4121. * @param result defines the target matrix to store data to
  4122. * @returns the current matrix
  4123. */
  4124. getRotationMatrixToRef(result: Matrix): Matrix;
  4125. /**
  4126. * Toggles model matrix from being right handed to left handed in place and vice versa
  4127. */
  4128. toggleModelMatrixHandInPlace(): void;
  4129. /**
  4130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleProjectionMatrixHandInPlace(): void;
  4133. /**
  4134. * Creates a matrix from an array
  4135. * @param array defines the source array
  4136. * @param offset defines an offset in the source array
  4137. * @returns a new Matrix set from the starting index of the given array
  4138. */
  4139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4140. /**
  4141. * Copy the content of an array into a given matrix
  4142. * @param array defines the source array
  4143. * @param offset defines an offset in the source array
  4144. * @param result defines the target matrix
  4145. */
  4146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4147. /**
  4148. * Stores an array into a matrix after having multiplied each component by a given factor
  4149. * @param array defines the source array
  4150. * @param offset defines the offset in the source array
  4151. * @param scale defines the scaling factor
  4152. * @param result defines the target matrix
  4153. */
  4154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4155. /**
  4156. * Gets an identity matrix that must not be updated
  4157. */
  4158. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4159. /**
  4160. * Stores a list of values (16) inside a given matrix
  4161. * @param initialM11 defines 1st value of 1st row
  4162. * @param initialM12 defines 2nd value of 1st row
  4163. * @param initialM13 defines 3rd value of 1st row
  4164. * @param initialM14 defines 4th value of 1st row
  4165. * @param initialM21 defines 1st value of 2nd row
  4166. * @param initialM22 defines 2nd value of 2nd row
  4167. * @param initialM23 defines 3rd value of 2nd row
  4168. * @param initialM24 defines 4th value of 2nd row
  4169. * @param initialM31 defines 1st value of 3rd row
  4170. * @param initialM32 defines 2nd value of 3rd row
  4171. * @param initialM33 defines 3rd value of 3rd row
  4172. * @param initialM34 defines 4th value of 3rd row
  4173. * @param initialM41 defines 1st value of 4th row
  4174. * @param initialM42 defines 2nd value of 4th row
  4175. * @param initialM43 defines 3rd value of 4th row
  4176. * @param initialM44 defines 4th value of 4th row
  4177. * @param result defines the target matrix
  4178. */
  4179. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4180. /**
  4181. * Creates new matrix from a list of values (16)
  4182. * @param initialM11 defines 1st value of 1st row
  4183. * @param initialM12 defines 2nd value of 1st row
  4184. * @param initialM13 defines 3rd value of 1st row
  4185. * @param initialM14 defines 4th value of 1st row
  4186. * @param initialM21 defines 1st value of 2nd row
  4187. * @param initialM22 defines 2nd value of 2nd row
  4188. * @param initialM23 defines 3rd value of 2nd row
  4189. * @param initialM24 defines 4th value of 2nd row
  4190. * @param initialM31 defines 1st value of 3rd row
  4191. * @param initialM32 defines 2nd value of 3rd row
  4192. * @param initialM33 defines 3rd value of 3rd row
  4193. * @param initialM34 defines 4th value of 3rd row
  4194. * @param initialM41 defines 1st value of 4th row
  4195. * @param initialM42 defines 2nd value of 4th row
  4196. * @param initialM43 defines 3rd value of 4th row
  4197. * @param initialM44 defines 4th value of 4th row
  4198. * @returns the new matrix
  4199. */
  4200. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4201. /**
  4202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4203. * @param scale defines the scale vector3
  4204. * @param rotation defines the rotation quaternion
  4205. * @param translation defines the translation vector3
  4206. * @returns a new matrix
  4207. */
  4208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4211. * @param scale defines the scale vector3
  4212. * @param rotation defines the rotation quaternion
  4213. * @param translation defines the translation vector3
  4214. * @param result defines the target matrix
  4215. */
  4216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4217. /**
  4218. * Creates a new identity matrix
  4219. * @returns a new identity matrix
  4220. */
  4221. static Identity(): Matrix;
  4222. /**
  4223. * Creates a new identity matrix and stores the result in a given matrix
  4224. * @param result defines the target matrix
  4225. */
  4226. static IdentityToRef(result: Matrix): void;
  4227. /**
  4228. * Creates a new zero matrix
  4229. * @returns a new zero matrix
  4230. */
  4231. static Zero(): Matrix;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the X axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationX(angle: number): Matrix;
  4238. /**
  4239. * Creates a new matrix as the invert of a given matrix
  4240. * @param source defines the source matrix
  4241. * @returns the new matrix
  4242. */
  4243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4246. * @param angle defines the angle (in radians) to use
  4247. * @param result defines the target matrix
  4248. */
  4249. static RotationXToRef(angle: number, result: Matrix): void;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Y axis
  4252. * @param angle defines the angle (in radians) to use
  4253. * @return the new matrix
  4254. */
  4255. static RotationY(angle: number): Matrix;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4258. * @param angle defines the angle (in radians) to use
  4259. * @param result defines the target matrix
  4260. */
  4261. static RotationYToRef(angle: number, result: Matrix): void;
  4262. /**
  4263. * Creates a new rotation matrix for "angle" radians around the Z axis
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationZ(angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationZToRef(angle: number, result: Matrix): void;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the given axis
  4276. * @param axis defines the axis to use
  4277. * @param angle defines the angle (in radians) to use
  4278. * @return the new matrix
  4279. */
  4280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4283. * @param axis defines the axis to use
  4284. * @param angle defines the angle (in radians) to use
  4285. * @param result defines the target matrix
  4286. */
  4287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4288. /**
  4289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4291. * @param from defines the vector to align
  4292. * @param to defines the vector to align to
  4293. * @param result defines the target matrix
  4294. */
  4295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4296. /**
  4297. * Creates a rotation matrix
  4298. * @param yaw defines the yaw angle in radians (Y axis)
  4299. * @param pitch defines the pitch angle in radians (X axis)
  4300. * @param roll defines the roll angle in radians (X axis)
  4301. * @returns the new rotation matrix
  4302. */
  4303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4304. /**
  4305. * Creates a rotation matrix and stores it in a given matrix
  4306. * @param yaw defines the yaw angle in radians (Y axis)
  4307. * @param pitch defines the pitch angle in radians (X axis)
  4308. * @param roll defines the roll angle in radians (X axis)
  4309. * @param result defines the target matrix
  4310. */
  4311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4312. /**
  4313. * Creates a scaling matrix
  4314. * @param x defines the scale factor on X axis
  4315. * @param y defines the scale factor on Y axis
  4316. * @param z defines the scale factor on Z axis
  4317. * @returns the new matrix
  4318. */
  4319. static Scaling(x: number, y: number, z: number): Matrix;
  4320. /**
  4321. * Creates a scaling matrix and stores it in a given matrix
  4322. * @param x defines the scale factor on X axis
  4323. * @param y defines the scale factor on Y axis
  4324. * @param z defines the scale factor on Z axis
  4325. * @param result defines the target matrix
  4326. */
  4327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4328. /**
  4329. * Creates a translation matrix
  4330. * @param x defines the translation on X axis
  4331. * @param y defines the translation on Y axis
  4332. * @param z defines the translationon Z axis
  4333. * @returns the new matrix
  4334. */
  4335. static Translation(x: number, y: number, z: number): Matrix;
  4336. /**
  4337. * Creates a translation matrix and stores it in a given matrix
  4338. * @param x defines the translation on X axis
  4339. * @param y defines the translation on Y axis
  4340. * @param z defines the translationon Z axis
  4341. * @param result defines the target matrix
  4342. */
  4343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4344. /**
  4345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4346. * @param startValue defines the start value
  4347. * @param endValue defines the end value
  4348. * @param gradient defines the gradient factor
  4349. * @returns the new matrix
  4350. */
  4351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4352. /**
  4353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4354. * @param startValue defines the start value
  4355. * @param endValue defines the end value
  4356. * @param gradient defines the gradient factor
  4357. * @param result defines the Matrix object where to store data
  4358. */
  4359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4360. /**
  4361. * Builds a new matrix whose values are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @returns the new matrix
  4369. */
  4370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Update a matrix to values which are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @param result defines the target matrix
  4380. */
  4381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4382. /**
  4383. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4384. * This function works in left handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4402. * This function works in right handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @returns the new matrix
  4407. */
  4408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4409. /**
  4410. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @param result defines the target matrix
  4416. */
  4417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param width defines the viewport width
  4421. * @param height defines the viewport height
  4422. * @param znear defines the near clip plane
  4423. * @param zfar defines the far clip plane
  4424. * @returns a new matrix as a left-handed orthographic projection matrix
  4425. */
  4426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4427. /**
  4428. * Store a left-handed orthographic projection to a given matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @param result defines the target matrix
  4434. */
  4435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4436. /**
  4437. * Create a left-handed orthographic projection matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @returns a new matrix as a left-handed orthographic projection matrix
  4445. */
  4446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4447. /**
  4448. * Stores a left-handed orthographic projection into a given matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @param result defines the target matrix
  4456. */
  4457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4458. /**
  4459. * Creates a right-handed orthographic projection matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed orthographic projection matrix
  4467. */
  4468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed orthographic projection into a given matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @param result defines the target matrix
  4478. */
  4479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4480. /**
  4481. * Creates a left-handed perspective projection matrix
  4482. * @param width defines the viewport width
  4483. * @param height defines the viewport height
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed perspective projection matrix
  4487. */
  4488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Stores a left-handed perspective projection into a given matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4506. */
  4507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4508. /**
  4509. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar not used as infinity is used as far clip
  4514. * @param result defines the target matrix
  4515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4516. */
  4517. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4518. /**
  4519. * Creates a right-handed perspective projection matrix
  4520. * @param fov defines the horizontal field of view
  4521. * @param aspect defines the aspect ratio
  4522. * @param znear defines the near clip plane
  4523. * @param zfar defines the far clip plane
  4524. * @returns a new matrix as a right-handed perspective projection matrix
  4525. */
  4526. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4527. /**
  4528. * Stores a right-handed perspective projection into a given matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Stores a right-handed perspective projection into a given matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar not used as infinity is used as far clip
  4543. * @param result defines the target matrix
  4544. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4545. */
  4546. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4547. /**
  4548. * Stores a perspective projection for WebVR info a given matrix
  4549. * @param fov defines the field of view
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4554. */
  4555. static PerspectiveFovWebVRToRef(fov: {
  4556. upDegrees: number;
  4557. downDegrees: number;
  4558. leftDegrees: number;
  4559. rightDegrees: number;
  4560. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4561. /**
  4562. * Computes a complete transformation matrix
  4563. * @param viewport defines the viewport to use
  4564. * @param world defines the world matrix
  4565. * @param view defines the view matrix
  4566. * @param projection defines the projection matrix
  4567. * @param zmin defines the near clip plane
  4568. * @param zmax defines the far clip plane
  4569. * @returns the transformation matrix
  4570. */
  4571. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4572. /**
  4573. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4574. * @param matrix defines the matrix to use
  4575. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4576. */
  4577. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4578. /**
  4579. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4580. * @param matrix defines the matrix to use
  4581. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4582. */
  4583. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4584. /**
  4585. * Compute the transpose of a given matrix
  4586. * @param matrix defines the matrix to transpose
  4587. * @returns the new matrix
  4588. */
  4589. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4590. /**
  4591. * Compute the transpose of a matrix and store it in a target matrix
  4592. * @param matrix defines the matrix to transpose
  4593. * @param result defines the target matrix
  4594. */
  4595. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4596. /**
  4597. * Computes a reflection matrix from a plane
  4598. * @param plane defines the reflection plane
  4599. * @returns a new matrix
  4600. */
  4601. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4602. /**
  4603. * Computes a reflection matrix from a plane
  4604. * @param plane defines the reflection plane
  4605. * @param result defines the target matrix
  4606. */
  4607. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4608. /**
  4609. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4610. * @param xaxis defines the value of the 1st axis
  4611. * @param yaxis defines the value of the 2nd axis
  4612. * @param zaxis defines the value of the 3rd axis
  4613. * @param result defines the target matrix
  4614. */
  4615. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4616. /**
  4617. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4618. * @param quat defines the quaternion to use
  4619. * @param result defines the target matrix
  4620. */
  4621. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4622. }
  4623. /**
  4624. * @hidden
  4625. */
  4626. export class TmpVectors {
  4627. static Vector2: Vector2[];
  4628. static Vector3: Vector3[];
  4629. static Vector4: Vector4[];
  4630. static Quaternion: Quaternion[];
  4631. static Matrix: Matrix[];
  4632. }
  4633. }
  4634. declare module BABYLON {
  4635. /**
  4636. * Defines potential orientation for back face culling
  4637. */
  4638. export enum Orientation {
  4639. /**
  4640. * Clockwise
  4641. */
  4642. CW = 0,
  4643. /** Counter clockwise */
  4644. CCW = 1
  4645. }
  4646. /** Class used to represent a Bezier curve */
  4647. export class BezierCurve {
  4648. /**
  4649. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4650. * @param t defines the time
  4651. * @param x1 defines the left coordinate on X axis
  4652. * @param y1 defines the left coordinate on Y axis
  4653. * @param x2 defines the right coordinate on X axis
  4654. * @param y2 defines the right coordinate on Y axis
  4655. * @returns the interpolated value
  4656. */
  4657. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4658. }
  4659. /**
  4660. * Defines angle representation
  4661. */
  4662. export class Angle {
  4663. private _radians;
  4664. /**
  4665. * Creates an Angle object of "radians" radians (float).
  4666. * @param radians the angle in radians
  4667. */
  4668. constructor(radians: number);
  4669. /**
  4670. * Get value in degrees
  4671. * @returns the Angle value in degrees (float)
  4672. */
  4673. degrees(): number;
  4674. /**
  4675. * Get value in radians
  4676. * @returns the Angle value in radians (float)
  4677. */
  4678. radians(): number;
  4679. /**
  4680. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4681. * @param a defines first vector
  4682. * @param b defines second vector
  4683. * @returns a new Angle
  4684. */
  4685. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4686. /**
  4687. * Gets a new Angle object from the given float in radians
  4688. * @param radians defines the angle value in radians
  4689. * @returns a new Angle
  4690. */
  4691. static FromRadians(radians: number): Angle;
  4692. /**
  4693. * Gets a new Angle object from the given float in degrees
  4694. * @param degrees defines the angle value in degrees
  4695. * @returns a new Angle
  4696. */
  4697. static FromDegrees(degrees: number): Angle;
  4698. }
  4699. /**
  4700. * This represents an arc in a 2d space.
  4701. */
  4702. export class Arc2 {
  4703. /** Defines the start point of the arc */
  4704. startPoint: Vector2;
  4705. /** Defines the mid point of the arc */
  4706. midPoint: Vector2;
  4707. /** Defines the end point of the arc */
  4708. endPoint: Vector2;
  4709. /**
  4710. * Defines the center point of the arc.
  4711. */
  4712. centerPoint: Vector2;
  4713. /**
  4714. * Defines the radius of the arc.
  4715. */
  4716. radius: number;
  4717. /**
  4718. * Defines the angle of the arc (from mid point to end point).
  4719. */
  4720. angle: Angle;
  4721. /**
  4722. * Defines the start angle of the arc (from start point to middle point).
  4723. */
  4724. startAngle: Angle;
  4725. /**
  4726. * Defines the orientation of the arc (clock wise/counter clock wise).
  4727. */
  4728. orientation: Orientation;
  4729. /**
  4730. * Creates an Arc object from the three given points : start, middle and end.
  4731. * @param startPoint Defines the start point of the arc
  4732. * @param midPoint Defines the midlle point of the arc
  4733. * @param endPoint Defines the end point of the arc
  4734. */
  4735. constructor(
  4736. /** Defines the start point of the arc */
  4737. startPoint: Vector2,
  4738. /** Defines the mid point of the arc */
  4739. midPoint: Vector2,
  4740. /** Defines the end point of the arc */
  4741. endPoint: Vector2);
  4742. }
  4743. /**
  4744. * Represents a 2D path made up of multiple 2D points
  4745. */
  4746. export class Path2 {
  4747. private _points;
  4748. private _length;
  4749. /**
  4750. * If the path start and end point are the same
  4751. */
  4752. closed: boolean;
  4753. /**
  4754. * Creates a Path2 object from the starting 2D coordinates x and y.
  4755. * @param x the starting points x value
  4756. * @param y the starting points y value
  4757. */
  4758. constructor(x: number, y: number);
  4759. /**
  4760. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4761. * @param x the added points x value
  4762. * @param y the added points y value
  4763. * @returns the updated Path2.
  4764. */
  4765. addLineTo(x: number, y: number): Path2;
  4766. /**
  4767. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4768. * @param midX middle point x value
  4769. * @param midY middle point y value
  4770. * @param endX end point x value
  4771. * @param endY end point y value
  4772. * @param numberOfSegments (default: 36)
  4773. * @returns the updated Path2.
  4774. */
  4775. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4776. /**
  4777. * Closes the Path2.
  4778. * @returns the Path2.
  4779. */
  4780. close(): Path2;
  4781. /**
  4782. * Gets the sum of the distance between each sequential point in the path
  4783. * @returns the Path2 total length (float).
  4784. */
  4785. length(): number;
  4786. /**
  4787. * Gets the points which construct the path
  4788. * @returns the Path2 internal array of points.
  4789. */
  4790. getPoints(): Vector2[];
  4791. /**
  4792. * Retreives the point at the distance aways from the starting point
  4793. * @param normalizedLengthPosition the length along the path to retreive the point from
  4794. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4795. */
  4796. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4797. /**
  4798. * Creates a new path starting from an x and y position
  4799. * @param x starting x value
  4800. * @param y starting y value
  4801. * @returns a new Path2 starting at the coordinates (x, y).
  4802. */
  4803. static StartingAt(x: number, y: number): Path2;
  4804. }
  4805. /**
  4806. * Represents a 3D path made up of multiple 3D points
  4807. */
  4808. export class Path3D {
  4809. /**
  4810. * an array of Vector3, the curve axis of the Path3D
  4811. */
  4812. path: Vector3[];
  4813. private _curve;
  4814. private _distances;
  4815. private _tangents;
  4816. private _normals;
  4817. private _binormals;
  4818. private _raw;
  4819. private _alignTangentsWithPath;
  4820. private readonly _pointAtData;
  4821. /**
  4822. * new Path3D(path, normal, raw)
  4823. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4824. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4825. * @param path an array of Vector3, the curve axis of the Path3D
  4826. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4827. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4829. */
  4830. constructor(
  4831. /**
  4832. * an array of Vector3, the curve axis of the Path3D
  4833. */
  4834. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4835. /**
  4836. * Returns the Path3D array of successive Vector3 designing its curve.
  4837. * @returns the Path3D array of successive Vector3 designing its curve.
  4838. */
  4839. getCurve(): Vector3[];
  4840. /**
  4841. * Returns the Path3D array of successive Vector3 designing its curve.
  4842. * @returns the Path3D array of successive Vector3 designing its curve.
  4843. */
  4844. getPoints(): Vector3[];
  4845. /**
  4846. * @returns the computed length (float) of the path.
  4847. */
  4848. length(): number;
  4849. /**
  4850. * Returns an array populated with tangent vectors on each Path3D curve point.
  4851. * @returns an array populated with tangent vectors on each Path3D curve point.
  4852. */
  4853. getTangents(): Vector3[];
  4854. /**
  4855. * Returns an array populated with normal vectors on each Path3D curve point.
  4856. * @returns an array populated with normal vectors on each Path3D curve point.
  4857. */
  4858. getNormals(): Vector3[];
  4859. /**
  4860. * Returns an array populated with binormal vectors on each Path3D curve point.
  4861. * @returns an array populated with binormal vectors on each Path3D curve point.
  4862. */
  4863. getBinormals(): Vector3[];
  4864. /**
  4865. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4866. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4867. */
  4868. getDistances(): number[];
  4869. /**
  4870. * Returns an interpolated point along this path
  4871. * @param position the position of the point along this path, from 0.0 to 1.0
  4872. * @returns a new Vector3 as the point
  4873. */
  4874. getPointAt(position: number): Vector3;
  4875. /**
  4876. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4879. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4880. */
  4881. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4886. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4887. */
  4888. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4889. /**
  4890. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4891. * @param position the position of the point along this path, from 0.0 to 1.0
  4892. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4893. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4894. */
  4895. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4896. /**
  4897. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4900. */
  4901. getDistanceAt(position: number): number;
  4902. /**
  4903. * Returns the array index of the previous point of an interpolated point along this path
  4904. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4905. * @returns the array index
  4906. */
  4907. getPreviousPointIndexAt(position: number): number;
  4908. /**
  4909. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4910. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4911. * @returns the sub position
  4912. */
  4913. getSubPositionAt(position: number): number;
  4914. /**
  4915. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4916. * @param target the vector of which to get the closest position to
  4917. * @returns the position of the closest virtual point on this path to the target vector
  4918. */
  4919. getClosestPositionTo(target: Vector3): number;
  4920. /**
  4921. * Returns a sub path (slice) of this path
  4922. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4923. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4924. * @returns a sub path (slice) of this path
  4925. */
  4926. slice(start?: number, end?: number): Path3D;
  4927. /**
  4928. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4929. * @param path path which all values are copied into the curves points
  4930. * @param firstNormal which should be projected onto the curve
  4931. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4932. * @returns the same object updated.
  4933. */
  4934. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4935. private _compute;
  4936. private _getFirstNonNullVector;
  4937. private _getLastNonNullVector;
  4938. private _normalVector;
  4939. /**
  4940. * Updates the point at data for an interpolated point along this curve
  4941. * @param position the position of the point along this curve, from 0.0 to 1.0
  4942. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4943. * @returns the (updated) point at data
  4944. */
  4945. private _updatePointAtData;
  4946. /**
  4947. * Updates the point at data from the specified parameters
  4948. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4949. * @param point the interpolated point
  4950. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4951. */
  4952. private _setPointAtData;
  4953. /**
  4954. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4955. */
  4956. private _updateInterpolationMatrix;
  4957. }
  4958. /**
  4959. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4960. * A Curve3 is designed from a series of successive Vector3.
  4961. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4962. */
  4963. export class Curve3 {
  4964. private _points;
  4965. private _length;
  4966. /**
  4967. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4969. * @param v1 (Vector3) the control point
  4970. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4971. * @param nbPoints (integer) the wanted number of points in the curve
  4972. * @returns the created Curve3
  4973. */
  4974. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4975. /**
  4976. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4978. * @param v1 (Vector3) the first control point
  4979. * @param v2 (Vector3) the second control point
  4980. * @param v3 (Vector3) the end point of the Cubic Bezier
  4981. * @param nbPoints (integer) the wanted number of points in the curve
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4985. /**
  4986. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4987. * @param p1 (Vector3) the origin point of the Hermite Spline
  4988. * @param t1 (Vector3) the tangent vector at the origin point
  4989. * @param p2 (Vector3) the end point of the Hermite Spline
  4990. * @param t2 (Vector3) the tangent vector at the end point
  4991. * @param nbPoints (integer) the wanted number of points in the curve
  4992. * @returns the created Curve3
  4993. */
  4994. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4995. /**
  4996. * Returns a Curve3 object along a CatmullRom Spline curve :
  4997. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4998. * @param nbPoints (integer) the wanted number of points between each curve control points
  4999. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5000. * @returns the created Curve3
  5001. */
  5002. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5003. /**
  5004. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5005. * A Curve3 is designed from a series of successive Vector3.
  5006. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5007. * @param points points which make up the curve
  5008. */
  5009. constructor(points: Vector3[]);
  5010. /**
  5011. * @returns the Curve3 stored array of successive Vector3
  5012. */
  5013. getPoints(): Vector3[];
  5014. /**
  5015. * @returns the computed length (float) of the curve.
  5016. */
  5017. length(): number;
  5018. /**
  5019. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5020. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5021. * curveA and curveB keep unchanged.
  5022. * @param curve the curve to continue from this curve
  5023. * @returns the newly constructed curve
  5024. */
  5025. continue(curve: DeepImmutable<Curve3>): Curve3;
  5026. private _computeLength;
  5027. }
  5028. }
  5029. declare module BABYLON {
  5030. /**
  5031. * This represents the main contract an easing function should follow.
  5032. * Easing functions are used throughout the animation system.
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export interface IEasingFunction {
  5036. /**
  5037. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5038. * of the easing function.
  5039. * The link below provides some of the most common examples of easing functions.
  5040. * @see https://easings.net/
  5041. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5042. * @returns the corresponding value on the curve defined by the easing function
  5043. */
  5044. ease(gradient: number): number;
  5045. }
  5046. /**
  5047. * Base class used for every default easing function.
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class EasingFunction implements IEasingFunction {
  5051. /**
  5052. * Interpolation follows the mathematical formula associated with the easing function.
  5053. */
  5054. static readonly EASINGMODE_EASEIN: number;
  5055. /**
  5056. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEOUT: number;
  5059. /**
  5060. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5061. */
  5062. static readonly EASINGMODE_EASEINOUT: number;
  5063. private _easingMode;
  5064. /**
  5065. * Sets the easing mode of the current function.
  5066. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5067. */
  5068. setEasingMode(easingMode: number): void;
  5069. /**
  5070. * Gets the current easing mode.
  5071. * @returns the easing mode
  5072. */
  5073. getEasingMode(): number;
  5074. /**
  5075. * @hidden
  5076. */
  5077. easeInCore(gradient: number): number;
  5078. /**
  5079. * Given an input gradient between 0 and 1, this returns the corresponding value
  5080. * of the easing function.
  5081. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5082. * @returns the corresponding value on the curve defined by the easing function
  5083. */
  5084. ease(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a circle shape (see link below).
  5088. * @see https://easings.net/#easeInCirc
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class CircleEase extends EasingFunction implements IEasingFunction {
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a ease back shape (see link below).
  5097. * @see https://easings.net/#easeInBack
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class BackEase extends EasingFunction implements IEasingFunction {
  5101. /** Defines the amplitude of the function */
  5102. amplitude: number;
  5103. /**
  5104. * Instantiates a back ease easing
  5105. * @see https://easings.net/#easeInBack
  5106. * @param amplitude Defines the amplitude of the function
  5107. */
  5108. constructor(
  5109. /** Defines the amplitude of the function */
  5110. amplitude?: number);
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a bouncing shape (see link below).
  5116. * @see https://easings.net/#easeInBounce
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BounceEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the number of bounces */
  5121. bounces: number;
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness: number;
  5124. /**
  5125. * Instantiates a bounce easing
  5126. * @see https://easings.net/#easeInBounce
  5127. * @param bounces Defines the number of bounces
  5128. * @param bounciness Defines the amplitude of the bounce
  5129. */
  5130. constructor(
  5131. /** Defines the number of bounces */
  5132. bounces?: number,
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness?: number);
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with a power of 3 shape (see link below).
  5140. * @see https://easings.net/#easeInCubic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class CubicEase extends EasingFunction implements IEasingFunction {
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with an elastic shape (see link below).
  5149. * @see https://easings.net/#easeInElastic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the number of oscillations*/
  5154. oscillations: number;
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness: number;
  5157. /**
  5158. * Instantiates an elastic easing function
  5159. * @see https://easings.net/#easeInElastic
  5160. * @param oscillations Defines the number of oscillations
  5161. * @param springiness Defines the amplitude of the oscillations
  5162. */
  5163. constructor(
  5164. /** Defines the number of oscillations*/
  5165. oscillations?: number,
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness?: number);
  5168. /** @hidden */
  5169. easeInCore(gradient: number): number;
  5170. }
  5171. /**
  5172. * Easing function with an exponential shape (see link below).
  5173. * @see https://easings.net/#easeInExpo
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5177. /** Defines the exponent of the function */
  5178. exponent: number;
  5179. /**
  5180. * Instantiates an exponential easing function
  5181. * @see https://easings.net/#easeInExpo
  5182. * @param exponent Defines the exponent of the function
  5183. */
  5184. constructor(
  5185. /** Defines the exponent of the function */
  5186. exponent?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with a power shape (see link below).
  5192. * @see https://easings.net/#easeInQuad
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class PowerEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the power of the function */
  5197. power: number;
  5198. /**
  5199. * Instantiates an power base easing function
  5200. * @see https://easings.net/#easeInQuad
  5201. * @param power Defines the power of the function
  5202. */
  5203. constructor(
  5204. /** Defines the power of the function */
  5205. power?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 2 shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 4 shape (see link below).
  5220. * @see https://easings.net/#easeInQuart
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 5 shape (see link below).
  5229. * @see https://easings.net/#easeInQuint
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a sin shape (see link below).
  5238. * @see https://easings.net/#easeInSine
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class SineEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a bezier shape (see link below).
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1: number;
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1: number;
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2: number;
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2: number;
  5259. /**
  5260. * Instantiates a bezier function
  5261. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5262. * @param x1 Defines the x component of the start tangent in the bezier curve
  5263. * @param y1 Defines the y component of the start tangent in the bezier curve
  5264. * @param x2 Defines the x component of the end tangent in the bezier curve
  5265. * @param y2 Defines the y component of the end tangent in the bezier curve
  5266. */
  5267. constructor(
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1?: number,
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1?: number,
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2?: number,
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /**
  5282. * Class used to hold a RBG color
  5283. */
  5284. export class Color3 {
  5285. /**
  5286. * Defines the red component (between 0 and 1, default is 0)
  5287. */
  5288. r: number;
  5289. /**
  5290. * Defines the green component (between 0 and 1, default is 0)
  5291. */
  5292. g: number;
  5293. /**
  5294. * Defines the blue component (between 0 and 1, default is 0)
  5295. */
  5296. b: number;
  5297. /**
  5298. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5299. * @param r defines the red component (between 0 and 1, default is 0)
  5300. * @param g defines the green component (between 0 and 1, default is 0)
  5301. * @param b defines the blue component (between 0 and 1, default is 0)
  5302. */
  5303. constructor(
  5304. /**
  5305. * Defines the red component (between 0 and 1, default is 0)
  5306. */
  5307. r?: number,
  5308. /**
  5309. * Defines the green component (between 0 and 1, default is 0)
  5310. */
  5311. g?: number,
  5312. /**
  5313. * Defines the blue component (between 0 and 1, default is 0)
  5314. */
  5315. b?: number);
  5316. /**
  5317. * Creates a string with the Color3 current values
  5318. * @returns the string representation of the Color3 object
  5319. */
  5320. toString(): string;
  5321. /**
  5322. * Returns the string "Color3"
  5323. * @returns "Color3"
  5324. */
  5325. getClassName(): string;
  5326. /**
  5327. * Compute the Color3 hash code
  5328. * @returns an unique number that can be used to hash Color3 objects
  5329. */
  5330. getHashCode(): number;
  5331. /**
  5332. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5333. * @param array defines the array where to store the r,g,b components
  5334. * @param index defines an optional index in the target array to define where to start storing values
  5335. * @returns the current Color3 object
  5336. */
  5337. toArray(array: FloatArray, index?: number): Color3;
  5338. /**
  5339. * Returns a new Color4 object from the current Color3 and the given alpha
  5340. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5341. * @returns a new Color4 object
  5342. */
  5343. toColor4(alpha?: number): Color4;
  5344. /**
  5345. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5346. * @returns the new array
  5347. */
  5348. asArray(): number[];
  5349. /**
  5350. * Returns the luminance value
  5351. * @returns a float value
  5352. */
  5353. toLuminance(): number;
  5354. /**
  5355. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3 object
  5358. */
  5359. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines the Color3 object where to store the result
  5364. * @returns the current Color3
  5365. */
  5366. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Determines equality between Color3 objects
  5369. * @param otherColor defines the second operand
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equals(otherColor: DeepImmutable<Color3>): boolean;
  5373. /**
  5374. * Determines equality between the current Color3 object and a set of r,b,g values
  5375. * @param r defines the red component to check
  5376. * @param g defines the green component to check
  5377. * @param b defines the blue component to check
  5378. * @returns true if the rgb values are equal to the given ones
  5379. */
  5380. equalsFloats(r: number, g: number, b: number): boolean;
  5381. /**
  5382. * Multiplies in place each rgb value by scale
  5383. * @param scale defines the scaling factor
  5384. * @returns the updated Color3
  5385. */
  5386. scale(scale: number): Color3;
  5387. /**
  5388. * Multiplies the rgb values by scale and stores the result into "result"
  5389. * @param scale defines the scaling factor
  5390. * @param result defines the Color3 object where to store the result
  5391. * @returns the unmodified current Color3
  5392. */
  5393. scaleToRef(scale: number, result: Color3): Color3;
  5394. /**
  5395. * Scale the current Color3 values by a factor and add the result to a given Color3
  5396. * @param scale defines the scale factor
  5397. * @param result defines color to store the result into
  5398. * @returns the unmodified current Color3
  5399. */
  5400. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5401. /**
  5402. * Clamps the rgb values by the min and max values and stores the result into "result"
  5403. * @param min defines minimum clamping value (default is 0)
  5404. * @param max defines maximum clamping value (default is 1)
  5405. * @param result defines color to store the result into
  5406. * @returns the original Color3
  5407. */
  5408. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5409. /**
  5410. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5411. * @param otherColor defines the second operand
  5412. * @returns the new Color3
  5413. */
  5414. add(otherColor: DeepImmutable<Color3>): Color3;
  5415. /**
  5416. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5417. * @param otherColor defines the second operand
  5418. * @param result defines Color3 object to store the result into
  5419. * @returns the unmodified current Color3
  5420. */
  5421. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5422. /**
  5423. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5424. * @param otherColor defines the second operand
  5425. * @returns the new Color3
  5426. */
  5427. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5430. * @param otherColor defines the second operand
  5431. * @param result defines Color3 object to store the result into
  5432. * @returns the unmodified current Color3
  5433. */
  5434. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5435. /**
  5436. * Copy the current object
  5437. * @returns a new Color3 copied the current one
  5438. */
  5439. clone(): Color3;
  5440. /**
  5441. * Copies the rgb values from the source in the current Color3
  5442. * @param source defines the source Color3 object
  5443. * @returns the updated Color3 object
  5444. */
  5445. copyFrom(source: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. copyFromFloats(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Updates the Color3 rgb values from the given floats
  5456. * @param r defines the red component to read from
  5457. * @param g defines the green component to read from
  5458. * @param b defines the blue component to read from
  5459. * @returns the current Color3 object
  5460. */
  5461. set(r: number, g: number, b: number): Color3;
  5462. /**
  5463. * Compute the Color3 hexadecimal code as a string
  5464. * @returns a string containing the hexadecimal representation of the Color3 object
  5465. */
  5466. toHexString(): string;
  5467. /**
  5468. * Computes a new Color3 converted from the current one to linear space
  5469. * @returns a new Color3 object
  5470. */
  5471. toLinearSpace(): Color3;
  5472. /**
  5473. * Converts current color in rgb space to HSV values
  5474. * @returns a new color3 representing the HSV values
  5475. */
  5476. toHSV(): Color3;
  5477. /**
  5478. * Converts current color in rgb space to HSV values
  5479. * @param result defines the Color3 where to store the HSV values
  5480. */
  5481. toHSVToRef(result: Color3): void;
  5482. /**
  5483. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5484. * @param convertedColor defines the Color3 object where to store the linear space version
  5485. * @returns the unmodified Color3
  5486. */
  5487. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5488. /**
  5489. * Computes a new Color3 converted from the current one to gamma space
  5490. * @returns a new Color3 object
  5491. */
  5492. toGammaSpace(): Color3;
  5493. /**
  5494. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the gamma space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5499. private static _BlackReadOnly;
  5500. /**
  5501. * Convert Hue, saturation and value to a Color3 (RGB)
  5502. * @param hue defines the hue
  5503. * @param saturation defines the saturation
  5504. * @param value defines the value
  5505. * @param result defines the Color3 where to store the RGB values
  5506. */
  5507. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5508. /**
  5509. * Creates a new Color3 from the string containing valid hexadecimal values
  5510. * @param hex defines a string containing valid hexadecimal values
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromHexString(hex: string): Color3;
  5514. /**
  5515. * Creates a new Color3 from the starting index of the given array
  5516. * @param array defines the source array
  5517. * @param offset defines an offset in the source array
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5521. /**
  5522. * Creates a new Color3 from integer values (< 256)
  5523. * @param r defines the red component to read from (value between 0 and 255)
  5524. * @param g defines the green component to read from (value between 0 and 255)
  5525. * @param b defines the blue component to read from (value between 0 and 255)
  5526. * @returns a new Color3 object
  5527. */
  5528. static FromInts(r: number, g: number, b: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param start defines the start Color3 value
  5532. * @param end defines the end Color3 value
  5533. * @param amount defines the gradient value between start and end
  5534. * @returns a new Color3 object
  5535. */
  5536. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5537. /**
  5538. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5539. * @param left defines the start value
  5540. * @param right defines the end value
  5541. * @param amount defines the gradient factor
  5542. * @param result defines the Color3 object where to store the result
  5543. */
  5544. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5545. /**
  5546. * Returns a Color3 value containing a red color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Red(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a green color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Green(): Color3;
  5555. /**
  5556. * Returns a Color3 value containing a blue color
  5557. * @returns a new Color3 object
  5558. */
  5559. static Blue(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a black color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Black(): Color3;
  5565. /**
  5566. * Gets a Color3 value containing a black color that must not be updated
  5567. */
  5568. static get BlackReadOnly(): DeepImmutable<Color3>;
  5569. /**
  5570. * Returns a Color3 value containing a white color
  5571. * @returns a new Color3 object
  5572. */
  5573. static White(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a purple color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Purple(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a magenta color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Magenta(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a yellow color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Yellow(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a gray color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Gray(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a teal color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Teal(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a random color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Random(): Color3;
  5604. }
  5605. /**
  5606. * Class used to hold a RBGA color
  5607. */
  5608. export class Color4 {
  5609. /**
  5610. * Defines the red component (between 0 and 1, default is 0)
  5611. */
  5612. r: number;
  5613. /**
  5614. * Defines the green component (between 0 and 1, default is 0)
  5615. */
  5616. g: number;
  5617. /**
  5618. * Defines the blue component (between 0 and 1, default is 0)
  5619. */
  5620. b: number;
  5621. /**
  5622. * Defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. a: number;
  5625. /**
  5626. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5627. * @param r defines the red component (between 0 and 1, default is 0)
  5628. * @param g defines the green component (between 0 and 1, default is 0)
  5629. * @param b defines the blue component (between 0 and 1, default is 0)
  5630. * @param a defines the alpha component (between 0 and 1, default is 1)
  5631. */
  5632. constructor(
  5633. /**
  5634. * Defines the red component (between 0 and 1, default is 0)
  5635. */
  5636. r?: number,
  5637. /**
  5638. * Defines the green component (between 0 and 1, default is 0)
  5639. */
  5640. g?: number,
  5641. /**
  5642. * Defines the blue component (between 0 and 1, default is 0)
  5643. */
  5644. b?: number,
  5645. /**
  5646. * Defines the alpha component (between 0 and 1, default is 1)
  5647. */
  5648. a?: number);
  5649. /**
  5650. * Adds in place the given Color4 values to the current Color4 object
  5651. * @param right defines the second operand
  5652. * @returns the current updated Color4 object
  5653. */
  5654. addInPlace(right: DeepImmutable<Color4>): Color4;
  5655. /**
  5656. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5657. * @returns the new array
  5658. */
  5659. asArray(): number[];
  5660. /**
  5661. * Stores from the starting index in the given array the Color4 successive values
  5662. * @param array defines the array where to store the r,g,b components
  5663. * @param index defines an optional index in the target array to define where to start storing values
  5664. * @returns the current Color4 object
  5665. */
  5666. toArray(array: number[], index?: number): Color4;
  5667. /**
  5668. * Determines equality between Color4 objects
  5669. * @param otherColor defines the second operand
  5670. * @returns true if the rgba values are equal to the given ones
  5671. */
  5672. equals(otherColor: DeepImmutable<Color4>): boolean;
  5673. /**
  5674. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5675. * @param right defines the second operand
  5676. * @returns a new Color4 object
  5677. */
  5678. add(right: DeepImmutable<Color4>): Color4;
  5679. /**
  5680. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5681. * @param right defines the second operand
  5682. * @returns a new Color4 object
  5683. */
  5684. subtract(right: DeepImmutable<Color4>): Color4;
  5685. /**
  5686. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5687. * @param right defines the second operand
  5688. * @param result defines the Color4 object where to store the result
  5689. * @returns the current Color4 object
  5690. */
  5691. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5692. /**
  5693. * Creates a new Color4 with the current Color4 values multiplied by scale
  5694. * @param scale defines the scaling factor to apply
  5695. * @returns a new Color4 object
  5696. */
  5697. scale(scale: number): Color4;
  5698. /**
  5699. * Multiplies the current Color4 values by scale and stores the result in "result"
  5700. * @param scale defines the scaling factor to apply
  5701. * @param result defines the Color4 object where to store the result
  5702. * @returns the current unmodified Color4
  5703. */
  5704. scaleToRef(scale: number, result: Color4): Color4;
  5705. /**
  5706. * Scale the current Color4 values by a factor and add the result to a given Color4
  5707. * @param scale defines the scale factor
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the unmodified current Color4
  5710. */
  5711. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5712. /**
  5713. * Clamps the rgb values by the min and max values and stores the result into "result"
  5714. * @param min defines minimum clamping value (default is 0)
  5715. * @param max defines maximum clamping value (default is 1)
  5716. * @param result defines color to store the result into.
  5717. * @returns the cuurent Color4
  5718. */
  5719. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5720. /**
  5721. * Multipy an Color4 value by another and return a new Color4 object
  5722. * @param color defines the Color4 value to multiply by
  5723. * @returns a new Color4 object
  5724. */
  5725. multiply(color: Color4): Color4;
  5726. /**
  5727. * Multipy a Color4 value by another and push the result in a reference value
  5728. * @param color defines the Color4 value to multiply by
  5729. * @param result defines the Color4 to fill the result in
  5730. * @returns the result Color4
  5731. */
  5732. multiplyToRef(color: Color4, result: Color4): Color4;
  5733. /**
  5734. * Creates a string with the Color4 current values
  5735. * @returns the string representation of the Color4 object
  5736. */
  5737. toString(): string;
  5738. /**
  5739. * Returns the string "Color4"
  5740. * @returns "Color4"
  5741. */
  5742. getClassName(): string;
  5743. /**
  5744. * Compute the Color4 hash code
  5745. * @returns an unique number that can be used to hash Color4 objects
  5746. */
  5747. getHashCode(): number;
  5748. /**
  5749. * Creates a new Color4 copied from the current one
  5750. * @returns a new Color4 object
  5751. */
  5752. clone(): Color4;
  5753. /**
  5754. * Copies the given Color4 values into the current one
  5755. * @param source defines the source Color4 object
  5756. * @returns the current updated Color4 object
  5757. */
  5758. copyFrom(source: Color4): Color4;
  5759. /**
  5760. * Copies the given float values into the current one
  5761. * @param r defines the red component to read from
  5762. * @param g defines the green component to read from
  5763. * @param b defines the blue component to read from
  5764. * @param a defines the alpha component to read from
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. set(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Compute the Color4 hexadecimal code as a string
  5779. * @returns a string containing the hexadecimal representation of the Color4 object
  5780. */
  5781. toHexString(): string;
  5782. /**
  5783. * Computes a new Color4 converted from the current one to linear space
  5784. * @returns a new Color4 object
  5785. */
  5786. toLinearSpace(): Color4;
  5787. /**
  5788. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5789. * @param convertedColor defines the Color4 object where to store the linear space version
  5790. * @returns the unmodified Color4
  5791. */
  5792. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5793. /**
  5794. * Computes a new Color4 converted from the current one to gamma space
  5795. * @returns a new Color4 object
  5796. */
  5797. toGammaSpace(): Color4;
  5798. /**
  5799. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5800. * @param convertedColor defines the Color4 object where to store the gamma space version
  5801. * @returns the unmodified Color4
  5802. */
  5803. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5804. /**
  5805. * Creates a new Color4 from the string containing valid hexadecimal values
  5806. * @param hex defines a string containing valid hexadecimal values
  5807. * @returns a new Color4 object
  5808. */
  5809. static FromHexString(hex: string): Color4;
  5810. /**
  5811. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5812. * @param left defines the start value
  5813. * @param right defines the end value
  5814. * @param amount defines the gradient factor
  5815. * @returns a new Color4 object
  5816. */
  5817. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5818. /**
  5819. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5820. * @param left defines the start value
  5821. * @param right defines the end value
  5822. * @param amount defines the gradient factor
  5823. * @param result defines the Color4 object where to store data
  5824. */
  5825. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5826. /**
  5827. * Creates a new Color4 from a Color3 and an alpha value
  5828. * @param color3 defines the source Color3 to read from
  5829. * @param alpha defines the alpha component (1.0 by default)
  5830. * @returns a new Color4 object
  5831. */
  5832. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5833. /**
  5834. * Creates a new Color4 from the starting index element of the given array
  5835. * @param array defines the source array to read from
  5836. * @param offset defines the offset in the source array
  5837. * @returns a new Color4 object
  5838. */
  5839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5840. /**
  5841. * Creates a new Color3 from integer values (< 256)
  5842. * @param r defines the red component to read from (value between 0 and 255)
  5843. * @param g defines the green component to read from (value between 0 and 255)
  5844. * @param b defines the blue component to read from (value between 0 and 255)
  5845. * @param a defines the alpha component to read from (value between 0 and 255)
  5846. * @returns a new Color3 object
  5847. */
  5848. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5849. /**
  5850. * Check the content of a given array and convert it to an array containing RGBA data
  5851. * If the original array was already containing count * 4 values then it is returned directly
  5852. * @param colors defines the array to check
  5853. * @param count defines the number of RGBA data to expect
  5854. * @returns an array containing count * 4 values (RGBA)
  5855. */
  5856. static CheckColors4(colors: number[], count: number): number[];
  5857. }
  5858. /**
  5859. * @hidden
  5860. */
  5861. export class TmpColors {
  5862. static Color3: Color3[];
  5863. static Color4: Color4[];
  5864. }
  5865. }
  5866. declare module BABYLON {
  5867. /**
  5868. * Defines an interface which represents an animation key frame
  5869. */
  5870. export interface IAnimationKey {
  5871. /**
  5872. * Frame of the key frame
  5873. */
  5874. frame: number;
  5875. /**
  5876. * Value at the specifies key frame
  5877. */
  5878. value: any;
  5879. /**
  5880. * The input tangent for the cubic hermite spline
  5881. */
  5882. inTangent?: any;
  5883. /**
  5884. * The output tangent for the cubic hermite spline
  5885. */
  5886. outTangent?: any;
  5887. /**
  5888. * The animation interpolation type
  5889. */
  5890. interpolation?: AnimationKeyInterpolation;
  5891. }
  5892. /**
  5893. * Enum for the animation key frame interpolation type
  5894. */
  5895. export enum AnimationKeyInterpolation {
  5896. /**
  5897. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5898. */
  5899. STEP = 1
  5900. }
  5901. }
  5902. declare module BABYLON {
  5903. /**
  5904. * Represents the range of an animation
  5905. */
  5906. export class AnimationRange {
  5907. /**The name of the animation range**/
  5908. name: string;
  5909. /**The starting frame of the animation */
  5910. from: number;
  5911. /**The ending frame of the animation*/
  5912. to: number;
  5913. /**
  5914. * Initializes the range of an animation
  5915. * @param name The name of the animation range
  5916. * @param from The starting frame of the animation
  5917. * @param to The ending frame of the animation
  5918. */
  5919. constructor(
  5920. /**The name of the animation range**/
  5921. name: string,
  5922. /**The starting frame of the animation */
  5923. from: number,
  5924. /**The ending frame of the animation*/
  5925. to: number);
  5926. /**
  5927. * Makes a copy of the animation range
  5928. * @returns A copy of the animation range
  5929. */
  5930. clone(): AnimationRange;
  5931. }
  5932. }
  5933. declare module BABYLON {
  5934. /**
  5935. * Composed of a frame, and an action function
  5936. */
  5937. export class AnimationEvent {
  5938. /** The frame for which the event is triggered **/
  5939. frame: number;
  5940. /** The event to perform when triggered **/
  5941. action: (currentFrame: number) => void;
  5942. /** Specifies if the event should be triggered only once**/
  5943. onlyOnce?: boolean | undefined;
  5944. /**
  5945. * Specifies if the animation event is done
  5946. */
  5947. isDone: boolean;
  5948. /**
  5949. * Initializes the animation event
  5950. * @param frame The frame for which the event is triggered
  5951. * @param action The event to perform when triggered
  5952. * @param onlyOnce Specifies if the event should be triggered only once
  5953. */
  5954. constructor(
  5955. /** The frame for which the event is triggered **/
  5956. frame: number,
  5957. /** The event to perform when triggered **/
  5958. action: (currentFrame: number) => void,
  5959. /** Specifies if the event should be triggered only once**/
  5960. onlyOnce?: boolean | undefined);
  5961. /** @hidden */
  5962. _clone(): AnimationEvent;
  5963. }
  5964. }
  5965. declare module BABYLON {
  5966. /**
  5967. * Interface used to define a behavior
  5968. */
  5969. export interface Behavior<T> {
  5970. /** gets or sets behavior's name */
  5971. name: string;
  5972. /**
  5973. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5974. */
  5975. init(): void;
  5976. /**
  5977. * Called when the behavior is attached to a target
  5978. * @param target defines the target where the behavior is attached to
  5979. */
  5980. attach(target: T): void;
  5981. /**
  5982. * Called when the behavior is detached from its target
  5983. */
  5984. detach(): void;
  5985. }
  5986. /**
  5987. * Interface implemented by classes supporting behaviors
  5988. */
  5989. export interface IBehaviorAware<T> {
  5990. /**
  5991. * Attach a behavior
  5992. * @param behavior defines the behavior to attach
  5993. * @returns the current host
  5994. */
  5995. addBehavior(behavior: Behavior<T>): T;
  5996. /**
  5997. * Remove a behavior from the current object
  5998. * @param behavior defines the behavior to detach
  5999. * @returns the current host
  6000. */
  6001. removeBehavior(behavior: Behavior<T>): T;
  6002. /**
  6003. * Gets a behavior using its name to search
  6004. * @param name defines the name to search
  6005. * @returns the behavior or null if not found
  6006. */
  6007. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6008. }
  6009. }
  6010. declare module BABYLON {
  6011. /**
  6012. * Defines an array and its length.
  6013. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6014. */
  6015. export interface ISmartArrayLike<T> {
  6016. /**
  6017. * The data of the array.
  6018. */
  6019. data: Array<T>;
  6020. /**
  6021. * The active length of the array.
  6022. */
  6023. length: number;
  6024. }
  6025. /**
  6026. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6027. */
  6028. export class SmartArray<T> implements ISmartArrayLike<T> {
  6029. /**
  6030. * The full set of data from the array.
  6031. */
  6032. data: Array<T>;
  6033. /**
  6034. * The active length of the array.
  6035. */
  6036. length: number;
  6037. protected _id: number;
  6038. /**
  6039. * Instantiates a Smart Array.
  6040. * @param capacity defines the default capacity of the array.
  6041. */
  6042. constructor(capacity: number);
  6043. /**
  6044. * Pushes a value at the end of the active data.
  6045. * @param value defines the object to push in the array.
  6046. */
  6047. push(value: T): void;
  6048. /**
  6049. * Iterates over the active data and apply the lambda to them.
  6050. * @param func defines the action to apply on each value.
  6051. */
  6052. forEach(func: (content: T) => void): void;
  6053. /**
  6054. * Sorts the full sets of data.
  6055. * @param compareFn defines the comparison function to apply.
  6056. */
  6057. sort(compareFn: (a: T, b: T) => number): void;
  6058. /**
  6059. * Resets the active data to an empty array.
  6060. */
  6061. reset(): void;
  6062. /**
  6063. * Releases all the data from the array as well as the array.
  6064. */
  6065. dispose(): void;
  6066. /**
  6067. * Concats the active data with a given array.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concat(array: any): void;
  6071. /**
  6072. * Returns the position of a value in the active data.
  6073. * @param value defines the value to find the index for
  6074. * @returns the index if found in the active data otherwise -1
  6075. */
  6076. indexOf(value: T): number;
  6077. /**
  6078. * Returns whether an element is part of the active data.
  6079. * @param value defines the value to look for
  6080. * @returns true if found in the active data otherwise false
  6081. */
  6082. contains(value: T): boolean;
  6083. private static _GlobalId;
  6084. }
  6085. /**
  6086. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6087. * The data in this array can only be present once
  6088. */
  6089. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6090. private _duplicateId;
  6091. /**
  6092. * Pushes a value at the end of the active data.
  6093. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6094. * @param value defines the object to push in the array.
  6095. */
  6096. push(value: T): void;
  6097. /**
  6098. * Pushes a value at the end of the active data.
  6099. * If the data is already present, it won t be added again
  6100. * @param value defines the object to push in the array.
  6101. * @returns true if added false if it was already present
  6102. */
  6103. pushNoDuplicate(value: T): boolean;
  6104. /**
  6105. * Resets the active data to an empty array.
  6106. */
  6107. reset(): void;
  6108. /**
  6109. * Concats the active data with a given array.
  6110. * This ensures no dupplicate will be present in the result.
  6111. * @param array defines the data to concatenate with.
  6112. */
  6113. concatWithNoDuplicate(array: any): void;
  6114. }
  6115. }
  6116. declare module BABYLON {
  6117. /**
  6118. * @ignore
  6119. * This is a list of all the different input types that are available in the application.
  6120. * Fo instance: ArcRotateCameraGamepadInput...
  6121. */
  6122. export var CameraInputTypes: {};
  6123. /**
  6124. * This is the contract to implement in order to create a new input class.
  6125. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6126. */
  6127. export interface ICameraInput<TCamera extends Camera> {
  6128. /**
  6129. * Defines the camera the input is attached to.
  6130. */
  6131. camera: Nullable<TCamera>;
  6132. /**
  6133. * Gets the class name of the current intput.
  6134. * @returns the class name
  6135. */
  6136. getClassName(): string;
  6137. /**
  6138. * Get the friendly name associated with the input class.
  6139. * @returns the input friendly name
  6140. */
  6141. getSimpleName(): string;
  6142. /**
  6143. * Attach the input controls to a specific dom element to get the input from.
  6144. * @param element Defines the element the controls should be listened from
  6145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6148. /**
  6149. * Detach the current controls from the specified dom element.
  6150. * @param element Defines the element to stop listening the inputs from
  6151. */
  6152. detachControl(element: Nullable<HTMLElement>): void;
  6153. /**
  6154. * Update the current camera state depending on the inputs that have been used this frame.
  6155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6156. */
  6157. checkInputs?: () => void;
  6158. }
  6159. /**
  6160. * Represents a map of input types to input instance or input index to input instance.
  6161. */
  6162. export interface CameraInputsMap<TCamera extends Camera> {
  6163. /**
  6164. * Accessor to the input by input type.
  6165. */
  6166. [name: string]: ICameraInput<TCamera>;
  6167. /**
  6168. * Accessor to the input by input index.
  6169. */
  6170. [idx: number]: ICameraInput<TCamera>;
  6171. }
  6172. /**
  6173. * This represents the input manager used within a camera.
  6174. * It helps dealing with all the different kind of input attached to a camera.
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. */
  6177. export class CameraInputsManager<TCamera extends Camera> {
  6178. /**
  6179. * Defines the list of inputs attahed to the camera.
  6180. */
  6181. attached: CameraInputsMap<TCamera>;
  6182. /**
  6183. * Defines the dom element the camera is collecting inputs from.
  6184. * This is null if the controls have not been attached.
  6185. */
  6186. attachedElement: Nullable<HTMLElement>;
  6187. /**
  6188. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6189. */
  6190. noPreventDefault: boolean;
  6191. /**
  6192. * Defined the camera the input manager belongs to.
  6193. */
  6194. camera: TCamera;
  6195. /**
  6196. * Update the current camera state depending on the inputs that have been used this frame.
  6197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6198. */
  6199. checkInputs: () => void;
  6200. /**
  6201. * Instantiate a new Camera Input Manager.
  6202. * @param camera Defines the camera the input manager blongs to
  6203. */
  6204. constructor(camera: TCamera);
  6205. /**
  6206. * Add an input method to a camera
  6207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6208. * @param input camera input method
  6209. */
  6210. add(input: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Remove a specific input method from a camera
  6213. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6214. * @param inputToRemove camera input method
  6215. */
  6216. remove(inputToRemove: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Remove a specific input type from a camera
  6219. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6220. * @param inputType the type of the input to remove
  6221. */
  6222. removeByType(inputType: string): void;
  6223. private _addCheckInputs;
  6224. /**
  6225. * Attach the input controls to the currently attached dom element to listen the events from.
  6226. * @param input Defines the input to attach
  6227. */
  6228. attachInput(input: ICameraInput<TCamera>): void;
  6229. /**
  6230. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6231. * @param element Defines the dom element to collect the events from
  6232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6233. */
  6234. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6235. /**
  6236. * Detach the current manager inputs controls from a specific dom element.
  6237. * @param element Defines the dom element to collect the events from
  6238. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6239. */
  6240. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6241. /**
  6242. * Rebuild the dynamic inputCheck function from the current list of
  6243. * defined inputs in the manager.
  6244. */
  6245. rebuildInputCheck(): void;
  6246. /**
  6247. * Remove all attached input methods from a camera
  6248. */
  6249. clear(): void;
  6250. /**
  6251. * Serialize the current input manager attached to a camera.
  6252. * This ensures than once parsed,
  6253. * the input associated to the camera will be identical to the current ones
  6254. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6255. */
  6256. serialize(serializedCamera: any): void;
  6257. /**
  6258. * Parses an input manager serialized JSON to restore the previous list of inputs
  6259. * and states associated to a camera.
  6260. * @param parsedCamera Defines the JSON to parse
  6261. */
  6262. parse(parsedCamera: any): void;
  6263. }
  6264. }
  6265. declare module BABYLON {
  6266. /**
  6267. * Class used to store data that will be store in GPU memory
  6268. */
  6269. export class Buffer {
  6270. private _engine;
  6271. private _buffer;
  6272. /** @hidden */
  6273. _data: Nullable<DataArray>;
  6274. private _updatable;
  6275. private _instanced;
  6276. private _divisor;
  6277. /**
  6278. * Gets the byte stride.
  6279. */
  6280. readonly byteStride: number;
  6281. /**
  6282. * Constructor
  6283. * @param engine the engine
  6284. * @param data the data to use for this buffer
  6285. * @param updatable whether the data is updatable
  6286. * @param stride the stride (optional)
  6287. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6288. * @param instanced whether the buffer is instanced (optional)
  6289. * @param useBytes set to true if the stride in in bytes (optional)
  6290. * @param divisor sets an optional divisor for instances (1 by default)
  6291. */
  6292. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6293. /**
  6294. * Create a new VertexBuffer based on the current buffer
  6295. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6296. * @param offset defines offset in the buffer (0 by default)
  6297. * @param size defines the size in floats of attributes (position is 3 for instance)
  6298. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6299. * @param instanced defines if the vertex buffer contains indexed data
  6300. * @param useBytes defines if the offset and stride are in bytes *
  6301. * @param divisor sets an optional divisor for instances (1 by default)
  6302. * @returns the new vertex buffer
  6303. */
  6304. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6305. /**
  6306. * Gets a boolean indicating if the Buffer is updatable?
  6307. * @returns true if the buffer is updatable
  6308. */
  6309. isUpdatable(): boolean;
  6310. /**
  6311. * Gets current buffer's data
  6312. * @returns a DataArray or null
  6313. */
  6314. getData(): Nullable<DataArray>;
  6315. /**
  6316. * Gets underlying native buffer
  6317. * @returns underlying native buffer
  6318. */
  6319. getBuffer(): Nullable<DataBuffer>;
  6320. /**
  6321. * Gets the stride in float32 units (i.e. byte stride / 4).
  6322. * May not be an integer if the byte stride is not divisible by 4.
  6323. * @returns the stride in float32 units
  6324. * @deprecated Please use byteStride instead.
  6325. */
  6326. getStrideSize(): number;
  6327. /**
  6328. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6329. * @param data defines the data to store
  6330. */
  6331. create(data?: Nullable<DataArray>): void;
  6332. /** @hidden */
  6333. _rebuild(): void;
  6334. /**
  6335. * Update current buffer data
  6336. * @param data defines the data to store
  6337. */
  6338. update(data: DataArray): void;
  6339. /**
  6340. * Updates the data directly.
  6341. * @param data the new data
  6342. * @param offset the new offset
  6343. * @param vertexCount the vertex count (optional)
  6344. * @param useBytes set to true if the offset is in bytes
  6345. */
  6346. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6347. /**
  6348. * Release all resources
  6349. */
  6350. dispose(): void;
  6351. }
  6352. /**
  6353. * Specialized buffer used to store vertex data
  6354. */
  6355. export class VertexBuffer {
  6356. /** @hidden */
  6357. _buffer: Buffer;
  6358. private _kind;
  6359. private _size;
  6360. private _ownsBuffer;
  6361. private _instanced;
  6362. private _instanceDivisor;
  6363. /**
  6364. * The byte type.
  6365. */
  6366. static readonly BYTE: number;
  6367. /**
  6368. * The unsigned byte type.
  6369. */
  6370. static readonly UNSIGNED_BYTE: number;
  6371. /**
  6372. * The short type.
  6373. */
  6374. static readonly SHORT: number;
  6375. /**
  6376. * The unsigned short type.
  6377. */
  6378. static readonly UNSIGNED_SHORT: number;
  6379. /**
  6380. * The integer type.
  6381. */
  6382. static readonly INT: number;
  6383. /**
  6384. * The unsigned integer type.
  6385. */
  6386. static readonly UNSIGNED_INT: number;
  6387. /**
  6388. * The float type.
  6389. */
  6390. static readonly FLOAT: number;
  6391. /**
  6392. * Gets or sets the instance divisor when in instanced mode
  6393. */
  6394. get instanceDivisor(): number;
  6395. set instanceDivisor(value: number);
  6396. /**
  6397. * Gets the byte stride.
  6398. */
  6399. readonly byteStride: number;
  6400. /**
  6401. * Gets the byte offset.
  6402. */
  6403. readonly byteOffset: number;
  6404. /**
  6405. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6406. */
  6407. readonly normalized: boolean;
  6408. /**
  6409. * Gets the data type of each component in the array.
  6410. */
  6411. readonly type: number;
  6412. /**
  6413. * Constructor
  6414. * @param engine the engine
  6415. * @param data the data to use for this vertex buffer
  6416. * @param kind the vertex buffer kind
  6417. * @param updatable whether the data is updatable
  6418. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6419. * @param stride the stride (optional)
  6420. * @param instanced whether the buffer is instanced (optional)
  6421. * @param offset the offset of the data (optional)
  6422. * @param size the number of components (optional)
  6423. * @param type the type of the component (optional)
  6424. * @param normalized whether the data contains normalized data (optional)
  6425. * @param useBytes set to true if stride and offset are in bytes (optional)
  6426. * @param divisor defines the instance divisor to use (1 by default)
  6427. */
  6428. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6429. /** @hidden */
  6430. _rebuild(): void;
  6431. /**
  6432. * Returns the kind of the VertexBuffer (string)
  6433. * @returns a string
  6434. */
  6435. getKind(): string;
  6436. /**
  6437. * Gets a boolean indicating if the VertexBuffer is updatable?
  6438. * @returns true if the buffer is updatable
  6439. */
  6440. isUpdatable(): boolean;
  6441. /**
  6442. * Gets current buffer's data
  6443. * @returns a DataArray or null
  6444. */
  6445. getData(): Nullable<DataArray>;
  6446. /**
  6447. * Gets underlying native buffer
  6448. * @returns underlying native buffer
  6449. */
  6450. getBuffer(): Nullable<DataBuffer>;
  6451. /**
  6452. * Gets the stride in float32 units (i.e. byte stride / 4).
  6453. * May not be an integer if the byte stride is not divisible by 4.
  6454. * @returns the stride in float32 units
  6455. * @deprecated Please use byteStride instead.
  6456. */
  6457. getStrideSize(): number;
  6458. /**
  6459. * Returns the offset as a multiple of the type byte length.
  6460. * @returns the offset in bytes
  6461. * @deprecated Please use byteOffset instead.
  6462. */
  6463. getOffset(): number;
  6464. /**
  6465. * Returns the number of components per vertex attribute (integer)
  6466. * @returns the size in float
  6467. */
  6468. getSize(): number;
  6469. /**
  6470. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6471. * @returns true if this buffer is instanced
  6472. */
  6473. getIsInstanced(): boolean;
  6474. /**
  6475. * Returns the instancing divisor, zero for non-instanced (integer).
  6476. * @returns a number
  6477. */
  6478. getInstanceDivisor(): number;
  6479. /**
  6480. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6481. * @param data defines the data to store
  6482. */
  6483. create(data?: DataArray): void;
  6484. /**
  6485. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6486. * This function will create a new buffer if the current one is not updatable
  6487. * @param data defines the data to store
  6488. */
  6489. update(data: DataArray): void;
  6490. /**
  6491. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6492. * Returns the directly updated WebGLBuffer.
  6493. * @param data the new data
  6494. * @param offset the new offset
  6495. * @param useBytes set to true if the offset is in bytes
  6496. */
  6497. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6498. /**
  6499. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Enumerates each value of this vertex buffer as numbers.
  6504. * @param count the number of values to enumerate
  6505. * @param callback the callback function called for each value
  6506. */
  6507. forEach(count: number, callback: (value: number, index: number) => void): void;
  6508. /**
  6509. * Positions
  6510. */
  6511. static readonly PositionKind: string;
  6512. /**
  6513. * Normals
  6514. */
  6515. static readonly NormalKind: string;
  6516. /**
  6517. * Tangents
  6518. */
  6519. static readonly TangentKind: string;
  6520. /**
  6521. * Texture coordinates
  6522. */
  6523. static readonly UVKind: string;
  6524. /**
  6525. * Texture coordinates 2
  6526. */
  6527. static readonly UV2Kind: string;
  6528. /**
  6529. * Texture coordinates 3
  6530. */
  6531. static readonly UV3Kind: string;
  6532. /**
  6533. * Texture coordinates 4
  6534. */
  6535. static readonly UV4Kind: string;
  6536. /**
  6537. * Texture coordinates 5
  6538. */
  6539. static readonly UV5Kind: string;
  6540. /**
  6541. * Texture coordinates 6
  6542. */
  6543. static readonly UV6Kind: string;
  6544. /**
  6545. * Colors
  6546. */
  6547. static readonly ColorKind: string;
  6548. /**
  6549. * Matrix indices (for bones)
  6550. */
  6551. static readonly MatricesIndicesKind: string;
  6552. /**
  6553. * Matrix weights (for bones)
  6554. */
  6555. static readonly MatricesWeightsKind: string;
  6556. /**
  6557. * Additional matrix indices (for bones)
  6558. */
  6559. static readonly MatricesIndicesExtraKind: string;
  6560. /**
  6561. * Additional matrix weights (for bones)
  6562. */
  6563. static readonly MatricesWeightsExtraKind: string;
  6564. /**
  6565. * Deduces the stride given a kind.
  6566. * @param kind The kind string to deduce
  6567. * @returns The deduced stride
  6568. */
  6569. static DeduceStride(kind: string): number;
  6570. /**
  6571. * Gets the byte length of the given type.
  6572. * @param type the type
  6573. * @returns the number of bytes
  6574. */
  6575. static GetTypeByteLength(type: number): number;
  6576. /**
  6577. * Enumerates each value of the given parameters as numbers.
  6578. * @param data the data to enumerate
  6579. * @param byteOffset the byte offset of the data
  6580. * @param byteStride the byte stride of the data
  6581. * @param componentCount the number of components per element
  6582. * @param componentType the type of the component
  6583. * @param count the number of values to enumerate
  6584. * @param normalized whether the data is normalized
  6585. * @param callback the callback function called for each value
  6586. */
  6587. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6588. private static _GetFloatValue;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * @hidden
  6594. */
  6595. export class IntersectionInfo {
  6596. bu: Nullable<number>;
  6597. bv: Nullable<number>;
  6598. distance: number;
  6599. faceId: number;
  6600. subMeshId: number;
  6601. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6602. }
  6603. }
  6604. declare module BABYLON {
  6605. /**
  6606. * Represens a plane by the equation ax + by + cz + d = 0
  6607. */
  6608. export class Plane {
  6609. private static _TmpMatrix;
  6610. /**
  6611. * Normal of the plane (a,b,c)
  6612. */
  6613. normal: Vector3;
  6614. /**
  6615. * d component of the plane
  6616. */
  6617. d: number;
  6618. /**
  6619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6620. * @param a a component of the plane
  6621. * @param b b component of the plane
  6622. * @param c c component of the plane
  6623. * @param d d component of the plane
  6624. */
  6625. constructor(a: number, b: number, c: number, d: number);
  6626. /**
  6627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6628. */
  6629. asArray(): number[];
  6630. /**
  6631. * @returns a new plane copied from the current Plane.
  6632. */
  6633. clone(): Plane;
  6634. /**
  6635. * @returns the string "Plane".
  6636. */
  6637. getClassName(): string;
  6638. /**
  6639. * @returns the Plane hash code.
  6640. */
  6641. getHashCode(): number;
  6642. /**
  6643. * Normalize the current Plane in place.
  6644. * @returns the updated Plane.
  6645. */
  6646. normalize(): Plane;
  6647. /**
  6648. * Applies a transformation the plane and returns the result
  6649. * @param transformation the transformation matrix to be applied to the plane
  6650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6651. */
  6652. transform(transformation: DeepImmutable<Matrix>): Plane;
  6653. /**
  6654. * Calcualtte the dot product between the point and the plane normal
  6655. * @param point point to calculate the dot product with
  6656. * @returns the dot product (float) of the point coordinates and the plane normal.
  6657. */
  6658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6659. /**
  6660. * Updates the current Plane from the plane defined by the three given points.
  6661. * @param point1 one of the points used to contruct the plane
  6662. * @param point2 one of the points used to contruct the plane
  6663. * @param point3 one of the points used to contruct the plane
  6664. * @returns the updated Plane.
  6665. */
  6666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6667. /**
  6668. * Checks if the plane is facing a given direction
  6669. * @param direction the direction to check if the plane is facing
  6670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6671. * @returns True is the vector "direction" is the same side than the plane normal.
  6672. */
  6673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6674. /**
  6675. * Calculates the distance to a point
  6676. * @param point point to calculate distance to
  6677. * @returns the signed distance (float) from the given point to the Plane.
  6678. */
  6679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6680. /**
  6681. * Creates a plane from an array
  6682. * @param array the array to create a plane from
  6683. * @returns a new Plane from the given array.
  6684. */
  6685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6686. /**
  6687. * Creates a plane from three points
  6688. * @param point1 point used to create the plane
  6689. * @param point2 point used to create the plane
  6690. * @param point3 point used to create the plane
  6691. * @returns a new Plane defined by the three given points.
  6692. */
  6693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Creates a plane from an origin point and a normal
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @returns a new Plane the normal vector to this plane at the given origin point.
  6699. * Note : the vector "normal" is updated because normalized.
  6700. */
  6701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Calculates the distance from a plane and a point
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6708. */
  6709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6710. }
  6711. }
  6712. declare module BABYLON {
  6713. /**
  6714. * Class used to store bounding sphere information
  6715. */
  6716. export class BoundingSphere {
  6717. /**
  6718. * Gets the center of the bounding sphere in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Radius of the bounding sphere in local space
  6723. */
  6724. radius: number;
  6725. /**
  6726. * Gets the center of the bounding sphere in world space
  6727. */
  6728. readonly centerWorld: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in world space
  6731. */
  6732. radiusWorld: number;
  6733. /**
  6734. * Gets the minimum vector in local space
  6735. */
  6736. readonly minimum: Vector3;
  6737. /**
  6738. * Gets the maximum vector in local space
  6739. */
  6740. readonly maximum: Vector3;
  6741. private _worldMatrix;
  6742. private static readonly TmpVector3;
  6743. /**
  6744. * Creates a new bounding sphere
  6745. * @param min defines the minimum vector (in local space)
  6746. * @param max defines the maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6750. /**
  6751. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6752. * @param min defines the new minimum vector (in local space)
  6753. * @param max defines the new maximum vector (in local space)
  6754. * @param worldMatrix defines the new world matrix
  6755. */
  6756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6757. /**
  6758. * Scale the current bounding sphere by applying a scale factor
  6759. * @param factor defines the scale factor to apply
  6760. * @returns the current bounding box
  6761. */
  6762. scale(factor: number): BoundingSphere;
  6763. /**
  6764. * Gets the world matrix of the bounding box
  6765. * @returns a matrix
  6766. */
  6767. getWorldMatrix(): DeepImmutable<Matrix>;
  6768. /** @hidden */
  6769. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6770. /**
  6771. * Tests if the bounding sphere is intersecting the frustum planes
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @returns true if there is an intersection
  6774. */
  6775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if the bounding sphere center is in between the frustum planes.
  6778. * Used for optimistic fast inclusion.
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if the sphere center is in between the frustum planes
  6781. */
  6782. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding sphere
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding sphere
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Checks if two sphere intersct
  6791. * @param sphere0 sphere 0
  6792. * @param sphere1 sphere 1
  6793. * @returns true if the speres intersect
  6794. */
  6795. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6796. }
  6797. }
  6798. declare module BABYLON {
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module BABYLON {
  6944. /** @hidden */
  6945. export class Collider {
  6946. /** Define if a collision was found */
  6947. collisionFound: boolean;
  6948. /**
  6949. * Define last intersection point in local space
  6950. */
  6951. intersectionPoint: Vector3;
  6952. /**
  6953. * Define last collided mesh
  6954. */
  6955. collidedMesh: Nullable<AbstractMesh>;
  6956. private _collisionPoint;
  6957. private _planeIntersectionPoint;
  6958. private _tempVector;
  6959. private _tempVector2;
  6960. private _tempVector3;
  6961. private _tempVector4;
  6962. private _edge;
  6963. private _baseToVertex;
  6964. private _destinationPoint;
  6965. private _slidePlaneNormal;
  6966. private _displacementVector;
  6967. /** @hidden */
  6968. _radius: Vector3;
  6969. /** @hidden */
  6970. _retry: number;
  6971. private _velocity;
  6972. private _basePoint;
  6973. private _epsilon;
  6974. /** @hidden */
  6975. _velocityWorldLength: number;
  6976. /** @hidden */
  6977. _basePointWorld: Vector3;
  6978. private _velocityWorld;
  6979. private _normalizedVelocity;
  6980. /** @hidden */
  6981. _initialVelocity: Vector3;
  6982. /** @hidden */
  6983. _initialPosition: Vector3;
  6984. private _nearestDistance;
  6985. private _collisionMask;
  6986. get collisionMask(): number;
  6987. set collisionMask(mask: number);
  6988. /**
  6989. * Gets the plane normal used to compute the sliding response (in local space)
  6990. */
  6991. get slidePlaneNormal(): Vector3;
  6992. /** @hidden */
  6993. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6994. /** @hidden */
  6995. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6996. /** @hidden */
  6997. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6998. /** @hidden */
  6999. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7000. /** @hidden */
  7001. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7002. /** @hidden */
  7003. _getResponse(pos: Vector3, vel: Vector3): void;
  7004. }
  7005. }
  7006. declare module BABYLON {
  7007. /**
  7008. * Interface for cullable objects
  7009. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7010. */
  7011. export interface ICullable {
  7012. /**
  7013. * Checks if the object or part of the object is in the frustum
  7014. * @param frustumPlanes Camera near/planes
  7015. * @returns true if the object is in frustum otherwise false
  7016. */
  7017. isInFrustum(frustumPlanes: Plane[]): boolean;
  7018. /**
  7019. * Checks if a cullable object (mesh...) is in the camera frustum
  7020. * Unlike isInFrustum this cheks the full bounding box
  7021. * @param frustumPlanes Camera near/planes
  7022. * @returns true if the object is in frustum otherwise false
  7023. */
  7024. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7025. }
  7026. /**
  7027. * Info for a bounding data of a mesh
  7028. */
  7029. export class BoundingInfo implements ICullable {
  7030. /**
  7031. * Bounding box for the mesh
  7032. */
  7033. readonly boundingBox: BoundingBox;
  7034. /**
  7035. * Bounding sphere for the mesh
  7036. */
  7037. readonly boundingSphere: BoundingSphere;
  7038. private _isLocked;
  7039. private static readonly TmpVector3;
  7040. /**
  7041. * Constructs bounding info
  7042. * @param minimum min vector of the bounding box/sphere
  7043. * @param maximum max vector of the bounding box/sphere
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7047. /**
  7048. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7049. * @param min defines the new minimum vector (in local space)
  7050. * @param max defines the new maximum vector (in local space)
  7051. * @param worldMatrix defines the new world matrix
  7052. */
  7053. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * min vector of the bounding box/sphere
  7056. */
  7057. get minimum(): Vector3;
  7058. /**
  7059. * max vector of the bounding box/sphere
  7060. */
  7061. get maximum(): Vector3;
  7062. /**
  7063. * If the info is locked and won't be updated to avoid perf overhead
  7064. */
  7065. get isLocked(): boolean;
  7066. set isLocked(value: boolean);
  7067. /**
  7068. * Updates the bounding sphere and box
  7069. * @param world world matrix to be used to update
  7070. */
  7071. update(world: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7074. * @param center New center of the bounding info
  7075. * @param extend New extend of the bounding info
  7076. * @returns the current bounding info
  7077. */
  7078. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7079. /**
  7080. * Scale the current bounding info by applying a scale factor
  7081. * @param factor defines the scale factor to apply
  7082. * @returns the current bounding info
  7083. */
  7084. scale(factor: number): BoundingInfo;
  7085. /**
  7086. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7087. * @param frustumPlanes defines the frustum to test
  7088. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7089. * @returns true if the bounding info is in the frustum planes
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7092. /**
  7093. * Gets the world distance between the min and max points of the bounding box
  7094. */
  7095. get diagonalLength(): number;
  7096. /**
  7097. * Checks if a cullable object (mesh...) is in the camera frustum
  7098. * Unlike isInFrustum this cheks the full bounding box
  7099. * @param frustumPlanes Camera near/planes
  7100. * @returns true if the object is in frustum otherwise false
  7101. */
  7102. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7103. /** @hidden */
  7104. _checkCollision(collider: Collider): boolean;
  7105. /**
  7106. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7107. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7108. * @param point the point to check intersection with
  7109. * @returns if the point intersects
  7110. */
  7111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7112. /**
  7113. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7114. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7115. * @param boundingInfo the bounding info to check intersection with
  7116. * @param precise if the intersection should be done using OBB
  7117. * @returns if the bounding info intersects
  7118. */
  7119. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7120. }
  7121. }
  7122. declare module BABYLON {
  7123. /**
  7124. * Extracts minimum and maximum values from a list of indexed positions
  7125. * @param positions defines the positions to use
  7126. * @param indices defines the indices to the positions
  7127. * @param indexStart defines the start index
  7128. * @param indexCount defines the end index
  7129. * @param bias defines bias value to add to the result
  7130. * @return minimum and maximum values
  7131. */
  7132. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7133. minimum: Vector3;
  7134. maximum: Vector3;
  7135. };
  7136. /**
  7137. * Extracts minimum and maximum values from a list of positions
  7138. * @param positions defines the positions to use
  7139. * @param start defines the start index in the positions array
  7140. * @param count defines the number of positions to handle
  7141. * @param bias defines bias value to add to the result
  7142. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7143. * @return minimum and maximum values
  7144. */
  7145. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7146. minimum: Vector3;
  7147. maximum: Vector3;
  7148. };
  7149. }
  7150. declare module BABYLON {
  7151. /** @hidden */
  7152. export class WebGLDataBuffer extends DataBuffer {
  7153. private _buffer;
  7154. constructor(resource: WebGLBuffer);
  7155. get underlyingResource(): any;
  7156. }
  7157. }
  7158. declare module BABYLON {
  7159. /** @hidden */
  7160. export class WebGLPipelineContext implements IPipelineContext {
  7161. engine: ThinEngine;
  7162. program: Nullable<WebGLProgram>;
  7163. context?: WebGLRenderingContext;
  7164. vertexShader?: WebGLShader;
  7165. fragmentShader?: WebGLShader;
  7166. isParallelCompiled: boolean;
  7167. onCompiled?: () => void;
  7168. transformFeedback?: WebGLTransformFeedback | null;
  7169. vertexCompilationError: Nullable<string>;
  7170. fragmentCompilationError: Nullable<string>;
  7171. programLinkError: Nullable<string>;
  7172. programValidationError: Nullable<string>;
  7173. get isAsync(): boolean;
  7174. get isReady(): boolean;
  7175. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7176. _getVertexShaderCode(): string | null;
  7177. _getFragmentShaderCode(): string | null;
  7178. }
  7179. }
  7180. declare module BABYLON {
  7181. interface ThinEngine {
  7182. /**
  7183. * Create an uniform buffer
  7184. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7185. * @param elements defines the content of the uniform buffer
  7186. * @returns the webGL uniform buffer
  7187. */
  7188. createUniformBuffer(elements: FloatArray): DataBuffer;
  7189. /**
  7190. * Create a dynamic uniform buffer
  7191. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7192. * @param elements defines the content of the uniform buffer
  7193. * @returns the webGL uniform buffer
  7194. */
  7195. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7196. /**
  7197. * Update an existing uniform buffer
  7198. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7199. * @param uniformBuffer defines the target uniform buffer
  7200. * @param elements defines the content to update
  7201. * @param offset defines the offset in the uniform buffer where update should start
  7202. * @param count defines the size of the data to update
  7203. */
  7204. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7205. /**
  7206. * Bind an uniform buffer to the current webGL context
  7207. * @param buffer defines the buffer to bind
  7208. */
  7209. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7210. /**
  7211. * Bind a buffer to the current webGL context at a given location
  7212. * @param buffer defines the buffer to bind
  7213. * @param location defines the index where to bind the buffer
  7214. */
  7215. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7216. /**
  7217. * Bind a specific block at a given index in a specific shader program
  7218. * @param pipelineContext defines the pipeline context to use
  7219. * @param blockName defines the block name
  7220. * @param index defines the index where to bind the block
  7221. */
  7222. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7223. }
  7224. }
  7225. declare module BABYLON {
  7226. /**
  7227. * Uniform buffer objects.
  7228. *
  7229. * Handles blocks of uniform on the GPU.
  7230. *
  7231. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7232. *
  7233. * For more information, please refer to :
  7234. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7235. */
  7236. export class UniformBuffer {
  7237. private _engine;
  7238. private _buffer;
  7239. private _data;
  7240. private _bufferData;
  7241. private _dynamic?;
  7242. private _uniformLocations;
  7243. private _uniformSizes;
  7244. private _uniformLocationPointer;
  7245. private _needSync;
  7246. private _noUBO;
  7247. private _currentEffect;
  7248. /** @hidden */
  7249. _alreadyBound: boolean;
  7250. private static _MAX_UNIFORM_SIZE;
  7251. private static _tempBuffer;
  7252. /**
  7253. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7254. * This is dynamic to allow compat with webgl 1 and 2.
  7255. * You will need to pass the name of the uniform as well as the value.
  7256. */
  7257. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7258. /**
  7259. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7260. * This is dynamic to allow compat with webgl 1 and 2.
  7261. * You will need to pass the name of the uniform as well as the value.
  7262. */
  7263. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7264. /**
  7265. * Lambda to Update a single float in a uniform buffer.
  7266. * This is dynamic to allow compat with webgl 1 and 2.
  7267. * You will need to pass the name of the uniform as well as the value.
  7268. */
  7269. updateFloat: (name: string, x: number) => void;
  7270. /**
  7271. * Lambda to Update a vec2 of float in a uniform buffer.
  7272. * This is dynamic to allow compat with webgl 1 and 2.
  7273. * You will need to pass the name of the uniform as well as the value.
  7274. */
  7275. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7276. /**
  7277. * Lambda to Update a vec3 of float in a uniform buffer.
  7278. * This is dynamic to allow compat with webgl 1 and 2.
  7279. * You will need to pass the name of the uniform as well as the value.
  7280. */
  7281. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7282. /**
  7283. * Lambda to Update a vec4 of float in a uniform buffer.
  7284. * This is dynamic to allow compat with webgl 1 and 2.
  7285. * You will need to pass the name of the uniform as well as the value.
  7286. */
  7287. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7288. /**
  7289. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7290. * This is dynamic to allow compat with webgl 1 and 2.
  7291. * You will need to pass the name of the uniform as well as the value.
  7292. */
  7293. updateMatrix: (name: string, mat: Matrix) => void;
  7294. /**
  7295. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7296. * This is dynamic to allow compat with webgl 1 and 2.
  7297. * You will need to pass the name of the uniform as well as the value.
  7298. */
  7299. updateVector3: (name: string, vector: Vector3) => void;
  7300. /**
  7301. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7302. * This is dynamic to allow compat with webgl 1 and 2.
  7303. * You will need to pass the name of the uniform as well as the value.
  7304. */
  7305. updateVector4: (name: string, vector: Vector4) => void;
  7306. /**
  7307. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7308. * This is dynamic to allow compat with webgl 1 and 2.
  7309. * You will need to pass the name of the uniform as well as the value.
  7310. */
  7311. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7312. /**
  7313. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7314. * This is dynamic to allow compat with webgl 1 and 2.
  7315. * You will need to pass the name of the uniform as well as the value.
  7316. */
  7317. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7318. /**
  7319. * Instantiates a new Uniform buffer objects.
  7320. *
  7321. * Handles blocks of uniform on the GPU.
  7322. *
  7323. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7324. *
  7325. * For more information, please refer to :
  7326. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7327. * @param engine Define the engine the buffer is associated with
  7328. * @param data Define the data contained in the buffer
  7329. * @param dynamic Define if the buffer is updatable
  7330. */
  7331. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7332. /**
  7333. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7334. * or just falling back on setUniformXXX calls.
  7335. */
  7336. get useUbo(): boolean;
  7337. /**
  7338. * Indicates if the WebGL underlying uniform buffer is in sync
  7339. * with the javascript cache data.
  7340. */
  7341. get isSync(): boolean;
  7342. /**
  7343. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7344. * Also, a dynamic UniformBuffer will disable cache verification and always
  7345. * update the underlying WebGL uniform buffer to the GPU.
  7346. * @returns if Dynamic, otherwise false
  7347. */
  7348. isDynamic(): boolean;
  7349. /**
  7350. * The data cache on JS side.
  7351. * @returns the underlying data as a float array
  7352. */
  7353. getData(): Float32Array;
  7354. /**
  7355. * The underlying WebGL Uniform buffer.
  7356. * @returns the webgl buffer
  7357. */
  7358. getBuffer(): Nullable<DataBuffer>;
  7359. /**
  7360. * std140 layout specifies how to align data within an UBO structure.
  7361. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7362. * for specs.
  7363. */
  7364. private _fillAlignment;
  7365. /**
  7366. * Adds an uniform in the buffer.
  7367. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7368. * for the layout to be correct !
  7369. * @param name Name of the uniform, as used in the uniform block in the shader.
  7370. * @param size Data size, or data directly.
  7371. */
  7372. addUniform(name: string, size: number | number[]): void;
  7373. /**
  7374. * Adds a Matrix 4x4 to the uniform buffer.
  7375. * @param name Name of the uniform, as used in the uniform block in the shader.
  7376. * @param mat A 4x4 matrix.
  7377. */
  7378. addMatrix(name: string, mat: Matrix): void;
  7379. /**
  7380. * Adds a vec2 to the uniform buffer.
  7381. * @param name Name of the uniform, as used in the uniform block in the shader.
  7382. * @param x Define the x component value of the vec2
  7383. * @param y Define the y component value of the vec2
  7384. */
  7385. addFloat2(name: string, x: number, y: number): void;
  7386. /**
  7387. * Adds a vec3 to the uniform buffer.
  7388. * @param name Name of the uniform, as used in the uniform block in the shader.
  7389. * @param x Define the x component value of the vec3
  7390. * @param y Define the y component value of the vec3
  7391. * @param z Define the z component value of the vec3
  7392. */
  7393. addFloat3(name: string, x: number, y: number, z: number): void;
  7394. /**
  7395. * Adds a vec3 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param color Define the vec3 from a Color
  7398. */
  7399. addColor3(name: string, color: Color3): void;
  7400. /**
  7401. * Adds a vec4 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param color Define the rgb components from a Color
  7404. * @param alpha Define the a component of the vec4
  7405. */
  7406. addColor4(name: string, color: Color3, alpha: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param vector Define the vec3 components from a Vector
  7411. */
  7412. addVector3(name: string, vector: Vector3): void;
  7413. /**
  7414. * Adds a Matrix 3x3 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. */
  7417. addMatrix3x3(name: string): void;
  7418. /**
  7419. * Adds a Matrix 2x2 to the uniform buffer.
  7420. * @param name Name of the uniform, as used in the uniform block in the shader.
  7421. */
  7422. addMatrix2x2(name: string): void;
  7423. /**
  7424. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7425. */
  7426. create(): void;
  7427. /** @hidden */
  7428. _rebuild(): void;
  7429. /**
  7430. * Updates the WebGL Uniform Buffer on the GPU.
  7431. * If the `dynamic` flag is set to true, no cache comparison is done.
  7432. * Otherwise, the buffer will be updated only if the cache differs.
  7433. */
  7434. update(): void;
  7435. /**
  7436. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7437. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7438. * @param data Define the flattened data
  7439. * @param size Define the size of the data.
  7440. */
  7441. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7442. private _valueCache;
  7443. private _cacheMatrix;
  7444. private _updateMatrix3x3ForUniform;
  7445. private _updateMatrix3x3ForEffect;
  7446. private _updateMatrix2x2ForEffect;
  7447. private _updateMatrix2x2ForUniform;
  7448. private _updateFloatForEffect;
  7449. private _updateFloatForUniform;
  7450. private _updateFloat2ForEffect;
  7451. private _updateFloat2ForUniform;
  7452. private _updateFloat3ForEffect;
  7453. private _updateFloat3ForUniform;
  7454. private _updateFloat4ForEffect;
  7455. private _updateFloat4ForUniform;
  7456. private _updateMatrixForEffect;
  7457. private _updateMatrixForUniform;
  7458. private _updateVector3ForEffect;
  7459. private _updateVector3ForUniform;
  7460. private _updateVector4ForEffect;
  7461. private _updateVector4ForUniform;
  7462. private _updateColor3ForEffect;
  7463. private _updateColor3ForUniform;
  7464. private _updateColor4ForEffect;
  7465. private _updateColor4ForUniform;
  7466. /**
  7467. * Sets a sampler uniform on the effect.
  7468. * @param name Define the name of the sampler.
  7469. * @param texture Define the texture to set in the sampler
  7470. */
  7471. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7472. /**
  7473. * Directly updates the value of the uniform in the cache AND on the GPU.
  7474. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7475. * @param data Define the flattened data
  7476. */
  7477. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7478. /**
  7479. * Binds this uniform buffer to an effect.
  7480. * @param effect Define the effect to bind the buffer to
  7481. * @param name Name of the uniform block in the shader.
  7482. */
  7483. bindToEffect(effect: Effect, name: string): void;
  7484. /**
  7485. * Disposes the uniform buffer.
  7486. */
  7487. dispose(): void;
  7488. }
  7489. }
  7490. declare module BABYLON {
  7491. /**
  7492. * Enum that determines the text-wrapping mode to use.
  7493. */
  7494. export enum InspectableType {
  7495. /**
  7496. * Checkbox for booleans
  7497. */
  7498. Checkbox = 0,
  7499. /**
  7500. * Sliders for numbers
  7501. */
  7502. Slider = 1,
  7503. /**
  7504. * Vector3
  7505. */
  7506. Vector3 = 2,
  7507. /**
  7508. * Quaternions
  7509. */
  7510. Quaternion = 3,
  7511. /**
  7512. * Color3
  7513. */
  7514. Color3 = 4,
  7515. /**
  7516. * String
  7517. */
  7518. String = 5
  7519. }
  7520. /**
  7521. * Interface used to define custom inspectable properties.
  7522. * This interface is used by the inspector to display custom property grids
  7523. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7524. */
  7525. export interface IInspectable {
  7526. /**
  7527. * Gets the label to display
  7528. */
  7529. label: string;
  7530. /**
  7531. * Gets the name of the property to edit
  7532. */
  7533. propertyName: string;
  7534. /**
  7535. * Gets the type of the editor to use
  7536. */
  7537. type: InspectableType;
  7538. /**
  7539. * Gets the minimum value of the property when using in "slider" mode
  7540. */
  7541. min?: number;
  7542. /**
  7543. * Gets the maximum value of the property when using in "slider" mode
  7544. */
  7545. max?: number;
  7546. /**
  7547. * Gets the setp to use when using in "slider" mode
  7548. */
  7549. step?: number;
  7550. }
  7551. }
  7552. declare module BABYLON {
  7553. /**
  7554. * Class used to provide helper for timing
  7555. */
  7556. export class TimingTools {
  7557. /**
  7558. * Polyfill for setImmediate
  7559. * @param action defines the action to execute after the current execution block
  7560. */
  7561. static SetImmediate(action: () => void): void;
  7562. }
  7563. }
  7564. declare module BABYLON {
  7565. /**
  7566. * Class used to enable instatition of objects by class name
  7567. */
  7568. export class InstantiationTools {
  7569. /**
  7570. * Use this object to register external classes like custom textures or material
  7571. * to allow the laoders to instantiate them
  7572. */
  7573. static RegisteredExternalClasses: {
  7574. [key: string]: Object;
  7575. };
  7576. /**
  7577. * Tries to instantiate a new object from a given class name
  7578. * @param className defines the class name to instantiate
  7579. * @returns the new object or null if the system was not able to do the instantiation
  7580. */
  7581. static Instantiate(className: string): any;
  7582. }
  7583. }
  7584. declare module BABYLON {
  7585. /**
  7586. * Define options used to create a depth texture
  7587. */
  7588. export class DepthTextureCreationOptions {
  7589. /** Specifies whether or not a stencil should be allocated in the texture */
  7590. generateStencil?: boolean;
  7591. /** Specifies whether or not bilinear filtering is enable on the texture */
  7592. bilinearFiltering?: boolean;
  7593. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7594. comparisonFunction?: number;
  7595. /** Specifies if the created texture is a cube texture */
  7596. isCube?: boolean;
  7597. }
  7598. }
  7599. declare module BABYLON {
  7600. interface ThinEngine {
  7601. /**
  7602. * Creates a depth stencil cube texture.
  7603. * This is only available in WebGL 2.
  7604. * @param size The size of face edge in the cube texture.
  7605. * @param options The options defining the cube texture.
  7606. * @returns The cube texture
  7607. */
  7608. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7609. /**
  7610. * Creates a cube texture
  7611. * @param rootUrl defines the url where the files to load is located
  7612. * @param scene defines the current scene
  7613. * @param files defines the list of files to load (1 per face)
  7614. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7615. * @param onLoad defines an optional callback raised when the texture is loaded
  7616. * @param onError defines an optional callback raised if there is an issue to load the texture
  7617. * @param format defines the format of the data
  7618. * @param forcedExtension defines the extension to use to pick the right loader
  7619. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7620. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7621. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7622. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7623. * @returns the cube texture as an InternalTexture
  7624. */
  7625. 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;
  7626. /**
  7627. * Creates a cube texture
  7628. * @param rootUrl defines the url where the files to load is located
  7629. * @param scene defines the current scene
  7630. * @param files defines the list of files to load (1 per face)
  7631. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7632. * @param onLoad defines an optional callback raised when the texture is loaded
  7633. * @param onError defines an optional callback raised if there is an issue to load the texture
  7634. * @param format defines the format of the data
  7635. * @param forcedExtension defines the extension to use to pick the right loader
  7636. * @returns the cube texture as an InternalTexture
  7637. */
  7638. 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;
  7639. /**
  7640. * Creates a cube texture
  7641. * @param rootUrl defines the url where the files to load is located
  7642. * @param scene defines the current scene
  7643. * @param files defines the list of files to load (1 per face)
  7644. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7645. * @param onLoad defines an optional callback raised when the texture is loaded
  7646. * @param onError defines an optional callback raised if there is an issue to load the texture
  7647. * @param format defines the format of the data
  7648. * @param forcedExtension defines the extension to use to pick the right loader
  7649. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7650. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7651. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7652. * @returns the cube texture as an InternalTexture
  7653. */
  7654. 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;
  7655. /** @hidden */
  7656. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7657. /** @hidden */
  7658. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7659. /** @hidden */
  7660. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7661. /** @hidden */
  7662. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7663. /**
  7664. * @hidden
  7665. */
  7666. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7667. }
  7668. }
  7669. declare module BABYLON {
  7670. /**
  7671. * Class for creating a cube texture
  7672. */
  7673. export class CubeTexture extends BaseTexture {
  7674. private _delayedOnLoad;
  7675. /**
  7676. * Observable triggered once the texture has been loaded.
  7677. */
  7678. onLoadObservable: Observable<CubeTexture>;
  7679. /**
  7680. * The url of the texture
  7681. */
  7682. url: string;
  7683. /**
  7684. * Gets or sets the center of the bounding box associated with the cube texture.
  7685. * It must define where the camera used to render the texture was set
  7686. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7687. */
  7688. boundingBoxPosition: Vector3;
  7689. private _boundingBoxSize;
  7690. /**
  7691. * Gets or sets the size of the bounding box associated with the cube texture
  7692. * When defined, the cubemap will switch to local mode
  7693. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7694. * @example https://www.babylonjs-playground.com/#RNASML
  7695. */
  7696. set boundingBoxSize(value: Vector3);
  7697. /**
  7698. * Returns the bounding box size
  7699. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7700. */
  7701. get boundingBoxSize(): Vector3;
  7702. protected _rotationY: number;
  7703. /**
  7704. * Sets texture matrix rotation angle around Y axis in radians.
  7705. */
  7706. set rotationY(value: number);
  7707. /**
  7708. * Gets texture matrix rotation angle around Y axis radians.
  7709. */
  7710. get rotationY(): number;
  7711. /**
  7712. * Are mip maps generated for this texture or not.
  7713. */
  7714. get noMipmap(): boolean;
  7715. private _noMipmap;
  7716. private _files;
  7717. protected _forcedExtension: Nullable<string>;
  7718. private _extensions;
  7719. private _textureMatrix;
  7720. private _format;
  7721. private _createPolynomials;
  7722. /** @hidden */
  7723. _prefiltered: boolean;
  7724. /**
  7725. * Creates a cube texture from an array of image urls
  7726. * @param files defines an array of image urls
  7727. * @param scene defines the hosting scene
  7728. * @param noMipmap specifies if mip maps are not used
  7729. * @returns a cube texture
  7730. */
  7731. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7732. /**
  7733. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7734. * @param url defines the url of the prefiltered texture
  7735. * @param scene defines the scene the texture is attached to
  7736. * @param forcedExtension defines the extension of the file if different from the url
  7737. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7738. * @return the prefiltered texture
  7739. */
  7740. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7741. /**
  7742. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7743. * as prefiltered data.
  7744. * @param rootUrl defines the url of the texture or the root name of the six images
  7745. * @param scene defines the scene the texture is attached to
  7746. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7747. * @param noMipmap defines if mipmaps should be created or not
  7748. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7749. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7750. * @param onError defines a callback triggered in case of error during load
  7751. * @param format defines the internal format to use for the texture once loaded
  7752. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7753. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7754. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7755. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7756. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7757. * @return the cube texture
  7758. */
  7759. 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);
  7760. /**
  7761. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7762. */
  7763. get isPrefiltered(): boolean;
  7764. /**
  7765. * Get the current class name of the texture useful for serialization or dynamic coding.
  7766. * @returns "CubeTexture"
  7767. */
  7768. getClassName(): string;
  7769. /**
  7770. * Update the url (and optional buffer) of this texture if url was null during construction.
  7771. * @param url the url of the texture
  7772. * @param forcedExtension defines the extension to use
  7773. * @param onLoad callback called when the texture is loaded (defaults to null)
  7774. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7775. */
  7776. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7777. /**
  7778. * Delays loading of the cube texture
  7779. * @param forcedExtension defines the extension to use
  7780. */
  7781. delayLoad(forcedExtension?: string): void;
  7782. /**
  7783. * Returns the reflection texture matrix
  7784. * @returns the reflection texture matrix
  7785. */
  7786. getReflectionTextureMatrix(): Matrix;
  7787. /**
  7788. * Sets the reflection texture matrix
  7789. * @param value Reflection texture matrix
  7790. */
  7791. setReflectionTextureMatrix(value: Matrix): void;
  7792. /**
  7793. * Parses text to create a cube texture
  7794. * @param parsedTexture define the serialized text to read from
  7795. * @param scene defines the hosting scene
  7796. * @param rootUrl defines the root url of the cube texture
  7797. * @returns a cube texture
  7798. */
  7799. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7800. /**
  7801. * Makes a clone, or deep copy, of the cube texture
  7802. * @returns a new cube texture
  7803. */
  7804. clone(): CubeTexture;
  7805. }
  7806. }
  7807. declare module BABYLON {
  7808. /**
  7809. * Manages the defines for the Material
  7810. */
  7811. export class MaterialDefines {
  7812. /** @hidden */
  7813. protected _keys: string[];
  7814. private _isDirty;
  7815. /** @hidden */
  7816. _renderId: number;
  7817. /** @hidden */
  7818. _areLightsDirty: boolean;
  7819. /** @hidden */
  7820. _areLightsDisposed: boolean;
  7821. /** @hidden */
  7822. _areAttributesDirty: boolean;
  7823. /** @hidden */
  7824. _areTexturesDirty: boolean;
  7825. /** @hidden */
  7826. _areFresnelDirty: boolean;
  7827. /** @hidden */
  7828. _areMiscDirty: boolean;
  7829. /** @hidden */
  7830. _areImageProcessingDirty: boolean;
  7831. /** @hidden */
  7832. _normals: boolean;
  7833. /** @hidden */
  7834. _uvs: boolean;
  7835. /** @hidden */
  7836. _needNormals: boolean;
  7837. /** @hidden */
  7838. _needUVs: boolean;
  7839. [id: string]: any;
  7840. /**
  7841. * Specifies if the material needs to be re-calculated
  7842. */
  7843. get isDirty(): boolean;
  7844. /**
  7845. * Marks the material to indicate that it has been re-calculated
  7846. */
  7847. markAsProcessed(): void;
  7848. /**
  7849. * Marks the material to indicate that it needs to be re-calculated
  7850. */
  7851. markAsUnprocessed(): void;
  7852. /**
  7853. * Marks the material to indicate all of its defines need to be re-calculated
  7854. */
  7855. markAllAsDirty(): void;
  7856. /**
  7857. * Marks the material to indicate that image processing needs to be re-calculated
  7858. */
  7859. markAsImageProcessingDirty(): void;
  7860. /**
  7861. * Marks the material to indicate the lights need to be re-calculated
  7862. * @param disposed Defines whether the light is dirty due to dispose or not
  7863. */
  7864. markAsLightDirty(disposed?: boolean): void;
  7865. /**
  7866. * Marks the attribute state as changed
  7867. */
  7868. markAsAttributesDirty(): void;
  7869. /**
  7870. * Marks the texture state as changed
  7871. */
  7872. markAsTexturesDirty(): void;
  7873. /**
  7874. * Marks the fresnel state as changed
  7875. */
  7876. markAsFresnelDirty(): void;
  7877. /**
  7878. * Marks the misc state as changed
  7879. */
  7880. markAsMiscDirty(): void;
  7881. /**
  7882. * Rebuilds the material defines
  7883. */
  7884. rebuild(): void;
  7885. /**
  7886. * Specifies if two material defines are equal
  7887. * @param other - A material define instance to compare to
  7888. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7889. */
  7890. isEqual(other: MaterialDefines): boolean;
  7891. /**
  7892. * Clones this instance's defines to another instance
  7893. * @param other - material defines to clone values to
  7894. */
  7895. cloneTo(other: MaterialDefines): void;
  7896. /**
  7897. * Resets the material define values
  7898. */
  7899. reset(): void;
  7900. /**
  7901. * Converts the material define values to a string
  7902. * @returns - String of material define information
  7903. */
  7904. toString(): string;
  7905. }
  7906. }
  7907. declare module BABYLON {
  7908. /**
  7909. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7910. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7911. * 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;
  7912. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7913. */
  7914. export class ColorCurves {
  7915. private _dirty;
  7916. private _tempColor;
  7917. private _globalCurve;
  7918. private _highlightsCurve;
  7919. private _midtonesCurve;
  7920. private _shadowsCurve;
  7921. private _positiveCurve;
  7922. private _negativeCurve;
  7923. private _globalHue;
  7924. private _globalDensity;
  7925. private _globalSaturation;
  7926. private _globalExposure;
  7927. /**
  7928. * Gets the global Hue value.
  7929. * 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).
  7930. */
  7931. get globalHue(): number;
  7932. /**
  7933. * Sets the global Hue value.
  7934. * 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).
  7935. */
  7936. set globalHue(value: number);
  7937. /**
  7938. * Gets the global Density value.
  7939. * 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.
  7940. * Values less than zero provide a filter of opposite hue.
  7941. */
  7942. get globalDensity(): number;
  7943. /**
  7944. * Sets the global Density value.
  7945. * 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.
  7946. * Values less than zero provide a filter of opposite hue.
  7947. */
  7948. set globalDensity(value: number);
  7949. /**
  7950. * Gets the global Saturation value.
  7951. * 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.
  7952. */
  7953. get globalSaturation(): number;
  7954. /**
  7955. * Sets the global Saturation value.
  7956. * 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.
  7957. */
  7958. set globalSaturation(value: number);
  7959. /**
  7960. * Gets the global Exposure value.
  7961. * 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.
  7962. */
  7963. get globalExposure(): number;
  7964. /**
  7965. * Sets the global Exposure value.
  7966. * 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.
  7967. */
  7968. set globalExposure(value: number);
  7969. private _highlightsHue;
  7970. private _highlightsDensity;
  7971. private _highlightsSaturation;
  7972. private _highlightsExposure;
  7973. /**
  7974. * Gets the highlights Hue value.
  7975. * 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).
  7976. */
  7977. get highlightsHue(): number;
  7978. /**
  7979. * Sets the highlights Hue value.
  7980. * 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).
  7981. */
  7982. set highlightsHue(value: number);
  7983. /**
  7984. * Gets the highlights Density value.
  7985. * 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.
  7986. * Values less than zero provide a filter of opposite hue.
  7987. */
  7988. get highlightsDensity(): number;
  7989. /**
  7990. * Sets the highlights Density value.
  7991. * 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.
  7992. * Values less than zero provide a filter of opposite hue.
  7993. */
  7994. set highlightsDensity(value: number);
  7995. /**
  7996. * Gets the highlights Saturation value.
  7997. * 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.
  7998. */
  7999. get highlightsSaturation(): number;
  8000. /**
  8001. * Sets the highlights Saturation value.
  8002. * 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.
  8003. */
  8004. set highlightsSaturation(value: number);
  8005. /**
  8006. * Gets the highlights Exposure value.
  8007. * 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.
  8008. */
  8009. get highlightsExposure(): number;
  8010. /**
  8011. * Sets the highlights Exposure value.
  8012. * 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.
  8013. */
  8014. set highlightsExposure(value: number);
  8015. private _midtonesHue;
  8016. private _midtonesDensity;
  8017. private _midtonesSaturation;
  8018. private _midtonesExposure;
  8019. /**
  8020. * Gets the midtones Hue value.
  8021. * 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).
  8022. */
  8023. get midtonesHue(): number;
  8024. /**
  8025. * Sets the midtones Hue value.
  8026. * 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).
  8027. */
  8028. set midtonesHue(value: number);
  8029. /**
  8030. * Gets the midtones Density value.
  8031. * 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.
  8032. * Values less than zero provide a filter of opposite hue.
  8033. */
  8034. get midtonesDensity(): number;
  8035. /**
  8036. * Sets the midtones Density value.
  8037. * 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.
  8038. * Values less than zero provide a filter of opposite hue.
  8039. */
  8040. set midtonesDensity(value: number);
  8041. /**
  8042. * Gets the midtones Saturation value.
  8043. * 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.
  8044. */
  8045. get midtonesSaturation(): number;
  8046. /**
  8047. * Sets the midtones Saturation value.
  8048. * 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.
  8049. */
  8050. set midtonesSaturation(value: number);
  8051. /**
  8052. * Gets the midtones Exposure value.
  8053. * 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.
  8054. */
  8055. get midtonesExposure(): number;
  8056. /**
  8057. * Sets the midtones Exposure value.
  8058. * 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.
  8059. */
  8060. set midtonesExposure(value: number);
  8061. private _shadowsHue;
  8062. private _shadowsDensity;
  8063. private _shadowsSaturation;
  8064. private _shadowsExposure;
  8065. /**
  8066. * Gets the shadows Hue value.
  8067. * 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).
  8068. */
  8069. get shadowsHue(): number;
  8070. /**
  8071. * Sets the shadows Hue value.
  8072. * 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).
  8073. */
  8074. set shadowsHue(value: number);
  8075. /**
  8076. * Gets the shadows Density value.
  8077. * 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.
  8078. * Values less than zero provide a filter of opposite hue.
  8079. */
  8080. get shadowsDensity(): number;
  8081. /**
  8082. * Sets the shadows Density value.
  8083. * 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.
  8084. * Values less than zero provide a filter of opposite hue.
  8085. */
  8086. set shadowsDensity(value: number);
  8087. /**
  8088. * Gets the shadows Saturation value.
  8089. * 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.
  8090. */
  8091. get shadowsSaturation(): number;
  8092. /**
  8093. * Sets the shadows Saturation value.
  8094. * 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.
  8095. */
  8096. set shadowsSaturation(value: number);
  8097. /**
  8098. * Gets the shadows Exposure value.
  8099. * 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.
  8100. */
  8101. get shadowsExposure(): number;
  8102. /**
  8103. * Sets the shadows Exposure value.
  8104. * 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.
  8105. */
  8106. set shadowsExposure(value: number);
  8107. /**
  8108. * Returns the class name
  8109. * @returns The class name
  8110. */
  8111. getClassName(): string;
  8112. /**
  8113. * Binds the color curves to the shader.
  8114. * @param colorCurves The color curve to bind
  8115. * @param effect The effect to bind to
  8116. * @param positiveUniform The positive uniform shader parameter
  8117. * @param neutralUniform The neutral uniform shader parameter
  8118. * @param negativeUniform The negative uniform shader parameter
  8119. */
  8120. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8121. /**
  8122. * Prepare the list of uniforms associated with the ColorCurves effects.
  8123. * @param uniformsList The list of uniforms used in the effect
  8124. */
  8125. static PrepareUniforms(uniformsList: string[]): void;
  8126. /**
  8127. * Returns color grading data based on a hue, density, saturation and exposure value.
  8128. * @param filterHue The hue of the color filter.
  8129. * @param filterDensity The density of the color filter.
  8130. * @param saturation The saturation.
  8131. * @param exposure The exposure.
  8132. * @param result The result data container.
  8133. */
  8134. private getColorGradingDataToRef;
  8135. /**
  8136. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8137. * @param value The input slider value in range [-100,100].
  8138. * @returns Adjusted value.
  8139. */
  8140. private static applyColorGradingSliderNonlinear;
  8141. /**
  8142. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8143. * @param hue The hue (H) input.
  8144. * @param saturation The saturation (S) input.
  8145. * @param brightness The brightness (B) input.
  8146. * @result An RGBA color represented as Vector4.
  8147. */
  8148. private static fromHSBToRef;
  8149. /**
  8150. * Returns a value clamped between min and max
  8151. * @param value The value to clamp
  8152. * @param min The minimum of value
  8153. * @param max The maximum of value
  8154. * @returns The clamped value.
  8155. */
  8156. private static clamp;
  8157. /**
  8158. * Clones the current color curve instance.
  8159. * @return The cloned curves
  8160. */
  8161. clone(): ColorCurves;
  8162. /**
  8163. * Serializes the current color curve instance to a json representation.
  8164. * @return a JSON representation
  8165. */
  8166. serialize(): any;
  8167. /**
  8168. * Parses the color curve from a json representation.
  8169. * @param source the JSON source to parse
  8170. * @return The parsed curves
  8171. */
  8172. static Parse(source: any): ColorCurves;
  8173. }
  8174. }
  8175. declare module BABYLON {
  8176. /**
  8177. * Interface to follow in your material defines to integrate easily the
  8178. * Image proccessing functions.
  8179. * @hidden
  8180. */
  8181. export interface IImageProcessingConfigurationDefines {
  8182. IMAGEPROCESSING: boolean;
  8183. VIGNETTE: boolean;
  8184. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8185. VIGNETTEBLENDMODEOPAQUE: boolean;
  8186. TONEMAPPING: boolean;
  8187. TONEMAPPING_ACES: boolean;
  8188. CONTRAST: boolean;
  8189. EXPOSURE: boolean;
  8190. COLORCURVES: boolean;
  8191. COLORGRADING: boolean;
  8192. COLORGRADING3D: boolean;
  8193. SAMPLER3DGREENDEPTH: boolean;
  8194. SAMPLER3DBGRMAP: boolean;
  8195. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8196. }
  8197. /**
  8198. * @hidden
  8199. */
  8200. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. COLORCURVES: boolean;
  8209. COLORGRADING: boolean;
  8210. COLORGRADING3D: boolean;
  8211. SAMPLER3DGREENDEPTH: boolean;
  8212. SAMPLER3DBGRMAP: boolean;
  8213. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8214. EXPOSURE: boolean;
  8215. constructor();
  8216. }
  8217. /**
  8218. * This groups together the common properties used for image processing either in direct forward pass
  8219. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8220. * or not.
  8221. */
  8222. export class ImageProcessingConfiguration {
  8223. /**
  8224. * Default tone mapping applied in BabylonJS.
  8225. */
  8226. static readonly TONEMAPPING_STANDARD: number;
  8227. /**
  8228. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8229. * to other engines rendering to increase portability.
  8230. */
  8231. static readonly TONEMAPPING_ACES: number;
  8232. /**
  8233. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8234. */
  8235. colorCurves: Nullable<ColorCurves>;
  8236. private _colorCurvesEnabled;
  8237. /**
  8238. * Gets wether the color curves effect is enabled.
  8239. */
  8240. get colorCurvesEnabled(): boolean;
  8241. /**
  8242. * Sets wether the color curves effect is enabled.
  8243. */
  8244. set colorCurvesEnabled(value: boolean);
  8245. private _colorGradingTexture;
  8246. /**
  8247. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8248. */
  8249. get colorGradingTexture(): Nullable<BaseTexture>;
  8250. /**
  8251. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8252. */
  8253. set colorGradingTexture(value: Nullable<BaseTexture>);
  8254. private _colorGradingEnabled;
  8255. /**
  8256. * Gets wether the color grading effect is enabled.
  8257. */
  8258. get colorGradingEnabled(): boolean;
  8259. /**
  8260. * Sets wether the color grading effect is enabled.
  8261. */
  8262. set colorGradingEnabled(value: boolean);
  8263. private _colorGradingWithGreenDepth;
  8264. /**
  8265. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8266. */
  8267. get colorGradingWithGreenDepth(): boolean;
  8268. /**
  8269. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8270. */
  8271. set colorGradingWithGreenDepth(value: boolean);
  8272. private _colorGradingBGR;
  8273. /**
  8274. * Gets wether the color grading texture contains BGR values.
  8275. */
  8276. get colorGradingBGR(): boolean;
  8277. /**
  8278. * Sets wether the color grading texture contains BGR values.
  8279. */
  8280. set colorGradingBGR(value: boolean);
  8281. /** @hidden */
  8282. _exposure: number;
  8283. /**
  8284. * Gets the Exposure used in the effect.
  8285. */
  8286. get exposure(): number;
  8287. /**
  8288. * Sets the Exposure used in the effect.
  8289. */
  8290. set exposure(value: number);
  8291. private _toneMappingEnabled;
  8292. /**
  8293. * Gets wether the tone mapping effect is enabled.
  8294. */
  8295. get toneMappingEnabled(): boolean;
  8296. /**
  8297. * Sets wether the tone mapping effect is enabled.
  8298. */
  8299. set toneMappingEnabled(value: boolean);
  8300. private _toneMappingType;
  8301. /**
  8302. * Gets the type of tone mapping effect.
  8303. */
  8304. get toneMappingType(): number;
  8305. /**
  8306. * Sets the type of tone mapping effect used in BabylonJS.
  8307. */
  8308. set toneMappingType(value: number);
  8309. protected _contrast: number;
  8310. /**
  8311. * Gets the contrast used in the effect.
  8312. */
  8313. get contrast(): number;
  8314. /**
  8315. * Sets the contrast used in the effect.
  8316. */
  8317. set contrast(value: number);
  8318. /**
  8319. * Vignette stretch size.
  8320. */
  8321. vignetteStretch: number;
  8322. /**
  8323. * Vignette centre X Offset.
  8324. */
  8325. vignetteCentreX: number;
  8326. /**
  8327. * Vignette centre Y Offset.
  8328. */
  8329. vignetteCentreY: number;
  8330. /**
  8331. * Vignette weight or intensity of the vignette effect.
  8332. */
  8333. vignetteWeight: number;
  8334. /**
  8335. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8336. * if vignetteEnabled is set to true.
  8337. */
  8338. vignetteColor: Color4;
  8339. /**
  8340. * Camera field of view used by the Vignette effect.
  8341. */
  8342. vignetteCameraFov: number;
  8343. private _vignetteBlendMode;
  8344. /**
  8345. * Gets the vignette blend mode allowing different kind of effect.
  8346. */
  8347. get vignetteBlendMode(): number;
  8348. /**
  8349. * Sets the vignette blend mode allowing different kind of effect.
  8350. */
  8351. set vignetteBlendMode(value: number);
  8352. private _vignetteEnabled;
  8353. /**
  8354. * Gets wether the vignette effect is enabled.
  8355. */
  8356. get vignetteEnabled(): boolean;
  8357. /**
  8358. * Sets wether the vignette effect is enabled.
  8359. */
  8360. set vignetteEnabled(value: boolean);
  8361. private _applyByPostProcess;
  8362. /**
  8363. * Gets wether the image processing is applied through a post process or not.
  8364. */
  8365. get applyByPostProcess(): boolean;
  8366. /**
  8367. * Sets wether the image processing is applied through a post process or not.
  8368. */
  8369. set applyByPostProcess(value: boolean);
  8370. private _isEnabled;
  8371. /**
  8372. * Gets wether the image processing is enabled or not.
  8373. */
  8374. get isEnabled(): boolean;
  8375. /**
  8376. * Sets wether the image processing is enabled or not.
  8377. */
  8378. set isEnabled(value: boolean);
  8379. /**
  8380. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8381. */
  8382. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8383. /**
  8384. * Method called each time the image processing information changes requires to recompile the effect.
  8385. */
  8386. protected _updateParameters(): void;
  8387. /**
  8388. * Gets the current class name.
  8389. * @return "ImageProcessingConfiguration"
  8390. */
  8391. getClassName(): string;
  8392. /**
  8393. * Prepare the list of uniforms associated with the Image Processing effects.
  8394. * @param uniforms The list of uniforms used in the effect
  8395. * @param defines the list of defines currently in use
  8396. */
  8397. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8398. /**
  8399. * Prepare the list of samplers associated with the Image Processing effects.
  8400. * @param samplersList The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of defines associated to the shader.
  8406. * @param defines the list of defines to complete
  8407. * @param forPostProcess Define if we are currently in post process mode or not
  8408. */
  8409. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8410. /**
  8411. * Returns true if all the image processing information are ready.
  8412. * @returns True if ready, otherwise, false
  8413. */
  8414. isReady(): boolean;
  8415. /**
  8416. * Binds the image processing to the shader.
  8417. * @param effect The effect to bind to
  8418. * @param overrideAspectRatio Override the aspect ratio of the effect
  8419. */
  8420. bind(effect: Effect, overrideAspectRatio?: number): void;
  8421. /**
  8422. * Clones the current image processing instance.
  8423. * @return The cloned image processing
  8424. */
  8425. clone(): ImageProcessingConfiguration;
  8426. /**
  8427. * Serializes the current image processing instance to a json representation.
  8428. * @return a JSON representation
  8429. */
  8430. serialize(): any;
  8431. /**
  8432. * Parses the image processing from a json representation.
  8433. * @param source the JSON source to parse
  8434. * @return The parsed image processing
  8435. */
  8436. static Parse(source: any): ImageProcessingConfiguration;
  8437. private static _VIGNETTEMODE_MULTIPLY;
  8438. private static _VIGNETTEMODE_OPAQUE;
  8439. /**
  8440. * Used to apply the vignette as a mix with the pixel color.
  8441. */
  8442. static get VIGNETTEMODE_MULTIPLY(): number;
  8443. /**
  8444. * Used to apply the vignette as a replacement of the pixel color.
  8445. */
  8446. static get VIGNETTEMODE_OPAQUE(): number;
  8447. }
  8448. }
  8449. declare module BABYLON {
  8450. /** @hidden */
  8451. export var postprocessVertexShader: {
  8452. name: string;
  8453. shader: string;
  8454. };
  8455. }
  8456. declare module BABYLON {
  8457. interface ThinEngine {
  8458. /**
  8459. * Creates a new render target texture
  8460. * @param size defines the size of the texture
  8461. * @param options defines the options used to create the texture
  8462. * @returns a new render target texture stored in an InternalTexture
  8463. */
  8464. createRenderTargetTexture(size: number | {
  8465. width: number;
  8466. height: number;
  8467. layers?: number;
  8468. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8469. /**
  8470. * Creates a depth stencil texture.
  8471. * This is only available in WebGL 2 or with the depth texture extension available.
  8472. * @param size The size of face edge in the texture.
  8473. * @param options The options defining the texture.
  8474. * @returns The texture
  8475. */
  8476. createDepthStencilTexture(size: number | {
  8477. width: number;
  8478. height: number;
  8479. layers?: number;
  8480. }, options: DepthTextureCreationOptions): InternalTexture;
  8481. /** @hidden */
  8482. _createDepthStencilTexture(size: number | {
  8483. width: number;
  8484. height: number;
  8485. layers?: number;
  8486. }, options: DepthTextureCreationOptions): InternalTexture;
  8487. }
  8488. }
  8489. declare module BABYLON {
  8490. /** Defines supported spaces */
  8491. export enum Space {
  8492. /** Local (object) space */
  8493. LOCAL = 0,
  8494. /** World space */
  8495. WORLD = 1,
  8496. /** Bone space */
  8497. BONE = 2
  8498. }
  8499. /** Defines the 3 main axes */
  8500. export class Axis {
  8501. /** X axis */
  8502. static X: Vector3;
  8503. /** Y axis */
  8504. static Y: Vector3;
  8505. /** Z axis */
  8506. static Z: Vector3;
  8507. }
  8508. }
  8509. declare module BABYLON {
  8510. /**
  8511. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8512. * This is the base of the follow, arc rotate cameras and Free camera
  8513. * @see http://doc.babylonjs.com/features/cameras
  8514. */
  8515. export class TargetCamera extends Camera {
  8516. private static _RigCamTransformMatrix;
  8517. private static _TargetTransformMatrix;
  8518. private static _TargetFocalPoint;
  8519. /**
  8520. * Define the current direction the camera is moving to
  8521. */
  8522. cameraDirection: Vector3;
  8523. /**
  8524. * Define the current rotation the camera is rotating to
  8525. */
  8526. cameraRotation: Vector2;
  8527. /**
  8528. * When set, the up vector of the camera will be updated by the rotation of the camera
  8529. */
  8530. updateUpVectorFromRotation: boolean;
  8531. private _tmpQuaternion;
  8532. /**
  8533. * Define the current rotation of the camera
  8534. */
  8535. rotation: Vector3;
  8536. /**
  8537. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8538. */
  8539. rotationQuaternion: Quaternion;
  8540. /**
  8541. * Define the current speed of the camera
  8542. */
  8543. speed: number;
  8544. /**
  8545. * Add constraint to the camera to prevent it to move freely in all directions and
  8546. * around all axis.
  8547. */
  8548. noRotationConstraint: boolean;
  8549. /**
  8550. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8551. * panning
  8552. */
  8553. invertRotation: boolean;
  8554. /**
  8555. * Speed multiplier for inverse camera panning
  8556. */
  8557. inverseRotationSpeed: number;
  8558. /**
  8559. * Define the current target of the camera as an object or a position.
  8560. */
  8561. lockedTarget: any;
  8562. /** @hidden */
  8563. _currentTarget: Vector3;
  8564. /** @hidden */
  8565. _initialFocalDistance: number;
  8566. /** @hidden */
  8567. _viewMatrix: Matrix;
  8568. /** @hidden */
  8569. _camMatrix: Matrix;
  8570. /** @hidden */
  8571. _cameraTransformMatrix: Matrix;
  8572. /** @hidden */
  8573. _cameraRotationMatrix: Matrix;
  8574. /** @hidden */
  8575. _referencePoint: Vector3;
  8576. /** @hidden */
  8577. _transformedReferencePoint: Vector3;
  8578. protected _globalCurrentTarget: Vector3;
  8579. protected _globalCurrentUpVector: Vector3;
  8580. /** @hidden */
  8581. _reset: () => void;
  8582. private _defaultUp;
  8583. /**
  8584. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8585. * This is the base of the follow, arc rotate cameras and Free camera
  8586. * @see http://doc.babylonjs.com/features/cameras
  8587. * @param name Defines the name of the camera in the scene
  8588. * @param position Defines the start position of the camera in the scene
  8589. * @param scene Defines the scene the camera belongs to
  8590. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8591. */
  8592. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8593. /**
  8594. * Gets the position in front of the camera at a given distance.
  8595. * @param distance The distance from the camera we want the position to be
  8596. * @returns the position
  8597. */
  8598. getFrontPosition(distance: number): Vector3;
  8599. /** @hidden */
  8600. _getLockedTargetPosition(): Nullable<Vector3>;
  8601. private _storedPosition;
  8602. private _storedRotation;
  8603. private _storedRotationQuaternion;
  8604. /**
  8605. * Store current camera state of the camera (fov, position, rotation, etc..)
  8606. * @returns the camera
  8607. */
  8608. storeState(): Camera;
  8609. /**
  8610. * Restored camera state. You must call storeState() first
  8611. * @returns whether it was successful or not
  8612. * @hidden
  8613. */
  8614. _restoreStateValues(): boolean;
  8615. /** @hidden */
  8616. _initCache(): void;
  8617. /** @hidden */
  8618. _updateCache(ignoreParentClass?: boolean): void;
  8619. /** @hidden */
  8620. _isSynchronizedViewMatrix(): boolean;
  8621. /** @hidden */
  8622. _computeLocalCameraSpeed(): number;
  8623. /**
  8624. * Defines the target the camera should look at.
  8625. * @param target Defines the new target as a Vector or a mesh
  8626. */
  8627. setTarget(target: Vector3): void;
  8628. /**
  8629. * Return the current target position of the camera. This value is expressed in local space.
  8630. * @returns the target position
  8631. */
  8632. getTarget(): Vector3;
  8633. /** @hidden */
  8634. _decideIfNeedsToMove(): boolean;
  8635. /** @hidden */
  8636. _updatePosition(): void;
  8637. /** @hidden */
  8638. _checkInputs(): void;
  8639. protected _updateCameraRotationMatrix(): void;
  8640. /**
  8641. * 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)
  8642. * @returns the current camera
  8643. */
  8644. private _rotateUpVectorWithCameraRotationMatrix;
  8645. private _cachedRotationZ;
  8646. private _cachedQuaternionRotationZ;
  8647. /** @hidden */
  8648. _getViewMatrix(): Matrix;
  8649. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8650. /**
  8651. * @hidden
  8652. */
  8653. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8654. /**
  8655. * @hidden
  8656. */
  8657. _updateRigCameras(): void;
  8658. private _getRigCamPositionAndTarget;
  8659. /**
  8660. * Gets the current object class name.
  8661. * @return the class name
  8662. */
  8663. getClassName(): string;
  8664. }
  8665. }
  8666. declare module BABYLON {
  8667. /**
  8668. * Gather the list of keyboard event types as constants.
  8669. */
  8670. export class KeyboardEventTypes {
  8671. /**
  8672. * The keydown event is fired when a key becomes active (pressed).
  8673. */
  8674. static readonly KEYDOWN: number;
  8675. /**
  8676. * The keyup event is fired when a key has been released.
  8677. */
  8678. static readonly KEYUP: number;
  8679. }
  8680. /**
  8681. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8682. */
  8683. export class KeyboardInfo {
  8684. /**
  8685. * Defines the type of event (KeyboardEventTypes)
  8686. */
  8687. type: number;
  8688. /**
  8689. * Defines the related dom event
  8690. */
  8691. event: KeyboardEvent;
  8692. /**
  8693. * Instantiates a new keyboard info.
  8694. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8695. * @param type Defines the type of event (KeyboardEventTypes)
  8696. * @param event Defines the related dom event
  8697. */
  8698. constructor(
  8699. /**
  8700. * Defines the type of event (KeyboardEventTypes)
  8701. */
  8702. type: number,
  8703. /**
  8704. * Defines the related dom event
  8705. */
  8706. event: KeyboardEvent);
  8707. }
  8708. /**
  8709. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8710. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8711. */
  8712. export class KeyboardInfoPre extends KeyboardInfo {
  8713. /**
  8714. * Defines the type of event (KeyboardEventTypes)
  8715. */
  8716. type: number;
  8717. /**
  8718. * Defines the related dom event
  8719. */
  8720. event: KeyboardEvent;
  8721. /**
  8722. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8723. */
  8724. skipOnPointerObservable: boolean;
  8725. /**
  8726. * Instantiates a new keyboard pre info.
  8727. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8728. * @param type Defines the type of event (KeyboardEventTypes)
  8729. * @param event Defines the related dom event
  8730. */
  8731. constructor(
  8732. /**
  8733. * Defines the type of event (KeyboardEventTypes)
  8734. */
  8735. type: number,
  8736. /**
  8737. * Defines the related dom event
  8738. */
  8739. event: KeyboardEvent);
  8740. }
  8741. }
  8742. declare module BABYLON {
  8743. /**
  8744. * Manage the keyboard inputs to control the movement of a free camera.
  8745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8746. */
  8747. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8748. /**
  8749. * Defines the camera the input is attached to.
  8750. */
  8751. camera: FreeCamera;
  8752. /**
  8753. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8754. */
  8755. keysUp: number[];
  8756. /**
  8757. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8758. */
  8759. keysUpward: number[];
  8760. /**
  8761. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8762. */
  8763. keysDown: number[];
  8764. /**
  8765. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8766. */
  8767. keysDownward: number[];
  8768. /**
  8769. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8770. */
  8771. keysLeft: number[];
  8772. /**
  8773. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8774. */
  8775. keysRight: number[];
  8776. private _keys;
  8777. private _onCanvasBlurObserver;
  8778. private _onKeyboardObserver;
  8779. private _engine;
  8780. private _scene;
  8781. /**
  8782. * Attach the input controls to a specific dom element to get the input from.
  8783. * @param element Defines the element the controls should be listened from
  8784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8785. */
  8786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8787. /**
  8788. * Detach the current controls from the specified dom element.
  8789. * @param element Defines the element to stop listening the inputs from
  8790. */
  8791. detachControl(element: Nullable<HTMLElement>): void;
  8792. /**
  8793. * Update the current camera state depending on the inputs that have been used this frame.
  8794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8795. */
  8796. checkInputs(): void;
  8797. /**
  8798. * Gets the class name of the current intput.
  8799. * @returns the class name
  8800. */
  8801. getClassName(): string;
  8802. /** @hidden */
  8803. _onLostFocus(): void;
  8804. /**
  8805. * Get the friendly name associated with the input class.
  8806. * @returns the input friendly name
  8807. */
  8808. getSimpleName(): string;
  8809. }
  8810. }
  8811. declare module BABYLON {
  8812. /**
  8813. * Interface describing all the common properties and methods a shadow light needs to implement.
  8814. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8815. * as well as binding the different shadow properties to the effects.
  8816. */
  8817. export interface IShadowLight extends Light {
  8818. /**
  8819. * The light id in the scene (used in scene.findLighById for instance)
  8820. */
  8821. id: string;
  8822. /**
  8823. * The position the shdow will be casted from.
  8824. */
  8825. position: Vector3;
  8826. /**
  8827. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8828. */
  8829. direction: Vector3;
  8830. /**
  8831. * The transformed position. Position of the light in world space taking parenting in account.
  8832. */
  8833. transformedPosition: Vector3;
  8834. /**
  8835. * The transformed direction. Direction of the light in world space taking parenting in account.
  8836. */
  8837. transformedDirection: Vector3;
  8838. /**
  8839. * The friendly name of the light in the scene.
  8840. */
  8841. name: string;
  8842. /**
  8843. * Defines the shadow projection clipping minimum z value.
  8844. */
  8845. shadowMinZ: number;
  8846. /**
  8847. * Defines the shadow projection clipping maximum z value.
  8848. */
  8849. shadowMaxZ: number;
  8850. /**
  8851. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8852. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8853. */
  8854. computeTransformedInformation(): boolean;
  8855. /**
  8856. * Gets the scene the light belongs to.
  8857. * @returns The scene
  8858. */
  8859. getScene(): Scene;
  8860. /**
  8861. * Callback defining a custom Projection Matrix Builder.
  8862. * This can be used to override the default projection matrix computation.
  8863. */
  8864. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8865. /**
  8866. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8867. * @param matrix The materix to updated with the projection information
  8868. * @param viewMatrix The transform matrix of the light
  8869. * @param renderList The list of mesh to render in the map
  8870. * @returns The current light
  8871. */
  8872. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8873. /**
  8874. * Gets the current depth scale used in ESM.
  8875. * @returns The scale
  8876. */
  8877. getDepthScale(): number;
  8878. /**
  8879. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8880. * @returns true if a cube texture needs to be use
  8881. */
  8882. needCube(): boolean;
  8883. /**
  8884. * Detects if the projection matrix requires to be recomputed this frame.
  8885. * @returns true if it requires to be recomputed otherwise, false.
  8886. */
  8887. needProjectionMatrixCompute(): boolean;
  8888. /**
  8889. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8890. */
  8891. forceProjectionMatrixCompute(): void;
  8892. /**
  8893. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8894. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8895. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8896. */
  8897. getShadowDirection(faceIndex?: number): Vector3;
  8898. /**
  8899. * Gets the minZ used for shadow according to both the scene and the light.
  8900. * @param activeCamera The camera we are returning the min for
  8901. * @returns the depth min z
  8902. */
  8903. getDepthMinZ(activeCamera: Camera): number;
  8904. /**
  8905. * Gets the maxZ used for shadow according to both the scene and the light.
  8906. * @param activeCamera The camera we are returning the max for
  8907. * @returns the depth max z
  8908. */
  8909. getDepthMaxZ(activeCamera: Camera): number;
  8910. }
  8911. /**
  8912. * Base implementation IShadowLight
  8913. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8914. */
  8915. export abstract class ShadowLight extends Light implements IShadowLight {
  8916. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8917. protected _position: Vector3;
  8918. protected _setPosition(value: Vector3): void;
  8919. /**
  8920. * Sets the position the shadow will be casted from. Also use as the light position for both
  8921. * point and spot lights.
  8922. */
  8923. get position(): Vector3;
  8924. /**
  8925. * Sets the position the shadow will be casted from. Also use as the light position for both
  8926. * point and spot lights.
  8927. */
  8928. set position(value: Vector3);
  8929. protected _direction: Vector3;
  8930. protected _setDirection(value: Vector3): void;
  8931. /**
  8932. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8933. * Also use as the light direction on spot and directional lights.
  8934. */
  8935. get direction(): Vector3;
  8936. /**
  8937. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8938. * Also use as the light direction on spot and directional lights.
  8939. */
  8940. set direction(value: Vector3);
  8941. protected _shadowMinZ: number;
  8942. /**
  8943. * Gets the shadow projection clipping minimum z value.
  8944. */
  8945. get shadowMinZ(): number;
  8946. /**
  8947. * Sets the shadow projection clipping minimum z value.
  8948. */
  8949. set shadowMinZ(value: number);
  8950. protected _shadowMaxZ: number;
  8951. /**
  8952. * Sets the shadow projection clipping maximum z value.
  8953. */
  8954. get shadowMaxZ(): number;
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. set shadowMaxZ(value: number);
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module BABYLON {
  9052. /**
  9053. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9054. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9055. */
  9056. export class EffectFallbacks implements IEffectFallbacks {
  9057. private _defines;
  9058. private _currentRank;
  9059. private _maxRank;
  9060. private _mesh;
  9061. /**
  9062. * Removes the fallback from the bound mesh.
  9063. */
  9064. unBindMesh(): void;
  9065. /**
  9066. * Adds a fallback on the specified property.
  9067. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9068. * @param define The name of the define in the shader
  9069. */
  9070. addFallback(rank: number, define: string): void;
  9071. /**
  9072. * Sets the mesh to use CPU skinning when needing to fallback.
  9073. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9074. * @param mesh The mesh to use the fallbacks.
  9075. */
  9076. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9077. /**
  9078. * Checks to see if more fallbacks are still availible.
  9079. */
  9080. get hasMoreFallbacks(): boolean;
  9081. /**
  9082. * Removes the defines that should be removed when falling back.
  9083. * @param currentDefines defines the current define statements for the shader.
  9084. * @param effect defines the current effect we try to compile
  9085. * @returns The resulting defines with defines of the current rank removed.
  9086. */
  9087. reduce(currentDefines: string, effect: Effect): string;
  9088. }
  9089. }
  9090. declare module BABYLON {
  9091. /**
  9092. * "Static Class" containing the most commonly used helper while dealing with material for
  9093. * rendering purpose.
  9094. *
  9095. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9096. *
  9097. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9098. */
  9099. export class MaterialHelper {
  9100. /**
  9101. * Bind the current view position to an effect.
  9102. * @param effect The effect to be bound
  9103. * @param scene The scene the eyes position is used from
  9104. */
  9105. static BindEyePosition(effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Helps preparing the defines values about the UVs in used in the effect.
  9108. * UVs are shared as much as we can accross channels in the shaders.
  9109. * @param texture The texture we are preparing the UVs for
  9110. * @param defines The defines to update
  9111. * @param key The channel key "diffuse", "specular"... used in the shader
  9112. */
  9113. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9114. /**
  9115. * Binds a texture matrix value to its corrsponding uniform
  9116. * @param texture The texture to bind the matrix for
  9117. * @param uniformBuffer The uniform buffer receivin the data
  9118. * @param key The channel key "diffuse", "specular"... used in the shader
  9119. */
  9120. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9121. /**
  9122. * Gets the current status of the fog (should it be enabled?)
  9123. * @param mesh defines the mesh to evaluate for fog support
  9124. * @param scene defines the hosting scene
  9125. * @returns true if fog must be enabled
  9126. */
  9127. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9128. /**
  9129. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9130. * @param mesh defines the current mesh
  9131. * @param scene defines the current scene
  9132. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9133. * @param pointsCloud defines if point cloud rendering has to be turned on
  9134. * @param fogEnabled defines if fog has to be turned on
  9135. * @param alphaTest defines if alpha testing has to be turned on
  9136. * @param defines defines the current list of defines
  9137. */
  9138. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9139. /**
  9140. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9141. * @param scene defines the current scene
  9142. * @param engine defines the current engine
  9143. * @param defines specifies the list of active defines
  9144. * @param useInstances defines if instances have to be turned on
  9145. * @param useClipPlane defines if clip plane have to be turned on
  9146. */
  9147. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9148. /**
  9149. * Prepares the defines for bones
  9150. * @param mesh The mesh containing the geometry data we will draw
  9151. * @param defines The defines to update
  9152. */
  9153. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9154. /**
  9155. * Prepares the defines for morph targets
  9156. * @param mesh The mesh containing the geometry data we will draw
  9157. * @param defines The defines to update
  9158. */
  9159. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9160. /**
  9161. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9162. * @param mesh The mesh containing the geometry data we will draw
  9163. * @param defines The defines to update
  9164. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9165. * @param useBones Precise whether bones should be used or not (override mesh info)
  9166. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9167. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9168. * @returns false if defines are considered not dirty and have not been checked
  9169. */
  9170. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9171. /**
  9172. * Prepares the defines related to multiview
  9173. * @param scene The scene we are intending to draw
  9174. * @param defines The defines to update
  9175. */
  9176. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9177. /**
  9178. * Prepares the defines related to the light information passed in parameter
  9179. * @param scene The scene we are intending to draw
  9180. * @param mesh The mesh the effect is compiling for
  9181. * @param light The light the effect is compiling for
  9182. * @param lightIndex The index of the light
  9183. * @param defines The defines to update
  9184. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9185. * @param state Defines the current state regarding what is needed (normals, etc...)
  9186. */
  9187. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9188. needNormals: boolean;
  9189. needRebuild: boolean;
  9190. shadowEnabled: boolean;
  9191. specularEnabled: boolean;
  9192. lightmapMode: boolean;
  9193. }): void;
  9194. /**
  9195. * Prepares the defines related to the light information passed in parameter
  9196. * @param scene The scene we are intending to draw
  9197. * @param mesh The mesh the effect is compiling for
  9198. * @param defines The defines to update
  9199. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9200. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9201. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9202. * @returns true if normals will be required for the rest of the effect
  9203. */
  9204. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9205. /**
  9206. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9207. * @param lightIndex defines the light index
  9208. * @param uniformsList The uniform list
  9209. * @param samplersList The sampler list
  9210. * @param projectedLightTexture defines if projected texture must be used
  9211. * @param uniformBuffersList defines an optional list of uniform buffers
  9212. */
  9213. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9214. /**
  9215. * Prepares the uniforms and samplers list to be used in the effect
  9216. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9217. * @param samplersList The sampler list
  9218. * @param defines The defines helping in the list generation
  9219. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9220. */
  9221. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9222. /**
  9223. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9224. * @param defines The defines to update while falling back
  9225. * @param fallbacks The authorized effect fallbacks
  9226. * @param maxSimultaneousLights The maximum number of lights allowed
  9227. * @param rank the current rank of the Effect
  9228. * @returns The newly affected rank
  9229. */
  9230. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9231. private static _TmpMorphInfluencers;
  9232. /**
  9233. * Prepares the list of attributes required for morph targets according to the effect defines.
  9234. * @param attribs The current list of supported attribs
  9235. * @param mesh The mesh to prepare the morph targets attributes for
  9236. * @param influencers The number of influencers
  9237. */
  9238. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9239. /**
  9240. * Prepares the list of attributes required for morph targets according to the effect defines.
  9241. * @param attribs The current list of supported attribs
  9242. * @param mesh The mesh to prepare the morph targets attributes for
  9243. * @param defines The current Defines of the effect
  9244. */
  9245. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9246. /**
  9247. * Prepares the list of attributes required for bones according to the effect defines.
  9248. * @param attribs The current list of supported attribs
  9249. * @param mesh The mesh to prepare the bones attributes for
  9250. * @param defines The current Defines of the effect
  9251. * @param fallbacks The current efffect fallback strategy
  9252. */
  9253. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9254. /**
  9255. * Check and prepare the list of attributes required for instances according to the effect defines.
  9256. * @param attribs The current list of supported attribs
  9257. * @param defines The current MaterialDefines of the effect
  9258. */
  9259. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9260. /**
  9261. * Add the list of attributes required for instances to the attribs array.
  9262. * @param attribs The current list of supported attribs
  9263. */
  9264. static PushAttributesForInstances(attribs: string[]): void;
  9265. /**
  9266. * Binds the light information to the effect.
  9267. * @param light The light containing the generator
  9268. * @param effect The effect we are binding the data to
  9269. * @param lightIndex The light index in the effect used to render
  9270. */
  9271. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9272. /**
  9273. * Binds the lights information from the scene to the effect for the given mesh.
  9274. * @param light Light to bind
  9275. * @param lightIndex Light index
  9276. * @param scene The scene where the light belongs to
  9277. * @param effect The effect we are binding the data to
  9278. * @param useSpecular Defines if specular is supported
  9279. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9280. */
  9281. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9282. /**
  9283. * Binds the lights information from the scene to the effect for the given mesh.
  9284. * @param scene The scene the lights belongs to
  9285. * @param mesh The mesh we are binding the information to render
  9286. * @param effect The effect we are binding the data to
  9287. * @param defines The generated defines for the effect
  9288. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9289. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9290. */
  9291. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9292. private static _tempFogColor;
  9293. /**
  9294. * Binds the fog information from the scene to the effect for the given mesh.
  9295. * @param scene The scene the lights belongs to
  9296. * @param mesh The mesh we are binding the information to render
  9297. * @param effect The effect we are binding the data to
  9298. * @param linearSpace Defines if the fog effect is applied in linear space
  9299. */
  9300. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9301. /**
  9302. * Binds the bones information from the mesh to the effect.
  9303. * @param mesh The mesh we are binding the information to render
  9304. * @param effect The effect we are binding the data to
  9305. */
  9306. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9307. /**
  9308. * Binds the morph targets information from the mesh to the effect.
  9309. * @param abstractMesh The mesh we are binding the information to render
  9310. * @param effect The effect we are binding the data to
  9311. */
  9312. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9313. /**
  9314. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9315. * @param defines The generated defines used in the effect
  9316. * @param effect The effect we are binding the data to
  9317. * @param scene The scene we are willing to render with logarithmic scale for
  9318. */
  9319. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9320. /**
  9321. * Binds the clip plane information from the scene to the effect.
  9322. * @param scene The scene the clip plane information are extracted from
  9323. * @param effect The effect we are binding the data to
  9324. */
  9325. static BindClipPlane(effect: Effect, scene: Scene): void;
  9326. }
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var packingFunctions: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var clipPlaneFragmentDeclaration: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /** @hidden */
  9344. export var clipPlaneFragment: {
  9345. name: string;
  9346. shader: string;
  9347. };
  9348. }
  9349. declare module BABYLON {
  9350. /** @hidden */
  9351. export var shadowMapPixelShader: {
  9352. name: string;
  9353. shader: string;
  9354. };
  9355. }
  9356. declare module BABYLON {
  9357. /** @hidden */
  9358. export var bonesDeclaration: {
  9359. name: string;
  9360. shader: string;
  9361. };
  9362. }
  9363. declare module BABYLON {
  9364. /** @hidden */
  9365. export var morphTargetsVertexGlobalDeclaration: {
  9366. name: string;
  9367. shader: string;
  9368. };
  9369. }
  9370. declare module BABYLON {
  9371. /** @hidden */
  9372. export var morphTargetsVertexDeclaration: {
  9373. name: string;
  9374. shader: string;
  9375. };
  9376. }
  9377. declare module BABYLON {
  9378. /** @hidden */
  9379. export var instancesDeclaration: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module BABYLON {
  9385. /** @hidden */
  9386. export var helperFunctions: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module BABYLON {
  9392. /** @hidden */
  9393. export var clipPlaneVertexDeclaration: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module BABYLON {
  9399. /** @hidden */
  9400. export var morphTargetsVertex: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module BABYLON {
  9406. /** @hidden */
  9407. export var instancesVertex: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module BABYLON {
  9413. /** @hidden */
  9414. export var bonesVertex: {
  9415. name: string;
  9416. shader: string;
  9417. };
  9418. }
  9419. declare module BABYLON {
  9420. /** @hidden */
  9421. export var clipPlaneVertex: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module BABYLON {
  9427. /** @hidden */
  9428. export var shadowMapVertexShader: {
  9429. name: string;
  9430. shader: string;
  9431. };
  9432. }
  9433. declare module BABYLON {
  9434. /** @hidden */
  9435. export var depthBoxBlurPixelShader: {
  9436. name: string;
  9437. shader: string;
  9438. };
  9439. }
  9440. declare module BABYLON {
  9441. /**
  9442. * Class representing a ray with position and direction
  9443. */
  9444. export class Ray {
  9445. /** origin point */
  9446. origin: Vector3;
  9447. /** direction */
  9448. direction: Vector3;
  9449. /** length of the ray */
  9450. length: number;
  9451. private static readonly TmpVector3;
  9452. private _tmpRay;
  9453. /**
  9454. * Creates a new ray
  9455. * @param origin origin point
  9456. * @param direction direction
  9457. * @param length length of the ray
  9458. */
  9459. constructor(
  9460. /** origin point */
  9461. origin: Vector3,
  9462. /** direction */
  9463. direction: Vector3,
  9464. /** length of the ray */
  9465. length?: number);
  9466. /**
  9467. * Checks if the ray intersects a box
  9468. * @param minimum bound of the box
  9469. * @param maximum bound of the box
  9470. * @param intersectionTreshold extra extend to be added to the box in all direction
  9471. * @returns if the box was hit
  9472. */
  9473. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9474. /**
  9475. * Checks if the ray intersects a box
  9476. * @param box the bounding box to check
  9477. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9478. * @returns if the box was hit
  9479. */
  9480. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9481. /**
  9482. * If the ray hits a sphere
  9483. * @param sphere the bounding sphere to check
  9484. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9485. * @returns true if it hits the sphere
  9486. */
  9487. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9488. /**
  9489. * If the ray hits a triange
  9490. * @param vertex0 triangle vertex
  9491. * @param vertex1 triangle vertex
  9492. * @param vertex2 triangle vertex
  9493. * @returns intersection information if hit
  9494. */
  9495. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9496. /**
  9497. * Checks if ray intersects a plane
  9498. * @param plane the plane to check
  9499. * @returns the distance away it was hit
  9500. */
  9501. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9502. /**
  9503. * Calculate the intercept of a ray on a given axis
  9504. * @param axis to check 'x' | 'y' | 'z'
  9505. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9506. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9507. */
  9508. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9509. /**
  9510. * Checks if ray intersects a mesh
  9511. * @param mesh the mesh to check
  9512. * @param fastCheck if only the bounding box should checked
  9513. * @returns picking info of the intersecton
  9514. */
  9515. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9516. /**
  9517. * Checks if ray intersects a mesh
  9518. * @param meshes the meshes to check
  9519. * @param fastCheck if only the bounding box should checked
  9520. * @param results array to store result in
  9521. * @returns Array of picking infos
  9522. */
  9523. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9524. private _comparePickingInfo;
  9525. private static smallnum;
  9526. private static rayl;
  9527. /**
  9528. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9529. * @param sega the first point of the segment to test the intersection against
  9530. * @param segb the second point of the segment to test the intersection against
  9531. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9532. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9533. */
  9534. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9535. /**
  9536. * Update the ray from viewport position
  9537. * @param x position
  9538. * @param y y position
  9539. * @param viewportWidth viewport width
  9540. * @param viewportHeight viewport height
  9541. * @param world world matrix
  9542. * @param view view matrix
  9543. * @param projection projection matrix
  9544. * @returns this ray updated
  9545. */
  9546. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9547. /**
  9548. * Creates a ray with origin and direction of 0,0,0
  9549. * @returns the new ray
  9550. */
  9551. static Zero(): Ray;
  9552. /**
  9553. * Creates a new ray from screen space and viewport
  9554. * @param x position
  9555. * @param y y position
  9556. * @param viewportWidth viewport width
  9557. * @param viewportHeight viewport height
  9558. * @param world world matrix
  9559. * @param view view matrix
  9560. * @param projection projection matrix
  9561. * @returns new ray
  9562. */
  9563. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9564. /**
  9565. * 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
  9566. * transformed to the given world matrix.
  9567. * @param origin The origin point
  9568. * @param end The end point
  9569. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9570. * @returns the new ray
  9571. */
  9572. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9573. /**
  9574. * Transforms a ray by a matrix
  9575. * @param ray ray to transform
  9576. * @param matrix matrix to apply
  9577. * @returns the resulting new ray
  9578. */
  9579. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9580. /**
  9581. * Transforms a ray by a matrix
  9582. * @param ray ray to transform
  9583. * @param matrix matrix to apply
  9584. * @param result ray to store result in
  9585. */
  9586. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9587. /**
  9588. * Unproject a ray from screen space to object space
  9589. * @param sourceX defines the screen space x coordinate to use
  9590. * @param sourceY defines the screen space y coordinate to use
  9591. * @param viewportWidth defines the current width of the viewport
  9592. * @param viewportHeight defines the current height of the viewport
  9593. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9594. * @param view defines the view matrix to use
  9595. * @param projection defines the projection matrix to use
  9596. */
  9597. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9598. }
  9599. /**
  9600. * Type used to define predicate used to select faces when a mesh intersection is detected
  9601. */
  9602. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9603. interface Scene {
  9604. /** @hidden */
  9605. _tempPickingRay: Nullable<Ray>;
  9606. /** @hidden */
  9607. _cachedRayForTransform: Ray;
  9608. /** @hidden */
  9609. _pickWithRayInverseMatrix: Matrix;
  9610. /** @hidden */
  9611. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9612. /** @hidden */
  9613. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9614. }
  9615. }
  9616. declare module BABYLON {
  9617. /**
  9618. * Groups all the scene component constants in one place to ease maintenance.
  9619. * @hidden
  9620. */
  9621. export class SceneComponentConstants {
  9622. static readonly NAME_EFFECTLAYER: string;
  9623. static readonly NAME_LAYER: string;
  9624. static readonly NAME_LENSFLARESYSTEM: string;
  9625. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9626. static readonly NAME_PARTICLESYSTEM: string;
  9627. static readonly NAME_GAMEPAD: string;
  9628. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9629. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9630. static readonly NAME_DEPTHRENDERER: string;
  9631. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9632. static readonly NAME_SPRITE: string;
  9633. static readonly NAME_OUTLINERENDERER: string;
  9634. static readonly NAME_PROCEDURALTEXTURE: string;
  9635. static readonly NAME_SHADOWGENERATOR: string;
  9636. static readonly NAME_OCTREE: string;
  9637. static readonly NAME_PHYSICSENGINE: string;
  9638. static readonly NAME_AUDIO: string;
  9639. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9640. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9641. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9642. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9643. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9644. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9645. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9646. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9647. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9648. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9649. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9650. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9651. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9652. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9653. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9654. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9655. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9656. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9657. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9658. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9659. static readonly STEP_AFTERRENDER_AUDIO: number;
  9660. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9661. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9662. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9663. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9664. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9665. static readonly STEP_POINTERMOVE_SPRITE: number;
  9666. static readonly STEP_POINTERDOWN_SPRITE: number;
  9667. static readonly STEP_POINTERUP_SPRITE: number;
  9668. }
  9669. /**
  9670. * This represents a scene component.
  9671. *
  9672. * This is used to decouple the dependency the scene is having on the different workloads like
  9673. * layers, post processes...
  9674. */
  9675. export interface ISceneComponent {
  9676. /**
  9677. * The name of the component. Each component must have a unique name.
  9678. */
  9679. name: string;
  9680. /**
  9681. * The scene the component belongs to.
  9682. */
  9683. scene: Scene;
  9684. /**
  9685. * Register the component to one instance of a scene.
  9686. */
  9687. register(): void;
  9688. /**
  9689. * Rebuilds the elements related to this component in case of
  9690. * context lost for instance.
  9691. */
  9692. rebuild(): void;
  9693. /**
  9694. * Disposes the component and the associated ressources.
  9695. */
  9696. dispose(): void;
  9697. }
  9698. /**
  9699. * This represents a SERIALIZABLE scene component.
  9700. *
  9701. * This extends Scene Component to add Serialization methods on top.
  9702. */
  9703. export interface ISceneSerializableComponent extends ISceneComponent {
  9704. /**
  9705. * Adds all the elements from the container to the scene
  9706. * @param container the container holding the elements
  9707. */
  9708. addFromContainer(container: AbstractScene): void;
  9709. /**
  9710. * Removes all the elements in the container from the scene
  9711. * @param container contains the elements to remove
  9712. * @param dispose if the removed element should be disposed (default: false)
  9713. */
  9714. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9715. /**
  9716. * Serializes the component data to the specified json object
  9717. * @param serializationObject The object to serialize to
  9718. */
  9719. serialize(serializationObject: any): void;
  9720. }
  9721. /**
  9722. * Strong typing of a Mesh related stage step action
  9723. */
  9724. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9725. /**
  9726. * Strong typing of a Evaluate Sub Mesh related stage step action
  9727. */
  9728. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9729. /**
  9730. * Strong typing of a Active Mesh related stage step action
  9731. */
  9732. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9733. /**
  9734. * Strong typing of a Camera related stage step action
  9735. */
  9736. export type CameraStageAction = (camera: Camera) => void;
  9737. /**
  9738. * Strong typing of a Camera Frame buffer related stage step action
  9739. */
  9740. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9741. /**
  9742. * Strong typing of a Render Target related stage step action
  9743. */
  9744. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9745. /**
  9746. * Strong typing of a RenderingGroup related stage step action
  9747. */
  9748. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9749. /**
  9750. * Strong typing of a Mesh Render related stage step action
  9751. */
  9752. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9753. /**
  9754. * Strong typing of a simple stage step action
  9755. */
  9756. export type SimpleStageAction = () => void;
  9757. /**
  9758. * Strong typing of a render target action.
  9759. */
  9760. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9761. /**
  9762. * Strong typing of a pointer move action.
  9763. */
  9764. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9765. /**
  9766. * Strong typing of a pointer up/down action.
  9767. */
  9768. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9769. /**
  9770. * Representation of a stage in the scene (Basically a list of ordered steps)
  9771. * @hidden
  9772. */
  9773. export class Stage<T extends Function> extends Array<{
  9774. index: number;
  9775. component: ISceneComponent;
  9776. action: T;
  9777. }> {
  9778. /**
  9779. * Hide ctor from the rest of the world.
  9780. * @param items The items to add.
  9781. */
  9782. private constructor();
  9783. /**
  9784. * Creates a new Stage.
  9785. * @returns A new instance of a Stage
  9786. */
  9787. static Create<T extends Function>(): Stage<T>;
  9788. /**
  9789. * Registers a step in an ordered way in the targeted stage.
  9790. * @param index Defines the position to register the step in
  9791. * @param component Defines the component attached to the step
  9792. * @param action Defines the action to launch during the step
  9793. */
  9794. registerStep(index: number, component: ISceneComponent, action: T): void;
  9795. /**
  9796. * Clears all the steps from the stage.
  9797. */
  9798. clear(): void;
  9799. }
  9800. }
  9801. declare module BABYLON {
  9802. interface Scene {
  9803. /** @hidden */
  9804. _pointerOverSprite: Nullable<Sprite>;
  9805. /** @hidden */
  9806. _pickedDownSprite: Nullable<Sprite>;
  9807. /** @hidden */
  9808. _tempSpritePickingRay: Nullable<Ray>;
  9809. /**
  9810. * All of the sprite managers added to this scene
  9811. * @see http://doc.babylonjs.com/babylon101/sprites
  9812. */
  9813. spriteManagers: Array<ISpriteManager>;
  9814. /**
  9815. * An event triggered when sprites rendering is about to start
  9816. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9817. */
  9818. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9819. /**
  9820. * An event triggered when sprites rendering is done
  9821. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9822. */
  9823. onAfterSpritesRenderingObservable: Observable<Scene>;
  9824. /** @hidden */
  9825. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9826. /** Launch a ray to try to pick a sprite in the scene
  9827. * @param x position on screen
  9828. * @param y position on screen
  9829. * @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
  9830. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9831. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9832. * @returns a PickingInfo
  9833. */
  9834. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9835. /** Use the given ray to pick a sprite in the scene
  9836. * @param ray The ray (in world space) to use to pick meshes
  9837. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9838. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9839. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9840. * @returns a PickingInfo
  9841. */
  9842. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9843. /** @hidden */
  9844. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9845. /** Launch a ray to try to pick sprites in the scene
  9846. * @param x position on screen
  9847. * @param y position on screen
  9848. * @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
  9849. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9850. * @returns a PickingInfo array
  9851. */
  9852. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9853. /** Use the given ray to pick sprites in the scene
  9854. * @param ray The ray (in world space) to use to pick meshes
  9855. * @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
  9856. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9857. * @returns a PickingInfo array
  9858. */
  9859. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9860. /**
  9861. * Force the sprite under the pointer
  9862. * @param sprite defines the sprite to use
  9863. */
  9864. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9865. /**
  9866. * Gets the sprite under the pointer
  9867. * @returns a Sprite or null if no sprite is under the pointer
  9868. */
  9869. getPointerOverSprite(): Nullable<Sprite>;
  9870. }
  9871. /**
  9872. * Defines the sprite scene component responsible to manage sprites
  9873. * in a given scene.
  9874. */
  9875. export class SpriteSceneComponent implements ISceneComponent {
  9876. /**
  9877. * The component name helpfull to identify the component in the list of scene components.
  9878. */
  9879. readonly name: string;
  9880. /**
  9881. * The scene the component belongs to.
  9882. */
  9883. scene: Scene;
  9884. /** @hidden */
  9885. private _spritePredicate;
  9886. /**
  9887. * Creates a new instance of the component for the given scene
  9888. * @param scene Defines the scene to register the component in
  9889. */
  9890. constructor(scene: Scene);
  9891. /**
  9892. * Registers the component in a given scene
  9893. */
  9894. register(): void;
  9895. /**
  9896. * Rebuilds the elements related to this component in case of
  9897. * context lost for instance.
  9898. */
  9899. rebuild(): void;
  9900. /**
  9901. * Disposes the component and the associated ressources.
  9902. */
  9903. dispose(): void;
  9904. private _pickSpriteButKeepRay;
  9905. private _pointerMove;
  9906. private _pointerDown;
  9907. private _pointerUp;
  9908. }
  9909. }
  9910. declare module BABYLON {
  9911. /** @hidden */
  9912. export var fogFragmentDeclaration: {
  9913. name: string;
  9914. shader: string;
  9915. };
  9916. }
  9917. declare module BABYLON {
  9918. /** @hidden */
  9919. export var fogFragment: {
  9920. name: string;
  9921. shader: string;
  9922. };
  9923. }
  9924. declare module BABYLON {
  9925. /** @hidden */
  9926. export var spritesPixelShader: {
  9927. name: string;
  9928. shader: string;
  9929. };
  9930. }
  9931. declare module BABYLON {
  9932. /** @hidden */
  9933. export var fogVertexDeclaration: {
  9934. name: string;
  9935. shader: string;
  9936. };
  9937. }
  9938. declare module BABYLON {
  9939. /** @hidden */
  9940. export var spritesVertexShader: {
  9941. name: string;
  9942. shader: string;
  9943. };
  9944. }
  9945. declare module BABYLON {
  9946. /**
  9947. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9948. */
  9949. export interface ISpriteManager extends IDisposable {
  9950. /**
  9951. * Restricts the camera to viewing objects with the same layerMask.
  9952. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9953. */
  9954. layerMask: number;
  9955. /**
  9956. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9957. */
  9958. isPickable: boolean;
  9959. /**
  9960. * Specifies the rendering group id for this mesh (0 by default)
  9961. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9962. */
  9963. renderingGroupId: number;
  9964. /**
  9965. * Defines the list of sprites managed by the manager.
  9966. */
  9967. sprites: Array<Sprite>;
  9968. /**
  9969. * Tests the intersection of a sprite with a specific ray.
  9970. * @param ray The ray we are sending to test the collision
  9971. * @param camera The camera space we are sending rays in
  9972. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9973. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9974. * @returns picking info or null.
  9975. */
  9976. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9977. /**
  9978. * Intersects the sprites with a ray
  9979. * @param ray defines the ray to intersect with
  9980. * @param camera defines the current active camera
  9981. * @param predicate defines a predicate used to select candidate sprites
  9982. * @returns null if no hit or a PickingInfo array
  9983. */
  9984. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9985. /**
  9986. * Renders the list of sprites on screen.
  9987. */
  9988. render(): void;
  9989. }
  9990. /**
  9991. * Class used to manage multiple sprites on the same spritesheet
  9992. * @see http://doc.babylonjs.com/babylon101/sprites
  9993. */
  9994. export class SpriteManager implements ISpriteManager {
  9995. /** defines the manager's name */
  9996. name: string;
  9997. /** Gets the list of sprites */
  9998. sprites: Sprite[];
  9999. /** Gets or sets the rendering group id (0 by default) */
  10000. renderingGroupId: number;
  10001. /** Gets or sets camera layer mask */
  10002. layerMask: number;
  10003. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10004. fogEnabled: boolean;
  10005. /** Gets or sets a boolean indicating if the sprites are pickable */
  10006. isPickable: boolean;
  10007. /** Defines the default width of a cell in the spritesheet */
  10008. cellWidth: number;
  10009. /** Defines the default height of a cell in the spritesheet */
  10010. cellHeight: number;
  10011. /** Associative array from JSON sprite data file */
  10012. private _cellData;
  10013. /** Array of sprite names from JSON sprite data file */
  10014. private _spriteMap;
  10015. /** True when packed cell data from JSON file is ready*/
  10016. private _packedAndReady;
  10017. /**
  10018. * An event triggered when the manager is disposed.
  10019. */
  10020. onDisposeObservable: Observable<SpriteManager>;
  10021. private _onDisposeObserver;
  10022. /**
  10023. * Callback called when the manager is disposed
  10024. */
  10025. set onDispose(callback: () => void);
  10026. private _capacity;
  10027. private _fromPacked;
  10028. private _spriteTexture;
  10029. private _epsilon;
  10030. private _scene;
  10031. private _vertexData;
  10032. private _buffer;
  10033. private _vertexBuffers;
  10034. private _indexBuffer;
  10035. private _effectBase;
  10036. private _effectFog;
  10037. /**
  10038. * Gets or sets the spritesheet texture
  10039. */
  10040. get texture(): Texture;
  10041. set texture(value: Texture);
  10042. private _blendMode;
  10043. /**
  10044. * Blend mode use to render the particle, it can be any of
  10045. * the static Constants.ALPHA_x properties provided in this class.
  10046. * Default value is Constants.ALPHA_COMBINE
  10047. */
  10048. get blendMode(): number;
  10049. set blendMode(blendMode: number);
  10050. /** Disables writing to the depth buffer when rendering the sprites.
  10051. * It can be handy to disable depth writing when using textures without alpha channel
  10052. * and setting some specific blend modes.
  10053. */
  10054. disableDepthWrite: boolean;
  10055. /**
  10056. * Creates a new sprite manager
  10057. * @param name defines the manager's name
  10058. * @param imgUrl defines the sprite sheet url
  10059. * @param capacity defines the maximum allowed number of sprites
  10060. * @param cellSize defines the size of a sprite cell
  10061. * @param scene defines the hosting scene
  10062. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10063. * @param samplingMode defines the smapling mode to use with spritesheet
  10064. * @param fromPacked set to false; do not alter
  10065. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10066. */
  10067. constructor(
  10068. /** defines the manager's name */
  10069. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10070. private _makePacked;
  10071. private _appendSpriteVertex;
  10072. /**
  10073. * Intersects the sprites with a ray
  10074. * @param ray defines the ray to intersect with
  10075. * @param camera defines the current active camera
  10076. * @param predicate defines a predicate used to select candidate sprites
  10077. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10078. * @returns null if no hit or a PickingInfo
  10079. */
  10080. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10081. /**
  10082. * Intersects the sprites with a ray
  10083. * @param ray defines the ray to intersect with
  10084. * @param camera defines the current active camera
  10085. * @param predicate defines a predicate used to select candidate sprites
  10086. * @returns null if no hit or a PickingInfo array
  10087. */
  10088. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10089. /**
  10090. * Render all child sprites
  10091. */
  10092. render(): void;
  10093. /**
  10094. * Release associated resources
  10095. */
  10096. dispose(): void;
  10097. }
  10098. }
  10099. declare module BABYLON {
  10100. /** Interface used by value gradients (color, factor, ...) */
  10101. export interface IValueGradient {
  10102. /**
  10103. * Gets or sets the gradient value (between 0 and 1)
  10104. */
  10105. gradient: number;
  10106. }
  10107. /** Class used to store color4 gradient */
  10108. export class ColorGradient implements IValueGradient {
  10109. /**
  10110. * Gets or sets the gradient value (between 0 and 1)
  10111. */
  10112. gradient: number;
  10113. /**
  10114. * Gets or sets first associated color
  10115. */
  10116. color1: Color4;
  10117. /**
  10118. * Gets or sets second associated color
  10119. */
  10120. color2?: Color4;
  10121. /**
  10122. * Will get a color picked randomly between color1 and color2.
  10123. * If color2 is undefined then color1 will be used
  10124. * @param result defines the target Color4 to store the result in
  10125. */
  10126. getColorToRef(result: Color4): void;
  10127. }
  10128. /** Class used to store color 3 gradient */
  10129. export class Color3Gradient implements IValueGradient {
  10130. /**
  10131. * Gets or sets the gradient value (between 0 and 1)
  10132. */
  10133. gradient: number;
  10134. /**
  10135. * Gets or sets the associated color
  10136. */
  10137. color: Color3;
  10138. }
  10139. /** Class used to store factor gradient */
  10140. export class FactorGradient implements IValueGradient {
  10141. /**
  10142. * Gets or sets the gradient value (between 0 and 1)
  10143. */
  10144. gradient: number;
  10145. /**
  10146. * Gets or sets first associated factor
  10147. */
  10148. factor1: number;
  10149. /**
  10150. * Gets or sets second associated factor
  10151. */
  10152. factor2?: number;
  10153. /**
  10154. * Will get a number picked randomly between factor1 and factor2.
  10155. * If factor2 is undefined then factor1 will be used
  10156. * @returns the picked number
  10157. */
  10158. getFactor(): number;
  10159. }
  10160. /**
  10161. * Helper used to simplify some generic gradient tasks
  10162. */
  10163. export class GradientHelper {
  10164. /**
  10165. * Gets the current gradient from an array of IValueGradient
  10166. * @param ratio defines the current ratio to get
  10167. * @param gradients defines the array of IValueGradient
  10168. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10169. */
  10170. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10171. }
  10172. }
  10173. declare module BABYLON {
  10174. /**
  10175. * Interface for the size containing width and height
  10176. */
  10177. export interface ISize {
  10178. /**
  10179. * Width
  10180. */
  10181. width: number;
  10182. /**
  10183. * Heighht
  10184. */
  10185. height: number;
  10186. }
  10187. /**
  10188. * Size containing widht and height
  10189. */
  10190. export class Size implements ISize {
  10191. /**
  10192. * Width
  10193. */
  10194. width: number;
  10195. /**
  10196. * Height
  10197. */
  10198. height: number;
  10199. /**
  10200. * Creates a Size object from the given width and height (floats).
  10201. * @param width width of the new size
  10202. * @param height height of the new size
  10203. */
  10204. constructor(width: number, height: number);
  10205. /**
  10206. * Returns a string with the Size width and height
  10207. * @returns a string with the Size width and height
  10208. */
  10209. toString(): string;
  10210. /**
  10211. * "Size"
  10212. * @returns the string "Size"
  10213. */
  10214. getClassName(): string;
  10215. /**
  10216. * Returns the Size hash code.
  10217. * @returns a hash code for a unique width and height
  10218. */
  10219. getHashCode(): number;
  10220. /**
  10221. * Updates the current size from the given one.
  10222. * @param src the given size
  10223. */
  10224. copyFrom(src: Size): void;
  10225. /**
  10226. * Updates in place the current Size from the given floats.
  10227. * @param width width of the new size
  10228. * @param height height of the new size
  10229. * @returns the updated Size.
  10230. */
  10231. copyFromFloats(width: number, height: number): Size;
  10232. /**
  10233. * Updates in place the current Size from the given floats.
  10234. * @param width width to set
  10235. * @param height height to set
  10236. * @returns the updated Size.
  10237. */
  10238. set(width: number, height: number): Size;
  10239. /**
  10240. * Multiplies the width and height by numbers
  10241. * @param w factor to multiple the width by
  10242. * @param h factor to multiple the height by
  10243. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10244. */
  10245. multiplyByFloats(w: number, h: number): Size;
  10246. /**
  10247. * Clones the size
  10248. * @returns a new Size copied from the given one.
  10249. */
  10250. clone(): Size;
  10251. /**
  10252. * True if the current Size and the given one width and height are strictly equal.
  10253. * @param other the other size to compare against
  10254. * @returns True if the current Size and the given one width and height are strictly equal.
  10255. */
  10256. equals(other: Size): boolean;
  10257. /**
  10258. * The surface of the Size : width * height (float).
  10259. */
  10260. get surface(): number;
  10261. /**
  10262. * Create a new size of zero
  10263. * @returns a new Size set to (0.0, 0.0)
  10264. */
  10265. static Zero(): Size;
  10266. /**
  10267. * Sums the width and height of two sizes
  10268. * @param otherSize size to add to this size
  10269. * @returns a new Size set as the addition result of the current Size and the given one.
  10270. */
  10271. add(otherSize: Size): Size;
  10272. /**
  10273. * Subtracts the width and height of two
  10274. * @param otherSize size to subtract to this size
  10275. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10276. */
  10277. subtract(otherSize: Size): Size;
  10278. /**
  10279. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10280. * @param start starting size to lerp between
  10281. * @param end end size to lerp between
  10282. * @param amount amount to lerp between the start and end values
  10283. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10284. */
  10285. static Lerp(start: Size, end: Size, amount: number): Size;
  10286. }
  10287. }
  10288. declare module BABYLON {
  10289. interface ThinEngine {
  10290. /**
  10291. * Creates a dynamic texture
  10292. * @param width defines the width of the texture
  10293. * @param height defines the height of the texture
  10294. * @param generateMipMaps defines if the engine should generate the mip levels
  10295. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10296. * @returns the dynamic texture inside an InternalTexture
  10297. */
  10298. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10299. /**
  10300. * Update the content of a dynamic texture
  10301. * @param texture defines the texture to update
  10302. * @param canvas defines the canvas containing the source
  10303. * @param invertY defines if data must be stored with Y axis inverted
  10304. * @param premulAlpha defines if alpha is stored as premultiplied
  10305. * @param format defines the format of the data
  10306. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10307. */
  10308. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10309. }
  10310. }
  10311. declare module BABYLON {
  10312. /**
  10313. * Helper class used to generate a canvas to manipulate images
  10314. */
  10315. export class CanvasGenerator {
  10316. /**
  10317. * Create a new canvas (or offscreen canvas depending on the context)
  10318. * @param width defines the expected width
  10319. * @param height defines the expected height
  10320. * @return a new canvas or offscreen canvas
  10321. */
  10322. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10323. }
  10324. }
  10325. declare module BABYLON {
  10326. /**
  10327. * A class extending Texture allowing drawing on a texture
  10328. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10329. */
  10330. export class DynamicTexture extends Texture {
  10331. private _generateMipMaps;
  10332. private _canvas;
  10333. private _context;
  10334. private _engine;
  10335. /**
  10336. * Creates a DynamicTexture
  10337. * @param name defines the name of the texture
  10338. * @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
  10339. * @param scene defines the scene where you want the texture
  10340. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10341. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10342. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10343. */
  10344. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10345. /**
  10346. * Get the current class name of the texture useful for serialization or dynamic coding.
  10347. * @returns "DynamicTexture"
  10348. */
  10349. getClassName(): string;
  10350. /**
  10351. * Gets the current state of canRescale
  10352. */
  10353. get canRescale(): boolean;
  10354. private _recreate;
  10355. /**
  10356. * Scales the texture
  10357. * @param ratio the scale factor to apply to both width and height
  10358. */
  10359. scale(ratio: number): void;
  10360. /**
  10361. * Resizes the texture
  10362. * @param width the new width
  10363. * @param height the new height
  10364. */
  10365. scaleTo(width: number, height: number): void;
  10366. /**
  10367. * Gets the context of the canvas used by the texture
  10368. * @returns the canvas context of the dynamic texture
  10369. */
  10370. getContext(): CanvasRenderingContext2D;
  10371. /**
  10372. * Clears the texture
  10373. */
  10374. clear(): void;
  10375. /**
  10376. * Updates the texture
  10377. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10378. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10379. */
  10380. update(invertY?: boolean, premulAlpha?: boolean): void;
  10381. /**
  10382. * Draws text onto the texture
  10383. * @param text defines the text to be drawn
  10384. * @param x defines the placement of the text from the left
  10385. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10386. * @param font defines the font to be used with font-style, font-size, font-name
  10387. * @param color defines the color used for the text
  10388. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10389. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10390. * @param update defines whether texture is immediately update (default is true)
  10391. */
  10392. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10393. /**
  10394. * Clones the texture
  10395. * @returns the clone of the texture.
  10396. */
  10397. clone(): DynamicTexture;
  10398. /**
  10399. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10400. * @returns a serialized dynamic texture object
  10401. */
  10402. serialize(): any;
  10403. /** @hidden */
  10404. _rebuild(): void;
  10405. }
  10406. }
  10407. declare module BABYLON {
  10408. interface Engine {
  10409. /**
  10410. * Creates a raw texture
  10411. * @param data defines the data to store in the texture
  10412. * @param width defines the width of the texture
  10413. * @param height defines the height of the texture
  10414. * @param format defines the format of the data
  10415. * @param generateMipMaps defines if the engine should generate the mip levels
  10416. * @param invertY defines if data must be stored with Y axis inverted
  10417. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10418. * @param compression defines the compression used (null by default)
  10419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10420. * @returns the raw texture inside an InternalTexture
  10421. */
  10422. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10423. /**
  10424. * Update a raw texture
  10425. * @param texture defines the texture to update
  10426. * @param data defines the data to store in the texture
  10427. * @param format defines the format of the data
  10428. * @param invertY defines if data must be stored with Y axis inverted
  10429. */
  10430. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10431. /**
  10432. * Update a raw texture
  10433. * @param texture defines the texture to update
  10434. * @param data defines the data to store in the texture
  10435. * @param format defines the format of the data
  10436. * @param invertY defines if data must be stored with Y axis inverted
  10437. * @param compression defines the compression used (null by default)
  10438. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10439. */
  10440. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10441. /**
  10442. * Creates a new raw cube texture
  10443. * @param data defines the array of data to use to create each face
  10444. * @param size defines the size of the textures
  10445. * @param format defines the format of the data
  10446. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10447. * @param generateMipMaps defines if the engine should generate the mip levels
  10448. * @param invertY defines if data must be stored with Y axis inverted
  10449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10450. * @param compression defines the compression used (null by default)
  10451. * @returns the cube texture as an InternalTexture
  10452. */
  10453. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10454. /**
  10455. * Update a raw cube texture
  10456. * @param texture defines the texture to udpdate
  10457. * @param data defines the data to store
  10458. * @param format defines the data format
  10459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10460. * @param invertY defines if data must be stored with Y axis inverted
  10461. */
  10462. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10463. /**
  10464. * Update a raw cube texture
  10465. * @param texture defines the texture to udpdate
  10466. * @param data defines the data to store
  10467. * @param format defines the data format
  10468. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10469. * @param invertY defines if data must be stored with Y axis inverted
  10470. * @param compression defines the compression used (null by default)
  10471. */
  10472. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10473. /**
  10474. * Update a raw cube texture
  10475. * @param texture defines the texture to udpdate
  10476. * @param data defines the data to store
  10477. * @param format defines the data format
  10478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10479. * @param invertY defines if data must be stored with Y axis inverted
  10480. * @param compression defines the compression used (null by default)
  10481. * @param level defines which level of the texture to update
  10482. */
  10483. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10484. /**
  10485. * Creates a new raw cube texture from a specified url
  10486. * @param url defines the url where the data is located
  10487. * @param scene defines the current scene
  10488. * @param size defines the size of the textures
  10489. * @param format defines the format of the data
  10490. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10491. * @param noMipmap defines if the engine should avoid generating the mip levels
  10492. * @param callback defines a callback used to extract texture data from loaded data
  10493. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10494. * @param onLoad defines a callback called when texture is loaded
  10495. * @param onError defines a callback called if there is an error
  10496. * @returns the cube texture as an InternalTexture
  10497. */
  10498. 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;
  10499. /**
  10500. * Creates a new raw cube texture from a specified url
  10501. * @param url defines the url where the data is located
  10502. * @param scene defines the current scene
  10503. * @param size defines the size of the textures
  10504. * @param format defines the format of the data
  10505. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10506. * @param noMipmap defines if the engine should avoid generating the mip levels
  10507. * @param callback defines a callback used to extract texture data from loaded data
  10508. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10509. * @param onLoad defines a callback called when texture is loaded
  10510. * @param onError defines a callback called if there is an error
  10511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10512. * @param invertY defines if data must be stored with Y axis inverted
  10513. * @returns the cube texture as an InternalTexture
  10514. */
  10515. 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;
  10516. /**
  10517. * Creates a new raw 3D texture
  10518. * @param data defines the data used to create the texture
  10519. * @param width defines the width of the texture
  10520. * @param height defines the height of the texture
  10521. * @param depth defines the depth of the texture
  10522. * @param format defines the format of the texture
  10523. * @param generateMipMaps defines if the engine must generate mip levels
  10524. * @param invertY defines if data must be stored with Y axis inverted
  10525. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10526. * @param compression defines the compressed used (can be null)
  10527. * @param textureType defines the compressed used (can be null)
  10528. * @returns a new raw 3D texture (stored in an InternalTexture)
  10529. */
  10530. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10531. /**
  10532. * Update a raw 3D texture
  10533. * @param texture defines the texture to update
  10534. * @param data defines the data to store
  10535. * @param format defines the data format
  10536. * @param invertY defines if data must be stored with Y axis inverted
  10537. */
  10538. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10539. /**
  10540. * Update a raw 3D texture
  10541. * @param texture defines the texture to update
  10542. * @param data defines the data to store
  10543. * @param format defines the data format
  10544. * @param invertY defines if data must be stored with Y axis inverted
  10545. * @param compression defines the used compression (can be null)
  10546. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10547. */
  10548. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10549. /**
  10550. * Creates a new raw 2D array texture
  10551. * @param data defines the data used to create the texture
  10552. * @param width defines the width of the texture
  10553. * @param height defines the height of the texture
  10554. * @param depth defines the number of layers of the texture
  10555. * @param format defines the format of the texture
  10556. * @param generateMipMaps defines if the engine must generate mip levels
  10557. * @param invertY defines if data must be stored with Y axis inverted
  10558. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10559. * @param compression defines the compressed used (can be null)
  10560. * @param textureType defines the compressed used (can be null)
  10561. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10562. */
  10563. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10564. /**
  10565. * Update a raw 2D array texture
  10566. * @param texture defines the texture to update
  10567. * @param data defines the data to store
  10568. * @param format defines the data format
  10569. * @param invertY defines if data must be stored with Y axis inverted
  10570. */
  10571. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10572. /**
  10573. * Update a raw 2D array texture
  10574. * @param texture defines the texture to update
  10575. * @param data defines the data to store
  10576. * @param format defines the data format
  10577. * @param invertY defines if data must be stored with Y axis inverted
  10578. * @param compression defines the used compression (can be null)
  10579. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10580. */
  10581. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10582. }
  10583. }
  10584. declare module BABYLON {
  10585. /**
  10586. * Raw texture can help creating a texture directly from an array of data.
  10587. * This can be super useful if you either get the data from an uncompressed source or
  10588. * if you wish to create your texture pixel by pixel.
  10589. */
  10590. export class RawTexture extends Texture {
  10591. /**
  10592. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10593. */
  10594. format: number;
  10595. private _engine;
  10596. /**
  10597. * Instantiates a new RawTexture.
  10598. * Raw texture can help creating a texture directly from an array of data.
  10599. * This can be super useful if you either get the data from an uncompressed source or
  10600. * if you wish to create your texture pixel by pixel.
  10601. * @param data define the array of data to use to create the texture
  10602. * @param width define the width of the texture
  10603. * @param height define the height of the texture
  10604. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10605. * @param scene define the scene the texture belongs to
  10606. * @param generateMipMaps define whether mip maps should be generated or not
  10607. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10608. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10609. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10610. */
  10611. constructor(data: ArrayBufferView, width: number, height: number,
  10612. /**
  10613. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10614. */
  10615. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10616. /**
  10617. * Updates the texture underlying data.
  10618. * @param data Define the new data of the texture
  10619. */
  10620. update(data: ArrayBufferView): void;
  10621. /**
  10622. * Creates a luminance texture from some data.
  10623. * @param data Define the texture data
  10624. * @param width Define the width of the texture
  10625. * @param height Define the height of the texture
  10626. * @param scene Define the scene the texture belongs to
  10627. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10628. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10629. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10630. * @returns the luminance texture
  10631. */
  10632. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10633. /**
  10634. * Creates a luminance alpha texture from some data.
  10635. * @param data Define the texture data
  10636. * @param width Define the width of the texture
  10637. * @param height Define the height of the texture
  10638. * @param scene Define the scene the texture belongs to
  10639. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10640. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10641. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10642. * @returns the luminance alpha texture
  10643. */
  10644. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10645. /**
  10646. * Creates an alpha texture from some data.
  10647. * @param data Define the texture data
  10648. * @param width Define the width of the texture
  10649. * @param height Define the height of the texture
  10650. * @param scene Define the scene the texture belongs to
  10651. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10652. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10653. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10654. * @returns the alpha texture
  10655. */
  10656. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10657. /**
  10658. * Creates a RGB texture from some data.
  10659. * @param data Define the texture data
  10660. * @param width Define the width of the texture
  10661. * @param height Define the height of the texture
  10662. * @param scene Define the scene the texture belongs to
  10663. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10666. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10667. * @returns the RGB alpha texture
  10668. */
  10669. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10670. /**
  10671. * Creates a RGBA texture from some data.
  10672. * @param data Define the texture data
  10673. * @param width Define the width of the texture
  10674. * @param height Define the height of the texture
  10675. * @param scene Define the scene the texture belongs to
  10676. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10677. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10678. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10679. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10680. * @returns the RGBA texture
  10681. */
  10682. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10683. /**
  10684. * Creates a R texture from some data.
  10685. * @param data Define the texture data
  10686. * @param width Define the width of the texture
  10687. * @param height Define the height of the texture
  10688. * @param scene Define the scene the texture belongs to
  10689. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10690. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10691. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10692. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10693. * @returns the R texture
  10694. */
  10695. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10696. }
  10697. }
  10698. declare module BABYLON {
  10699. interface AbstractScene {
  10700. /**
  10701. * The list of procedural textures added to the scene
  10702. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10703. */
  10704. proceduralTextures: Array<ProceduralTexture>;
  10705. }
  10706. /**
  10707. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10708. * in a given scene.
  10709. */
  10710. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10711. /**
  10712. * The component name helpfull to identify the component in the list of scene components.
  10713. */
  10714. readonly name: string;
  10715. /**
  10716. * The scene the component belongs to.
  10717. */
  10718. scene: Scene;
  10719. /**
  10720. * Creates a new instance of the component for the given scene
  10721. * @param scene Defines the scene to register the component in
  10722. */
  10723. constructor(scene: Scene);
  10724. /**
  10725. * Registers the component in a given scene
  10726. */
  10727. register(): void;
  10728. /**
  10729. * Rebuilds the elements related to this component in case of
  10730. * context lost for instance.
  10731. */
  10732. rebuild(): void;
  10733. /**
  10734. * Disposes the component and the associated ressources.
  10735. */
  10736. dispose(): void;
  10737. private _beforeClear;
  10738. }
  10739. }
  10740. declare module BABYLON {
  10741. interface ThinEngine {
  10742. /**
  10743. * Creates a new render target cube texture
  10744. * @param size defines the size of the texture
  10745. * @param options defines the options used to create the texture
  10746. * @returns a new render target cube texture stored in an InternalTexture
  10747. */
  10748. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10749. }
  10750. }
  10751. declare module BABYLON {
  10752. /** @hidden */
  10753. export var proceduralVertexShader: {
  10754. name: string;
  10755. shader: string;
  10756. };
  10757. }
  10758. declare module BABYLON {
  10759. /**
  10760. * 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.
  10761. * This is the base class of any Procedural texture and contains most of the shareable code.
  10762. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10763. */
  10764. export class ProceduralTexture extends Texture {
  10765. isCube: boolean;
  10766. /**
  10767. * Define if the texture is enabled or not (disabled texture will not render)
  10768. */
  10769. isEnabled: boolean;
  10770. /**
  10771. * Define if the texture must be cleared before rendering (default is true)
  10772. */
  10773. autoClear: boolean;
  10774. /**
  10775. * Callback called when the texture is generated
  10776. */
  10777. onGenerated: () => void;
  10778. /**
  10779. * Event raised when the texture is generated
  10780. */
  10781. onGeneratedObservable: Observable<ProceduralTexture>;
  10782. /** @hidden */
  10783. _generateMipMaps: boolean;
  10784. /** @hidden **/
  10785. _effect: Effect;
  10786. /** @hidden */
  10787. _textures: {
  10788. [key: string]: Texture;
  10789. };
  10790. private _size;
  10791. private _currentRefreshId;
  10792. private _frameId;
  10793. private _refreshRate;
  10794. private _vertexBuffers;
  10795. private _indexBuffer;
  10796. private _uniforms;
  10797. private _samplers;
  10798. private _fragment;
  10799. private _floats;
  10800. private _ints;
  10801. private _floatsArrays;
  10802. private _colors3;
  10803. private _colors4;
  10804. private _vectors2;
  10805. private _vectors3;
  10806. private _matrices;
  10807. private _fallbackTexture;
  10808. private _fallbackTextureUsed;
  10809. private _engine;
  10810. private _cachedDefines;
  10811. private _contentUpdateId;
  10812. private _contentData;
  10813. /**
  10814. * Instantiates a new procedural texture.
  10815. * 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.
  10816. * This is the base class of any Procedural texture and contains most of the shareable code.
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10818. * @param name Define the name of the texture
  10819. * @param size Define the size of the texture to create
  10820. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10821. * @param scene Define the scene the texture belongs to
  10822. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10823. * @param generateMipMaps Define if the texture should creates mip maps or not
  10824. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10825. */
  10826. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10827. /**
  10828. * The effect that is created when initializing the post process.
  10829. * @returns The created effect corresponding the the postprocess.
  10830. */
  10831. getEffect(): Effect;
  10832. /**
  10833. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10834. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10835. */
  10836. getContent(): Nullable<ArrayBufferView>;
  10837. private _createIndexBuffer;
  10838. /** @hidden */
  10839. _rebuild(): void;
  10840. /**
  10841. * Resets the texture in order to recreate its associated resources.
  10842. * This can be called in case of context loss
  10843. */
  10844. reset(): void;
  10845. protected _getDefines(): string;
  10846. /**
  10847. * Is the texture ready to be used ? (rendered at least once)
  10848. * @returns true if ready, otherwise, false.
  10849. */
  10850. isReady(): boolean;
  10851. /**
  10852. * Resets the refresh counter of the texture and start bak from scratch.
  10853. * Could be useful to regenerate the texture if it is setup to render only once.
  10854. */
  10855. resetRefreshCounter(): void;
  10856. /**
  10857. * Set the fragment shader to use in order to render the texture.
  10858. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10859. */
  10860. setFragment(fragment: any): void;
  10861. /**
  10862. * Define the refresh rate of the texture or the rendering frequency.
  10863. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10864. */
  10865. get refreshRate(): number;
  10866. set refreshRate(value: number);
  10867. /** @hidden */
  10868. _shouldRender(): boolean;
  10869. /**
  10870. * Get the size the texture is rendering at.
  10871. * @returns the size (texture is always squared)
  10872. */
  10873. getRenderSize(): number;
  10874. /**
  10875. * Resize the texture to new value.
  10876. * @param size Define the new size the texture should have
  10877. * @param generateMipMaps Define whether the new texture should create mip maps
  10878. */
  10879. resize(size: number, generateMipMaps: boolean): void;
  10880. private _checkUniform;
  10881. /**
  10882. * Set a texture in the shader program used to render.
  10883. * @param name Define the name of the uniform samplers as defined in the shader
  10884. * @param texture Define the texture to bind to this sampler
  10885. * @return the texture itself allowing "fluent" like uniform updates
  10886. */
  10887. setTexture(name: string, texture: Texture): ProceduralTexture;
  10888. /**
  10889. * Set a float in the shader.
  10890. * @param name Define the name of the uniform as defined in the shader
  10891. * @param value Define the value to give to the uniform
  10892. * @return the texture itself allowing "fluent" like uniform updates
  10893. */
  10894. setFloat(name: string, value: number): ProceduralTexture;
  10895. /**
  10896. * Set a int in the shader.
  10897. * @param name Define the name of the uniform as defined in the shader
  10898. * @param value Define the value to give to the uniform
  10899. * @return the texture itself allowing "fluent" like uniform updates
  10900. */
  10901. setInt(name: string, value: number): ProceduralTexture;
  10902. /**
  10903. * Set an array of floats in the shader.
  10904. * @param name Define the name of the uniform as defined in the shader
  10905. * @param value Define the value to give to the uniform
  10906. * @return the texture itself allowing "fluent" like uniform updates
  10907. */
  10908. setFloats(name: string, value: number[]): ProceduralTexture;
  10909. /**
  10910. * Set a vec3 in the shader from a Color3.
  10911. * @param name Define the name of the uniform as defined in the shader
  10912. * @param value Define the value to give to the uniform
  10913. * @return the texture itself allowing "fluent" like uniform updates
  10914. */
  10915. setColor3(name: string, value: Color3): ProceduralTexture;
  10916. /**
  10917. * Set a vec4 in the shader from a Color4.
  10918. * @param name Define the name of the uniform as defined in the shader
  10919. * @param value Define the value to give to the uniform
  10920. * @return the texture itself allowing "fluent" like uniform updates
  10921. */
  10922. setColor4(name: string, value: Color4): ProceduralTexture;
  10923. /**
  10924. * Set a vec2 in the shader from a Vector2.
  10925. * @param name Define the name of the uniform as defined in the shader
  10926. * @param value Define the value to give to the uniform
  10927. * @return the texture itself allowing "fluent" like uniform updates
  10928. */
  10929. setVector2(name: string, value: Vector2): ProceduralTexture;
  10930. /**
  10931. * Set a vec3 in the shader from a Vector3.
  10932. * @param name Define the name of the uniform as defined in the shader
  10933. * @param value Define the value to give to the uniform
  10934. * @return the texture itself allowing "fluent" like uniform updates
  10935. */
  10936. setVector3(name: string, value: Vector3): ProceduralTexture;
  10937. /**
  10938. * Set a mat4 in the shader from a MAtrix.
  10939. * @param name Define the name of the uniform as defined in the shader
  10940. * @param value Define the value to give to the uniform
  10941. * @return the texture itself allowing "fluent" like uniform updates
  10942. */
  10943. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10944. /**
  10945. * Render the texture to its associated render target.
  10946. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10947. */
  10948. render(useCameraPostProcess?: boolean): void;
  10949. /**
  10950. * Clone the texture.
  10951. * @returns the cloned texture
  10952. */
  10953. clone(): ProceduralTexture;
  10954. /**
  10955. * Dispose the texture and release its asoociated resources.
  10956. */
  10957. dispose(): void;
  10958. }
  10959. }
  10960. declare module BABYLON {
  10961. /**
  10962. * This represents the base class for particle system in Babylon.
  10963. * 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.
  10964. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10965. * @example https://doc.babylonjs.com/babylon101/particles
  10966. */
  10967. export class BaseParticleSystem {
  10968. /**
  10969. * Source color is added to the destination color without alpha affecting the result
  10970. */
  10971. static BLENDMODE_ONEONE: number;
  10972. /**
  10973. * Blend current color and particle color using particle’s alpha
  10974. */
  10975. static BLENDMODE_STANDARD: number;
  10976. /**
  10977. * Add current color and particle color multiplied by particle’s alpha
  10978. */
  10979. static BLENDMODE_ADD: number;
  10980. /**
  10981. * Multiply current color with particle color
  10982. */
  10983. static BLENDMODE_MULTIPLY: number;
  10984. /**
  10985. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10986. */
  10987. static BLENDMODE_MULTIPLYADD: number;
  10988. /**
  10989. * List of animations used by the particle system.
  10990. */
  10991. animations: Animation[];
  10992. /**
  10993. * The id of the Particle system.
  10994. */
  10995. id: string;
  10996. /**
  10997. * The friendly name of the Particle system.
  10998. */
  10999. name: string;
  11000. /**
  11001. * The rendering group used by the Particle system to chose when to render.
  11002. */
  11003. renderingGroupId: number;
  11004. /**
  11005. * The emitter represents the Mesh or position we are attaching the particle system to.
  11006. */
  11007. emitter: Nullable<AbstractMesh | Vector3>;
  11008. /**
  11009. * The maximum number of particles to emit per frame
  11010. */
  11011. emitRate: number;
  11012. /**
  11013. * If you want to launch only a few particles at once, that can be done, as well.
  11014. */
  11015. manualEmitCount: number;
  11016. /**
  11017. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11018. */
  11019. updateSpeed: number;
  11020. /**
  11021. * The amount of time the particle system is running (depends of the overall update speed).
  11022. */
  11023. targetStopDuration: number;
  11024. /**
  11025. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11026. */
  11027. disposeOnStop: boolean;
  11028. /**
  11029. * Minimum power of emitting particles.
  11030. */
  11031. minEmitPower: number;
  11032. /**
  11033. * Maximum power of emitting particles.
  11034. */
  11035. maxEmitPower: number;
  11036. /**
  11037. * Minimum life time of emitting particles.
  11038. */
  11039. minLifeTime: number;
  11040. /**
  11041. * Maximum life time of emitting particles.
  11042. */
  11043. maxLifeTime: number;
  11044. /**
  11045. * Minimum Size of emitting particles.
  11046. */
  11047. minSize: number;
  11048. /**
  11049. * Maximum Size of emitting particles.
  11050. */
  11051. maxSize: number;
  11052. /**
  11053. * Minimum scale of emitting particles on X axis.
  11054. */
  11055. minScaleX: number;
  11056. /**
  11057. * Maximum scale of emitting particles on X axis.
  11058. */
  11059. maxScaleX: number;
  11060. /**
  11061. * Minimum scale of emitting particles on Y axis.
  11062. */
  11063. minScaleY: number;
  11064. /**
  11065. * Maximum scale of emitting particles on Y axis.
  11066. */
  11067. maxScaleY: number;
  11068. /**
  11069. * Gets or sets the minimal initial rotation in radians.
  11070. */
  11071. minInitialRotation: number;
  11072. /**
  11073. * Gets or sets the maximal initial rotation in radians.
  11074. */
  11075. maxInitialRotation: number;
  11076. /**
  11077. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11078. */
  11079. minAngularSpeed: number;
  11080. /**
  11081. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11082. */
  11083. maxAngularSpeed: number;
  11084. /**
  11085. * The texture used to render each particle. (this can be a spritesheet)
  11086. */
  11087. particleTexture: Nullable<Texture>;
  11088. /**
  11089. * The layer mask we are rendering the particles through.
  11090. */
  11091. layerMask: number;
  11092. /**
  11093. * This can help using your own shader to render the particle system.
  11094. * The according effect will be created
  11095. */
  11096. customShader: any;
  11097. /**
  11098. * By default particle system starts as soon as they are created. This prevents the
  11099. * automatic start to happen and let you decide when to start emitting particles.
  11100. */
  11101. preventAutoStart: boolean;
  11102. private _noiseTexture;
  11103. /**
  11104. * Gets or sets a texture used to add random noise to particle positions
  11105. */
  11106. get noiseTexture(): Nullable<ProceduralTexture>;
  11107. set noiseTexture(value: Nullable<ProceduralTexture>);
  11108. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11109. noiseStrength: Vector3;
  11110. /**
  11111. * Callback triggered when the particle animation is ending.
  11112. */
  11113. onAnimationEnd: Nullable<() => void>;
  11114. /**
  11115. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11116. */
  11117. blendMode: number;
  11118. /**
  11119. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11120. * to override the particles.
  11121. */
  11122. forceDepthWrite: boolean;
  11123. /** 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 */
  11124. preWarmCycles: number;
  11125. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11126. preWarmStepOffset: number;
  11127. /**
  11128. * 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)
  11129. */
  11130. spriteCellChangeSpeed: number;
  11131. /**
  11132. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11133. */
  11134. startSpriteCellID: number;
  11135. /**
  11136. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11137. */
  11138. endSpriteCellID: number;
  11139. /**
  11140. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11141. */
  11142. spriteCellWidth: number;
  11143. /**
  11144. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11145. */
  11146. spriteCellHeight: number;
  11147. /**
  11148. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11149. */
  11150. spriteRandomStartCell: boolean;
  11151. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11152. translationPivot: Vector2;
  11153. /** @hidden */
  11154. protected _isAnimationSheetEnabled: boolean;
  11155. /**
  11156. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11157. */
  11158. beginAnimationOnStart: boolean;
  11159. /**
  11160. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11161. */
  11162. beginAnimationFrom: number;
  11163. /**
  11164. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11165. */
  11166. beginAnimationTo: number;
  11167. /**
  11168. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11169. */
  11170. beginAnimationLoop: boolean;
  11171. /**
  11172. * Gets or sets a world offset applied to all particles
  11173. */
  11174. worldOffset: Vector3;
  11175. /**
  11176. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11177. */
  11178. get isAnimationSheetEnabled(): boolean;
  11179. set isAnimationSheetEnabled(value: boolean);
  11180. /**
  11181. * Get hosting scene
  11182. * @returns the scene
  11183. */
  11184. getScene(): Scene;
  11185. /**
  11186. * You can use gravity if you want to give an orientation to your particles.
  11187. */
  11188. gravity: Vector3;
  11189. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11190. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11191. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11192. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11193. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11194. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11195. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11196. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11197. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11198. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11199. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11200. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11201. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11202. /**
  11203. * Defines the delay in milliseconds before starting the system (0 by default)
  11204. */
  11205. startDelay: number;
  11206. /**
  11207. * Gets the current list of drag gradients.
  11208. * You must use addDragGradient and removeDragGradient to udpate this list
  11209. * @returns the list of drag gradients
  11210. */
  11211. getDragGradients(): Nullable<Array<FactorGradient>>;
  11212. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11213. limitVelocityDamping: number;
  11214. /**
  11215. * Gets the current list of limit velocity gradients.
  11216. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11217. * @returns the list of limit velocity gradients
  11218. */
  11219. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11220. /**
  11221. * Gets the current list of color gradients.
  11222. * You must use addColorGradient and removeColorGradient to udpate this list
  11223. * @returns the list of color gradients
  11224. */
  11225. getColorGradients(): Nullable<Array<ColorGradient>>;
  11226. /**
  11227. * Gets the current list of size gradients.
  11228. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11229. * @returns the list of size gradients
  11230. */
  11231. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11232. /**
  11233. * Gets the current list of color remap gradients.
  11234. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11235. * @returns the list of color remap gradients
  11236. */
  11237. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11238. /**
  11239. * Gets the current list of alpha remap gradients.
  11240. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11241. * @returns the list of alpha remap gradients
  11242. */
  11243. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11244. /**
  11245. * Gets the current list of life time gradients.
  11246. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11247. * @returns the list of life time gradients
  11248. */
  11249. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11250. /**
  11251. * Gets the current list of angular speed gradients.
  11252. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11253. * @returns the list of angular speed gradients
  11254. */
  11255. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11256. /**
  11257. * Gets the current list of velocity gradients.
  11258. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11259. * @returns the list of velocity gradients
  11260. */
  11261. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11262. /**
  11263. * Gets the current list of start size gradients.
  11264. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11265. * @returns the list of start size gradients
  11266. */
  11267. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11268. /**
  11269. * Gets the current list of emit rate gradients.
  11270. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11271. * @returns the list of emit rate gradients
  11272. */
  11273. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11274. /**
  11275. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11276. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11277. */
  11278. get direction1(): Vector3;
  11279. set direction1(value: Vector3);
  11280. /**
  11281. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11282. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11283. */
  11284. get direction2(): Vector3;
  11285. set direction2(value: Vector3);
  11286. /**
  11287. * 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.
  11288. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11289. */
  11290. get minEmitBox(): Vector3;
  11291. set minEmitBox(value: Vector3);
  11292. /**
  11293. * 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.
  11294. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11295. */
  11296. get maxEmitBox(): Vector3;
  11297. set maxEmitBox(value: Vector3);
  11298. /**
  11299. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11300. */
  11301. color1: Color4;
  11302. /**
  11303. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11304. */
  11305. color2: Color4;
  11306. /**
  11307. * Color the particle will have at the end of its lifetime
  11308. */
  11309. colorDead: Color4;
  11310. /**
  11311. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11312. */
  11313. textureMask: Color4;
  11314. /**
  11315. * The particle emitter type defines the emitter used by the particle system.
  11316. * It can be for example box, sphere, or cone...
  11317. */
  11318. particleEmitterType: IParticleEmitterType;
  11319. /** @hidden */
  11320. _isSubEmitter: boolean;
  11321. /**
  11322. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11323. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11324. */
  11325. billboardMode: number;
  11326. protected _isBillboardBased: boolean;
  11327. /**
  11328. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11329. */
  11330. get isBillboardBased(): boolean;
  11331. set isBillboardBased(value: boolean);
  11332. /**
  11333. * The scene the particle system belongs to.
  11334. */
  11335. protected _scene: Scene;
  11336. /**
  11337. * Local cache of defines for image processing.
  11338. */
  11339. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11340. /**
  11341. * Default configuration related to image processing available in the standard Material.
  11342. */
  11343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11344. /**
  11345. * Gets the image processing configuration used either in this material.
  11346. */
  11347. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11348. /**
  11349. * Sets the Default image processing configuration used either in the this material.
  11350. *
  11351. * If sets to null, the scene one is in use.
  11352. */
  11353. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11354. /**
  11355. * Attaches a new image processing configuration to the Standard Material.
  11356. * @param configuration
  11357. */
  11358. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11359. /** @hidden */
  11360. protected _reset(): void;
  11361. /** @hidden */
  11362. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11363. /**
  11364. * Instantiates a particle system.
  11365. * 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.
  11366. * @param name The name of the particle system
  11367. */
  11368. constructor(name: string);
  11369. /**
  11370. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11373. * @returns the emitter
  11374. */
  11375. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11376. /**
  11377. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11378. * @param radius The radius of the hemisphere to emit from
  11379. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11380. * @returns the emitter
  11381. */
  11382. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11383. /**
  11384. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11385. * @param radius The radius of the sphere to emit from
  11386. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11387. * @returns the emitter
  11388. */
  11389. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11390. /**
  11391. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11392. * @param radius The radius of the sphere to emit from
  11393. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11394. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11395. * @returns the emitter
  11396. */
  11397. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11398. /**
  11399. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11400. * @param radius The radius of the emission cylinder
  11401. * @param height The height of the emission cylinder
  11402. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11403. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11404. * @returns the emitter
  11405. */
  11406. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11407. /**
  11408. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11409. * @param radius The radius of the cylinder to emit from
  11410. * @param height The height of the emission cylinder
  11411. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11412. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11413. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11414. * @returns the emitter
  11415. */
  11416. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11417. /**
  11418. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11419. * @param radius The radius of the cone to emit from
  11420. * @param angle The base angle of the cone
  11421. * @returns the emitter
  11422. */
  11423. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11424. /**
  11425. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11426. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11427. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11428. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11429. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11430. * @returns the emitter
  11431. */
  11432. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11433. }
  11434. }
  11435. declare module BABYLON {
  11436. /**
  11437. * Type of sub emitter
  11438. */
  11439. export enum SubEmitterType {
  11440. /**
  11441. * Attached to the particle over it's lifetime
  11442. */
  11443. ATTACHED = 0,
  11444. /**
  11445. * Created when the particle dies
  11446. */
  11447. END = 1
  11448. }
  11449. /**
  11450. * Sub emitter class used to emit particles from an existing particle
  11451. */
  11452. export class SubEmitter {
  11453. /**
  11454. * the particle system to be used by the sub emitter
  11455. */
  11456. particleSystem: ParticleSystem;
  11457. /**
  11458. * Type of the submitter (Default: END)
  11459. */
  11460. type: SubEmitterType;
  11461. /**
  11462. * 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)
  11463. * Note: This only is supported when using an emitter of type Mesh
  11464. */
  11465. inheritDirection: boolean;
  11466. /**
  11467. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11468. */
  11469. inheritedVelocityAmount: number;
  11470. /**
  11471. * Creates a sub emitter
  11472. * @param particleSystem the particle system to be used by the sub emitter
  11473. */
  11474. constructor(
  11475. /**
  11476. * the particle system to be used by the sub emitter
  11477. */
  11478. particleSystem: ParticleSystem);
  11479. /**
  11480. * Clones the sub emitter
  11481. * @returns the cloned sub emitter
  11482. */
  11483. clone(): SubEmitter;
  11484. /**
  11485. * Serialize current object to a JSON object
  11486. * @returns the serialized object
  11487. */
  11488. serialize(): any;
  11489. /** @hidden */
  11490. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11491. /**
  11492. * Creates a new SubEmitter from a serialized JSON version
  11493. * @param serializationObject defines the JSON object to read from
  11494. * @param scene defines the hosting scene
  11495. * @param rootUrl defines the rootUrl for data loading
  11496. * @returns a new SubEmitter
  11497. */
  11498. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11499. /** Release associated resources */
  11500. dispose(): void;
  11501. }
  11502. }
  11503. declare module BABYLON {
  11504. /** @hidden */
  11505. export var imageProcessingDeclaration: {
  11506. name: string;
  11507. shader: string;
  11508. };
  11509. }
  11510. declare module BABYLON {
  11511. /** @hidden */
  11512. export var imageProcessingFunctions: {
  11513. name: string;
  11514. shader: string;
  11515. };
  11516. }
  11517. declare module BABYLON {
  11518. /** @hidden */
  11519. export var particlesPixelShader: {
  11520. name: string;
  11521. shader: string;
  11522. };
  11523. }
  11524. declare module BABYLON {
  11525. /** @hidden */
  11526. export var particlesVertexShader: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module BABYLON {
  11532. /**
  11533. * This represents a particle system in Babylon.
  11534. * 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.
  11535. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11536. * @example https://doc.babylonjs.com/babylon101/particles
  11537. */
  11538. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11539. /**
  11540. * Billboard mode will only apply to Y axis
  11541. */
  11542. static readonly BILLBOARDMODE_Y: number;
  11543. /**
  11544. * Billboard mode will apply to all axes
  11545. */
  11546. static readonly BILLBOARDMODE_ALL: number;
  11547. /**
  11548. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11549. */
  11550. static readonly BILLBOARDMODE_STRETCHED: number;
  11551. /**
  11552. * This function can be defined to provide custom update for active particles.
  11553. * This function will be called instead of regular update (age, position, color, etc.).
  11554. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11555. */
  11556. updateFunction: (particles: Particle[]) => void;
  11557. private _emitterWorldMatrix;
  11558. /**
  11559. * This function can be defined to specify initial direction for every new particle.
  11560. * It by default use the emitterType defined function
  11561. */
  11562. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11563. /**
  11564. * This function can be defined to specify initial position for every new particle.
  11565. * It by default use the emitterType defined function
  11566. */
  11567. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11568. /**
  11569. * @hidden
  11570. */
  11571. _inheritedVelocityOffset: Vector3;
  11572. /**
  11573. * An event triggered when the system is disposed
  11574. */
  11575. onDisposeObservable: Observable<ParticleSystem>;
  11576. private _onDisposeObserver;
  11577. /**
  11578. * Sets a callback that will be triggered when the system is disposed
  11579. */
  11580. set onDispose(callback: () => void);
  11581. private _particles;
  11582. private _epsilon;
  11583. private _capacity;
  11584. private _stockParticles;
  11585. private _newPartsExcess;
  11586. private _vertexData;
  11587. private _vertexBuffer;
  11588. private _vertexBuffers;
  11589. private _spriteBuffer;
  11590. private _indexBuffer;
  11591. private _effect;
  11592. private _customEffect;
  11593. private _cachedDefines;
  11594. private _scaledColorStep;
  11595. private _colorDiff;
  11596. private _scaledDirection;
  11597. private _scaledGravity;
  11598. private _currentRenderId;
  11599. private _alive;
  11600. private _useInstancing;
  11601. private _started;
  11602. private _stopped;
  11603. private _actualFrame;
  11604. private _scaledUpdateSpeed;
  11605. private _vertexBufferSize;
  11606. /** @hidden */
  11607. _currentEmitRateGradient: Nullable<FactorGradient>;
  11608. /** @hidden */
  11609. _currentEmitRate1: number;
  11610. /** @hidden */
  11611. _currentEmitRate2: number;
  11612. /** @hidden */
  11613. _currentStartSizeGradient: Nullable<FactorGradient>;
  11614. /** @hidden */
  11615. _currentStartSize1: number;
  11616. /** @hidden */
  11617. _currentStartSize2: number;
  11618. private readonly _rawTextureWidth;
  11619. private _rampGradientsTexture;
  11620. private _useRampGradients;
  11621. /** Gets or sets a boolean indicating that ramp gradients must be used
  11622. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11623. */
  11624. get useRampGradients(): boolean;
  11625. set useRampGradients(value: boolean);
  11626. /**
  11627. * 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.
  11628. * 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: [])
  11629. */
  11630. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11631. private _subEmitters;
  11632. /**
  11633. * @hidden
  11634. * If the particle systems emitter should be disposed when the particle system is disposed
  11635. */
  11636. _disposeEmitterOnDispose: boolean;
  11637. /**
  11638. * The current active Sub-systems, this property is used by the root particle system only.
  11639. */
  11640. activeSubSystems: Array<ParticleSystem>;
  11641. /**
  11642. * Specifies if the particles are updated in emitter local space or world space
  11643. */
  11644. isLocal: boolean;
  11645. private _rootParticleSystem;
  11646. /**
  11647. * Gets the current list of active particles
  11648. */
  11649. get particles(): Particle[];
  11650. /**
  11651. * Returns the string "ParticleSystem"
  11652. * @returns a string containing the class name
  11653. */
  11654. getClassName(): string;
  11655. /**
  11656. * Instantiates a particle system.
  11657. * 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.
  11658. * @param name The name of the particle system
  11659. * @param capacity The max number of particles alive at the same time
  11660. * @param scene The scene the particle system belongs to
  11661. * @param customEffect a custom effect used to change the way particles are rendered by default
  11662. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11663. * @param epsilon Offset used to render the particles
  11664. */
  11665. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11666. private _addFactorGradient;
  11667. private _removeFactorGradient;
  11668. /**
  11669. * Adds a new life time gradient
  11670. * @param gradient defines the gradient to use (between 0 and 1)
  11671. * @param factor defines the life time factor to affect to the specified gradient
  11672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11673. * @returns the current particle system
  11674. */
  11675. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11676. /**
  11677. * Remove a specific life time gradient
  11678. * @param gradient defines the gradient to remove
  11679. * @returns the current particle system
  11680. */
  11681. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11682. /**
  11683. * Adds a new size gradient
  11684. * @param gradient defines the gradient to use (between 0 and 1)
  11685. * @param factor defines the size factor to affect to the specified gradient
  11686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11687. * @returns the current particle system
  11688. */
  11689. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11690. /**
  11691. * Remove a specific size gradient
  11692. * @param gradient defines the gradient to remove
  11693. * @returns the current particle system
  11694. */
  11695. removeSizeGradient(gradient: number): IParticleSystem;
  11696. /**
  11697. * Adds a new color remap gradient
  11698. * @param gradient defines the gradient to use (between 0 and 1)
  11699. * @param min defines the color remap minimal range
  11700. * @param max defines the color remap maximal range
  11701. * @returns the current particle system
  11702. */
  11703. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11704. /**
  11705. * Remove a specific color remap gradient
  11706. * @param gradient defines the gradient to remove
  11707. * @returns the current particle system
  11708. */
  11709. removeColorRemapGradient(gradient: number): IParticleSystem;
  11710. /**
  11711. * Adds a new alpha remap gradient
  11712. * @param gradient defines the gradient to use (between 0 and 1)
  11713. * @param min defines the alpha remap minimal range
  11714. * @param max defines the alpha remap maximal range
  11715. * @returns the current particle system
  11716. */
  11717. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11718. /**
  11719. * Remove a specific alpha remap gradient
  11720. * @param gradient defines the gradient to remove
  11721. * @returns the current particle system
  11722. */
  11723. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11724. /**
  11725. * Adds a new angular speed gradient
  11726. * @param gradient defines the gradient to use (between 0 and 1)
  11727. * @param factor defines the angular speed to affect to the specified gradient
  11728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11729. * @returns the current particle system
  11730. */
  11731. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11732. /**
  11733. * Remove a specific angular speed gradient
  11734. * @param gradient defines the gradient to remove
  11735. * @returns the current particle system
  11736. */
  11737. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11738. /**
  11739. * Adds a new velocity gradient
  11740. * @param gradient defines the gradient to use (between 0 and 1)
  11741. * @param factor defines the velocity to affect to the specified gradient
  11742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11743. * @returns the current particle system
  11744. */
  11745. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11746. /**
  11747. * Remove a specific velocity gradient
  11748. * @param gradient defines the gradient to remove
  11749. * @returns the current particle system
  11750. */
  11751. removeVelocityGradient(gradient: number): IParticleSystem;
  11752. /**
  11753. * Adds a new limit velocity gradient
  11754. * @param gradient defines the gradient to use (between 0 and 1)
  11755. * @param factor defines the limit velocity value to affect to the specified gradient
  11756. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11757. * @returns the current particle system
  11758. */
  11759. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11760. /**
  11761. * Remove a specific limit velocity gradient
  11762. * @param gradient defines the gradient to remove
  11763. * @returns the current particle system
  11764. */
  11765. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11766. /**
  11767. * Adds a new drag gradient
  11768. * @param gradient defines the gradient to use (between 0 and 1)
  11769. * @param factor defines the drag value to affect to the specified gradient
  11770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11771. * @returns the current particle system
  11772. */
  11773. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11774. /**
  11775. * Remove a specific drag gradient
  11776. * @param gradient defines the gradient to remove
  11777. * @returns the current particle system
  11778. */
  11779. removeDragGradient(gradient: number): IParticleSystem;
  11780. /**
  11781. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11782. * @param gradient defines the gradient to use (between 0 and 1)
  11783. * @param factor defines the emit rate value to affect to the specified gradient
  11784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11785. * @returns the current particle system
  11786. */
  11787. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11788. /**
  11789. * Remove a specific emit rate gradient
  11790. * @param gradient defines the gradient to remove
  11791. * @returns the current particle system
  11792. */
  11793. removeEmitRateGradient(gradient: number): IParticleSystem;
  11794. /**
  11795. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11796. * @param gradient defines the gradient to use (between 0 and 1)
  11797. * @param factor defines the start size value to affect to the specified gradient
  11798. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11799. * @returns the current particle system
  11800. */
  11801. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11802. /**
  11803. * Remove a specific start size gradient
  11804. * @param gradient defines the gradient to remove
  11805. * @returns the current particle system
  11806. */
  11807. removeStartSizeGradient(gradient: number): IParticleSystem;
  11808. private _createRampGradientTexture;
  11809. /**
  11810. * Gets the current list of ramp gradients.
  11811. * You must use addRampGradient and removeRampGradient to udpate this list
  11812. * @returns the list of ramp gradients
  11813. */
  11814. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11815. /**
  11816. * Adds a new ramp gradient used to remap particle colors
  11817. * @param gradient defines the gradient to use (between 0 and 1)
  11818. * @param color defines the color to affect to the specified gradient
  11819. * @returns the current particle system
  11820. */
  11821. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11822. /**
  11823. * Remove a specific ramp gradient
  11824. * @param gradient defines the gradient to remove
  11825. * @returns the current particle system
  11826. */
  11827. removeRampGradient(gradient: number): ParticleSystem;
  11828. /**
  11829. * Adds a new color gradient
  11830. * @param gradient defines the gradient to use (between 0 and 1)
  11831. * @param color1 defines the color to affect to the specified gradient
  11832. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11833. * @returns this particle system
  11834. */
  11835. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11836. /**
  11837. * Remove a specific color gradient
  11838. * @param gradient defines the gradient to remove
  11839. * @returns this particle system
  11840. */
  11841. removeColorGradient(gradient: number): IParticleSystem;
  11842. private _fetchR;
  11843. protected _reset(): void;
  11844. private _resetEffect;
  11845. private _createVertexBuffers;
  11846. private _createIndexBuffer;
  11847. /**
  11848. * Gets the maximum number of particles active at the same time.
  11849. * @returns The max number of active particles.
  11850. */
  11851. getCapacity(): number;
  11852. /**
  11853. * Gets whether there are still active particles in the system.
  11854. * @returns True if it is alive, otherwise false.
  11855. */
  11856. isAlive(): boolean;
  11857. /**
  11858. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11859. * @returns True if it has been started, otherwise false.
  11860. */
  11861. isStarted(): boolean;
  11862. private _prepareSubEmitterInternalArray;
  11863. /**
  11864. * Starts the particle system and begins to emit
  11865. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11866. */
  11867. start(delay?: number): void;
  11868. /**
  11869. * Stops the particle system.
  11870. * @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.
  11871. */
  11872. stop(stopSubEmitters?: boolean): void;
  11873. /**
  11874. * Remove all active particles
  11875. */
  11876. reset(): void;
  11877. /**
  11878. * @hidden (for internal use only)
  11879. */
  11880. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11881. /**
  11882. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11883. * Its lifetime will start back at 0.
  11884. */
  11885. recycleParticle: (particle: Particle) => void;
  11886. private _stopSubEmitters;
  11887. private _createParticle;
  11888. private _removeFromRoot;
  11889. private _emitFromParticle;
  11890. private _update;
  11891. /** @hidden */
  11892. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11893. /** @hidden */
  11894. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11895. /** @hidden */
  11896. private _getEffect;
  11897. /**
  11898. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11899. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11900. */
  11901. animate(preWarmOnly?: boolean): void;
  11902. private _appendParticleVertices;
  11903. /**
  11904. * Rebuilds the particle system.
  11905. */
  11906. rebuild(): void;
  11907. /**
  11908. * Is this system ready to be used/rendered
  11909. * @return true if the system is ready
  11910. */
  11911. isReady(): boolean;
  11912. private _render;
  11913. /**
  11914. * Renders the particle system in its current state.
  11915. * @returns the current number of particles
  11916. */
  11917. render(): number;
  11918. /**
  11919. * Disposes the particle system and free the associated resources
  11920. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11921. */
  11922. dispose(disposeTexture?: boolean): void;
  11923. /**
  11924. * Clones the particle system.
  11925. * @param name The name of the cloned object
  11926. * @param newEmitter The new emitter to use
  11927. * @returns the cloned particle system
  11928. */
  11929. clone(name: string, newEmitter: any): ParticleSystem;
  11930. /**
  11931. * Serializes the particle system to a JSON object.
  11932. * @returns the JSON object
  11933. */
  11934. serialize(): any;
  11935. /** @hidden */
  11936. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11937. /** @hidden */
  11938. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11939. /**
  11940. * Parses a JSON object to create a particle system.
  11941. * @param parsedParticleSystem The JSON object to parse
  11942. * @param scene The scene to create the particle system in
  11943. * @param rootUrl The root url to use to load external dependencies like texture
  11944. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11945. * @returns the Parsed particle system
  11946. */
  11947. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11948. }
  11949. }
  11950. declare module BABYLON {
  11951. /**
  11952. * A particle represents one of the element emitted by a particle system.
  11953. * This is mainly define by its coordinates, direction, velocity and age.
  11954. */
  11955. export class Particle {
  11956. /**
  11957. * The particle system the particle belongs to.
  11958. */
  11959. particleSystem: ParticleSystem;
  11960. private static _Count;
  11961. /**
  11962. * Unique ID of the particle
  11963. */
  11964. id: number;
  11965. /**
  11966. * The world position of the particle in the scene.
  11967. */
  11968. position: Vector3;
  11969. /**
  11970. * The world direction of the particle in the scene.
  11971. */
  11972. direction: Vector3;
  11973. /**
  11974. * The color of the particle.
  11975. */
  11976. color: Color4;
  11977. /**
  11978. * The color change of the particle per step.
  11979. */
  11980. colorStep: Color4;
  11981. /**
  11982. * Defines how long will the life of the particle be.
  11983. */
  11984. lifeTime: number;
  11985. /**
  11986. * The current age of the particle.
  11987. */
  11988. age: number;
  11989. /**
  11990. * The current size of the particle.
  11991. */
  11992. size: number;
  11993. /**
  11994. * The current scale of the particle.
  11995. */
  11996. scale: Vector2;
  11997. /**
  11998. * The current angle of the particle.
  11999. */
  12000. angle: number;
  12001. /**
  12002. * Defines how fast is the angle changing.
  12003. */
  12004. angularSpeed: number;
  12005. /**
  12006. * Defines the cell index used by the particle to be rendered from a sprite.
  12007. */
  12008. cellIndex: number;
  12009. /**
  12010. * The information required to support color remapping
  12011. */
  12012. remapData: Vector4;
  12013. /** @hidden */
  12014. _randomCellOffset?: number;
  12015. /** @hidden */
  12016. _initialDirection: Nullable<Vector3>;
  12017. /** @hidden */
  12018. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12019. /** @hidden */
  12020. _initialStartSpriteCellID: number;
  12021. /** @hidden */
  12022. _initialEndSpriteCellID: number;
  12023. /** @hidden */
  12024. _currentColorGradient: Nullable<ColorGradient>;
  12025. /** @hidden */
  12026. _currentColor1: Color4;
  12027. /** @hidden */
  12028. _currentColor2: Color4;
  12029. /** @hidden */
  12030. _currentSizeGradient: Nullable<FactorGradient>;
  12031. /** @hidden */
  12032. _currentSize1: number;
  12033. /** @hidden */
  12034. _currentSize2: number;
  12035. /** @hidden */
  12036. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12037. /** @hidden */
  12038. _currentAngularSpeed1: number;
  12039. /** @hidden */
  12040. _currentAngularSpeed2: number;
  12041. /** @hidden */
  12042. _currentVelocityGradient: Nullable<FactorGradient>;
  12043. /** @hidden */
  12044. _currentVelocity1: number;
  12045. /** @hidden */
  12046. _currentVelocity2: number;
  12047. /** @hidden */
  12048. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12049. /** @hidden */
  12050. _currentLimitVelocity1: number;
  12051. /** @hidden */
  12052. _currentLimitVelocity2: number;
  12053. /** @hidden */
  12054. _currentDragGradient: Nullable<FactorGradient>;
  12055. /** @hidden */
  12056. _currentDrag1: number;
  12057. /** @hidden */
  12058. _currentDrag2: number;
  12059. /** @hidden */
  12060. _randomNoiseCoordinates1: Vector3;
  12061. /** @hidden */
  12062. _randomNoiseCoordinates2: Vector3;
  12063. /** @hidden */
  12064. _localPosition?: Vector3;
  12065. /**
  12066. * Creates a new instance Particle
  12067. * @param particleSystem the particle system the particle belongs to
  12068. */
  12069. constructor(
  12070. /**
  12071. * The particle system the particle belongs to.
  12072. */
  12073. particleSystem: ParticleSystem);
  12074. private updateCellInfoFromSystem;
  12075. /**
  12076. * Defines how the sprite cell index is updated for the particle
  12077. */
  12078. updateCellIndex(): void;
  12079. /** @hidden */
  12080. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12081. /** @hidden */
  12082. _inheritParticleInfoToSubEmitters(): void;
  12083. /** @hidden */
  12084. _reset(): void;
  12085. /**
  12086. * Copy the properties of particle to another one.
  12087. * @param other the particle to copy the information to.
  12088. */
  12089. copyTo(other: Particle): void;
  12090. }
  12091. }
  12092. declare module BABYLON {
  12093. /**
  12094. * Particle emitter represents a volume emitting particles.
  12095. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12096. */
  12097. export interface IParticleEmitterType {
  12098. /**
  12099. * Called by the particle System when the direction is computed for the created particle.
  12100. * @param worldMatrix is the world matrix of the particle system
  12101. * @param directionToUpdate is the direction vector to update with the result
  12102. * @param particle is the particle we are computed the direction for
  12103. * @param isLocal defines if the direction should be set in local space
  12104. */
  12105. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12106. /**
  12107. * Called by the particle System when the position is computed for the created particle.
  12108. * @param worldMatrix is the world matrix of the particle system
  12109. * @param positionToUpdate is the position vector to update with the result
  12110. * @param particle is the particle we are computed the position for
  12111. * @param isLocal defines if the position should be set in local space
  12112. */
  12113. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12114. /**
  12115. * Clones the current emitter and returns a copy of it
  12116. * @returns the new emitter
  12117. */
  12118. clone(): IParticleEmitterType;
  12119. /**
  12120. * Called by the GPUParticleSystem to setup the update shader
  12121. * @param effect defines the update shader
  12122. */
  12123. applyToShader(effect: Effect): void;
  12124. /**
  12125. * Returns a string to use to update the GPU particles update shader
  12126. * @returns the effect defines string
  12127. */
  12128. getEffectDefines(): string;
  12129. /**
  12130. * Returns a string representing the class name
  12131. * @returns a string containing the class name
  12132. */
  12133. getClassName(): string;
  12134. /**
  12135. * Serializes the particle system to a JSON object.
  12136. * @returns the JSON object
  12137. */
  12138. serialize(): any;
  12139. /**
  12140. * Parse properties from a JSON object
  12141. * @param serializationObject defines the JSON object
  12142. * @param scene defines the hosting scene
  12143. */
  12144. parse(serializationObject: any, scene: Scene): void;
  12145. }
  12146. }
  12147. declare module BABYLON {
  12148. /**
  12149. * Particle emitter emitting particles from the inside of a box.
  12150. * It emits the particles randomly between 2 given directions.
  12151. */
  12152. export class BoxParticleEmitter implements IParticleEmitterType {
  12153. /**
  12154. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12155. */
  12156. direction1: Vector3;
  12157. /**
  12158. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12159. */
  12160. direction2: Vector3;
  12161. /**
  12162. * 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.
  12163. */
  12164. minEmitBox: Vector3;
  12165. /**
  12166. * 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.
  12167. */
  12168. maxEmitBox: Vector3;
  12169. /**
  12170. * Creates a new instance BoxParticleEmitter
  12171. */
  12172. constructor();
  12173. /**
  12174. * Called by the particle System when the direction is computed for the created particle.
  12175. * @param worldMatrix is the world matrix of the particle system
  12176. * @param directionToUpdate is the direction vector to update with the result
  12177. * @param particle is the particle we are computed the direction for
  12178. * @param isLocal defines if the direction should be set in local space
  12179. */
  12180. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12181. /**
  12182. * Called by the particle System when the position is computed for the created particle.
  12183. * @param worldMatrix is the world matrix of the particle system
  12184. * @param positionToUpdate is the position vector to update with the result
  12185. * @param particle is the particle we are computed the position for
  12186. * @param isLocal defines if the position should be set in local space
  12187. */
  12188. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12189. /**
  12190. * Clones the current emitter and returns a copy of it
  12191. * @returns the new emitter
  12192. */
  12193. clone(): BoxParticleEmitter;
  12194. /**
  12195. * Called by the GPUParticleSystem to setup the update shader
  12196. * @param effect defines the update shader
  12197. */
  12198. applyToShader(effect: Effect): void;
  12199. /**
  12200. * Returns a string to use to update the GPU particles update shader
  12201. * @returns a string containng the defines string
  12202. */
  12203. getEffectDefines(): string;
  12204. /**
  12205. * Returns the string "BoxParticleEmitter"
  12206. * @returns a string containing the class name
  12207. */
  12208. getClassName(): string;
  12209. /**
  12210. * Serializes the particle system to a JSON object.
  12211. * @returns the JSON object
  12212. */
  12213. serialize(): any;
  12214. /**
  12215. * Parse properties from a JSON object
  12216. * @param serializationObject defines the JSON object
  12217. */
  12218. parse(serializationObject: any): void;
  12219. }
  12220. }
  12221. declare module BABYLON {
  12222. /**
  12223. * Particle emitter emitting particles from the inside of a cone.
  12224. * It emits the particles alongside the cone volume from the base to the particle.
  12225. * The emission direction might be randomized.
  12226. */
  12227. export class ConeParticleEmitter implements IParticleEmitterType {
  12228. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12229. directionRandomizer: number;
  12230. private _radius;
  12231. private _angle;
  12232. private _height;
  12233. /**
  12234. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12235. */
  12236. radiusRange: number;
  12237. /**
  12238. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12239. */
  12240. heightRange: number;
  12241. /**
  12242. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12243. */
  12244. emitFromSpawnPointOnly: boolean;
  12245. /**
  12246. * Gets or sets the radius of the emission cone
  12247. */
  12248. get radius(): number;
  12249. set radius(value: number);
  12250. /**
  12251. * Gets or sets the angle of the emission cone
  12252. */
  12253. get angle(): number;
  12254. set angle(value: number);
  12255. private _buildHeight;
  12256. /**
  12257. * Creates a new instance ConeParticleEmitter
  12258. * @param radius the radius of the emission cone (1 by default)
  12259. * @param angle the cone base angle (PI by default)
  12260. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12261. */
  12262. constructor(radius?: number, angle?: number,
  12263. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12264. directionRandomizer?: number);
  12265. /**
  12266. * Called by the particle System when the direction is computed for the created particle.
  12267. * @param worldMatrix is the world matrix of the particle system
  12268. * @param directionToUpdate is the direction vector to update with the result
  12269. * @param particle is the particle we are computed the direction for
  12270. * @param isLocal defines if the direction should be set in local space
  12271. */
  12272. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12273. /**
  12274. * Called by the particle System when the position is computed for the created particle.
  12275. * @param worldMatrix is the world matrix of the particle system
  12276. * @param positionToUpdate is the position vector to update with the result
  12277. * @param particle is the particle we are computed the position for
  12278. * @param isLocal defines if the position should be set in local space
  12279. */
  12280. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12281. /**
  12282. * Clones the current emitter and returns a copy of it
  12283. * @returns the new emitter
  12284. */
  12285. clone(): ConeParticleEmitter;
  12286. /**
  12287. * Called by the GPUParticleSystem to setup the update shader
  12288. * @param effect defines the update shader
  12289. */
  12290. applyToShader(effect: Effect): void;
  12291. /**
  12292. * Returns a string to use to update the GPU particles update shader
  12293. * @returns a string containng the defines string
  12294. */
  12295. getEffectDefines(): string;
  12296. /**
  12297. * Returns the string "ConeParticleEmitter"
  12298. * @returns a string containing the class name
  12299. */
  12300. getClassName(): string;
  12301. /**
  12302. * Serializes the particle system to a JSON object.
  12303. * @returns the JSON object
  12304. */
  12305. serialize(): any;
  12306. /**
  12307. * Parse properties from a JSON object
  12308. * @param serializationObject defines the JSON object
  12309. */
  12310. parse(serializationObject: any): void;
  12311. }
  12312. }
  12313. declare module BABYLON {
  12314. /**
  12315. * Particle emitter emitting particles from the inside of a cylinder.
  12316. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12317. */
  12318. export class CylinderParticleEmitter implements IParticleEmitterType {
  12319. /**
  12320. * The radius of the emission cylinder.
  12321. */
  12322. radius: number;
  12323. /**
  12324. * The height of the emission cylinder.
  12325. */
  12326. height: number;
  12327. /**
  12328. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12329. */
  12330. radiusRange: number;
  12331. /**
  12332. * How much to randomize the particle direction [0-1].
  12333. */
  12334. directionRandomizer: number;
  12335. /**
  12336. * Creates a new instance CylinderParticleEmitter
  12337. * @param radius the radius of the emission cylinder (1 by default)
  12338. * @param height the height of the emission cylinder (1 by default)
  12339. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12340. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12341. */
  12342. constructor(
  12343. /**
  12344. * The radius of the emission cylinder.
  12345. */
  12346. radius?: number,
  12347. /**
  12348. * The height of the emission cylinder.
  12349. */
  12350. height?: number,
  12351. /**
  12352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12353. */
  12354. radiusRange?: number,
  12355. /**
  12356. * How much to randomize the particle direction [0-1].
  12357. */
  12358. directionRandomizer?: number);
  12359. /**
  12360. * Called by the particle System when the direction is computed for the created particle.
  12361. * @param worldMatrix is the world matrix of the particle system
  12362. * @param directionToUpdate is the direction vector to update with the result
  12363. * @param particle is the particle we are computed the direction for
  12364. * @param isLocal defines if the direction should be set in local space
  12365. */
  12366. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12367. /**
  12368. * Called by the particle System when the position is computed for the created particle.
  12369. * @param worldMatrix is the world matrix of the particle system
  12370. * @param positionToUpdate is the position vector to update with the result
  12371. * @param particle is the particle we are computed the position for
  12372. * @param isLocal defines if the position should be set in local space
  12373. */
  12374. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12375. /**
  12376. * Clones the current emitter and returns a copy of it
  12377. * @returns the new emitter
  12378. */
  12379. clone(): CylinderParticleEmitter;
  12380. /**
  12381. * Called by the GPUParticleSystem to setup the update shader
  12382. * @param effect defines the update shader
  12383. */
  12384. applyToShader(effect: Effect): void;
  12385. /**
  12386. * Returns a string to use to update the GPU particles update shader
  12387. * @returns a string containng the defines string
  12388. */
  12389. getEffectDefines(): string;
  12390. /**
  12391. * Returns the string "CylinderParticleEmitter"
  12392. * @returns a string containing the class name
  12393. */
  12394. getClassName(): string;
  12395. /**
  12396. * Serializes the particle system to a JSON object.
  12397. * @returns the JSON object
  12398. */
  12399. serialize(): any;
  12400. /**
  12401. * Parse properties from a JSON object
  12402. * @param serializationObject defines the JSON object
  12403. */
  12404. parse(serializationObject: any): void;
  12405. }
  12406. /**
  12407. * Particle emitter emitting particles from the inside of a cylinder.
  12408. * It emits the particles randomly between two vectors.
  12409. */
  12410. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12411. /**
  12412. * The min limit of the emission direction.
  12413. */
  12414. direction1: Vector3;
  12415. /**
  12416. * The max limit of the emission direction.
  12417. */
  12418. direction2: Vector3;
  12419. /**
  12420. * Creates a new instance CylinderDirectedParticleEmitter
  12421. * @param radius the radius of the emission cylinder (1 by default)
  12422. * @param height the height of the emission cylinder (1 by default)
  12423. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12424. * @param direction1 the min limit of the emission direction (up vector by default)
  12425. * @param direction2 the max limit of the emission direction (up vector by default)
  12426. */
  12427. constructor(radius?: number, height?: number, radiusRange?: number,
  12428. /**
  12429. * The min limit of the emission direction.
  12430. */
  12431. direction1?: Vector3,
  12432. /**
  12433. * The max limit of the emission direction.
  12434. */
  12435. direction2?: Vector3);
  12436. /**
  12437. * Called by the particle System when the direction is computed for the created particle.
  12438. * @param worldMatrix is the world matrix of the particle system
  12439. * @param directionToUpdate is the direction vector to update with the result
  12440. * @param particle is the particle we are computed the direction for
  12441. */
  12442. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12443. /**
  12444. * Clones the current emitter and returns a copy of it
  12445. * @returns the new emitter
  12446. */
  12447. clone(): CylinderDirectedParticleEmitter;
  12448. /**
  12449. * Called by the GPUParticleSystem to setup the update shader
  12450. * @param effect defines the update shader
  12451. */
  12452. applyToShader(effect: Effect): void;
  12453. /**
  12454. * Returns a string to use to update the GPU particles update shader
  12455. * @returns a string containng the defines string
  12456. */
  12457. getEffectDefines(): string;
  12458. /**
  12459. * Returns the string "CylinderDirectedParticleEmitter"
  12460. * @returns a string containing the class name
  12461. */
  12462. getClassName(): string;
  12463. /**
  12464. * Serializes the particle system to a JSON object.
  12465. * @returns the JSON object
  12466. */
  12467. serialize(): any;
  12468. /**
  12469. * Parse properties from a JSON object
  12470. * @param serializationObject defines the JSON object
  12471. */
  12472. parse(serializationObject: any): void;
  12473. }
  12474. }
  12475. declare module BABYLON {
  12476. /**
  12477. * Particle emitter emitting particles from the inside of a hemisphere.
  12478. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12479. */
  12480. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12481. /**
  12482. * The radius of the emission hemisphere.
  12483. */
  12484. radius: number;
  12485. /**
  12486. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12487. */
  12488. radiusRange: number;
  12489. /**
  12490. * How much to randomize the particle direction [0-1].
  12491. */
  12492. directionRandomizer: number;
  12493. /**
  12494. * Creates a new instance HemisphericParticleEmitter
  12495. * @param radius the radius of the emission hemisphere (1 by default)
  12496. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12497. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12498. */
  12499. constructor(
  12500. /**
  12501. * The radius of the emission hemisphere.
  12502. */
  12503. radius?: number,
  12504. /**
  12505. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12506. */
  12507. radiusRange?: number,
  12508. /**
  12509. * How much to randomize the particle direction [0-1].
  12510. */
  12511. directionRandomizer?: number);
  12512. /**
  12513. * Called by the particle System when the direction is computed for the created particle.
  12514. * @param worldMatrix is the world matrix of the particle system
  12515. * @param directionToUpdate is the direction vector to update with the result
  12516. * @param particle is the particle we are computed the direction for
  12517. * @param isLocal defines if the direction should be set in local space
  12518. */
  12519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12520. /**
  12521. * Called by the particle System when the position is computed for the created particle.
  12522. * @param worldMatrix is the world matrix of the particle system
  12523. * @param positionToUpdate is the position vector to update with the result
  12524. * @param particle is the particle we are computed the position for
  12525. * @param isLocal defines if the position should be set in local space
  12526. */
  12527. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12528. /**
  12529. * Clones the current emitter and returns a copy of it
  12530. * @returns the new emitter
  12531. */
  12532. clone(): HemisphericParticleEmitter;
  12533. /**
  12534. * Called by the GPUParticleSystem to setup the update shader
  12535. * @param effect defines the update shader
  12536. */
  12537. applyToShader(effect: Effect): void;
  12538. /**
  12539. * Returns a string to use to update the GPU particles update shader
  12540. * @returns a string containng the defines string
  12541. */
  12542. getEffectDefines(): string;
  12543. /**
  12544. * Returns the string "HemisphericParticleEmitter"
  12545. * @returns a string containing the class name
  12546. */
  12547. getClassName(): string;
  12548. /**
  12549. * Serializes the particle system to a JSON object.
  12550. * @returns the JSON object
  12551. */
  12552. serialize(): any;
  12553. /**
  12554. * Parse properties from a JSON object
  12555. * @param serializationObject defines the JSON object
  12556. */
  12557. parse(serializationObject: any): void;
  12558. }
  12559. }
  12560. declare module BABYLON {
  12561. /**
  12562. * Particle emitter emitting particles from a point.
  12563. * It emits the particles randomly between 2 given directions.
  12564. */
  12565. export class PointParticleEmitter implements IParticleEmitterType {
  12566. /**
  12567. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12568. */
  12569. direction1: Vector3;
  12570. /**
  12571. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12572. */
  12573. direction2: Vector3;
  12574. /**
  12575. * Creates a new instance PointParticleEmitter
  12576. */
  12577. constructor();
  12578. /**
  12579. * Called by the particle System when the direction is computed for the created particle.
  12580. * @param worldMatrix is the world matrix of the particle system
  12581. * @param directionToUpdate is the direction vector to update with the result
  12582. * @param particle is the particle we are computed the direction for
  12583. * @param isLocal defines if the direction should be set in local space
  12584. */
  12585. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12586. /**
  12587. * Called by the particle System when the position is computed for the created particle.
  12588. * @param worldMatrix is the world matrix of the particle system
  12589. * @param positionToUpdate is the position vector to update with the result
  12590. * @param particle is the particle we are computed the position for
  12591. * @param isLocal defines if the position should be set in local space
  12592. */
  12593. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12594. /**
  12595. * Clones the current emitter and returns a copy of it
  12596. * @returns the new emitter
  12597. */
  12598. clone(): PointParticleEmitter;
  12599. /**
  12600. * Called by the GPUParticleSystem to setup the update shader
  12601. * @param effect defines the update shader
  12602. */
  12603. applyToShader(effect: Effect): void;
  12604. /**
  12605. * Returns a string to use to update the GPU particles update shader
  12606. * @returns a string containng the defines string
  12607. */
  12608. getEffectDefines(): string;
  12609. /**
  12610. * Returns the string "PointParticleEmitter"
  12611. * @returns a string containing the class name
  12612. */
  12613. getClassName(): string;
  12614. /**
  12615. * Serializes the particle system to a JSON object.
  12616. * @returns the JSON object
  12617. */
  12618. serialize(): any;
  12619. /**
  12620. * Parse properties from a JSON object
  12621. * @param serializationObject defines the JSON object
  12622. */
  12623. parse(serializationObject: any): void;
  12624. }
  12625. }
  12626. declare module BABYLON {
  12627. /**
  12628. * Particle emitter emitting particles from the inside of a sphere.
  12629. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12630. */
  12631. export class SphereParticleEmitter implements IParticleEmitterType {
  12632. /**
  12633. * The radius of the emission sphere.
  12634. */
  12635. radius: number;
  12636. /**
  12637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12638. */
  12639. radiusRange: number;
  12640. /**
  12641. * How much to randomize the particle direction [0-1].
  12642. */
  12643. directionRandomizer: number;
  12644. /**
  12645. * Creates a new instance SphereParticleEmitter
  12646. * @param radius the radius of the emission sphere (1 by default)
  12647. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12648. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12649. */
  12650. constructor(
  12651. /**
  12652. * The radius of the emission sphere.
  12653. */
  12654. radius?: number,
  12655. /**
  12656. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12657. */
  12658. radiusRange?: number,
  12659. /**
  12660. * How much to randomize the particle direction [0-1].
  12661. */
  12662. directionRandomizer?: number);
  12663. /**
  12664. * Called by the particle System when the direction is computed for the created particle.
  12665. * @param worldMatrix is the world matrix of the particle system
  12666. * @param directionToUpdate is the direction vector to update with the result
  12667. * @param particle is the particle we are computed the direction for
  12668. * @param isLocal defines if the direction should be set in local space
  12669. */
  12670. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12671. /**
  12672. * Called by the particle System when the position is computed for the created particle.
  12673. * @param worldMatrix is the world matrix of the particle system
  12674. * @param positionToUpdate is the position vector to update with the result
  12675. * @param particle is the particle we are computed the position for
  12676. * @param isLocal defines if the position should be set in local space
  12677. */
  12678. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12679. /**
  12680. * Clones the current emitter and returns a copy of it
  12681. * @returns the new emitter
  12682. */
  12683. clone(): SphereParticleEmitter;
  12684. /**
  12685. * Called by the GPUParticleSystem to setup the update shader
  12686. * @param effect defines the update shader
  12687. */
  12688. applyToShader(effect: Effect): void;
  12689. /**
  12690. * Returns a string to use to update the GPU particles update shader
  12691. * @returns a string containng the defines string
  12692. */
  12693. getEffectDefines(): string;
  12694. /**
  12695. * Returns the string "SphereParticleEmitter"
  12696. * @returns a string containing the class name
  12697. */
  12698. getClassName(): string;
  12699. /**
  12700. * Serializes the particle system to a JSON object.
  12701. * @returns the JSON object
  12702. */
  12703. serialize(): any;
  12704. /**
  12705. * Parse properties from a JSON object
  12706. * @param serializationObject defines the JSON object
  12707. */
  12708. parse(serializationObject: any): void;
  12709. }
  12710. /**
  12711. * Particle emitter emitting particles from the inside of a sphere.
  12712. * It emits the particles randomly between two vectors.
  12713. */
  12714. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12715. /**
  12716. * The min limit of the emission direction.
  12717. */
  12718. direction1: Vector3;
  12719. /**
  12720. * The max limit of the emission direction.
  12721. */
  12722. direction2: Vector3;
  12723. /**
  12724. * Creates a new instance SphereDirectedParticleEmitter
  12725. * @param radius the radius of the emission sphere (1 by default)
  12726. * @param direction1 the min limit of the emission direction (up vector by default)
  12727. * @param direction2 the max limit of the emission direction (up vector by default)
  12728. */
  12729. constructor(radius?: number,
  12730. /**
  12731. * The min limit of the emission direction.
  12732. */
  12733. direction1?: Vector3,
  12734. /**
  12735. * The max limit of the emission direction.
  12736. */
  12737. direction2?: Vector3);
  12738. /**
  12739. * Called by the particle System when the direction is computed for the created particle.
  12740. * @param worldMatrix is the world matrix of the particle system
  12741. * @param directionToUpdate is the direction vector to update with the result
  12742. * @param particle is the particle we are computed the direction for
  12743. */
  12744. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12745. /**
  12746. * Clones the current emitter and returns a copy of it
  12747. * @returns the new emitter
  12748. */
  12749. clone(): SphereDirectedParticleEmitter;
  12750. /**
  12751. * Called by the GPUParticleSystem to setup the update shader
  12752. * @param effect defines the update shader
  12753. */
  12754. applyToShader(effect: Effect): void;
  12755. /**
  12756. * Returns a string to use to update the GPU particles update shader
  12757. * @returns a string containng the defines string
  12758. */
  12759. getEffectDefines(): string;
  12760. /**
  12761. * Returns the string "SphereDirectedParticleEmitter"
  12762. * @returns a string containing the class name
  12763. */
  12764. getClassName(): string;
  12765. /**
  12766. * Serializes the particle system to a JSON object.
  12767. * @returns the JSON object
  12768. */
  12769. serialize(): any;
  12770. /**
  12771. * Parse properties from a JSON object
  12772. * @param serializationObject defines the JSON object
  12773. */
  12774. parse(serializationObject: any): void;
  12775. }
  12776. }
  12777. declare module BABYLON {
  12778. /**
  12779. * Particle emitter emitting particles from a custom list of positions.
  12780. */
  12781. export class CustomParticleEmitter implements IParticleEmitterType {
  12782. /**
  12783. * Gets or sets the position generator that will create the inital position of each particle.
  12784. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12785. */
  12786. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12787. /**
  12788. * Gets or sets the destination generator that will create the final destination of each particle.
  12789. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12790. */
  12791. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12792. /**
  12793. * Creates a new instance CustomParticleEmitter
  12794. */
  12795. constructor();
  12796. /**
  12797. * Called by the particle System when the direction is computed for the created particle.
  12798. * @param worldMatrix is the world matrix of the particle system
  12799. * @param directionToUpdate is the direction vector to update with the result
  12800. * @param particle is the particle we are computed the direction for
  12801. * @param isLocal defines if the direction should be set in local space
  12802. */
  12803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12804. /**
  12805. * Called by the particle System when the position is computed for the created particle.
  12806. * @param worldMatrix is the world matrix of the particle system
  12807. * @param positionToUpdate is the position vector to update with the result
  12808. * @param particle is the particle we are computed the position for
  12809. * @param isLocal defines if the position should be set in local space
  12810. */
  12811. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12812. /**
  12813. * Clones the current emitter and returns a copy of it
  12814. * @returns the new emitter
  12815. */
  12816. clone(): CustomParticleEmitter;
  12817. /**
  12818. * Called by the GPUParticleSystem to setup the update shader
  12819. * @param effect defines the update shader
  12820. */
  12821. applyToShader(effect: Effect): void;
  12822. /**
  12823. * Returns a string to use to update the GPU particles update shader
  12824. * @returns a string containng the defines string
  12825. */
  12826. getEffectDefines(): string;
  12827. /**
  12828. * Returns the string "PointParticleEmitter"
  12829. * @returns a string containing the class name
  12830. */
  12831. getClassName(): string;
  12832. /**
  12833. * Serializes the particle system to a JSON object.
  12834. * @returns the JSON object
  12835. */
  12836. serialize(): any;
  12837. /**
  12838. * Parse properties from a JSON object
  12839. * @param serializationObject defines the JSON object
  12840. */
  12841. parse(serializationObject: any): void;
  12842. }
  12843. }
  12844. declare module BABYLON {
  12845. /**
  12846. * Particle emitter emitting particles from the inside of a box.
  12847. * It emits the particles randomly between 2 given directions.
  12848. */
  12849. export class MeshParticleEmitter implements IParticleEmitterType {
  12850. private _indices;
  12851. private _positions;
  12852. private _normals;
  12853. private _storedNormal;
  12854. private _mesh;
  12855. /**
  12856. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12857. */
  12858. direction1: Vector3;
  12859. /**
  12860. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12861. */
  12862. direction2: Vector3;
  12863. /**
  12864. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12865. */
  12866. useMeshNormalsForDirection: boolean;
  12867. /** Defines the mesh to use as source */
  12868. get mesh(): Nullable<AbstractMesh>;
  12869. set mesh(value: Nullable<AbstractMesh>);
  12870. /**
  12871. * Creates a new instance MeshParticleEmitter
  12872. * @param mesh defines the mesh to use as source
  12873. */
  12874. constructor(mesh?: Nullable<AbstractMesh>);
  12875. /**
  12876. * Called by the particle System when the direction is computed for the created particle.
  12877. * @param worldMatrix is the world matrix of the particle system
  12878. * @param directionToUpdate is the direction vector to update with the result
  12879. * @param particle is the particle we are computed the direction for
  12880. * @param isLocal defines if the direction should be set in local space
  12881. */
  12882. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12883. /**
  12884. * Called by the particle System when the position is computed for the created particle.
  12885. * @param worldMatrix is the world matrix of the particle system
  12886. * @param positionToUpdate is the position vector to update with the result
  12887. * @param particle is the particle we are computed the position for
  12888. * @param isLocal defines if the position should be set in local space
  12889. */
  12890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12891. /**
  12892. * Clones the current emitter and returns a copy of it
  12893. * @returns the new emitter
  12894. */
  12895. clone(): MeshParticleEmitter;
  12896. /**
  12897. * Called by the GPUParticleSystem to setup the update shader
  12898. * @param effect defines the update shader
  12899. */
  12900. applyToShader(effect: Effect): void;
  12901. /**
  12902. * Returns a string to use to update the GPU particles update shader
  12903. * @returns a string containng the defines string
  12904. */
  12905. getEffectDefines(): string;
  12906. /**
  12907. * Returns the string "BoxParticleEmitter"
  12908. * @returns a string containing the class name
  12909. */
  12910. getClassName(): string;
  12911. /**
  12912. * Serializes the particle system to a JSON object.
  12913. * @returns the JSON object
  12914. */
  12915. serialize(): any;
  12916. /**
  12917. * Parse properties from a JSON object
  12918. * @param serializationObject defines the JSON object
  12919. * @param scene defines the hosting scene
  12920. */
  12921. parse(serializationObject: any, scene: Scene): void;
  12922. }
  12923. }
  12924. declare module BABYLON {
  12925. /**
  12926. * Interface representing a particle system in Babylon.js.
  12927. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12928. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12929. */
  12930. export interface IParticleSystem {
  12931. /**
  12932. * List of animations used by the particle system.
  12933. */
  12934. animations: Animation[];
  12935. /**
  12936. * The id of the Particle system.
  12937. */
  12938. id: string;
  12939. /**
  12940. * The name of the Particle system.
  12941. */
  12942. name: string;
  12943. /**
  12944. * The emitter represents the Mesh or position we are attaching the particle system to.
  12945. */
  12946. emitter: Nullable<AbstractMesh | Vector3>;
  12947. /**
  12948. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12949. */
  12950. isBillboardBased: boolean;
  12951. /**
  12952. * The rendering group used by the Particle system to chose when to render.
  12953. */
  12954. renderingGroupId: number;
  12955. /**
  12956. * The layer mask we are rendering the particles through.
  12957. */
  12958. layerMask: number;
  12959. /**
  12960. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12961. */
  12962. updateSpeed: number;
  12963. /**
  12964. * The amount of time the particle system is running (depends of the overall update speed).
  12965. */
  12966. targetStopDuration: number;
  12967. /**
  12968. * The texture used to render each particle. (this can be a spritesheet)
  12969. */
  12970. particleTexture: Nullable<Texture>;
  12971. /**
  12972. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12973. */
  12974. blendMode: number;
  12975. /**
  12976. * Minimum life time of emitting particles.
  12977. */
  12978. minLifeTime: number;
  12979. /**
  12980. * Maximum life time of emitting particles.
  12981. */
  12982. maxLifeTime: number;
  12983. /**
  12984. * Minimum Size of emitting particles.
  12985. */
  12986. minSize: number;
  12987. /**
  12988. * Maximum Size of emitting particles.
  12989. */
  12990. maxSize: number;
  12991. /**
  12992. * Minimum scale of emitting particles on X axis.
  12993. */
  12994. minScaleX: number;
  12995. /**
  12996. * Maximum scale of emitting particles on X axis.
  12997. */
  12998. maxScaleX: number;
  12999. /**
  13000. * Minimum scale of emitting particles on Y axis.
  13001. */
  13002. minScaleY: number;
  13003. /**
  13004. * Maximum scale of emitting particles on Y axis.
  13005. */
  13006. maxScaleY: number;
  13007. /**
  13008. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13009. */
  13010. color1: Color4;
  13011. /**
  13012. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13013. */
  13014. color2: Color4;
  13015. /**
  13016. * Color the particle will have at the end of its lifetime.
  13017. */
  13018. colorDead: Color4;
  13019. /**
  13020. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13021. */
  13022. emitRate: number;
  13023. /**
  13024. * You can use gravity if you want to give an orientation to your particles.
  13025. */
  13026. gravity: Vector3;
  13027. /**
  13028. * Minimum power of emitting particles.
  13029. */
  13030. minEmitPower: number;
  13031. /**
  13032. * Maximum power of emitting particles.
  13033. */
  13034. maxEmitPower: number;
  13035. /**
  13036. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13037. */
  13038. minAngularSpeed: number;
  13039. /**
  13040. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13041. */
  13042. maxAngularSpeed: number;
  13043. /**
  13044. * Gets or sets the minimal initial rotation in radians.
  13045. */
  13046. minInitialRotation: number;
  13047. /**
  13048. * Gets or sets the maximal initial rotation in radians.
  13049. */
  13050. maxInitialRotation: number;
  13051. /**
  13052. * The particle emitter type defines the emitter used by the particle system.
  13053. * It can be for example box, sphere, or cone...
  13054. */
  13055. particleEmitterType: Nullable<IParticleEmitterType>;
  13056. /**
  13057. * Defines the delay in milliseconds before starting the system (0 by default)
  13058. */
  13059. startDelay: number;
  13060. /**
  13061. * 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
  13062. */
  13063. preWarmCycles: number;
  13064. /**
  13065. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13066. */
  13067. preWarmStepOffset: number;
  13068. /**
  13069. * 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)
  13070. */
  13071. spriteCellChangeSpeed: number;
  13072. /**
  13073. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13074. */
  13075. startSpriteCellID: number;
  13076. /**
  13077. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13078. */
  13079. endSpriteCellID: number;
  13080. /**
  13081. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13082. */
  13083. spriteCellWidth: number;
  13084. /**
  13085. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13086. */
  13087. spriteCellHeight: number;
  13088. /**
  13089. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13090. */
  13091. spriteRandomStartCell: boolean;
  13092. /**
  13093. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13094. */
  13095. isAnimationSheetEnabled: boolean;
  13096. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13097. translationPivot: Vector2;
  13098. /**
  13099. * Gets or sets a texture used to add random noise to particle positions
  13100. */
  13101. noiseTexture: Nullable<BaseTexture>;
  13102. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13103. noiseStrength: Vector3;
  13104. /**
  13105. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13106. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13107. */
  13108. billboardMode: number;
  13109. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13110. limitVelocityDamping: number;
  13111. /**
  13112. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13113. */
  13114. beginAnimationOnStart: boolean;
  13115. /**
  13116. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13117. */
  13118. beginAnimationFrom: number;
  13119. /**
  13120. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13121. */
  13122. beginAnimationTo: number;
  13123. /**
  13124. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13125. */
  13126. beginAnimationLoop: boolean;
  13127. /**
  13128. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13129. */
  13130. disposeOnStop: boolean;
  13131. /**
  13132. * Specifies if the particles are updated in emitter local space or world space
  13133. */
  13134. isLocal: boolean;
  13135. /**
  13136. * Gets the maximum number of particles active at the same time.
  13137. * @returns The max number of active particles.
  13138. */
  13139. getCapacity(): number;
  13140. /**
  13141. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13142. * @returns True if it has been started, otherwise false.
  13143. */
  13144. isStarted(): boolean;
  13145. /**
  13146. * Animates the particle system for this frame.
  13147. */
  13148. animate(): void;
  13149. /**
  13150. * Renders the particle system in its current state.
  13151. * @returns the current number of particles
  13152. */
  13153. render(): number;
  13154. /**
  13155. * Dispose the particle system and frees its associated resources.
  13156. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13157. */
  13158. dispose(disposeTexture?: boolean): void;
  13159. /**
  13160. * Clones the particle system.
  13161. * @param name The name of the cloned object
  13162. * @param newEmitter The new emitter to use
  13163. * @returns the cloned particle system
  13164. */
  13165. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13166. /**
  13167. * Serializes the particle system to a JSON object.
  13168. * @returns the JSON object
  13169. */
  13170. serialize(): any;
  13171. /**
  13172. * Rebuild the particle system
  13173. */
  13174. rebuild(): void;
  13175. /**
  13176. * Starts the particle system and begins to emit
  13177. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13178. */
  13179. start(delay?: number): void;
  13180. /**
  13181. * Stops the particle system.
  13182. */
  13183. stop(): void;
  13184. /**
  13185. * Remove all active particles
  13186. */
  13187. reset(): void;
  13188. /**
  13189. * Is this system ready to be used/rendered
  13190. * @return true if the system is ready
  13191. */
  13192. isReady(): boolean;
  13193. /**
  13194. * Returns the string "ParticleSystem"
  13195. * @returns a string containing the class name
  13196. */
  13197. getClassName(): string;
  13198. /**
  13199. * Adds a new color gradient
  13200. * @param gradient defines the gradient to use (between 0 and 1)
  13201. * @param color1 defines the color to affect to the specified gradient
  13202. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13203. * @returns the current particle system
  13204. */
  13205. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13206. /**
  13207. * Remove a specific color gradient
  13208. * @param gradient defines the gradient to remove
  13209. * @returns the current particle system
  13210. */
  13211. removeColorGradient(gradient: number): IParticleSystem;
  13212. /**
  13213. * Adds a new size gradient
  13214. * @param gradient defines the gradient to use (between 0 and 1)
  13215. * @param factor defines the size factor to affect to the specified gradient
  13216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13217. * @returns the current particle system
  13218. */
  13219. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13220. /**
  13221. * Remove a specific size gradient
  13222. * @param gradient defines the gradient to remove
  13223. * @returns the current particle system
  13224. */
  13225. removeSizeGradient(gradient: number): IParticleSystem;
  13226. /**
  13227. * Gets the current list of color gradients.
  13228. * You must use addColorGradient and removeColorGradient to udpate this list
  13229. * @returns the list of color gradients
  13230. */
  13231. getColorGradients(): Nullable<Array<ColorGradient>>;
  13232. /**
  13233. * Gets the current list of size gradients.
  13234. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13235. * @returns the list of size gradients
  13236. */
  13237. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13238. /**
  13239. * Gets the current list of angular speed gradients.
  13240. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13241. * @returns the list of angular speed gradients
  13242. */
  13243. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13244. /**
  13245. * Adds a new angular speed gradient
  13246. * @param gradient defines the gradient to use (between 0 and 1)
  13247. * @param factor defines the angular speed to affect to the specified gradient
  13248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13249. * @returns the current particle system
  13250. */
  13251. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13252. /**
  13253. * Remove a specific angular speed gradient
  13254. * @param gradient defines the gradient to remove
  13255. * @returns the current particle system
  13256. */
  13257. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13258. /**
  13259. * Gets the current list of velocity gradients.
  13260. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13261. * @returns the list of velocity gradients
  13262. */
  13263. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13264. /**
  13265. * Adds a new velocity gradient
  13266. * @param gradient defines the gradient to use (between 0 and 1)
  13267. * @param factor defines the velocity to affect to the specified gradient
  13268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13269. * @returns the current particle system
  13270. */
  13271. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13272. /**
  13273. * Remove a specific velocity gradient
  13274. * @param gradient defines the gradient to remove
  13275. * @returns the current particle system
  13276. */
  13277. removeVelocityGradient(gradient: number): IParticleSystem;
  13278. /**
  13279. * Gets the current list of limit velocity gradients.
  13280. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13281. * @returns the list of limit velocity gradients
  13282. */
  13283. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13284. /**
  13285. * Adds a new limit velocity gradient
  13286. * @param gradient defines the gradient to use (between 0 and 1)
  13287. * @param factor defines the limit velocity to affect to the specified gradient
  13288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13289. * @returns the current particle system
  13290. */
  13291. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13292. /**
  13293. * Remove a specific limit velocity gradient
  13294. * @param gradient defines the gradient to remove
  13295. * @returns the current particle system
  13296. */
  13297. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13298. /**
  13299. * Adds a new drag gradient
  13300. * @param gradient defines the gradient to use (between 0 and 1)
  13301. * @param factor defines the drag to affect to the specified gradient
  13302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13303. * @returns the current particle system
  13304. */
  13305. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13306. /**
  13307. * Remove a specific drag gradient
  13308. * @param gradient defines the gradient to remove
  13309. * @returns the current particle system
  13310. */
  13311. removeDragGradient(gradient: number): IParticleSystem;
  13312. /**
  13313. * Gets the current list of drag gradients.
  13314. * You must use addDragGradient and removeDragGradient to udpate this list
  13315. * @returns the list of drag gradients
  13316. */
  13317. getDragGradients(): Nullable<Array<FactorGradient>>;
  13318. /**
  13319. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13320. * @param gradient defines the gradient to use (between 0 and 1)
  13321. * @param factor defines the emit rate to affect to the specified gradient
  13322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13323. * @returns the current particle system
  13324. */
  13325. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13326. /**
  13327. * Remove a specific emit rate gradient
  13328. * @param gradient defines the gradient to remove
  13329. * @returns the current particle system
  13330. */
  13331. removeEmitRateGradient(gradient: number): IParticleSystem;
  13332. /**
  13333. * Gets the current list of emit rate gradients.
  13334. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13335. * @returns the list of emit rate gradients
  13336. */
  13337. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13338. /**
  13339. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13340. * @param gradient defines the gradient to use (between 0 and 1)
  13341. * @param factor defines the start size to affect to the specified gradient
  13342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13343. * @returns the current particle system
  13344. */
  13345. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13346. /**
  13347. * Remove a specific start size gradient
  13348. * @param gradient defines the gradient to remove
  13349. * @returns the current particle system
  13350. */
  13351. removeStartSizeGradient(gradient: number): IParticleSystem;
  13352. /**
  13353. * Gets the current list of start size gradients.
  13354. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13355. * @returns the list of start size gradients
  13356. */
  13357. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13358. /**
  13359. * Adds a new life time gradient
  13360. * @param gradient defines the gradient to use (between 0 and 1)
  13361. * @param factor defines the life time factor to affect to the specified gradient
  13362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13363. * @returns the current particle system
  13364. */
  13365. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13366. /**
  13367. * Remove a specific life time gradient
  13368. * @param gradient defines the gradient to remove
  13369. * @returns the current particle system
  13370. */
  13371. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13372. /**
  13373. * Gets the current list of life time gradients.
  13374. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13375. * @returns the list of life time gradients
  13376. */
  13377. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13378. /**
  13379. * Gets the current list of color gradients.
  13380. * You must use addColorGradient and removeColorGradient to udpate this list
  13381. * @returns the list of color gradients
  13382. */
  13383. getColorGradients(): Nullable<Array<ColorGradient>>;
  13384. /**
  13385. * Adds a new ramp gradient used to remap particle colors
  13386. * @param gradient defines the gradient to use (between 0 and 1)
  13387. * @param color defines the color to affect to the specified gradient
  13388. * @returns the current particle system
  13389. */
  13390. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13391. /**
  13392. * Gets the current list of ramp gradients.
  13393. * You must use addRampGradient and removeRampGradient to udpate this list
  13394. * @returns the list of ramp gradients
  13395. */
  13396. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13397. /** Gets or sets a boolean indicating that ramp gradients must be used
  13398. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13399. */
  13400. useRampGradients: boolean;
  13401. /**
  13402. * Adds a new color remap gradient
  13403. * @param gradient defines the gradient to use (between 0 and 1)
  13404. * @param min defines the color remap minimal range
  13405. * @param max defines the color remap maximal range
  13406. * @returns the current particle system
  13407. */
  13408. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13409. /**
  13410. * Gets the current list of color remap gradients.
  13411. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13412. * @returns the list of color remap gradients
  13413. */
  13414. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13415. /**
  13416. * Adds a new alpha remap gradient
  13417. * @param gradient defines the gradient to use (between 0 and 1)
  13418. * @param min defines the alpha remap minimal range
  13419. * @param max defines the alpha remap maximal range
  13420. * @returns the current particle system
  13421. */
  13422. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13423. /**
  13424. * Gets the current list of alpha remap gradients.
  13425. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13426. * @returns the list of alpha remap gradients
  13427. */
  13428. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13429. /**
  13430. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13431. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13432. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13433. * @returns the emitter
  13434. */
  13435. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13436. /**
  13437. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13438. * @param radius The radius of the hemisphere to emit from
  13439. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13440. * @returns the emitter
  13441. */
  13442. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13443. /**
  13444. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13445. * @param radius The radius of the sphere to emit from
  13446. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13447. * @returns the emitter
  13448. */
  13449. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13450. /**
  13451. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13452. * @param radius The radius of the sphere to emit from
  13453. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13454. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13455. * @returns the emitter
  13456. */
  13457. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13458. /**
  13459. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13460. * @param radius The radius of the emission cylinder
  13461. * @param height The height of the emission cylinder
  13462. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13463. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13464. * @returns the emitter
  13465. */
  13466. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13467. /**
  13468. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13469. * @param radius The radius of the cylinder to emit from
  13470. * @param height The height of the emission cylinder
  13471. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13472. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13473. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13474. * @returns the emitter
  13475. */
  13476. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13477. /**
  13478. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13479. * @param radius The radius of the cone to emit from
  13480. * @param angle The base angle of the cone
  13481. * @returns the emitter
  13482. */
  13483. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13484. /**
  13485. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13488. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13489. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13490. * @returns the emitter
  13491. */
  13492. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13493. /**
  13494. * Get hosting scene
  13495. * @returns the scene
  13496. */
  13497. getScene(): Scene;
  13498. }
  13499. }
  13500. declare module BABYLON {
  13501. /**
  13502. * 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.
  13503. * @see https://doc.babylonjs.com/how_to/transformnode
  13504. */
  13505. export class TransformNode extends Node {
  13506. /**
  13507. * Object will not rotate to face the camera
  13508. */
  13509. static BILLBOARDMODE_NONE: number;
  13510. /**
  13511. * Object will rotate to face the camera but only on the x axis
  13512. */
  13513. static BILLBOARDMODE_X: number;
  13514. /**
  13515. * Object will rotate to face the camera but only on the y axis
  13516. */
  13517. static BILLBOARDMODE_Y: number;
  13518. /**
  13519. * Object will rotate to face the camera but only on the z axis
  13520. */
  13521. static BILLBOARDMODE_Z: number;
  13522. /**
  13523. * Object will rotate to face the camera
  13524. */
  13525. static BILLBOARDMODE_ALL: number;
  13526. /**
  13527. * Object will rotate to face the camera's position instead of orientation
  13528. */
  13529. static BILLBOARDMODE_USE_POSITION: number;
  13530. private _forward;
  13531. private _forwardInverted;
  13532. private _up;
  13533. private _right;
  13534. private _rightInverted;
  13535. private _position;
  13536. private _rotation;
  13537. private _rotationQuaternion;
  13538. protected _scaling: Vector3;
  13539. protected _isDirty: boolean;
  13540. private _transformToBoneReferal;
  13541. private _isAbsoluteSynced;
  13542. private _billboardMode;
  13543. /**
  13544. * Gets or sets the billboard mode. Default is 0.
  13545. *
  13546. * | Value | Type | Description |
  13547. * | --- | --- | --- |
  13548. * | 0 | BILLBOARDMODE_NONE | |
  13549. * | 1 | BILLBOARDMODE_X | |
  13550. * | 2 | BILLBOARDMODE_Y | |
  13551. * | 4 | BILLBOARDMODE_Z | |
  13552. * | 7 | BILLBOARDMODE_ALL | |
  13553. *
  13554. */
  13555. get billboardMode(): number;
  13556. set billboardMode(value: number);
  13557. private _preserveParentRotationForBillboard;
  13558. /**
  13559. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13560. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13561. */
  13562. get preserveParentRotationForBillboard(): boolean;
  13563. set preserveParentRotationForBillboard(value: boolean);
  13564. /**
  13565. * 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
  13566. */
  13567. scalingDeterminant: number;
  13568. private _infiniteDistance;
  13569. /**
  13570. * Gets or sets the distance of the object to max, often used by skybox
  13571. */
  13572. get infiniteDistance(): boolean;
  13573. set infiniteDistance(value: boolean);
  13574. /**
  13575. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13576. * By default the system will update normals to compensate
  13577. */
  13578. ignoreNonUniformScaling: boolean;
  13579. /**
  13580. * 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
  13581. */
  13582. reIntegrateRotationIntoRotationQuaternion: boolean;
  13583. /** @hidden */
  13584. _poseMatrix: Nullable<Matrix>;
  13585. /** @hidden */
  13586. _localMatrix: Matrix;
  13587. private _usePivotMatrix;
  13588. private _absolutePosition;
  13589. private _absoluteScaling;
  13590. private _absoluteRotationQuaternion;
  13591. private _pivotMatrix;
  13592. private _pivotMatrixInverse;
  13593. protected _postMultiplyPivotMatrix: boolean;
  13594. protected _isWorldMatrixFrozen: boolean;
  13595. /** @hidden */
  13596. _indexInSceneTransformNodesArray: number;
  13597. /**
  13598. * An event triggered after the world matrix is updated
  13599. */
  13600. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13601. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13602. /**
  13603. * Gets a string identifying the name of the class
  13604. * @returns "TransformNode" string
  13605. */
  13606. getClassName(): string;
  13607. /**
  13608. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13609. */
  13610. get position(): Vector3;
  13611. set position(newPosition: Vector3);
  13612. /**
  13613. * 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)).
  13614. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13615. */
  13616. get rotation(): Vector3;
  13617. set rotation(newRotation: Vector3);
  13618. /**
  13619. * 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)).
  13620. */
  13621. get scaling(): Vector3;
  13622. set scaling(newScaling: Vector3);
  13623. /**
  13624. * 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).
  13625. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13626. */
  13627. get rotationQuaternion(): Nullable<Quaternion>;
  13628. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13629. /**
  13630. * The forward direction of that transform in world space.
  13631. */
  13632. get forward(): Vector3;
  13633. /**
  13634. * The up direction of that transform in world space.
  13635. */
  13636. get up(): Vector3;
  13637. /**
  13638. * The right direction of that transform in world space.
  13639. */
  13640. get right(): Vector3;
  13641. /**
  13642. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13643. * @param matrix the matrix to copy the pose from
  13644. * @returns this TransformNode.
  13645. */
  13646. updatePoseMatrix(matrix: Matrix): TransformNode;
  13647. /**
  13648. * Returns the mesh Pose matrix.
  13649. * @returns the pose matrix
  13650. */
  13651. getPoseMatrix(): Matrix;
  13652. /** @hidden */
  13653. _isSynchronized(): boolean;
  13654. /** @hidden */
  13655. _initCache(): void;
  13656. /**
  13657. * Flag the transform node as dirty (Forcing it to update everything)
  13658. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13659. * @returns this transform node
  13660. */
  13661. markAsDirty(property: string): TransformNode;
  13662. /**
  13663. * Returns the current mesh absolute position.
  13664. * Returns a Vector3.
  13665. */
  13666. get absolutePosition(): Vector3;
  13667. /**
  13668. * Returns the current mesh absolute scaling.
  13669. * Returns a Vector3.
  13670. */
  13671. get absoluteScaling(): Vector3;
  13672. /**
  13673. * Returns the current mesh absolute rotation.
  13674. * Returns a Quaternion.
  13675. */
  13676. get absoluteRotationQuaternion(): Quaternion;
  13677. /**
  13678. * Sets a new matrix to apply before all other transformation
  13679. * @param matrix defines the transform matrix
  13680. * @returns the current TransformNode
  13681. */
  13682. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13683. /**
  13684. * Sets a new pivot matrix to the current node
  13685. * @param matrix defines the new pivot matrix to use
  13686. * @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
  13687. * @returns the current TransformNode
  13688. */
  13689. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13690. /**
  13691. * Returns the mesh pivot matrix.
  13692. * Default : Identity.
  13693. * @returns the matrix
  13694. */
  13695. getPivotMatrix(): Matrix;
  13696. /**
  13697. * Instantiate (when possible) or clone that node with its hierarchy
  13698. * @param newParent defines the new parent to use for the instance (or clone)
  13699. * @param options defines options to configure how copy is done
  13700. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13701. * @returns an instance (or a clone) of the current node with its hiearchy
  13702. */
  13703. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13704. doNotInstantiate: boolean;
  13705. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13706. /**
  13707. * Prevents the World matrix to be computed any longer
  13708. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13709. * @returns the TransformNode.
  13710. */
  13711. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13712. /**
  13713. * Allows back the World matrix computation.
  13714. * @returns the TransformNode.
  13715. */
  13716. unfreezeWorldMatrix(): this;
  13717. /**
  13718. * True if the World matrix has been frozen.
  13719. */
  13720. get isWorldMatrixFrozen(): boolean;
  13721. /**
  13722. * Retuns the mesh absolute position in the World.
  13723. * @returns a Vector3.
  13724. */
  13725. getAbsolutePosition(): Vector3;
  13726. /**
  13727. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13728. * @param absolutePosition the absolute position to set
  13729. * @returns the TransformNode.
  13730. */
  13731. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13732. /**
  13733. * Sets the mesh position in its local space.
  13734. * @param vector3 the position to set in localspace
  13735. * @returns the TransformNode.
  13736. */
  13737. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13738. /**
  13739. * Returns the mesh position in the local space from the current World matrix values.
  13740. * @returns a new Vector3.
  13741. */
  13742. getPositionExpressedInLocalSpace(): Vector3;
  13743. /**
  13744. * Translates the mesh along the passed Vector3 in its local space.
  13745. * @param vector3 the distance to translate in localspace
  13746. * @returns the TransformNode.
  13747. */
  13748. locallyTranslate(vector3: Vector3): TransformNode;
  13749. private static _lookAtVectorCache;
  13750. /**
  13751. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13752. * @param targetPoint the position (must be in same space as current mesh) to look at
  13753. * @param yawCor optional yaw (y-axis) correction in radians
  13754. * @param pitchCor optional pitch (x-axis) correction in radians
  13755. * @param rollCor optional roll (z-axis) correction in radians
  13756. * @param space the choosen space of the target
  13757. * @returns the TransformNode.
  13758. */
  13759. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13760. /**
  13761. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13762. * This Vector3 is expressed in the World space.
  13763. * @param localAxis axis to rotate
  13764. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13765. */
  13766. getDirection(localAxis: Vector3): Vector3;
  13767. /**
  13768. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13769. * localAxis is expressed in the mesh local space.
  13770. * result is computed in the Wordl space from the mesh World matrix.
  13771. * @param localAxis axis to rotate
  13772. * @param result the resulting transformnode
  13773. * @returns this TransformNode.
  13774. */
  13775. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13776. /**
  13777. * Sets this transform node rotation to the given local axis.
  13778. * @param localAxis the axis in local space
  13779. * @param yawCor optional yaw (y-axis) correction in radians
  13780. * @param pitchCor optional pitch (x-axis) correction in radians
  13781. * @param rollCor optional roll (z-axis) correction in radians
  13782. * @returns this TransformNode
  13783. */
  13784. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13785. /**
  13786. * Sets a new pivot point to the current node
  13787. * @param point defines the new pivot point to use
  13788. * @param space defines if the point is in world or local space (local by default)
  13789. * @returns the current TransformNode
  13790. */
  13791. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13792. /**
  13793. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13794. * @returns the pivot point
  13795. */
  13796. getPivotPoint(): Vector3;
  13797. /**
  13798. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13799. * @param result the vector3 to store the result
  13800. * @returns this TransformNode.
  13801. */
  13802. getPivotPointToRef(result: Vector3): TransformNode;
  13803. /**
  13804. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13805. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13806. */
  13807. getAbsolutePivotPoint(): Vector3;
  13808. /**
  13809. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13810. * @param result vector3 to store the result
  13811. * @returns this TransformNode.
  13812. */
  13813. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13814. /**
  13815. * Defines the passed node as the parent of the current node.
  13816. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13817. * @see https://doc.babylonjs.com/how_to/parenting
  13818. * @param node the node ot set as the parent
  13819. * @returns this TransformNode.
  13820. */
  13821. setParent(node: Nullable<Node>): TransformNode;
  13822. private _nonUniformScaling;
  13823. /**
  13824. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13825. */
  13826. get nonUniformScaling(): boolean;
  13827. /** @hidden */
  13828. _updateNonUniformScalingState(value: boolean): boolean;
  13829. /**
  13830. * Attach the current TransformNode to another TransformNode associated with a bone
  13831. * @param bone Bone affecting the TransformNode
  13832. * @param affectedTransformNode TransformNode associated with the bone
  13833. * @returns this object
  13834. */
  13835. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13836. /**
  13837. * Detach the transform node if its associated with a bone
  13838. * @returns this object
  13839. */
  13840. detachFromBone(): TransformNode;
  13841. private static _rotationAxisCache;
  13842. /**
  13843. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13844. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13845. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13846. * The passed axis is also normalized.
  13847. * @param axis the axis to rotate around
  13848. * @param amount the amount to rotate in radians
  13849. * @param space Space to rotate in (Default: local)
  13850. * @returns the TransformNode.
  13851. */
  13852. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13853. /**
  13854. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13855. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13856. * The passed axis is also normalized. .
  13857. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13858. * @param point the point to rotate around
  13859. * @param axis the axis to rotate around
  13860. * @param amount the amount to rotate in radians
  13861. * @returns the TransformNode
  13862. */
  13863. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13864. /**
  13865. * Translates the mesh along the axis vector for the passed distance in the given space.
  13866. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13867. * @param axis the axis to translate in
  13868. * @param distance the distance to translate
  13869. * @param space Space to rotate in (Default: local)
  13870. * @returns the TransformNode.
  13871. */
  13872. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13873. /**
  13874. * Adds a rotation step to the mesh current rotation.
  13875. * x, y, z are Euler angles expressed in radians.
  13876. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13877. * This means this rotation is made in the mesh local space only.
  13878. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13879. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13880. * ```javascript
  13881. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13882. * ```
  13883. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13884. * 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.
  13885. * @param x Rotation to add
  13886. * @param y Rotation to add
  13887. * @param z Rotation to add
  13888. * @returns the TransformNode.
  13889. */
  13890. addRotation(x: number, y: number, z: number): TransformNode;
  13891. /**
  13892. * @hidden
  13893. */
  13894. protected _getEffectiveParent(): Nullable<Node>;
  13895. /**
  13896. * Computes the world matrix of the node
  13897. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13898. * @returns the world matrix
  13899. */
  13900. computeWorldMatrix(force?: boolean): Matrix;
  13901. /**
  13902. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13903. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13904. */
  13905. resetLocalMatrix(independentOfChildren?: boolean): void;
  13906. protected _afterComputeWorldMatrix(): void;
  13907. /**
  13908. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13909. * @param func callback function to add
  13910. *
  13911. * @returns the TransformNode.
  13912. */
  13913. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13914. /**
  13915. * Removes a registered callback function.
  13916. * @param func callback function to remove
  13917. * @returns the TransformNode.
  13918. */
  13919. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13920. /**
  13921. * Gets the position of the current mesh in camera space
  13922. * @param camera defines the camera to use
  13923. * @returns a position
  13924. */
  13925. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13926. /**
  13927. * Returns the distance from the mesh to the active camera
  13928. * @param camera defines the camera to use
  13929. * @returns the distance
  13930. */
  13931. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13932. /**
  13933. * Clone the current transform node
  13934. * @param name Name of the new clone
  13935. * @param newParent New parent for the clone
  13936. * @param doNotCloneChildren Do not clone children hierarchy
  13937. * @returns the new transform node
  13938. */
  13939. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13940. /**
  13941. * Serializes the objects information.
  13942. * @param currentSerializationObject defines the object to serialize in
  13943. * @returns the serialized object
  13944. */
  13945. serialize(currentSerializationObject?: any): any;
  13946. /**
  13947. * Returns a new TransformNode object parsed from the source provided.
  13948. * @param parsedTransformNode is the source.
  13949. * @param scene the scne the object belongs to
  13950. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13951. * @returns a new TransformNode object parsed from the source provided.
  13952. */
  13953. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13954. /**
  13955. * Get all child-transformNodes of this node
  13956. * @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
  13957. * @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
  13958. * @returns an array of TransformNode
  13959. */
  13960. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13961. /**
  13962. * Releases resources associated with this transform node.
  13963. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13964. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13965. */
  13966. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13967. /**
  13968. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13969. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13970. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13971. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13972. * @returns the current mesh
  13973. */
  13974. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13975. private _syncAbsoluteScalingAndRotation;
  13976. }
  13977. }
  13978. declare module BABYLON {
  13979. /**
  13980. * Class used to override all child animations of a given target
  13981. */
  13982. export class AnimationPropertiesOverride {
  13983. /**
  13984. * Gets or sets a value indicating if animation blending must be used
  13985. */
  13986. enableBlending: boolean;
  13987. /**
  13988. * Gets or sets the blending speed to use when enableBlending is true
  13989. */
  13990. blendingSpeed: number;
  13991. /**
  13992. * Gets or sets the default loop mode to use
  13993. */
  13994. loopMode: number;
  13995. }
  13996. }
  13997. declare module BABYLON {
  13998. /**
  13999. * Class used to store bone information
  14000. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14001. */
  14002. export class Bone extends Node {
  14003. /**
  14004. * defines the bone name
  14005. */
  14006. name: string;
  14007. private static _tmpVecs;
  14008. private static _tmpQuat;
  14009. private static _tmpMats;
  14010. /**
  14011. * Gets the list of child bones
  14012. */
  14013. children: Bone[];
  14014. /** Gets the animations associated with this bone */
  14015. animations: Animation[];
  14016. /**
  14017. * Gets or sets bone length
  14018. */
  14019. length: number;
  14020. /**
  14021. * @hidden Internal only
  14022. * Set this value to map this bone to a different index in the transform matrices
  14023. * Set this value to -1 to exclude the bone from the transform matrices
  14024. */
  14025. _index: Nullable<number>;
  14026. private _skeleton;
  14027. private _localMatrix;
  14028. private _restPose;
  14029. private _baseMatrix;
  14030. private _absoluteTransform;
  14031. private _invertedAbsoluteTransform;
  14032. private _parent;
  14033. private _scalingDeterminant;
  14034. private _worldTransform;
  14035. private _localScaling;
  14036. private _localRotation;
  14037. private _localPosition;
  14038. private _needToDecompose;
  14039. private _needToCompose;
  14040. /** @hidden */
  14041. _linkedTransformNode: Nullable<TransformNode>;
  14042. /** @hidden */
  14043. _waitingTransformNodeId: Nullable<string>;
  14044. /** @hidden */
  14045. get _matrix(): Matrix;
  14046. /** @hidden */
  14047. set _matrix(value: Matrix);
  14048. /**
  14049. * Create a new bone
  14050. * @param name defines the bone name
  14051. * @param skeleton defines the parent skeleton
  14052. * @param parentBone defines the parent (can be null if the bone is the root)
  14053. * @param localMatrix defines the local matrix
  14054. * @param restPose defines the rest pose matrix
  14055. * @param baseMatrix defines the base matrix
  14056. * @param index defines index of the bone in the hiearchy
  14057. */
  14058. constructor(
  14059. /**
  14060. * defines the bone name
  14061. */
  14062. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14063. /**
  14064. * Gets the current object class name.
  14065. * @return the class name
  14066. */
  14067. getClassName(): string;
  14068. /**
  14069. * Gets the parent skeleton
  14070. * @returns a skeleton
  14071. */
  14072. getSkeleton(): Skeleton;
  14073. /**
  14074. * Gets parent bone
  14075. * @returns a bone or null if the bone is the root of the bone hierarchy
  14076. */
  14077. getParent(): Nullable<Bone>;
  14078. /**
  14079. * Returns an array containing the root bones
  14080. * @returns an array containing the root bones
  14081. */
  14082. getChildren(): Array<Bone>;
  14083. /**
  14084. * Gets the node index in matrix array generated for rendering
  14085. * @returns the node index
  14086. */
  14087. getIndex(): number;
  14088. /**
  14089. * Sets the parent bone
  14090. * @param parent defines the parent (can be null if the bone is the root)
  14091. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14092. */
  14093. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14094. /**
  14095. * Gets the local matrix
  14096. * @returns a matrix
  14097. */
  14098. getLocalMatrix(): Matrix;
  14099. /**
  14100. * Gets the base matrix (initial matrix which remains unchanged)
  14101. * @returns a matrix
  14102. */
  14103. getBaseMatrix(): Matrix;
  14104. /**
  14105. * Gets the rest pose matrix
  14106. * @returns a matrix
  14107. */
  14108. getRestPose(): Matrix;
  14109. /**
  14110. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14111. */
  14112. getWorldMatrix(): Matrix;
  14113. /**
  14114. * Sets the local matrix to rest pose matrix
  14115. */
  14116. returnToRest(): void;
  14117. /**
  14118. * Gets the inverse of the absolute transform matrix.
  14119. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14120. * @returns a matrix
  14121. */
  14122. getInvertedAbsoluteTransform(): Matrix;
  14123. /**
  14124. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14125. * @returns a matrix
  14126. */
  14127. getAbsoluteTransform(): Matrix;
  14128. /**
  14129. * Links with the given transform node.
  14130. * The local matrix of this bone is copied from the transform node every frame.
  14131. * @param transformNode defines the transform node to link to
  14132. */
  14133. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14134. /**
  14135. * Gets the node used to drive the bone's transformation
  14136. * @returns a transform node or null
  14137. */
  14138. getTransformNode(): Nullable<TransformNode>;
  14139. /** Gets or sets current position (in local space) */
  14140. get position(): Vector3;
  14141. set position(newPosition: Vector3);
  14142. /** Gets or sets current rotation (in local space) */
  14143. get rotation(): Vector3;
  14144. set rotation(newRotation: Vector3);
  14145. /** Gets or sets current rotation quaternion (in local space) */
  14146. get rotationQuaternion(): Quaternion;
  14147. set rotationQuaternion(newRotation: Quaternion);
  14148. /** Gets or sets current scaling (in local space) */
  14149. get scaling(): Vector3;
  14150. set scaling(newScaling: Vector3);
  14151. /**
  14152. * Gets the animation properties override
  14153. */
  14154. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14155. private _decompose;
  14156. private _compose;
  14157. /**
  14158. * Update the base and local matrices
  14159. * @param matrix defines the new base or local matrix
  14160. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14161. * @param updateLocalMatrix defines if the local matrix should be updated
  14162. */
  14163. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14164. /** @hidden */
  14165. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14166. /**
  14167. * Flag the bone as dirty (Forcing it to update everything)
  14168. */
  14169. markAsDirty(): void;
  14170. /** @hidden */
  14171. _markAsDirtyAndCompose(): void;
  14172. private _markAsDirtyAndDecompose;
  14173. /**
  14174. * Translate the bone in local or world space
  14175. * @param vec The amount to translate the bone
  14176. * @param space The space that the translation is in
  14177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14178. */
  14179. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14180. /**
  14181. * Set the postion of the bone in local or world space
  14182. * @param position The position to set the bone
  14183. * @param space The space that the position is in
  14184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14185. */
  14186. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14187. /**
  14188. * Set the absolute position of the bone (world space)
  14189. * @param position The position to set the bone
  14190. * @param mesh The mesh that this bone is attached to
  14191. */
  14192. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14193. /**
  14194. * Scale the bone on the x, y and z axes (in local space)
  14195. * @param x The amount to scale the bone on the x axis
  14196. * @param y The amount to scale the bone on the y axis
  14197. * @param z The amount to scale the bone on the z axis
  14198. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14199. */
  14200. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14201. /**
  14202. * Set the bone scaling in local space
  14203. * @param scale defines the scaling vector
  14204. */
  14205. setScale(scale: Vector3): void;
  14206. /**
  14207. * Gets the current scaling in local space
  14208. * @returns the current scaling vector
  14209. */
  14210. getScale(): Vector3;
  14211. /**
  14212. * Gets the current scaling in local space and stores it in a target vector
  14213. * @param result defines the target vector
  14214. */
  14215. getScaleToRef(result: Vector3): void;
  14216. /**
  14217. * Set the yaw, pitch, and roll of the bone in local or world space
  14218. * @param yaw The rotation of the bone on the y axis
  14219. * @param pitch The rotation of the bone on the x axis
  14220. * @param roll The rotation of the bone on the z axis
  14221. * @param space The space that the axes of rotation are in
  14222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14223. */
  14224. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14225. /**
  14226. * Add a rotation to the bone on an axis in local or world space
  14227. * @param axis The axis to rotate the bone on
  14228. * @param amount The amount to rotate the bone
  14229. * @param space The space that the axis is in
  14230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14231. */
  14232. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14233. /**
  14234. * Set the rotation of the bone to a particular axis angle in local or world space
  14235. * @param axis The axis to rotate the bone on
  14236. * @param angle The angle that the bone should be rotated to
  14237. * @param space The space that the axis is in
  14238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14239. */
  14240. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14241. /**
  14242. * Set the euler rotation of the bone in local of world space
  14243. * @param rotation The euler rotation that the bone should be set to
  14244. * @param space The space that the rotation is in
  14245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14246. */
  14247. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14248. /**
  14249. * Set the quaternion rotation of the bone in local of world space
  14250. * @param quat The quaternion rotation that the bone should be set to
  14251. * @param space The space that the rotation is in
  14252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14253. */
  14254. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14255. /**
  14256. * Set the rotation matrix of the bone in local of world space
  14257. * @param rotMat The rotation matrix that the bone should be set to
  14258. * @param space The space that the rotation is in
  14259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14260. */
  14261. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14262. private _rotateWithMatrix;
  14263. private _getNegativeRotationToRef;
  14264. /**
  14265. * Get the position of the bone in local or world space
  14266. * @param space The space that the returned position is in
  14267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14268. * @returns The position of the bone
  14269. */
  14270. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14271. /**
  14272. * Copy the position of the bone to a vector3 in local or world space
  14273. * @param space The space that the returned position is in
  14274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14275. * @param result The vector3 to copy the position to
  14276. */
  14277. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14278. /**
  14279. * Get the absolute position of the bone (world space)
  14280. * @param mesh The mesh that this bone is attached to
  14281. * @returns The absolute position of the bone
  14282. */
  14283. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14284. /**
  14285. * Copy the absolute position of the bone (world space) to the result param
  14286. * @param mesh The mesh that this bone is attached to
  14287. * @param result The vector3 to copy the absolute position to
  14288. */
  14289. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14290. /**
  14291. * Compute the absolute transforms of this bone and its children
  14292. */
  14293. computeAbsoluteTransforms(): void;
  14294. /**
  14295. * Get the world direction from an axis that is in the local space of the bone
  14296. * @param localAxis The local direction that is used to compute the world direction
  14297. * @param mesh The mesh that this bone is attached to
  14298. * @returns The world direction
  14299. */
  14300. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14301. /**
  14302. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14303. * @param localAxis The local direction that is used to compute the world direction
  14304. * @param mesh The mesh that this bone is attached to
  14305. * @param result The vector3 that the world direction will be copied to
  14306. */
  14307. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14308. /**
  14309. * Get the euler rotation of the bone in local or world space
  14310. * @param space The space that the rotation should be in
  14311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14312. * @returns The euler rotation
  14313. */
  14314. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14315. /**
  14316. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14317. * @param space The space that the rotation should be in
  14318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14319. * @param result The vector3 that the rotation should be copied to
  14320. */
  14321. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14322. /**
  14323. * Get the quaternion rotation of the bone in either local or world space
  14324. * @param space The space that the rotation should be in
  14325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14326. * @returns The quaternion rotation
  14327. */
  14328. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14329. /**
  14330. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14331. * @param space The space that the rotation should be in
  14332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14333. * @param result The quaternion that the rotation should be copied to
  14334. */
  14335. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14336. /**
  14337. * Get the rotation matrix of the bone in local or world space
  14338. * @param space The space that the rotation should be in
  14339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14340. * @returns The rotation matrix
  14341. */
  14342. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14343. /**
  14344. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14345. * @param space The space that the rotation should be in
  14346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14347. * @param result The quaternion that the rotation should be copied to
  14348. */
  14349. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14350. /**
  14351. * Get the world position of a point that is in the local space of the bone
  14352. * @param position The local position
  14353. * @param mesh The mesh that this bone is attached to
  14354. * @returns The world position
  14355. */
  14356. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14357. /**
  14358. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14359. * @param position The local position
  14360. * @param mesh The mesh that this bone is attached to
  14361. * @param result The vector3 that the world position should be copied to
  14362. */
  14363. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14364. /**
  14365. * Get the local position of a point that is in world space
  14366. * @param position The world position
  14367. * @param mesh The mesh that this bone is attached to
  14368. * @returns The local position
  14369. */
  14370. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14371. /**
  14372. * Get the local position of a point that is in world space and copy it to the result param
  14373. * @param position The world position
  14374. * @param mesh The mesh that this bone is attached to
  14375. * @param result The vector3 that the local position should be copied to
  14376. */
  14377. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14378. }
  14379. }
  14380. declare module BABYLON {
  14381. /**
  14382. * Defines a runtime animation
  14383. */
  14384. export class RuntimeAnimation {
  14385. private _events;
  14386. /**
  14387. * The current frame of the runtime animation
  14388. */
  14389. private _currentFrame;
  14390. /**
  14391. * The animation used by the runtime animation
  14392. */
  14393. private _animation;
  14394. /**
  14395. * The target of the runtime animation
  14396. */
  14397. private _target;
  14398. /**
  14399. * The initiating animatable
  14400. */
  14401. private _host;
  14402. /**
  14403. * The original value of the runtime animation
  14404. */
  14405. private _originalValue;
  14406. /**
  14407. * The original blend value of the runtime animation
  14408. */
  14409. private _originalBlendValue;
  14410. /**
  14411. * The offsets cache of the runtime animation
  14412. */
  14413. private _offsetsCache;
  14414. /**
  14415. * The high limits cache of the runtime animation
  14416. */
  14417. private _highLimitsCache;
  14418. /**
  14419. * Specifies if the runtime animation has been stopped
  14420. */
  14421. private _stopped;
  14422. /**
  14423. * The blending factor of the runtime animation
  14424. */
  14425. private _blendingFactor;
  14426. /**
  14427. * The BabylonJS scene
  14428. */
  14429. private _scene;
  14430. /**
  14431. * The current value of the runtime animation
  14432. */
  14433. private _currentValue;
  14434. /** @hidden */
  14435. _animationState: _IAnimationState;
  14436. /**
  14437. * The active target of the runtime animation
  14438. */
  14439. private _activeTargets;
  14440. private _currentActiveTarget;
  14441. private _directTarget;
  14442. /**
  14443. * The target path of the runtime animation
  14444. */
  14445. private _targetPath;
  14446. /**
  14447. * The weight of the runtime animation
  14448. */
  14449. private _weight;
  14450. /**
  14451. * The ratio offset of the runtime animation
  14452. */
  14453. private _ratioOffset;
  14454. /**
  14455. * The previous delay of the runtime animation
  14456. */
  14457. private _previousDelay;
  14458. /**
  14459. * The previous ratio of the runtime animation
  14460. */
  14461. private _previousRatio;
  14462. private _enableBlending;
  14463. private _keys;
  14464. private _minFrame;
  14465. private _maxFrame;
  14466. private _minValue;
  14467. private _maxValue;
  14468. private _targetIsArray;
  14469. /**
  14470. * Gets the current frame of the runtime animation
  14471. */
  14472. get currentFrame(): number;
  14473. /**
  14474. * Gets the weight of the runtime animation
  14475. */
  14476. get weight(): number;
  14477. /**
  14478. * Gets the current value of the runtime animation
  14479. */
  14480. get currentValue(): any;
  14481. /**
  14482. * Gets the target path of the runtime animation
  14483. */
  14484. get targetPath(): string;
  14485. /**
  14486. * Gets the actual target of the runtime animation
  14487. */
  14488. get target(): any;
  14489. /** @hidden */
  14490. _onLoop: () => void;
  14491. /**
  14492. * Create a new RuntimeAnimation object
  14493. * @param target defines the target of the animation
  14494. * @param animation defines the source animation object
  14495. * @param scene defines the hosting scene
  14496. * @param host defines the initiating Animatable
  14497. */
  14498. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14499. private _preparePath;
  14500. /**
  14501. * Gets the animation from the runtime animation
  14502. */
  14503. get animation(): Animation;
  14504. /**
  14505. * Resets the runtime animation to the beginning
  14506. * @param restoreOriginal defines whether to restore the target property to the original value
  14507. */
  14508. reset(restoreOriginal?: boolean): void;
  14509. /**
  14510. * Specifies if the runtime animation is stopped
  14511. * @returns Boolean specifying if the runtime animation is stopped
  14512. */
  14513. isStopped(): boolean;
  14514. /**
  14515. * Disposes of the runtime animation
  14516. */
  14517. dispose(): void;
  14518. /**
  14519. * Apply the interpolated value to the target
  14520. * @param currentValue defines the value computed by the animation
  14521. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14522. */
  14523. setValue(currentValue: any, weight: number): void;
  14524. private _getOriginalValues;
  14525. private _setValue;
  14526. /**
  14527. * Gets the loop pmode of the runtime animation
  14528. * @returns Loop Mode
  14529. */
  14530. private _getCorrectLoopMode;
  14531. /**
  14532. * Move the current animation to a given frame
  14533. * @param frame defines the frame to move to
  14534. */
  14535. goToFrame(frame: number): void;
  14536. /**
  14537. * @hidden Internal use only
  14538. */
  14539. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14540. /**
  14541. * Execute the current animation
  14542. * @param delay defines the delay to add to the current frame
  14543. * @param from defines the lower bound of the animation range
  14544. * @param to defines the upper bound of the animation range
  14545. * @param loop defines if the current animation must loop
  14546. * @param speedRatio defines the current speed ratio
  14547. * @param weight defines the weight of the animation (default is -1 so no weight)
  14548. * @param onLoop optional callback called when animation loops
  14549. * @returns a boolean indicating if the animation is running
  14550. */
  14551. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14552. }
  14553. }
  14554. declare module BABYLON {
  14555. /**
  14556. * Class used to store an actual running animation
  14557. */
  14558. export class Animatable {
  14559. /** defines the target object */
  14560. target: any;
  14561. /** defines the starting frame number (default is 0) */
  14562. fromFrame: number;
  14563. /** defines the ending frame number (default is 100) */
  14564. toFrame: number;
  14565. /** defines if the animation must loop (default is false) */
  14566. loopAnimation: boolean;
  14567. /** defines a callback to call when animation ends if it is not looping */
  14568. onAnimationEnd?: (() => void) | null | undefined;
  14569. /** defines a callback to call when animation loops */
  14570. onAnimationLoop?: (() => void) | null | undefined;
  14571. private _localDelayOffset;
  14572. private _pausedDelay;
  14573. private _runtimeAnimations;
  14574. private _paused;
  14575. private _scene;
  14576. private _speedRatio;
  14577. private _weight;
  14578. private _syncRoot;
  14579. /**
  14580. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14581. * This will only apply for non looping animation (default is true)
  14582. */
  14583. disposeOnEnd: boolean;
  14584. /**
  14585. * Gets a boolean indicating if the animation has started
  14586. */
  14587. animationStarted: boolean;
  14588. /**
  14589. * Observer raised when the animation ends
  14590. */
  14591. onAnimationEndObservable: Observable<Animatable>;
  14592. /**
  14593. * Observer raised when the animation loops
  14594. */
  14595. onAnimationLoopObservable: Observable<Animatable>;
  14596. /**
  14597. * Gets the root Animatable used to synchronize and normalize animations
  14598. */
  14599. get syncRoot(): Nullable<Animatable>;
  14600. /**
  14601. * Gets the current frame of the first RuntimeAnimation
  14602. * Used to synchronize Animatables
  14603. */
  14604. get masterFrame(): number;
  14605. /**
  14606. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14607. */
  14608. get weight(): number;
  14609. set weight(value: number);
  14610. /**
  14611. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14612. */
  14613. get speedRatio(): number;
  14614. set speedRatio(value: number);
  14615. /**
  14616. * Creates a new Animatable
  14617. * @param scene defines the hosting scene
  14618. * @param target defines the target object
  14619. * @param fromFrame defines the starting frame number (default is 0)
  14620. * @param toFrame defines the ending frame number (default is 100)
  14621. * @param loopAnimation defines if the animation must loop (default is false)
  14622. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14623. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14624. * @param animations defines a group of animation to add to the new Animatable
  14625. * @param onAnimationLoop defines a callback to call when animation loops
  14626. */
  14627. constructor(scene: Scene,
  14628. /** defines the target object */
  14629. target: any,
  14630. /** defines the starting frame number (default is 0) */
  14631. fromFrame?: number,
  14632. /** defines the ending frame number (default is 100) */
  14633. toFrame?: number,
  14634. /** defines if the animation must loop (default is false) */
  14635. loopAnimation?: boolean, speedRatio?: number,
  14636. /** defines a callback to call when animation ends if it is not looping */
  14637. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14638. /** defines a callback to call when animation loops */
  14639. onAnimationLoop?: (() => void) | null | undefined);
  14640. /**
  14641. * Synchronize and normalize current Animatable with a source Animatable
  14642. * This is useful when using animation weights and when animations are not of the same length
  14643. * @param root defines the root Animatable to synchronize with
  14644. * @returns the current Animatable
  14645. */
  14646. syncWith(root: Animatable): Animatable;
  14647. /**
  14648. * Gets the list of runtime animations
  14649. * @returns an array of RuntimeAnimation
  14650. */
  14651. getAnimations(): RuntimeAnimation[];
  14652. /**
  14653. * Adds more animations to the current animatable
  14654. * @param target defines the target of the animations
  14655. * @param animations defines the new animations to add
  14656. */
  14657. appendAnimations(target: any, animations: Animation[]): void;
  14658. /**
  14659. * Gets the source animation for a specific property
  14660. * @param property defines the propertyu to look for
  14661. * @returns null or the source animation for the given property
  14662. */
  14663. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14664. /**
  14665. * Gets the runtime animation for a specific property
  14666. * @param property defines the propertyu to look for
  14667. * @returns null or the runtime animation for the given property
  14668. */
  14669. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14670. /**
  14671. * Resets the animatable to its original state
  14672. */
  14673. reset(): void;
  14674. /**
  14675. * Allows the animatable to blend with current running animations
  14676. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14677. * @param blendingSpeed defines the blending speed to use
  14678. */
  14679. enableBlending(blendingSpeed: number): void;
  14680. /**
  14681. * Disable animation blending
  14682. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14683. */
  14684. disableBlending(): void;
  14685. /**
  14686. * Jump directly to a given frame
  14687. * @param frame defines the frame to jump to
  14688. */
  14689. goToFrame(frame: number): void;
  14690. /**
  14691. * Pause the animation
  14692. */
  14693. pause(): void;
  14694. /**
  14695. * Restart the animation
  14696. */
  14697. restart(): void;
  14698. private _raiseOnAnimationEnd;
  14699. /**
  14700. * Stop and delete the current animation
  14701. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14702. * @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)
  14703. */
  14704. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14705. /**
  14706. * Wait asynchronously for the animation to end
  14707. * @returns a promise which will be fullfilled when the animation ends
  14708. */
  14709. waitAsync(): Promise<Animatable>;
  14710. /** @hidden */
  14711. _animate(delay: number): boolean;
  14712. }
  14713. interface Scene {
  14714. /** @hidden */
  14715. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14716. /** @hidden */
  14717. _processLateAnimationBindingsForMatrices(holder: {
  14718. totalWeight: number;
  14719. animations: RuntimeAnimation[];
  14720. originalValue: Matrix;
  14721. }): any;
  14722. /** @hidden */
  14723. _processLateAnimationBindingsForQuaternions(holder: {
  14724. totalWeight: number;
  14725. animations: RuntimeAnimation[];
  14726. originalValue: Quaternion;
  14727. }, refQuaternion: Quaternion): Quaternion;
  14728. /** @hidden */
  14729. _processLateAnimationBindings(): void;
  14730. /**
  14731. * Will start the animation sequence of a given target
  14732. * @param target defines the target
  14733. * @param from defines from which frame should animation start
  14734. * @param to defines until which frame should animation run.
  14735. * @param weight defines the weight to apply to the animation (1.0 by default)
  14736. * @param loop defines if the animation loops
  14737. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14738. * @param onAnimationEnd defines the function to be executed when the animation ends
  14739. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14740. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14741. * @param onAnimationLoop defines the callback to call when an animation loops
  14742. * @returns the animatable object created for this animation
  14743. */
  14744. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14745. /**
  14746. * Will start the animation sequence of a given target
  14747. * @param target defines the target
  14748. * @param from defines from which frame should animation start
  14749. * @param to defines until which frame should animation run.
  14750. * @param loop defines if the animation loops
  14751. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14752. * @param onAnimationEnd defines the function to be executed when the animation ends
  14753. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14754. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14755. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14756. * @param onAnimationLoop defines the callback to call when an animation loops
  14757. * @returns the animatable object created for this animation
  14758. */
  14759. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14760. /**
  14761. * Will start the animation sequence of a given target and its hierarchy
  14762. * @param target defines the target
  14763. * @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.
  14764. * @param from defines from which frame should animation start
  14765. * @param to defines until which frame should animation run.
  14766. * @param loop defines if the animation loops
  14767. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14768. * @param onAnimationEnd defines the function to be executed when the animation ends
  14769. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14770. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14771. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14772. * @param onAnimationLoop defines the callback to call when an animation loops
  14773. * @returns the list of created animatables
  14774. */
  14775. 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[];
  14776. /**
  14777. * Begin a new animation on a given node
  14778. * @param target defines the target where the animation will take place
  14779. * @param animations defines the list of animations to start
  14780. * @param from defines the initial value
  14781. * @param to defines the final value
  14782. * @param loop defines if you want animation to loop (off by default)
  14783. * @param speedRatio defines the speed ratio to apply to all animations
  14784. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14785. * @param onAnimationLoop defines the callback to call when an animation loops
  14786. * @returns the list of created animatables
  14787. */
  14788. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14789. /**
  14790. * Begin a new animation on a given node and its hierarchy
  14791. * @param target defines the root node where the animation will take place
  14792. * @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.
  14793. * @param animations defines the list of animations to start
  14794. * @param from defines the initial value
  14795. * @param to defines the final value
  14796. * @param loop defines if you want animation to loop (off by default)
  14797. * @param speedRatio defines the speed ratio to apply to all animations
  14798. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14799. * @param onAnimationLoop defines the callback to call when an animation loops
  14800. * @returns the list of animatables created for all nodes
  14801. */
  14802. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14803. /**
  14804. * Gets the animatable associated with a specific target
  14805. * @param target defines the target of the animatable
  14806. * @returns the required animatable if found
  14807. */
  14808. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14809. /**
  14810. * Gets all animatables associated with a given target
  14811. * @param target defines the target to look animatables for
  14812. * @returns an array of Animatables
  14813. */
  14814. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14815. /**
  14816. * Stops and removes all animations that have been applied to the scene
  14817. */
  14818. stopAllAnimations(): void;
  14819. /**
  14820. * Gets the current delta time used by animation engine
  14821. */
  14822. deltaTime: number;
  14823. }
  14824. interface Bone {
  14825. /**
  14826. * Copy an animation range from another bone
  14827. * @param source defines the source bone
  14828. * @param rangeName defines the range name to copy
  14829. * @param frameOffset defines the frame offset
  14830. * @param rescaleAsRequired defines if rescaling must be applied if required
  14831. * @param skelDimensionsRatio defines the scaling ratio
  14832. * @returns true if operation was successful
  14833. */
  14834. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14835. }
  14836. }
  14837. declare module BABYLON {
  14838. /**
  14839. * Class used to handle skinning animations
  14840. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14841. */
  14842. export class Skeleton implements IAnimatable {
  14843. /** defines the skeleton name */
  14844. name: string;
  14845. /** defines the skeleton Id */
  14846. id: string;
  14847. /**
  14848. * Defines the list of child bones
  14849. */
  14850. bones: Bone[];
  14851. /**
  14852. * Defines an estimate of the dimension of the skeleton at rest
  14853. */
  14854. dimensionsAtRest: Vector3;
  14855. /**
  14856. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14857. */
  14858. needInitialSkinMatrix: boolean;
  14859. /**
  14860. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14861. */
  14862. overrideMesh: Nullable<AbstractMesh>;
  14863. /**
  14864. * Gets the list of animations attached to this skeleton
  14865. */
  14866. animations: Array<Animation>;
  14867. private _scene;
  14868. private _isDirty;
  14869. private _transformMatrices;
  14870. private _transformMatrixTexture;
  14871. private _meshesWithPoseMatrix;
  14872. private _animatables;
  14873. private _identity;
  14874. private _synchronizedWithMesh;
  14875. private _ranges;
  14876. private _lastAbsoluteTransformsUpdateId;
  14877. private _canUseTextureForBones;
  14878. private _uniqueId;
  14879. /** @hidden */
  14880. _numBonesWithLinkedTransformNode: number;
  14881. /** @hidden */
  14882. _hasWaitingData: Nullable<boolean>;
  14883. /**
  14884. * Specifies if the skeleton should be serialized
  14885. */
  14886. doNotSerialize: boolean;
  14887. private _useTextureToStoreBoneMatrices;
  14888. /**
  14889. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14890. * Please note that this option is not available if the hardware does not support it
  14891. */
  14892. get useTextureToStoreBoneMatrices(): boolean;
  14893. set useTextureToStoreBoneMatrices(value: boolean);
  14894. private _animationPropertiesOverride;
  14895. /**
  14896. * Gets or sets the animation properties override
  14897. */
  14898. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14899. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14900. /**
  14901. * List of inspectable custom properties (used by the Inspector)
  14902. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14903. */
  14904. inspectableCustomProperties: IInspectable[];
  14905. /**
  14906. * An observable triggered before computing the skeleton's matrices
  14907. */
  14908. onBeforeComputeObservable: Observable<Skeleton>;
  14909. /**
  14910. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14911. */
  14912. get isUsingTextureForMatrices(): boolean;
  14913. /**
  14914. * Gets the unique ID of this skeleton
  14915. */
  14916. get uniqueId(): number;
  14917. /**
  14918. * Creates a new skeleton
  14919. * @param name defines the skeleton name
  14920. * @param id defines the skeleton Id
  14921. * @param scene defines the hosting scene
  14922. */
  14923. constructor(
  14924. /** defines the skeleton name */
  14925. name: string,
  14926. /** defines the skeleton Id */
  14927. id: string, scene: Scene);
  14928. /**
  14929. * Gets the current object class name.
  14930. * @return the class name
  14931. */
  14932. getClassName(): string;
  14933. /**
  14934. * Returns an array containing the root bones
  14935. * @returns an array containing the root bones
  14936. */
  14937. getChildren(): Array<Bone>;
  14938. /**
  14939. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14940. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14941. * @returns a Float32Array containing matrices data
  14942. */
  14943. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14944. /**
  14945. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14946. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14947. * @returns a raw texture containing the data
  14948. */
  14949. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14950. /**
  14951. * Gets the current hosting scene
  14952. * @returns a scene object
  14953. */
  14954. getScene(): Scene;
  14955. /**
  14956. * Gets a string representing the current skeleton data
  14957. * @param fullDetails defines a boolean indicating if we want a verbose version
  14958. * @returns a string representing the current skeleton data
  14959. */
  14960. toString(fullDetails?: boolean): string;
  14961. /**
  14962. * Get bone's index searching by name
  14963. * @param name defines bone's name to search for
  14964. * @return the indice of the bone. Returns -1 if not found
  14965. */
  14966. getBoneIndexByName(name: string): number;
  14967. /**
  14968. * Creater a new animation range
  14969. * @param name defines the name of the range
  14970. * @param from defines the start key
  14971. * @param to defines the end key
  14972. */
  14973. createAnimationRange(name: string, from: number, to: number): void;
  14974. /**
  14975. * Delete a specific animation range
  14976. * @param name defines the name of the range
  14977. * @param deleteFrames defines if frames must be removed as well
  14978. */
  14979. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14980. /**
  14981. * Gets a specific animation range
  14982. * @param name defines the name of the range to look for
  14983. * @returns the requested animation range or null if not found
  14984. */
  14985. getAnimationRange(name: string): Nullable<AnimationRange>;
  14986. /**
  14987. * Gets the list of all animation ranges defined on this skeleton
  14988. * @returns an array
  14989. */
  14990. getAnimationRanges(): Nullable<AnimationRange>[];
  14991. /**
  14992. * Copy animation range from a source skeleton.
  14993. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14994. * @param source defines the source skeleton
  14995. * @param name defines the name of the range to copy
  14996. * @param rescaleAsRequired defines if rescaling must be applied if required
  14997. * @returns true if operation was successful
  14998. */
  14999. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15000. /**
  15001. * Forces the skeleton to go to rest pose
  15002. */
  15003. returnToRest(): void;
  15004. private _getHighestAnimationFrame;
  15005. /**
  15006. * Begin a specific animation range
  15007. * @param name defines the name of the range to start
  15008. * @param loop defines if looping must be turned on (false by default)
  15009. * @param speedRatio defines the speed ratio to apply (1 by default)
  15010. * @param onAnimationEnd defines a callback which will be called when animation will end
  15011. * @returns a new animatable
  15012. */
  15013. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15014. /** @hidden */
  15015. _markAsDirty(): void;
  15016. /** @hidden */
  15017. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15018. /** @hidden */
  15019. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15020. private _computeTransformMatrices;
  15021. /**
  15022. * Build all resources required to render a skeleton
  15023. */
  15024. prepare(): void;
  15025. /**
  15026. * Gets the list of animatables currently running for this skeleton
  15027. * @returns an array of animatables
  15028. */
  15029. getAnimatables(): IAnimatable[];
  15030. /**
  15031. * Clone the current skeleton
  15032. * @param name defines the name of the new skeleton
  15033. * @param id defines the id of the new skeleton
  15034. * @returns the new skeleton
  15035. */
  15036. clone(name: string, id?: string): Skeleton;
  15037. /**
  15038. * Enable animation blending for this skeleton
  15039. * @param blendingSpeed defines the blending speed to apply
  15040. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15041. */
  15042. enableBlending(blendingSpeed?: number): void;
  15043. /**
  15044. * Releases all resources associated with the current skeleton
  15045. */
  15046. dispose(): void;
  15047. /**
  15048. * Serialize the skeleton in a JSON object
  15049. * @returns a JSON object
  15050. */
  15051. serialize(): any;
  15052. /**
  15053. * Creates a new skeleton from serialized data
  15054. * @param parsedSkeleton defines the serialized data
  15055. * @param scene defines the hosting scene
  15056. * @returns a new skeleton
  15057. */
  15058. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15059. /**
  15060. * Compute all node absolute transforms
  15061. * @param forceUpdate defines if computation must be done even if cache is up to date
  15062. */
  15063. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15064. /**
  15065. * Gets the root pose matrix
  15066. * @returns a matrix
  15067. */
  15068. getPoseMatrix(): Nullable<Matrix>;
  15069. /**
  15070. * Sorts bones per internal index
  15071. */
  15072. sortBones(): void;
  15073. private _sortBones;
  15074. }
  15075. }
  15076. declare module BABYLON {
  15077. /**
  15078. * Creates an instance based on a source mesh.
  15079. */
  15080. export class InstancedMesh extends AbstractMesh {
  15081. private _sourceMesh;
  15082. private _currentLOD;
  15083. /** @hidden */
  15084. _indexInSourceMeshInstanceArray: number;
  15085. constructor(name: string, source: Mesh);
  15086. /**
  15087. * Returns the string "InstancedMesh".
  15088. */
  15089. getClassName(): string;
  15090. /** Gets the list of lights affecting that mesh */
  15091. get lightSources(): Light[];
  15092. _resyncLightSources(): void;
  15093. _resyncLightSource(light: Light): void;
  15094. _removeLightSource(light: Light, dispose: boolean): void;
  15095. /**
  15096. * If the source mesh receives shadows
  15097. */
  15098. get receiveShadows(): boolean;
  15099. /**
  15100. * The material of the source mesh
  15101. */
  15102. get material(): Nullable<Material>;
  15103. /**
  15104. * Visibility of the source mesh
  15105. */
  15106. get visibility(): number;
  15107. /**
  15108. * Skeleton of the source mesh
  15109. */
  15110. get skeleton(): Nullable<Skeleton>;
  15111. /**
  15112. * Rendering ground id of the source mesh
  15113. */
  15114. get renderingGroupId(): number;
  15115. set renderingGroupId(value: number);
  15116. /**
  15117. * Returns the total number of vertices (integer).
  15118. */
  15119. getTotalVertices(): number;
  15120. /**
  15121. * Returns a positive integer : the total number of indices in this mesh geometry.
  15122. * @returns the numner of indices or zero if the mesh has no geometry.
  15123. */
  15124. getTotalIndices(): number;
  15125. /**
  15126. * The source mesh of the instance
  15127. */
  15128. get sourceMesh(): Mesh;
  15129. /**
  15130. * Is this node ready to be used/rendered
  15131. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15132. * @return {boolean} is it ready
  15133. */
  15134. isReady(completeCheck?: boolean): boolean;
  15135. /**
  15136. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15137. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15138. * @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.
  15139. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15140. */
  15141. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15142. /**
  15143. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15144. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15145. * The `data` are either a numeric array either a Float32Array.
  15146. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15147. * 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).
  15148. * Note that a new underlying VertexBuffer object is created each call.
  15149. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15150. *
  15151. * Possible `kind` values :
  15152. * - VertexBuffer.PositionKind
  15153. * - VertexBuffer.UVKind
  15154. * - VertexBuffer.UV2Kind
  15155. * - VertexBuffer.UV3Kind
  15156. * - VertexBuffer.UV4Kind
  15157. * - VertexBuffer.UV5Kind
  15158. * - VertexBuffer.UV6Kind
  15159. * - VertexBuffer.ColorKind
  15160. * - VertexBuffer.MatricesIndicesKind
  15161. * - VertexBuffer.MatricesIndicesExtraKind
  15162. * - VertexBuffer.MatricesWeightsKind
  15163. * - VertexBuffer.MatricesWeightsExtraKind
  15164. *
  15165. * Returns the Mesh.
  15166. */
  15167. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15168. /**
  15169. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15170. * If the mesh has no geometry, it is simply returned as it is.
  15171. * The `data` are either a numeric array either a Float32Array.
  15172. * No new underlying VertexBuffer object is created.
  15173. * 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.
  15174. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15175. *
  15176. * Possible `kind` values :
  15177. * - VertexBuffer.PositionKind
  15178. * - VertexBuffer.UVKind
  15179. * - VertexBuffer.UV2Kind
  15180. * - VertexBuffer.UV3Kind
  15181. * - VertexBuffer.UV4Kind
  15182. * - VertexBuffer.UV5Kind
  15183. * - VertexBuffer.UV6Kind
  15184. * - VertexBuffer.ColorKind
  15185. * - VertexBuffer.MatricesIndicesKind
  15186. * - VertexBuffer.MatricesIndicesExtraKind
  15187. * - VertexBuffer.MatricesWeightsKind
  15188. * - VertexBuffer.MatricesWeightsExtraKind
  15189. *
  15190. * Returns the Mesh.
  15191. */
  15192. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15193. /**
  15194. * Sets the mesh indices.
  15195. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15196. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15197. * This method creates a new index buffer each call.
  15198. * Returns the Mesh.
  15199. */
  15200. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15201. /**
  15202. * Boolean : True if the mesh owns the requested kind of data.
  15203. */
  15204. isVerticesDataPresent(kind: string): boolean;
  15205. /**
  15206. * Returns an array of indices (IndicesArray).
  15207. */
  15208. getIndices(): Nullable<IndicesArray>;
  15209. get _positions(): Nullable<Vector3[]>;
  15210. /**
  15211. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15212. * This means the mesh underlying bounding box and sphere are recomputed.
  15213. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15214. * @returns the current mesh
  15215. */
  15216. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15217. /** @hidden */
  15218. _preActivate(): InstancedMesh;
  15219. /** @hidden */
  15220. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15221. /** @hidden */
  15222. _postActivate(): void;
  15223. getWorldMatrix(): Matrix;
  15224. get isAnInstance(): boolean;
  15225. /**
  15226. * Returns the current associated LOD AbstractMesh.
  15227. */
  15228. getLOD(camera: Camera): AbstractMesh;
  15229. /** @hidden */
  15230. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15231. /** @hidden */
  15232. _syncSubMeshes(): InstancedMesh;
  15233. /** @hidden */
  15234. _generatePointsArray(): boolean;
  15235. /**
  15236. * Creates a new InstancedMesh from the current mesh.
  15237. * - name (string) : the cloned mesh name
  15238. * - newParent (optional Node) : the optional Node to parent the clone to.
  15239. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15240. *
  15241. * Returns the clone.
  15242. */
  15243. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15244. /**
  15245. * Disposes the InstancedMesh.
  15246. * Returns nothing.
  15247. */
  15248. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15249. }
  15250. interface Mesh {
  15251. /**
  15252. * Register a custom buffer that will be instanced
  15253. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15254. * @param kind defines the buffer kind
  15255. * @param stride defines the stride in floats
  15256. */
  15257. registerInstancedBuffer(kind: string, stride: number): void;
  15258. /** @hidden */
  15259. _userInstancedBuffersStorage: {
  15260. data: {
  15261. [key: string]: Float32Array;
  15262. };
  15263. sizes: {
  15264. [key: string]: number;
  15265. };
  15266. vertexBuffers: {
  15267. [key: string]: Nullable<VertexBuffer>;
  15268. };
  15269. strides: {
  15270. [key: string]: number;
  15271. };
  15272. };
  15273. }
  15274. interface AbstractMesh {
  15275. /**
  15276. * Object used to store instanced buffers defined by user
  15277. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15278. */
  15279. instancedBuffers: {
  15280. [key: string]: any;
  15281. };
  15282. }
  15283. }
  15284. declare module BABYLON {
  15285. /**
  15286. * Defines the options associated with the creation of a shader material.
  15287. */
  15288. export interface IShaderMaterialOptions {
  15289. /**
  15290. * Does the material work in alpha blend mode
  15291. */
  15292. needAlphaBlending: boolean;
  15293. /**
  15294. * Does the material work in alpha test mode
  15295. */
  15296. needAlphaTesting: boolean;
  15297. /**
  15298. * The list of attribute names used in the shader
  15299. */
  15300. attributes: string[];
  15301. /**
  15302. * The list of unifrom names used in the shader
  15303. */
  15304. uniforms: string[];
  15305. /**
  15306. * The list of UBO names used in the shader
  15307. */
  15308. uniformBuffers: string[];
  15309. /**
  15310. * The list of sampler names used in the shader
  15311. */
  15312. samplers: string[];
  15313. /**
  15314. * The list of defines used in the shader
  15315. */
  15316. defines: string[];
  15317. }
  15318. /**
  15319. * 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.
  15320. *
  15321. * This returned material effects how the mesh will look based on the code in the shaders.
  15322. *
  15323. * @see http://doc.babylonjs.com/how_to/shader_material
  15324. */
  15325. export class ShaderMaterial extends Material {
  15326. private _shaderPath;
  15327. private _options;
  15328. private _textures;
  15329. private _textureArrays;
  15330. private _floats;
  15331. private _ints;
  15332. private _floatsArrays;
  15333. private _colors3;
  15334. private _colors3Arrays;
  15335. private _colors4;
  15336. private _colors4Arrays;
  15337. private _vectors2;
  15338. private _vectors3;
  15339. private _vectors4;
  15340. private _matrices;
  15341. private _matrixArrays;
  15342. private _matrices3x3;
  15343. private _matrices2x2;
  15344. private _vectors2Arrays;
  15345. private _vectors3Arrays;
  15346. private _vectors4Arrays;
  15347. private _cachedWorldViewMatrix;
  15348. private _cachedWorldViewProjectionMatrix;
  15349. private _renderId;
  15350. private _multiview;
  15351. /**
  15352. * Instantiate a new shader material.
  15353. * 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.
  15354. * This returned material effects how the mesh will look based on the code in the shaders.
  15355. * @see http://doc.babylonjs.com/how_to/shader_material
  15356. * @param name Define the name of the material in the scene
  15357. * @param scene Define the scene the material belongs to
  15358. * @param shaderPath Defines the route to the shader code in one of three ways:
  15359. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15360. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15361. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15362. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15363. * @param options Define the options used to create the shader
  15364. */
  15365. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15366. /**
  15367. * Gets the shader path used to define the shader code
  15368. * It can be modified to trigger a new compilation
  15369. */
  15370. get shaderPath(): any;
  15371. /**
  15372. * Sets the shader path used to define the shader code
  15373. * It can be modified to trigger a new compilation
  15374. */
  15375. set shaderPath(shaderPath: any);
  15376. /**
  15377. * Gets the options used to compile the shader.
  15378. * They can be modified to trigger a new compilation
  15379. */
  15380. get options(): IShaderMaterialOptions;
  15381. /**
  15382. * Gets the current class name of the material e.g. "ShaderMaterial"
  15383. * Mainly use in serialization.
  15384. * @returns the class name
  15385. */
  15386. getClassName(): string;
  15387. /**
  15388. * Specifies if the material will require alpha blending
  15389. * @returns a boolean specifying if alpha blending is needed
  15390. */
  15391. needAlphaBlending(): boolean;
  15392. /**
  15393. * Specifies if this material should be rendered in alpha test mode
  15394. * @returns a boolean specifying if an alpha test is needed.
  15395. */
  15396. needAlphaTesting(): boolean;
  15397. private _checkUniform;
  15398. /**
  15399. * Set a texture in the shader.
  15400. * @param name Define the name of the uniform samplers as defined in the shader
  15401. * @param texture Define the texture to bind to this sampler
  15402. * @return the material itself allowing "fluent" like uniform updates
  15403. */
  15404. setTexture(name: string, texture: Texture): ShaderMaterial;
  15405. /**
  15406. * Set a texture array in the shader.
  15407. * @param name Define the name of the uniform sampler array as defined in the shader
  15408. * @param textures Define the list of textures to bind to this sampler
  15409. * @return the material itself allowing "fluent" like uniform updates
  15410. */
  15411. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15412. /**
  15413. * Set a float in the shader.
  15414. * @param name Define the name of the uniform as defined in the shader
  15415. * @param value Define the value to give to the uniform
  15416. * @return the material itself allowing "fluent" like uniform updates
  15417. */
  15418. setFloat(name: string, value: number): ShaderMaterial;
  15419. /**
  15420. * Set a int in the shader.
  15421. * @param name Define the name of the uniform as defined in the shader
  15422. * @param value Define the value to give to the uniform
  15423. * @return the material itself allowing "fluent" like uniform updates
  15424. */
  15425. setInt(name: string, value: number): ShaderMaterial;
  15426. /**
  15427. * Set an array of floats in the shader.
  15428. * @param name Define the name of the uniform as defined in the shader
  15429. * @param value Define the value to give to the uniform
  15430. * @return the material itself allowing "fluent" like uniform updates
  15431. */
  15432. setFloats(name: string, value: number[]): ShaderMaterial;
  15433. /**
  15434. * Set a vec3 in the shader from a Color3.
  15435. * @param name Define the name of the uniform as defined in the shader
  15436. * @param value Define the value to give to the uniform
  15437. * @return the material itself allowing "fluent" like uniform updates
  15438. */
  15439. setColor3(name: string, value: Color3): ShaderMaterial;
  15440. /**
  15441. * Set a vec3 array in the shader from a Color3 array.
  15442. * @param name Define the name of the uniform as defined in the shader
  15443. * @param value Define the value to give to the uniform
  15444. * @return the material itself allowing "fluent" like uniform updates
  15445. */
  15446. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15447. /**
  15448. * Set a vec4 in the shader from a Color4.
  15449. * @param name Define the name of the uniform as defined in the shader
  15450. * @param value Define the value to give to the uniform
  15451. * @return the material itself allowing "fluent" like uniform updates
  15452. */
  15453. setColor4(name: string, value: Color4): ShaderMaterial;
  15454. /**
  15455. * Set a vec4 array in the shader from a Color4 array.
  15456. * @param name Define the name of the uniform as defined in the shader
  15457. * @param value Define the value to give to the uniform
  15458. * @return the material itself allowing "fluent" like uniform updates
  15459. */
  15460. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15461. /**
  15462. * Set a vec2 in the shader from a Vector2.
  15463. * @param name Define the name of the uniform as defined in the shader
  15464. * @param value Define the value to give to the uniform
  15465. * @return the material itself allowing "fluent" like uniform updates
  15466. */
  15467. setVector2(name: string, value: Vector2): ShaderMaterial;
  15468. /**
  15469. * Set a vec3 in the shader from a Vector3.
  15470. * @param name Define the name of the uniform as defined in the shader
  15471. * @param value Define the value to give to the uniform
  15472. * @return the material itself allowing "fluent" like uniform updates
  15473. */
  15474. setVector3(name: string, value: Vector3): ShaderMaterial;
  15475. /**
  15476. * Set a vec4 in the shader from a Vector4.
  15477. * @param name Define the name of the uniform as defined in the shader
  15478. * @param value Define the value to give to the uniform
  15479. * @return the material itself allowing "fluent" like uniform updates
  15480. */
  15481. setVector4(name: string, value: Vector4): ShaderMaterial;
  15482. /**
  15483. * Set a mat4 in the shader from a Matrix.
  15484. * @param name Define the name of the uniform as defined in the shader
  15485. * @param value Define the value to give to the uniform
  15486. * @return the material itself allowing "fluent" like uniform updates
  15487. */
  15488. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15489. /**
  15490. * Set a float32Array in the shader from a matrix array.
  15491. * @param name Define the name of the uniform as defined in the shader
  15492. * @param value Define the value to give to the uniform
  15493. * @return the material itself allowing "fluent" like uniform updates
  15494. */
  15495. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15496. /**
  15497. * Set a mat3 in the shader from a Float32Array.
  15498. * @param name Define the name of the uniform as defined in the shader
  15499. * @param value Define the value to give to the uniform
  15500. * @return the material itself allowing "fluent" like uniform updates
  15501. */
  15502. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15503. /**
  15504. * Set a mat2 in the shader from a Float32Array.
  15505. * @param name Define the name of the uniform as defined in the shader
  15506. * @param value Define the value to give to the uniform
  15507. * @return the material itself allowing "fluent" like uniform updates
  15508. */
  15509. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15510. /**
  15511. * Set a vec2 array in the shader from a number array.
  15512. * @param name Define the name of the uniform as defined in the shader
  15513. * @param value Define the value to give to the uniform
  15514. * @return the material itself allowing "fluent" like uniform updates
  15515. */
  15516. setArray2(name: string, value: number[]): ShaderMaterial;
  15517. /**
  15518. * Set a vec3 array in the shader from a number array.
  15519. * @param name Define the name of the uniform as defined in the shader
  15520. * @param value Define the value to give to the uniform
  15521. * @return the material itself allowing "fluent" like uniform updates
  15522. */
  15523. setArray3(name: string, value: number[]): ShaderMaterial;
  15524. /**
  15525. * Set a vec4 array in the shader from a number array.
  15526. * @param name Define the name of the uniform as defined in the shader
  15527. * @param value Define the value to give to the uniform
  15528. * @return the material itself allowing "fluent" like uniform updates
  15529. */
  15530. setArray4(name: string, value: number[]): ShaderMaterial;
  15531. private _checkCache;
  15532. /**
  15533. * Specifies that the submesh is ready to be used
  15534. * @param mesh defines the mesh to check
  15535. * @param subMesh defines which submesh to check
  15536. * @param useInstances specifies that instances should be used
  15537. * @returns a boolean indicating that the submesh is ready or not
  15538. */
  15539. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15540. /**
  15541. * Checks if the material is ready to render the requested mesh
  15542. * @param mesh Define the mesh to render
  15543. * @param useInstances Define whether or not the material is used with instances
  15544. * @returns true if ready, otherwise false
  15545. */
  15546. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15547. /**
  15548. * Binds the world matrix to the material
  15549. * @param world defines the world transformation matrix
  15550. */
  15551. bindOnlyWorldMatrix(world: Matrix): void;
  15552. /**
  15553. * Binds the material to the mesh
  15554. * @param world defines the world transformation matrix
  15555. * @param mesh defines the mesh to bind the material to
  15556. */
  15557. bind(world: Matrix, mesh?: Mesh): void;
  15558. /**
  15559. * Gets the active textures from the material
  15560. * @returns an array of textures
  15561. */
  15562. getActiveTextures(): BaseTexture[];
  15563. /**
  15564. * Specifies if the material uses a texture
  15565. * @param texture defines the texture to check against the material
  15566. * @returns a boolean specifying if the material uses the texture
  15567. */
  15568. hasTexture(texture: BaseTexture): boolean;
  15569. /**
  15570. * Makes a duplicate of the material, and gives it a new name
  15571. * @param name defines the new name for the duplicated material
  15572. * @returns the cloned material
  15573. */
  15574. clone(name: string): ShaderMaterial;
  15575. /**
  15576. * Disposes the material
  15577. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15578. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15579. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15580. */
  15581. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15582. /**
  15583. * Serializes this material in a JSON representation
  15584. * @returns the serialized material object
  15585. */
  15586. serialize(): any;
  15587. /**
  15588. * Creates a shader material from parsed shader material data
  15589. * @param source defines the JSON represnetation of the material
  15590. * @param scene defines the hosting scene
  15591. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15592. * @returns a new material
  15593. */
  15594. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15595. }
  15596. }
  15597. declare module BABYLON {
  15598. /** @hidden */
  15599. export var colorPixelShader: {
  15600. name: string;
  15601. shader: string;
  15602. };
  15603. }
  15604. declare module BABYLON {
  15605. /** @hidden */
  15606. export var colorVertexShader: {
  15607. name: string;
  15608. shader: string;
  15609. };
  15610. }
  15611. declare module BABYLON {
  15612. /**
  15613. * Line mesh
  15614. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15615. */
  15616. export class LinesMesh extends Mesh {
  15617. /**
  15618. * If vertex color should be applied to the mesh
  15619. */
  15620. readonly useVertexColor?: boolean | undefined;
  15621. /**
  15622. * If vertex alpha should be applied to the mesh
  15623. */
  15624. readonly useVertexAlpha?: boolean | undefined;
  15625. /**
  15626. * Color of the line (Default: White)
  15627. */
  15628. color: Color3;
  15629. /**
  15630. * Alpha of the line (Default: 1)
  15631. */
  15632. alpha: number;
  15633. /**
  15634. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15635. * This margin is expressed in world space coordinates, so its value may vary.
  15636. * Default value is 0.1
  15637. */
  15638. intersectionThreshold: number;
  15639. private _colorShader;
  15640. private color4;
  15641. /**
  15642. * Creates a new LinesMesh
  15643. * @param name defines the name
  15644. * @param scene defines the hosting scene
  15645. * @param parent defines the parent mesh if any
  15646. * @param source defines the optional source LinesMesh used to clone data from
  15647. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15648. * When false, achieved by calling a clone(), also passing False.
  15649. * This will make creation of children, recursive.
  15650. * @param useVertexColor defines if this LinesMesh supports vertex color
  15651. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15652. */
  15653. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15654. /**
  15655. * If vertex color should be applied to the mesh
  15656. */
  15657. useVertexColor?: boolean | undefined,
  15658. /**
  15659. * If vertex alpha should be applied to the mesh
  15660. */
  15661. useVertexAlpha?: boolean | undefined);
  15662. private _addClipPlaneDefine;
  15663. private _removeClipPlaneDefine;
  15664. isReady(): boolean;
  15665. /**
  15666. * Returns the string "LineMesh"
  15667. */
  15668. getClassName(): string;
  15669. /**
  15670. * @hidden
  15671. */
  15672. get material(): Material;
  15673. /**
  15674. * @hidden
  15675. */
  15676. set material(value: Material);
  15677. /**
  15678. * @hidden
  15679. */
  15680. get checkCollisions(): boolean;
  15681. /** @hidden */
  15682. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15683. /** @hidden */
  15684. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15685. /**
  15686. * Disposes of the line mesh
  15687. * @param doNotRecurse If children should be disposed
  15688. */
  15689. dispose(doNotRecurse?: boolean): void;
  15690. /**
  15691. * Returns a new LineMesh object cloned from the current one.
  15692. */
  15693. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15694. /**
  15695. * Creates a new InstancedLinesMesh object from the mesh model.
  15696. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15697. * @param name defines the name of the new instance
  15698. * @returns a new InstancedLinesMesh
  15699. */
  15700. createInstance(name: string): InstancedLinesMesh;
  15701. }
  15702. /**
  15703. * Creates an instance based on a source LinesMesh
  15704. */
  15705. export class InstancedLinesMesh extends InstancedMesh {
  15706. /**
  15707. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15708. * This margin is expressed in world space coordinates, so its value may vary.
  15709. * Initilized with the intersectionThreshold value of the source LinesMesh
  15710. */
  15711. intersectionThreshold: number;
  15712. constructor(name: string, source: LinesMesh);
  15713. /**
  15714. * Returns the string "InstancedLinesMesh".
  15715. */
  15716. getClassName(): string;
  15717. }
  15718. }
  15719. declare module BABYLON {
  15720. /** @hidden */
  15721. export var linePixelShader: {
  15722. name: string;
  15723. shader: string;
  15724. };
  15725. }
  15726. declare module BABYLON {
  15727. /** @hidden */
  15728. export var lineVertexShader: {
  15729. name: string;
  15730. shader: string;
  15731. };
  15732. }
  15733. declare module BABYLON {
  15734. interface AbstractMesh {
  15735. /**
  15736. * Gets the edgesRenderer associated with the mesh
  15737. */
  15738. edgesRenderer: Nullable<EdgesRenderer>;
  15739. }
  15740. interface LinesMesh {
  15741. /**
  15742. * Enables the edge rendering mode on the mesh.
  15743. * This mode makes the mesh edges visible
  15744. * @param epsilon defines the maximal distance between two angles to detect a face
  15745. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15746. * @returns the currentAbstractMesh
  15747. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15748. */
  15749. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15750. }
  15751. interface InstancedLinesMesh {
  15752. /**
  15753. * Enables the edge rendering mode on the mesh.
  15754. * This mode makes the mesh edges visible
  15755. * @param epsilon defines the maximal distance between two angles to detect a face
  15756. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15757. * @returns the current InstancedLinesMesh
  15758. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15759. */
  15760. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15761. }
  15762. /**
  15763. * Defines the minimum contract an Edges renderer should follow.
  15764. */
  15765. export interface IEdgesRenderer extends IDisposable {
  15766. /**
  15767. * Gets or sets a boolean indicating if the edgesRenderer is active
  15768. */
  15769. isEnabled: boolean;
  15770. /**
  15771. * Renders the edges of the attached mesh,
  15772. */
  15773. render(): void;
  15774. /**
  15775. * Checks wether or not the edges renderer is ready to render.
  15776. * @return true if ready, otherwise false.
  15777. */
  15778. isReady(): boolean;
  15779. }
  15780. /**
  15781. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15782. */
  15783. export class EdgesRenderer implements IEdgesRenderer {
  15784. /**
  15785. * Define the size of the edges with an orthographic camera
  15786. */
  15787. edgesWidthScalerForOrthographic: number;
  15788. /**
  15789. * Define the size of the edges with a perspective camera
  15790. */
  15791. edgesWidthScalerForPerspective: number;
  15792. protected _source: AbstractMesh;
  15793. protected _linesPositions: number[];
  15794. protected _linesNormals: number[];
  15795. protected _linesIndices: number[];
  15796. protected _epsilon: number;
  15797. protected _indicesCount: number;
  15798. protected _lineShader: ShaderMaterial;
  15799. protected _ib: DataBuffer;
  15800. protected _buffers: {
  15801. [key: string]: Nullable<VertexBuffer>;
  15802. };
  15803. protected _checkVerticesInsteadOfIndices: boolean;
  15804. private _meshRebuildObserver;
  15805. private _meshDisposeObserver;
  15806. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15807. isEnabled: boolean;
  15808. /**
  15809. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15810. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15811. * @param source Mesh used to create edges
  15812. * @param epsilon sum of angles in adjacency to check for edge
  15813. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15814. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15815. */
  15816. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15817. protected _prepareRessources(): void;
  15818. /** @hidden */
  15819. _rebuild(): void;
  15820. /**
  15821. * Releases the required resources for the edges renderer
  15822. */
  15823. dispose(): void;
  15824. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15825. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15826. /**
  15827. * Checks if the pair of p0 and p1 is en edge
  15828. * @param faceIndex
  15829. * @param edge
  15830. * @param faceNormals
  15831. * @param p0
  15832. * @param p1
  15833. * @private
  15834. */
  15835. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15836. /**
  15837. * push line into the position, normal and index buffer
  15838. * @protected
  15839. */
  15840. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15841. /**
  15842. * Generates lines edges from adjacencjes
  15843. * @private
  15844. */
  15845. _generateEdgesLines(): void;
  15846. /**
  15847. * Checks wether or not the edges renderer is ready to render.
  15848. * @return true if ready, otherwise false.
  15849. */
  15850. isReady(): boolean;
  15851. /**
  15852. * Renders the edges of the attached mesh,
  15853. */
  15854. render(): void;
  15855. }
  15856. /**
  15857. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15858. */
  15859. export class LineEdgesRenderer extends EdgesRenderer {
  15860. /**
  15861. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15862. * @param source LineMesh used to generate edges
  15863. * @param epsilon not important (specified angle for edge detection)
  15864. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15865. */
  15866. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15867. /**
  15868. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15869. */
  15870. _generateEdgesLines(): void;
  15871. }
  15872. }
  15873. declare module BABYLON {
  15874. /**
  15875. * This represents the object necessary to create a rendering group.
  15876. * This is exclusively used and created by the rendering manager.
  15877. * To modify the behavior, you use the available helpers in your scene or meshes.
  15878. * @hidden
  15879. */
  15880. export class RenderingGroup {
  15881. index: number;
  15882. private static _zeroVector;
  15883. private _scene;
  15884. private _opaqueSubMeshes;
  15885. private _transparentSubMeshes;
  15886. private _alphaTestSubMeshes;
  15887. private _depthOnlySubMeshes;
  15888. private _particleSystems;
  15889. private _spriteManagers;
  15890. private _opaqueSortCompareFn;
  15891. private _alphaTestSortCompareFn;
  15892. private _transparentSortCompareFn;
  15893. private _renderOpaque;
  15894. private _renderAlphaTest;
  15895. private _renderTransparent;
  15896. /** @hidden */
  15897. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15898. onBeforeTransparentRendering: () => void;
  15899. /**
  15900. * Set the opaque sort comparison function.
  15901. * If null the sub meshes will be render in the order they were created
  15902. */
  15903. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15904. /**
  15905. * Set the alpha test sort comparison function.
  15906. * If null the sub meshes will be render in the order they were created
  15907. */
  15908. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15909. /**
  15910. * Set the transparent sort comparison function.
  15911. * If null the sub meshes will be render in the order they were created
  15912. */
  15913. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15914. /**
  15915. * Creates a new rendering group.
  15916. * @param index The rendering group index
  15917. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15918. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15919. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15920. */
  15921. 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>);
  15922. /**
  15923. * Render all the sub meshes contained in the group.
  15924. * @param customRenderFunction Used to override the default render behaviour of the group.
  15925. * @returns true if rendered some submeshes.
  15926. */
  15927. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15928. /**
  15929. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15930. * @param subMeshes The submeshes to render
  15931. */
  15932. private renderOpaqueSorted;
  15933. /**
  15934. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15935. * @param subMeshes The submeshes to render
  15936. */
  15937. private renderAlphaTestSorted;
  15938. /**
  15939. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15940. * @param subMeshes The submeshes to render
  15941. */
  15942. private renderTransparentSorted;
  15943. /**
  15944. * Renders the submeshes in a specified order.
  15945. * @param subMeshes The submeshes to sort before render
  15946. * @param sortCompareFn The comparison function use to sort
  15947. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15948. * @param transparent Specifies to activate blending if true
  15949. */
  15950. private static renderSorted;
  15951. /**
  15952. * Renders the submeshes in the order they were dispatched (no sort applied).
  15953. * @param subMeshes The submeshes to render
  15954. */
  15955. private static renderUnsorted;
  15956. /**
  15957. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15958. * are rendered back to front if in the same alpha index.
  15959. *
  15960. * @param a The first submesh
  15961. * @param b The second submesh
  15962. * @returns The result of the comparison
  15963. */
  15964. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15965. /**
  15966. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15967. * are rendered back to front.
  15968. *
  15969. * @param a The first submesh
  15970. * @param b The second submesh
  15971. * @returns The result of the comparison
  15972. */
  15973. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15974. /**
  15975. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15976. * are rendered front to back (prevent overdraw).
  15977. *
  15978. * @param a The first submesh
  15979. * @param b The second submesh
  15980. * @returns The result of the comparison
  15981. */
  15982. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15983. /**
  15984. * Resets the different lists of submeshes to prepare a new frame.
  15985. */
  15986. prepare(): void;
  15987. dispose(): void;
  15988. /**
  15989. * Inserts the submesh in its correct queue depending on its material.
  15990. * @param subMesh The submesh to dispatch
  15991. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15992. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15993. */
  15994. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15995. dispatchSprites(spriteManager: ISpriteManager): void;
  15996. dispatchParticles(particleSystem: IParticleSystem): void;
  15997. private _renderParticles;
  15998. private _renderSprites;
  15999. }
  16000. }
  16001. declare module BABYLON {
  16002. /**
  16003. * Interface describing the different options available in the rendering manager
  16004. * regarding Auto Clear between groups.
  16005. */
  16006. export interface IRenderingManagerAutoClearSetup {
  16007. /**
  16008. * Defines whether or not autoclear is enable.
  16009. */
  16010. autoClear: boolean;
  16011. /**
  16012. * Defines whether or not to autoclear the depth buffer.
  16013. */
  16014. depth: boolean;
  16015. /**
  16016. * Defines whether or not to autoclear the stencil buffer.
  16017. */
  16018. stencil: boolean;
  16019. }
  16020. /**
  16021. * This class is used by the onRenderingGroupObservable
  16022. */
  16023. export class RenderingGroupInfo {
  16024. /**
  16025. * The Scene that being rendered
  16026. */
  16027. scene: Scene;
  16028. /**
  16029. * The camera currently used for the rendering pass
  16030. */
  16031. camera: Nullable<Camera>;
  16032. /**
  16033. * The ID of the renderingGroup being processed
  16034. */
  16035. renderingGroupId: number;
  16036. }
  16037. /**
  16038. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16039. * It is enable to manage the different groups as well as the different necessary sort functions.
  16040. * This should not be used directly aside of the few static configurations
  16041. */
  16042. export class RenderingManager {
  16043. /**
  16044. * The max id used for rendering groups (not included)
  16045. */
  16046. static MAX_RENDERINGGROUPS: number;
  16047. /**
  16048. * The min id used for rendering groups (included)
  16049. */
  16050. static MIN_RENDERINGGROUPS: number;
  16051. /**
  16052. * Used to globally prevent autoclearing scenes.
  16053. */
  16054. static AUTOCLEAR: boolean;
  16055. /**
  16056. * @hidden
  16057. */
  16058. _useSceneAutoClearSetup: boolean;
  16059. private _scene;
  16060. private _renderingGroups;
  16061. private _depthStencilBufferAlreadyCleaned;
  16062. private _autoClearDepthStencil;
  16063. private _customOpaqueSortCompareFn;
  16064. private _customAlphaTestSortCompareFn;
  16065. private _customTransparentSortCompareFn;
  16066. private _renderingGroupInfo;
  16067. /**
  16068. * Instantiates a new rendering group for a particular scene
  16069. * @param scene Defines the scene the groups belongs to
  16070. */
  16071. constructor(scene: Scene);
  16072. private _clearDepthStencilBuffer;
  16073. /**
  16074. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16075. * @hidden
  16076. */
  16077. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16078. /**
  16079. * Resets the different information of the group to prepare a new frame
  16080. * @hidden
  16081. */
  16082. reset(): void;
  16083. /**
  16084. * Dispose and release the group and its associated resources.
  16085. * @hidden
  16086. */
  16087. dispose(): void;
  16088. /**
  16089. * Clear the info related to rendering groups preventing retention points during dispose.
  16090. */
  16091. freeRenderingGroups(): void;
  16092. private _prepareRenderingGroup;
  16093. /**
  16094. * Add a sprite manager to the rendering manager in order to render it this frame.
  16095. * @param spriteManager Define the sprite manager to render
  16096. */
  16097. dispatchSprites(spriteManager: ISpriteManager): void;
  16098. /**
  16099. * Add a particle system to the rendering manager in order to render it this frame.
  16100. * @param particleSystem Define the particle system to render
  16101. */
  16102. dispatchParticles(particleSystem: IParticleSystem): void;
  16103. /**
  16104. * Add a submesh to the manager in order to render it this frame
  16105. * @param subMesh The submesh to dispatch
  16106. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16107. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16108. */
  16109. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16110. /**
  16111. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16112. * This allowed control for front to back rendering or reversly depending of the special needs.
  16113. *
  16114. * @param renderingGroupId The rendering group id corresponding to its index
  16115. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16116. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16117. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16118. */
  16119. 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;
  16120. /**
  16121. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16122. *
  16123. * @param renderingGroupId The rendering group id corresponding to its index
  16124. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16125. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16126. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16127. */
  16128. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16129. /**
  16130. * Gets the current auto clear configuration for one rendering group of the rendering
  16131. * manager.
  16132. * @param index the rendering group index to get the information for
  16133. * @returns The auto clear setup for the requested rendering group
  16134. */
  16135. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16136. }
  16137. }
  16138. declare module BABYLON {
  16139. /**
  16140. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16141. */
  16142. export interface ICustomShaderOptions {
  16143. /**
  16144. * Gets or sets the custom shader name to use
  16145. */
  16146. shaderName: string;
  16147. /**
  16148. * The list of attribute names used in the shader
  16149. */
  16150. attributes?: string[];
  16151. /**
  16152. * The list of unifrom names used in the shader
  16153. */
  16154. uniforms?: string[];
  16155. /**
  16156. * The list of sampler names used in the shader
  16157. */
  16158. samplers?: string[];
  16159. /**
  16160. * The list of defines used in the shader
  16161. */
  16162. defines?: string[];
  16163. }
  16164. /**
  16165. * Interface to implement to create a shadow generator compatible with BJS.
  16166. */
  16167. export interface IShadowGenerator {
  16168. /**
  16169. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16170. * @returns The render target texture if present otherwise, null
  16171. */
  16172. getShadowMap(): Nullable<RenderTargetTexture>;
  16173. /**
  16174. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16175. * @param subMesh The submesh we want to render in the shadow map
  16176. * @param useInstances Defines wether will draw in the map using instances
  16177. * @returns true if ready otherwise, false
  16178. */
  16179. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16180. /**
  16181. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16182. * @param defines Defines of the material we want to update
  16183. * @param lightIndex Index of the light in the enabled light list of the material
  16184. */
  16185. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16186. /**
  16187. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16188. * defined in the generator but impacting the effect).
  16189. * It implies the unifroms available on the materials are the standard BJS ones.
  16190. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16191. * @param effect The effect we are binfing the information for
  16192. */
  16193. bindShadowLight(lightIndex: string, effect: Effect): void;
  16194. /**
  16195. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16196. * (eq to shadow prjection matrix * light transform matrix)
  16197. * @returns The transform matrix used to create the shadow map
  16198. */
  16199. getTransformMatrix(): Matrix;
  16200. /**
  16201. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16202. * Cube and 2D textures for instance.
  16203. */
  16204. recreateShadowMap(): void;
  16205. /**
  16206. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16207. * @param onCompiled Callback triggered at the and of the effects compilation
  16208. * @param options Sets of optional options forcing the compilation with different modes
  16209. */
  16210. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16211. useInstances: boolean;
  16212. }>): void;
  16213. /**
  16214. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16215. * @param options Sets of optional options forcing the compilation with different modes
  16216. * @returns A promise that resolves when the compilation completes
  16217. */
  16218. forceCompilationAsync(options?: Partial<{
  16219. useInstances: boolean;
  16220. }>): Promise<void>;
  16221. /**
  16222. * Serializes the shadow generator setup to a json object.
  16223. * @returns The serialized JSON object
  16224. */
  16225. serialize(): any;
  16226. /**
  16227. * Disposes the Shadow map and related Textures and effects.
  16228. */
  16229. dispose(): void;
  16230. }
  16231. /**
  16232. * Default implementation IShadowGenerator.
  16233. * This is the main object responsible of generating shadows in the framework.
  16234. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16235. */
  16236. export class ShadowGenerator implements IShadowGenerator {
  16237. /**
  16238. * Name of the shadow generator class
  16239. */
  16240. static CLASSNAME: string;
  16241. /**
  16242. * Shadow generator mode None: no filtering applied.
  16243. */
  16244. static readonly FILTER_NONE: number;
  16245. /**
  16246. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16247. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16248. */
  16249. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16250. /**
  16251. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16252. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16253. */
  16254. static readonly FILTER_POISSONSAMPLING: number;
  16255. /**
  16256. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16257. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16258. */
  16259. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16260. /**
  16261. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16262. * edge artifacts on steep falloff.
  16263. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16264. */
  16265. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16266. /**
  16267. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16268. * edge artifacts on steep falloff.
  16269. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16270. */
  16271. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16272. /**
  16273. * Shadow generator mode PCF: Percentage Closer Filtering
  16274. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16275. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16276. */
  16277. static readonly FILTER_PCF: number;
  16278. /**
  16279. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16280. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16281. * Contact Hardening
  16282. */
  16283. static readonly FILTER_PCSS: number;
  16284. /**
  16285. * Reserved for PCF and PCSS
  16286. * Highest Quality.
  16287. *
  16288. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16289. *
  16290. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16291. */
  16292. static readonly QUALITY_HIGH: number;
  16293. /**
  16294. * Reserved for PCF and PCSS
  16295. * Good tradeoff for quality/perf cross devices
  16296. *
  16297. * Execute PCF on a 3*3 kernel.
  16298. *
  16299. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16300. */
  16301. static readonly QUALITY_MEDIUM: number;
  16302. /**
  16303. * Reserved for PCF and PCSS
  16304. * The lowest quality but the fastest.
  16305. *
  16306. * Execute PCF on a 1*1 kernel.
  16307. *
  16308. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16309. */
  16310. static readonly QUALITY_LOW: number;
  16311. /** Gets or sets the custom shader name to use */
  16312. customShaderOptions: ICustomShaderOptions;
  16313. /**
  16314. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16315. */
  16316. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16317. /**
  16318. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16319. */
  16320. onAfterShadowMapRenderObservable: Observable<Effect>;
  16321. /**
  16322. * Observable triggered before a mesh is rendered in the shadow map.
  16323. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16324. */
  16325. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16326. /**
  16327. * Observable triggered after a mesh is rendered in the shadow map.
  16328. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16329. */
  16330. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16331. protected _bias: number;
  16332. /**
  16333. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16334. */
  16335. get bias(): number;
  16336. /**
  16337. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16338. */
  16339. set bias(bias: number);
  16340. protected _normalBias: number;
  16341. /**
  16342. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16343. */
  16344. get normalBias(): number;
  16345. /**
  16346. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16347. */
  16348. set normalBias(normalBias: number);
  16349. protected _blurBoxOffset: number;
  16350. /**
  16351. * Gets the blur box offset: offset applied during the blur pass.
  16352. * Only useful if useKernelBlur = false
  16353. */
  16354. get blurBoxOffset(): number;
  16355. /**
  16356. * Sets the blur box offset: offset applied during the blur pass.
  16357. * Only useful if useKernelBlur = false
  16358. */
  16359. set blurBoxOffset(value: number);
  16360. protected _blurScale: number;
  16361. /**
  16362. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16363. * 2 means half of the size.
  16364. */
  16365. get blurScale(): number;
  16366. /**
  16367. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16368. * 2 means half of the size.
  16369. */
  16370. set blurScale(value: number);
  16371. protected _blurKernel: number;
  16372. /**
  16373. * Gets the blur kernel: kernel size of the blur pass.
  16374. * Only useful if useKernelBlur = true
  16375. */
  16376. get blurKernel(): number;
  16377. /**
  16378. * Sets the blur kernel: kernel size of the blur pass.
  16379. * Only useful if useKernelBlur = true
  16380. */
  16381. set blurKernel(value: number);
  16382. protected _useKernelBlur: boolean;
  16383. /**
  16384. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16385. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16386. */
  16387. get useKernelBlur(): boolean;
  16388. /**
  16389. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16390. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16391. */
  16392. set useKernelBlur(value: boolean);
  16393. protected _depthScale: number;
  16394. /**
  16395. * Gets the depth scale used in ESM mode.
  16396. */
  16397. get depthScale(): number;
  16398. /**
  16399. * Sets the depth scale used in ESM mode.
  16400. * This can override the scale stored on the light.
  16401. */
  16402. set depthScale(value: number);
  16403. protected _validateFilter(filter: number): number;
  16404. protected _filter: number;
  16405. /**
  16406. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16407. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16408. */
  16409. get filter(): number;
  16410. /**
  16411. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16412. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16413. */
  16414. set filter(value: number);
  16415. /**
  16416. * Gets if the current filter is set to Poisson Sampling.
  16417. */
  16418. get usePoissonSampling(): boolean;
  16419. /**
  16420. * Sets the current filter to Poisson Sampling.
  16421. */
  16422. set usePoissonSampling(value: boolean);
  16423. /**
  16424. * Gets if the current filter is set to ESM.
  16425. */
  16426. get useExponentialShadowMap(): boolean;
  16427. /**
  16428. * Sets the current filter is to ESM.
  16429. */
  16430. set useExponentialShadowMap(value: boolean);
  16431. /**
  16432. * Gets if the current filter is set to filtered ESM.
  16433. */
  16434. get useBlurExponentialShadowMap(): boolean;
  16435. /**
  16436. * Gets if the current filter is set to filtered ESM.
  16437. */
  16438. set useBlurExponentialShadowMap(value: boolean);
  16439. /**
  16440. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16441. * exponential to prevent steep falloff artifacts).
  16442. */
  16443. get useCloseExponentialShadowMap(): boolean;
  16444. /**
  16445. * Sets the current filter to "close ESM" (using the inverse of the
  16446. * exponential to prevent steep falloff artifacts).
  16447. */
  16448. set useCloseExponentialShadowMap(value: boolean);
  16449. /**
  16450. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16451. * exponential to prevent steep falloff artifacts).
  16452. */
  16453. get useBlurCloseExponentialShadowMap(): boolean;
  16454. /**
  16455. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16456. * exponential to prevent steep falloff artifacts).
  16457. */
  16458. set useBlurCloseExponentialShadowMap(value: boolean);
  16459. /**
  16460. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16461. */
  16462. get usePercentageCloserFiltering(): boolean;
  16463. /**
  16464. * Sets the current filter to "PCF" (percentage closer filtering).
  16465. */
  16466. set usePercentageCloserFiltering(value: boolean);
  16467. protected _filteringQuality: number;
  16468. /**
  16469. * Gets the PCF or PCSS Quality.
  16470. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16471. */
  16472. get filteringQuality(): number;
  16473. /**
  16474. * Sets the PCF or PCSS Quality.
  16475. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16476. */
  16477. set filteringQuality(filteringQuality: number);
  16478. /**
  16479. * Gets if the current filter is set to "PCSS" (contact hardening).
  16480. */
  16481. get useContactHardeningShadow(): boolean;
  16482. /**
  16483. * Sets the current filter to "PCSS" (contact hardening).
  16484. */
  16485. set useContactHardeningShadow(value: boolean);
  16486. protected _contactHardeningLightSizeUVRatio: number;
  16487. /**
  16488. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16489. * Using a ratio helps keeping shape stability independently of the map size.
  16490. *
  16491. * It does not account for the light projection as it was having too much
  16492. * instability during the light setup or during light position changes.
  16493. *
  16494. * Only valid if useContactHardeningShadow is true.
  16495. */
  16496. get contactHardeningLightSizeUVRatio(): number;
  16497. /**
  16498. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16499. * Using a ratio helps keeping shape stability independently of the map size.
  16500. *
  16501. * It does not account for the light projection as it was having too much
  16502. * instability during the light setup or during light position changes.
  16503. *
  16504. * Only valid if useContactHardeningShadow is true.
  16505. */
  16506. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16507. protected _darkness: number;
  16508. /** Gets or sets the actual darkness of a shadow */
  16509. get darkness(): number;
  16510. set darkness(value: number);
  16511. /**
  16512. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16513. * 0 means strongest and 1 would means no shadow.
  16514. * @returns the darkness.
  16515. */
  16516. getDarkness(): number;
  16517. /**
  16518. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16519. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16520. * @returns the shadow generator allowing fluent coding.
  16521. */
  16522. setDarkness(darkness: number): ShadowGenerator;
  16523. protected _transparencyShadow: boolean;
  16524. /** Gets or sets the ability to have transparent shadow */
  16525. get transparencyShadow(): boolean;
  16526. set transparencyShadow(value: boolean);
  16527. /**
  16528. * Sets the ability to have transparent shadow (boolean).
  16529. * @param transparent True if transparent else False
  16530. * @returns the shadow generator allowing fluent coding
  16531. */
  16532. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16533. protected _shadowMap: Nullable<RenderTargetTexture>;
  16534. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16535. /**
  16536. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16537. * @returns The render target texture if present otherwise, null
  16538. */
  16539. getShadowMap(): Nullable<RenderTargetTexture>;
  16540. /**
  16541. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16542. * @returns The render target texture if the shadow map is present otherwise, null
  16543. */
  16544. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16545. /**
  16546. * Gets the class name of that object
  16547. * @returns "ShadowGenerator"
  16548. */
  16549. getClassName(): string;
  16550. /**
  16551. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16552. * @param mesh Mesh to add
  16553. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16554. * @returns the Shadow Generator itself
  16555. */
  16556. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16557. /**
  16558. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16559. * @param mesh Mesh to remove
  16560. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16561. * @returns the Shadow Generator itself
  16562. */
  16563. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16564. /**
  16565. * Controls the extent to which the shadows fade out at the edge of the frustum
  16566. */
  16567. frustumEdgeFalloff: number;
  16568. protected _light: IShadowLight;
  16569. /**
  16570. * Returns the associated light object.
  16571. * @returns the light generating the shadow
  16572. */
  16573. getLight(): IShadowLight;
  16574. /**
  16575. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16576. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16577. * It might on the other hand introduce peter panning.
  16578. */
  16579. forceBackFacesOnly: boolean;
  16580. protected _scene: Scene;
  16581. protected _lightDirection: Vector3;
  16582. protected _effect: Effect;
  16583. protected _viewMatrix: Matrix;
  16584. protected _projectionMatrix: Matrix;
  16585. protected _transformMatrix: Matrix;
  16586. protected _cachedPosition: Vector3;
  16587. protected _cachedDirection: Vector3;
  16588. protected _cachedDefines: string;
  16589. protected _currentRenderID: number;
  16590. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16591. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16592. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16593. protected _blurPostProcesses: PostProcess[];
  16594. protected _mapSize: number;
  16595. protected _currentFaceIndex: number;
  16596. protected _currentFaceIndexCache: number;
  16597. protected _textureType: number;
  16598. protected _defaultTextureMatrix: Matrix;
  16599. protected _storedUniqueId: Nullable<number>;
  16600. /** @hidden */
  16601. static _SceneComponentInitialization: (scene: Scene) => void;
  16602. /**
  16603. * Creates a ShadowGenerator object.
  16604. * A ShadowGenerator is the required tool to use the shadows.
  16605. * Each light casting shadows needs to use its own ShadowGenerator.
  16606. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16607. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16608. * @param light The light object generating the shadows.
  16609. * @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.
  16610. */
  16611. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16612. protected _initializeGenerator(): void;
  16613. protected _createTargetRenderTexture(): void;
  16614. protected _initializeShadowMap(): void;
  16615. protected _initializeBlurRTTAndPostProcesses(): void;
  16616. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16617. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16618. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16619. protected _applyFilterValues(): void;
  16620. /**
  16621. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16622. * @param onCompiled Callback triggered at the and of the effects compilation
  16623. * @param options Sets of optional options forcing the compilation with different modes
  16624. */
  16625. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16626. useInstances: boolean;
  16627. }>): void;
  16628. /**
  16629. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16630. * @param options Sets of optional options forcing the compilation with different modes
  16631. * @returns A promise that resolves when the compilation completes
  16632. */
  16633. forceCompilationAsync(options?: Partial<{
  16634. useInstances: boolean;
  16635. }>): Promise<void>;
  16636. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16637. /**
  16638. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16639. * @param subMesh The submesh we want to render in the shadow map
  16640. * @param useInstances Defines wether will draw in the map using instances
  16641. * @returns true if ready otherwise, false
  16642. */
  16643. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16644. /**
  16645. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16646. * @param defines Defines of the material we want to update
  16647. * @param lightIndex Index of the light in the enabled light list of the material
  16648. */
  16649. prepareDefines(defines: any, lightIndex: number): void;
  16650. /**
  16651. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16652. * defined in the generator but impacting the effect).
  16653. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16654. * @param effect The effect we are binfing the information for
  16655. */
  16656. bindShadowLight(lightIndex: string, effect: Effect): void;
  16657. /**
  16658. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16659. * (eq to shadow prjection matrix * light transform matrix)
  16660. * @returns The transform matrix used to create the shadow map
  16661. */
  16662. getTransformMatrix(): Matrix;
  16663. /**
  16664. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16665. * Cube and 2D textures for instance.
  16666. */
  16667. recreateShadowMap(): void;
  16668. protected _disposeBlurPostProcesses(): void;
  16669. protected _disposeRTTandPostProcesses(): void;
  16670. /**
  16671. * Disposes the ShadowGenerator.
  16672. * Returns nothing.
  16673. */
  16674. dispose(): void;
  16675. /**
  16676. * Serializes the shadow generator setup to a json object.
  16677. * @returns The serialized JSON object
  16678. */
  16679. serialize(): any;
  16680. /**
  16681. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16682. * @param parsedShadowGenerator The JSON object to parse
  16683. * @param scene The scene to create the shadow map for
  16684. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16685. * @returns The parsed shadow generator
  16686. */
  16687. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16688. }
  16689. }
  16690. declare module BABYLON {
  16691. /**
  16692. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16693. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16694. * 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.
  16695. */
  16696. export abstract class Light extends Node {
  16697. /**
  16698. * Falloff Default: light is falling off following the material specification:
  16699. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16700. */
  16701. static readonly FALLOFF_DEFAULT: number;
  16702. /**
  16703. * Falloff Physical: light is falling off following the inverse squared distance law.
  16704. */
  16705. static readonly FALLOFF_PHYSICAL: number;
  16706. /**
  16707. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16708. * to enhance interoperability with other engines.
  16709. */
  16710. static readonly FALLOFF_GLTF: number;
  16711. /**
  16712. * Falloff Standard: light is falling off like in the standard material
  16713. * to enhance interoperability with other materials.
  16714. */
  16715. static readonly FALLOFF_STANDARD: number;
  16716. /**
  16717. * If every light affecting the material is in this lightmapMode,
  16718. * material.lightmapTexture adds or multiplies
  16719. * (depends on material.useLightmapAsShadowmap)
  16720. * after every other light calculations.
  16721. */
  16722. static readonly LIGHTMAP_DEFAULT: number;
  16723. /**
  16724. * material.lightmapTexture as only diffuse lighting from this light
  16725. * adds only specular lighting from this light
  16726. * adds dynamic shadows
  16727. */
  16728. static readonly LIGHTMAP_SPECULAR: number;
  16729. /**
  16730. * material.lightmapTexture as only lighting
  16731. * no light calculation from this light
  16732. * only adds dynamic shadows from this light
  16733. */
  16734. static readonly LIGHTMAP_SHADOWSONLY: number;
  16735. /**
  16736. * Each light type uses the default quantity according to its type:
  16737. * point/spot lights use luminous intensity
  16738. * directional lights use illuminance
  16739. */
  16740. static readonly INTENSITYMODE_AUTOMATIC: number;
  16741. /**
  16742. * lumen (lm)
  16743. */
  16744. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16745. /**
  16746. * candela (lm/sr)
  16747. */
  16748. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16749. /**
  16750. * lux (lm/m^2)
  16751. */
  16752. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16753. /**
  16754. * nit (cd/m^2)
  16755. */
  16756. static readonly INTENSITYMODE_LUMINANCE: number;
  16757. /**
  16758. * Light type const id of the point light.
  16759. */
  16760. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16761. /**
  16762. * Light type const id of the directional light.
  16763. */
  16764. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16765. /**
  16766. * Light type const id of the spot light.
  16767. */
  16768. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16769. /**
  16770. * Light type const id of the hemispheric light.
  16771. */
  16772. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16773. /**
  16774. * Diffuse gives the basic color to an object.
  16775. */
  16776. diffuse: Color3;
  16777. /**
  16778. * Specular produces a highlight color on an object.
  16779. * Note: This is note affecting PBR materials.
  16780. */
  16781. specular: Color3;
  16782. /**
  16783. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16784. * falling off base on range or angle.
  16785. * This can be set to any values in Light.FALLOFF_x.
  16786. *
  16787. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16788. * other types of materials.
  16789. */
  16790. falloffType: number;
  16791. /**
  16792. * Strength of the light.
  16793. * Note: By default it is define in the framework own unit.
  16794. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16795. */
  16796. intensity: number;
  16797. private _range;
  16798. protected _inverseSquaredRange: number;
  16799. /**
  16800. * Defines how far from the source the light is impacting in scene units.
  16801. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16802. */
  16803. get range(): number;
  16804. /**
  16805. * Defines how far from the source the light is impacting in scene units.
  16806. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16807. */
  16808. set range(value: number);
  16809. /**
  16810. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16811. * of light.
  16812. */
  16813. private _photometricScale;
  16814. private _intensityMode;
  16815. /**
  16816. * Gets the photometric scale used to interpret the intensity.
  16817. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16818. */
  16819. get intensityMode(): number;
  16820. /**
  16821. * Sets the photometric scale used to interpret the intensity.
  16822. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16823. */
  16824. set intensityMode(value: number);
  16825. private _radius;
  16826. /**
  16827. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16828. */
  16829. get radius(): number;
  16830. /**
  16831. * sets the light radius used by PBR Materials to simulate soft area lights.
  16832. */
  16833. set radius(value: number);
  16834. private _renderPriority;
  16835. /**
  16836. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16837. * exceeding the number allowed of the materials.
  16838. */
  16839. renderPriority: number;
  16840. private _shadowEnabled;
  16841. /**
  16842. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16843. * the current shadow generator.
  16844. */
  16845. get shadowEnabled(): boolean;
  16846. /**
  16847. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16848. * the current shadow generator.
  16849. */
  16850. set shadowEnabled(value: boolean);
  16851. private _includedOnlyMeshes;
  16852. /**
  16853. * Gets the only meshes impacted by this light.
  16854. */
  16855. get includedOnlyMeshes(): AbstractMesh[];
  16856. /**
  16857. * Sets the only meshes impacted by this light.
  16858. */
  16859. set includedOnlyMeshes(value: AbstractMesh[]);
  16860. private _excludedMeshes;
  16861. /**
  16862. * Gets the meshes not impacted by this light.
  16863. */
  16864. get excludedMeshes(): AbstractMesh[];
  16865. /**
  16866. * Sets the meshes not impacted by this light.
  16867. */
  16868. set excludedMeshes(value: AbstractMesh[]);
  16869. private _excludeWithLayerMask;
  16870. /**
  16871. * Gets the layer id use to find what meshes are not impacted by the light.
  16872. * Inactive if 0
  16873. */
  16874. get excludeWithLayerMask(): number;
  16875. /**
  16876. * Sets the layer id use to find what meshes are not impacted by the light.
  16877. * Inactive if 0
  16878. */
  16879. set excludeWithLayerMask(value: number);
  16880. private _includeOnlyWithLayerMask;
  16881. /**
  16882. * Gets the layer id use to find what meshes are impacted by the light.
  16883. * Inactive if 0
  16884. */
  16885. get includeOnlyWithLayerMask(): number;
  16886. /**
  16887. * Sets the layer id use to find what meshes are impacted by the light.
  16888. * Inactive if 0
  16889. */
  16890. set includeOnlyWithLayerMask(value: number);
  16891. private _lightmapMode;
  16892. /**
  16893. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16894. */
  16895. get lightmapMode(): number;
  16896. /**
  16897. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16898. */
  16899. set lightmapMode(value: number);
  16900. /**
  16901. * Shadow generator associted to the light.
  16902. * @hidden Internal use only.
  16903. */
  16904. _shadowGenerator: Nullable<IShadowGenerator>;
  16905. /**
  16906. * @hidden Internal use only.
  16907. */
  16908. _excludedMeshesIds: string[];
  16909. /**
  16910. * @hidden Internal use only.
  16911. */
  16912. _includedOnlyMeshesIds: string[];
  16913. /**
  16914. * The current light unifom buffer.
  16915. * @hidden Internal use only.
  16916. */
  16917. _uniformBuffer: UniformBuffer;
  16918. /** @hidden */
  16919. _renderId: number;
  16920. /**
  16921. * Creates a Light object in the scene.
  16922. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16923. * @param name The firendly name of the light
  16924. * @param scene The scene the light belongs too
  16925. */
  16926. constructor(name: string, scene: Scene);
  16927. protected abstract _buildUniformLayout(): void;
  16928. /**
  16929. * Sets the passed Effect "effect" with the Light information.
  16930. * @param effect The effect to update
  16931. * @param lightIndex The index of the light in the effect to update
  16932. * @returns The light
  16933. */
  16934. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16935. /**
  16936. * Sets the passed Effect "effect" with the Light textures.
  16937. * @param effect The effect to update
  16938. * @param lightIndex The index of the light in the effect to update
  16939. * @returns The light
  16940. */
  16941. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16942. /**
  16943. * Binds the lights information from the scene to the effect for the given mesh.
  16944. * @param lightIndex Light index
  16945. * @param scene The scene where the light belongs to
  16946. * @param effect The effect we are binding the data to
  16947. * @param useSpecular Defines if specular is supported
  16948. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16949. */
  16950. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16951. /**
  16952. * Sets the passed Effect "effect" with the Light information.
  16953. * @param effect The effect to update
  16954. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16955. * @returns The light
  16956. */
  16957. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16958. /**
  16959. * Returns the string "Light".
  16960. * @returns the class name
  16961. */
  16962. getClassName(): string;
  16963. /** @hidden */
  16964. readonly _isLight: boolean;
  16965. /**
  16966. * Converts the light information to a readable string for debug purpose.
  16967. * @param fullDetails Supports for multiple levels of logging within scene loading
  16968. * @returns the human readable light info
  16969. */
  16970. toString(fullDetails?: boolean): string;
  16971. /** @hidden */
  16972. protected _syncParentEnabledState(): void;
  16973. /**
  16974. * Set the enabled state of this node.
  16975. * @param value - the new enabled state
  16976. */
  16977. setEnabled(value: boolean): void;
  16978. /**
  16979. * Returns the Light associated shadow generator if any.
  16980. * @return the associated shadow generator.
  16981. */
  16982. getShadowGenerator(): Nullable<IShadowGenerator>;
  16983. /**
  16984. * Returns a Vector3, the absolute light position in the World.
  16985. * @returns the world space position of the light
  16986. */
  16987. getAbsolutePosition(): Vector3;
  16988. /**
  16989. * Specifies if the light will affect the passed mesh.
  16990. * @param mesh The mesh to test against the light
  16991. * @return true the mesh is affected otherwise, false.
  16992. */
  16993. canAffectMesh(mesh: AbstractMesh): boolean;
  16994. /**
  16995. * Sort function to order lights for rendering.
  16996. * @param a First Light object to compare to second.
  16997. * @param b Second Light object to compare first.
  16998. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16999. */
  17000. static CompareLightsPriority(a: Light, b: Light): number;
  17001. /**
  17002. * Releases resources associated with this node.
  17003. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17004. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17005. */
  17006. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17007. /**
  17008. * Returns the light type ID (integer).
  17009. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17010. */
  17011. getTypeID(): number;
  17012. /**
  17013. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17014. * @returns the scaled intensity in intensity mode unit
  17015. */
  17016. getScaledIntensity(): number;
  17017. /**
  17018. * Returns a new Light object, named "name", from the current one.
  17019. * @param name The name of the cloned light
  17020. * @returns the new created light
  17021. */
  17022. clone(name: string): Nullable<Light>;
  17023. /**
  17024. * Serializes the current light into a Serialization object.
  17025. * @returns the serialized object.
  17026. */
  17027. serialize(): any;
  17028. /**
  17029. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17030. * This new light is named "name" and added to the passed scene.
  17031. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17032. * @param name The friendly name of the light
  17033. * @param scene The scene the new light will belong to
  17034. * @returns the constructor function
  17035. */
  17036. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17037. /**
  17038. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17039. * @param parsedLight The JSON representation of the light
  17040. * @param scene The scene to create the parsed light in
  17041. * @returns the created light after parsing
  17042. */
  17043. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17044. private _hookArrayForExcluded;
  17045. private _hookArrayForIncludedOnly;
  17046. private _resyncMeshes;
  17047. /**
  17048. * Forces the meshes to update their light related information in their rendering used effects
  17049. * @hidden Internal Use Only
  17050. */
  17051. _markMeshesAsLightDirty(): void;
  17052. /**
  17053. * Recomputes the cached photometric scale if needed.
  17054. */
  17055. private _computePhotometricScale;
  17056. /**
  17057. * Returns the Photometric Scale according to the light type and intensity mode.
  17058. */
  17059. private _getPhotometricScale;
  17060. /**
  17061. * Reorder the light in the scene according to their defined priority.
  17062. * @hidden Internal Use Only
  17063. */
  17064. _reorderLightsInScene(): void;
  17065. /**
  17066. * Prepares the list of defines specific to the light type.
  17067. * @param defines the list of defines
  17068. * @param lightIndex defines the index of the light for the effect
  17069. */
  17070. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17071. }
  17072. }
  17073. declare module BABYLON {
  17074. /**
  17075. * Interface used to define Action
  17076. */
  17077. export interface IAction {
  17078. /**
  17079. * Trigger for the action
  17080. */
  17081. trigger: number;
  17082. /** Options of the trigger */
  17083. triggerOptions: any;
  17084. /**
  17085. * Gets the trigger parameters
  17086. * @returns the trigger parameters
  17087. */
  17088. getTriggerParameter(): any;
  17089. /**
  17090. * Internal only - executes current action event
  17091. * @hidden
  17092. */
  17093. _executeCurrent(evt?: ActionEvent): void;
  17094. /**
  17095. * Serialize placeholder for child classes
  17096. * @param parent of child
  17097. * @returns the serialized object
  17098. */
  17099. serialize(parent: any): any;
  17100. /**
  17101. * Internal only
  17102. * @hidden
  17103. */
  17104. _prepare(): void;
  17105. /**
  17106. * Internal only - manager for action
  17107. * @hidden
  17108. */
  17109. _actionManager: AbstractActionManager;
  17110. /**
  17111. * Adds action to chain of actions, may be a DoNothingAction
  17112. * @param action defines the next action to execute
  17113. * @returns The action passed in
  17114. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17115. */
  17116. then(action: IAction): IAction;
  17117. }
  17118. /**
  17119. * The action to be carried out following a trigger
  17120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17121. */
  17122. export class Action implements IAction {
  17123. /** the trigger, with or without parameters, for the action */
  17124. triggerOptions: any;
  17125. /**
  17126. * Trigger for the action
  17127. */
  17128. trigger: number;
  17129. /**
  17130. * Internal only - manager for action
  17131. * @hidden
  17132. */
  17133. _actionManager: ActionManager;
  17134. private _nextActiveAction;
  17135. private _child;
  17136. private _condition?;
  17137. private _triggerParameter;
  17138. /**
  17139. * An event triggered prior to action being executed.
  17140. */
  17141. onBeforeExecuteObservable: Observable<Action>;
  17142. /**
  17143. * Creates a new Action
  17144. * @param triggerOptions the trigger, with or without parameters, for the action
  17145. * @param condition an optional determinant of action
  17146. */
  17147. constructor(
  17148. /** the trigger, with or without parameters, for the action */
  17149. triggerOptions: any, condition?: Condition);
  17150. /**
  17151. * Internal only
  17152. * @hidden
  17153. */
  17154. _prepare(): void;
  17155. /**
  17156. * Gets the trigger parameters
  17157. * @returns the trigger parameters
  17158. */
  17159. getTriggerParameter(): any;
  17160. /**
  17161. * Internal only - executes current action event
  17162. * @hidden
  17163. */
  17164. _executeCurrent(evt?: ActionEvent): void;
  17165. /**
  17166. * Execute placeholder for child classes
  17167. * @param evt optional action event
  17168. */
  17169. execute(evt?: ActionEvent): void;
  17170. /**
  17171. * Skips to next active action
  17172. */
  17173. skipToNextActiveAction(): void;
  17174. /**
  17175. * Adds action to chain of actions, may be a DoNothingAction
  17176. * @param action defines the next action to execute
  17177. * @returns The action passed in
  17178. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17179. */
  17180. then(action: Action): Action;
  17181. /**
  17182. * Internal only
  17183. * @hidden
  17184. */
  17185. _getProperty(propertyPath: string): string;
  17186. /**
  17187. * Internal only
  17188. * @hidden
  17189. */
  17190. _getEffectiveTarget(target: any, propertyPath: string): any;
  17191. /**
  17192. * Serialize placeholder for child classes
  17193. * @param parent of child
  17194. * @returns the serialized object
  17195. */
  17196. serialize(parent: any): any;
  17197. /**
  17198. * Internal only called by serialize
  17199. * @hidden
  17200. */
  17201. protected _serialize(serializedAction: any, parent?: any): any;
  17202. /**
  17203. * Internal only
  17204. * @hidden
  17205. */
  17206. static _SerializeValueAsString: (value: any) => string;
  17207. /**
  17208. * Internal only
  17209. * @hidden
  17210. */
  17211. static _GetTargetProperty: (target: Node | Scene) => {
  17212. name: string;
  17213. targetType: string;
  17214. value: string;
  17215. };
  17216. }
  17217. }
  17218. declare module BABYLON {
  17219. /**
  17220. * A Condition applied to an Action
  17221. */
  17222. export class Condition {
  17223. /**
  17224. * Internal only - manager for action
  17225. * @hidden
  17226. */
  17227. _actionManager: ActionManager;
  17228. /**
  17229. * Internal only
  17230. * @hidden
  17231. */
  17232. _evaluationId: number;
  17233. /**
  17234. * Internal only
  17235. * @hidden
  17236. */
  17237. _currentResult: boolean;
  17238. /**
  17239. * Creates a new Condition
  17240. * @param actionManager the manager of the action the condition is applied to
  17241. */
  17242. constructor(actionManager: ActionManager);
  17243. /**
  17244. * Check if the current condition is valid
  17245. * @returns a boolean
  17246. */
  17247. isValid(): boolean;
  17248. /**
  17249. * Internal only
  17250. * @hidden
  17251. */
  17252. _getProperty(propertyPath: string): string;
  17253. /**
  17254. * Internal only
  17255. * @hidden
  17256. */
  17257. _getEffectiveTarget(target: any, propertyPath: string): any;
  17258. /**
  17259. * Serialize placeholder for child classes
  17260. * @returns the serialized object
  17261. */
  17262. serialize(): any;
  17263. /**
  17264. * Internal only
  17265. * @hidden
  17266. */
  17267. protected _serialize(serializedCondition: any): any;
  17268. }
  17269. /**
  17270. * Defines specific conditional operators as extensions of Condition
  17271. */
  17272. export class ValueCondition extends Condition {
  17273. /** path to specify the property of the target the conditional operator uses */
  17274. propertyPath: string;
  17275. /** the value compared by the conditional operator against the current value of the property */
  17276. value: any;
  17277. /** the conditional operator, default ValueCondition.IsEqual */
  17278. operator: number;
  17279. /**
  17280. * Internal only
  17281. * @hidden
  17282. */
  17283. private static _IsEqual;
  17284. /**
  17285. * Internal only
  17286. * @hidden
  17287. */
  17288. private static _IsDifferent;
  17289. /**
  17290. * Internal only
  17291. * @hidden
  17292. */
  17293. private static _IsGreater;
  17294. /**
  17295. * Internal only
  17296. * @hidden
  17297. */
  17298. private static _IsLesser;
  17299. /**
  17300. * returns the number for IsEqual
  17301. */
  17302. static get IsEqual(): number;
  17303. /**
  17304. * Returns the number for IsDifferent
  17305. */
  17306. static get IsDifferent(): number;
  17307. /**
  17308. * Returns the number for IsGreater
  17309. */
  17310. static get IsGreater(): number;
  17311. /**
  17312. * Returns the number for IsLesser
  17313. */
  17314. static get IsLesser(): number;
  17315. /**
  17316. * Internal only The action manager for the condition
  17317. * @hidden
  17318. */
  17319. _actionManager: ActionManager;
  17320. /**
  17321. * Internal only
  17322. * @hidden
  17323. */
  17324. private _target;
  17325. /**
  17326. * Internal only
  17327. * @hidden
  17328. */
  17329. private _effectiveTarget;
  17330. /**
  17331. * Internal only
  17332. * @hidden
  17333. */
  17334. private _property;
  17335. /**
  17336. * Creates a new ValueCondition
  17337. * @param actionManager manager for the action the condition applies to
  17338. * @param target for the action
  17339. * @param propertyPath path to specify the property of the target the conditional operator uses
  17340. * @param value the value compared by the conditional operator against the current value of the property
  17341. * @param operator the conditional operator, default ValueCondition.IsEqual
  17342. */
  17343. constructor(actionManager: ActionManager, target: any,
  17344. /** path to specify the property of the target the conditional operator uses */
  17345. propertyPath: string,
  17346. /** the value compared by the conditional operator against the current value of the property */
  17347. value: any,
  17348. /** the conditional operator, default ValueCondition.IsEqual */
  17349. operator?: number);
  17350. /**
  17351. * Compares the given value with the property value for the specified conditional operator
  17352. * @returns the result of the comparison
  17353. */
  17354. isValid(): boolean;
  17355. /**
  17356. * Serialize the ValueCondition into a JSON compatible object
  17357. * @returns serialization object
  17358. */
  17359. serialize(): any;
  17360. /**
  17361. * Gets the name of the conditional operator for the ValueCondition
  17362. * @param operator the conditional operator
  17363. * @returns the name
  17364. */
  17365. static GetOperatorName(operator: number): string;
  17366. }
  17367. /**
  17368. * Defines a predicate condition as an extension of Condition
  17369. */
  17370. export class PredicateCondition extends Condition {
  17371. /** defines the predicate function used to validate the condition */
  17372. predicate: () => boolean;
  17373. /**
  17374. * Internal only - manager for action
  17375. * @hidden
  17376. */
  17377. _actionManager: ActionManager;
  17378. /**
  17379. * Creates a new PredicateCondition
  17380. * @param actionManager manager for the action the condition applies to
  17381. * @param predicate defines the predicate function used to validate the condition
  17382. */
  17383. constructor(actionManager: ActionManager,
  17384. /** defines the predicate function used to validate the condition */
  17385. predicate: () => boolean);
  17386. /**
  17387. * @returns the validity of the predicate condition
  17388. */
  17389. isValid(): boolean;
  17390. }
  17391. /**
  17392. * Defines a state condition as an extension of Condition
  17393. */
  17394. export class StateCondition extends Condition {
  17395. /** Value to compare with target state */
  17396. value: string;
  17397. /**
  17398. * Internal only - manager for action
  17399. * @hidden
  17400. */
  17401. _actionManager: ActionManager;
  17402. /**
  17403. * Internal only
  17404. * @hidden
  17405. */
  17406. private _target;
  17407. /**
  17408. * Creates a new StateCondition
  17409. * @param actionManager manager for the action the condition applies to
  17410. * @param target of the condition
  17411. * @param value to compare with target state
  17412. */
  17413. constructor(actionManager: ActionManager, target: any,
  17414. /** Value to compare with target state */
  17415. value: string);
  17416. /**
  17417. * Gets a boolean indicating if the current condition is met
  17418. * @returns the validity of the state
  17419. */
  17420. isValid(): boolean;
  17421. /**
  17422. * Serialize the StateCondition into a JSON compatible object
  17423. * @returns serialization object
  17424. */
  17425. serialize(): any;
  17426. }
  17427. }
  17428. declare module BABYLON {
  17429. /**
  17430. * This defines an action responsible to toggle a boolean once triggered.
  17431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17432. */
  17433. export class SwitchBooleanAction extends Action {
  17434. /**
  17435. * The path to the boolean property in the target object
  17436. */
  17437. propertyPath: string;
  17438. private _target;
  17439. private _effectiveTarget;
  17440. private _property;
  17441. /**
  17442. * Instantiate the action
  17443. * @param triggerOptions defines the trigger options
  17444. * @param target defines the object containing the boolean
  17445. * @param propertyPath defines the path to the boolean property in the target object
  17446. * @param condition defines the trigger related conditions
  17447. */
  17448. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17449. /** @hidden */
  17450. _prepare(): void;
  17451. /**
  17452. * Execute the action toggle the boolean value.
  17453. */
  17454. execute(): void;
  17455. /**
  17456. * Serializes the actions and its related information.
  17457. * @param parent defines the object to serialize in
  17458. * @returns the serialized object
  17459. */
  17460. serialize(parent: any): any;
  17461. }
  17462. /**
  17463. * This defines an action responsible to set a the state field of the target
  17464. * to a desired value once triggered.
  17465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17466. */
  17467. export class SetStateAction extends Action {
  17468. /**
  17469. * The value to store in the state field.
  17470. */
  17471. value: string;
  17472. private _target;
  17473. /**
  17474. * Instantiate the action
  17475. * @param triggerOptions defines the trigger options
  17476. * @param target defines the object containing the state property
  17477. * @param value defines the value to store in the state field
  17478. * @param condition defines the trigger related conditions
  17479. */
  17480. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17481. /**
  17482. * Execute the action and store the value on the target state property.
  17483. */
  17484. execute(): void;
  17485. /**
  17486. * Serializes the actions and its related information.
  17487. * @param parent defines the object to serialize in
  17488. * @returns the serialized object
  17489. */
  17490. serialize(parent: any): any;
  17491. }
  17492. /**
  17493. * This defines an action responsible to set a property of the target
  17494. * to a desired value once triggered.
  17495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17496. */
  17497. export class SetValueAction extends Action {
  17498. /**
  17499. * The path of the property to set in the target.
  17500. */
  17501. propertyPath: string;
  17502. /**
  17503. * The value to set in the property
  17504. */
  17505. value: any;
  17506. private _target;
  17507. private _effectiveTarget;
  17508. private _property;
  17509. /**
  17510. * Instantiate the action
  17511. * @param triggerOptions defines the trigger options
  17512. * @param target defines the object containing the property
  17513. * @param propertyPath defines the path of the property to set in the target
  17514. * @param value defines the value to set in the property
  17515. * @param condition defines the trigger related conditions
  17516. */
  17517. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17518. /** @hidden */
  17519. _prepare(): void;
  17520. /**
  17521. * Execute the action and set the targetted property to the desired value.
  17522. */
  17523. execute(): void;
  17524. /**
  17525. * Serializes the actions and its related information.
  17526. * @param parent defines the object to serialize in
  17527. * @returns the serialized object
  17528. */
  17529. serialize(parent: any): any;
  17530. }
  17531. /**
  17532. * This defines an action responsible to increment the target value
  17533. * to a desired value once triggered.
  17534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17535. */
  17536. export class IncrementValueAction extends Action {
  17537. /**
  17538. * The path of the property to increment in the target.
  17539. */
  17540. propertyPath: string;
  17541. /**
  17542. * The value we should increment the property by.
  17543. */
  17544. value: any;
  17545. private _target;
  17546. private _effectiveTarget;
  17547. private _property;
  17548. /**
  17549. * Instantiate the action
  17550. * @param triggerOptions defines the trigger options
  17551. * @param target defines the object containing the property
  17552. * @param propertyPath defines the path of the property to increment in the target
  17553. * @param value defines the value value we should increment the property by
  17554. * @param condition defines the trigger related conditions
  17555. */
  17556. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17557. /** @hidden */
  17558. _prepare(): void;
  17559. /**
  17560. * Execute the action and increment the target of the value amount.
  17561. */
  17562. execute(): void;
  17563. /**
  17564. * Serializes the actions and its related information.
  17565. * @param parent defines the object to serialize in
  17566. * @returns the serialized object
  17567. */
  17568. serialize(parent: any): any;
  17569. }
  17570. /**
  17571. * This defines an action responsible to start an animation once triggered.
  17572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17573. */
  17574. export class PlayAnimationAction extends Action {
  17575. /**
  17576. * Where the animation should start (animation frame)
  17577. */
  17578. from: number;
  17579. /**
  17580. * Where the animation should stop (animation frame)
  17581. */
  17582. to: number;
  17583. /**
  17584. * Define if the animation should loop or stop after the first play.
  17585. */
  17586. loop?: boolean;
  17587. private _target;
  17588. /**
  17589. * Instantiate the action
  17590. * @param triggerOptions defines the trigger options
  17591. * @param target defines the target animation or animation name
  17592. * @param from defines from where the animation should start (animation frame)
  17593. * @param end defines where the animation should stop (animation frame)
  17594. * @param loop defines if the animation should loop or stop after the first play
  17595. * @param condition defines the trigger related conditions
  17596. */
  17597. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17598. /** @hidden */
  17599. _prepare(): void;
  17600. /**
  17601. * Execute the action and play the animation.
  17602. */
  17603. execute(): void;
  17604. /**
  17605. * Serializes the actions and its related information.
  17606. * @param parent defines the object to serialize in
  17607. * @returns the serialized object
  17608. */
  17609. serialize(parent: any): any;
  17610. }
  17611. /**
  17612. * This defines an action responsible to stop an animation once triggered.
  17613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17614. */
  17615. export class StopAnimationAction extends Action {
  17616. private _target;
  17617. /**
  17618. * Instantiate the action
  17619. * @param triggerOptions defines the trigger options
  17620. * @param target defines the target animation or animation name
  17621. * @param condition defines the trigger related conditions
  17622. */
  17623. constructor(triggerOptions: any, target: any, condition?: Condition);
  17624. /** @hidden */
  17625. _prepare(): void;
  17626. /**
  17627. * Execute the action and stop the animation.
  17628. */
  17629. execute(): void;
  17630. /**
  17631. * Serializes the actions and its related information.
  17632. * @param parent defines the object to serialize in
  17633. * @returns the serialized object
  17634. */
  17635. serialize(parent: any): any;
  17636. }
  17637. /**
  17638. * This defines an action responsible that does nothing once triggered.
  17639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17640. */
  17641. export class DoNothingAction extends Action {
  17642. /**
  17643. * Instantiate the action
  17644. * @param triggerOptions defines the trigger options
  17645. * @param condition defines the trigger related conditions
  17646. */
  17647. constructor(triggerOptions?: any, condition?: Condition);
  17648. /**
  17649. * Execute the action and do nothing.
  17650. */
  17651. execute(): void;
  17652. /**
  17653. * Serializes the actions and its related information.
  17654. * @param parent defines the object to serialize in
  17655. * @returns the serialized object
  17656. */
  17657. serialize(parent: any): any;
  17658. }
  17659. /**
  17660. * This defines an action responsible to trigger several actions once triggered.
  17661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17662. */
  17663. export class CombineAction extends Action {
  17664. /**
  17665. * The list of aggregated animations to run.
  17666. */
  17667. children: Action[];
  17668. /**
  17669. * Instantiate the action
  17670. * @param triggerOptions defines the trigger options
  17671. * @param children defines the list of aggregated animations to run
  17672. * @param condition defines the trigger related conditions
  17673. */
  17674. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17675. /** @hidden */
  17676. _prepare(): void;
  17677. /**
  17678. * Execute the action and executes all the aggregated actions.
  17679. */
  17680. execute(evt: ActionEvent): void;
  17681. /**
  17682. * Serializes the actions and its related information.
  17683. * @param parent defines the object to serialize in
  17684. * @returns the serialized object
  17685. */
  17686. serialize(parent: any): any;
  17687. }
  17688. /**
  17689. * This defines an action responsible to run code (external event) once triggered.
  17690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17691. */
  17692. export class ExecuteCodeAction extends Action {
  17693. /**
  17694. * The callback function to run.
  17695. */
  17696. func: (evt: ActionEvent) => void;
  17697. /**
  17698. * Instantiate the action
  17699. * @param triggerOptions defines the trigger options
  17700. * @param func defines the callback function to run
  17701. * @param condition defines the trigger related conditions
  17702. */
  17703. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17704. /**
  17705. * Execute the action and run the attached code.
  17706. */
  17707. execute(evt: ActionEvent): void;
  17708. }
  17709. /**
  17710. * This defines an action responsible to set the parent property of the target once triggered.
  17711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17712. */
  17713. export class SetParentAction extends Action {
  17714. private _parent;
  17715. private _target;
  17716. /**
  17717. * Instantiate the action
  17718. * @param triggerOptions defines the trigger options
  17719. * @param target defines the target containing the parent property
  17720. * @param parent defines from where the animation should start (animation frame)
  17721. * @param condition defines the trigger related conditions
  17722. */
  17723. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17724. /** @hidden */
  17725. _prepare(): void;
  17726. /**
  17727. * Execute the action and set the parent property.
  17728. */
  17729. execute(): void;
  17730. /**
  17731. * Serializes the actions and its related information.
  17732. * @param parent defines the object to serialize in
  17733. * @returns the serialized object
  17734. */
  17735. serialize(parent: any): any;
  17736. }
  17737. }
  17738. declare module BABYLON {
  17739. /**
  17740. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17741. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17743. */
  17744. export class ActionManager extends AbstractActionManager {
  17745. /**
  17746. * Nothing
  17747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17748. */
  17749. static readonly NothingTrigger: number;
  17750. /**
  17751. * On pick
  17752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17753. */
  17754. static readonly OnPickTrigger: number;
  17755. /**
  17756. * On left pick
  17757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17758. */
  17759. static readonly OnLeftPickTrigger: number;
  17760. /**
  17761. * On right pick
  17762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17763. */
  17764. static readonly OnRightPickTrigger: number;
  17765. /**
  17766. * On center pick
  17767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17768. */
  17769. static readonly OnCenterPickTrigger: number;
  17770. /**
  17771. * On pick down
  17772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17773. */
  17774. static readonly OnPickDownTrigger: number;
  17775. /**
  17776. * On double pick
  17777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17778. */
  17779. static readonly OnDoublePickTrigger: number;
  17780. /**
  17781. * On pick up
  17782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17783. */
  17784. static readonly OnPickUpTrigger: number;
  17785. /**
  17786. * On pick out.
  17787. * This trigger will only be raised if you also declared a OnPickDown
  17788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17789. */
  17790. static readonly OnPickOutTrigger: number;
  17791. /**
  17792. * On long press
  17793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17794. */
  17795. static readonly OnLongPressTrigger: number;
  17796. /**
  17797. * On pointer over
  17798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17799. */
  17800. static readonly OnPointerOverTrigger: number;
  17801. /**
  17802. * On pointer out
  17803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17804. */
  17805. static readonly OnPointerOutTrigger: number;
  17806. /**
  17807. * On every frame
  17808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17809. */
  17810. static readonly OnEveryFrameTrigger: number;
  17811. /**
  17812. * On intersection enter
  17813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17814. */
  17815. static readonly OnIntersectionEnterTrigger: number;
  17816. /**
  17817. * On intersection exit
  17818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17819. */
  17820. static readonly OnIntersectionExitTrigger: number;
  17821. /**
  17822. * On key down
  17823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17824. */
  17825. static readonly OnKeyDownTrigger: number;
  17826. /**
  17827. * On key up
  17828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17829. */
  17830. static readonly OnKeyUpTrigger: number;
  17831. private _scene;
  17832. /**
  17833. * Creates a new action manager
  17834. * @param scene defines the hosting scene
  17835. */
  17836. constructor(scene: Scene);
  17837. /**
  17838. * Releases all associated resources
  17839. */
  17840. dispose(): void;
  17841. /**
  17842. * Gets hosting scene
  17843. * @returns the hosting scene
  17844. */
  17845. getScene(): Scene;
  17846. /**
  17847. * Does this action manager handles actions of any of the given triggers
  17848. * @param triggers defines the triggers to be tested
  17849. * @return a boolean indicating whether one (or more) of the triggers is handled
  17850. */
  17851. hasSpecificTriggers(triggers: number[]): boolean;
  17852. /**
  17853. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17854. * speed.
  17855. * @param triggerA defines the trigger to be tested
  17856. * @param triggerB defines the trigger to be tested
  17857. * @return a boolean indicating whether one (or more) of the triggers is handled
  17858. */
  17859. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17860. /**
  17861. * Does this action manager handles actions of a given trigger
  17862. * @param trigger defines the trigger to be tested
  17863. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17864. * @return whether the trigger is handled
  17865. */
  17866. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17867. /**
  17868. * Does this action manager has pointer triggers
  17869. */
  17870. get hasPointerTriggers(): boolean;
  17871. /**
  17872. * Does this action manager has pick triggers
  17873. */
  17874. get hasPickTriggers(): boolean;
  17875. /**
  17876. * Registers an action to this action manager
  17877. * @param action defines the action to be registered
  17878. * @return the action amended (prepared) after registration
  17879. */
  17880. registerAction(action: IAction): Nullable<IAction>;
  17881. /**
  17882. * Unregisters an action to this action manager
  17883. * @param action defines the action to be unregistered
  17884. * @return a boolean indicating whether the action has been unregistered
  17885. */
  17886. unregisterAction(action: IAction): Boolean;
  17887. /**
  17888. * Process a specific trigger
  17889. * @param trigger defines the trigger to process
  17890. * @param evt defines the event details to be processed
  17891. */
  17892. processTrigger(trigger: number, evt?: IActionEvent): void;
  17893. /** @hidden */
  17894. _getEffectiveTarget(target: any, propertyPath: string): any;
  17895. /** @hidden */
  17896. _getProperty(propertyPath: string): string;
  17897. /**
  17898. * Serialize this manager to a JSON object
  17899. * @param name defines the property name to store this manager
  17900. * @returns a JSON representation of this manager
  17901. */
  17902. serialize(name: string): any;
  17903. /**
  17904. * Creates a new ActionManager from a JSON data
  17905. * @param parsedActions defines the JSON data to read from
  17906. * @param object defines the hosting mesh
  17907. * @param scene defines the hosting scene
  17908. */
  17909. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17910. /**
  17911. * Get a trigger name by index
  17912. * @param trigger defines the trigger index
  17913. * @returns a trigger name
  17914. */
  17915. static GetTriggerName(trigger: number): string;
  17916. }
  17917. }
  17918. declare module BABYLON {
  17919. /**
  17920. * Class used to represent a sprite
  17921. * @see http://doc.babylonjs.com/babylon101/sprites
  17922. */
  17923. export class Sprite {
  17924. /** defines the name */
  17925. name: string;
  17926. /** Gets or sets the current world position */
  17927. position: Vector3;
  17928. /** Gets or sets the main color */
  17929. color: Color4;
  17930. /** Gets or sets the width */
  17931. width: number;
  17932. /** Gets or sets the height */
  17933. height: number;
  17934. /** Gets or sets rotation angle */
  17935. angle: number;
  17936. /** Gets or sets the cell index in the sprite sheet */
  17937. cellIndex: number;
  17938. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17939. cellRef: string;
  17940. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17941. invertU: number;
  17942. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17943. invertV: number;
  17944. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17945. disposeWhenFinishedAnimating: boolean;
  17946. /** Gets the list of attached animations */
  17947. animations: Animation[];
  17948. /** Gets or sets a boolean indicating if the sprite can be picked */
  17949. isPickable: boolean;
  17950. /**
  17951. * Gets or sets the associated action manager
  17952. */
  17953. actionManager: Nullable<ActionManager>;
  17954. private _animationStarted;
  17955. private _loopAnimation;
  17956. private _fromIndex;
  17957. private _toIndex;
  17958. private _delay;
  17959. private _direction;
  17960. private _manager;
  17961. private _time;
  17962. private _onAnimationEnd;
  17963. /**
  17964. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17965. */
  17966. isVisible: boolean;
  17967. /**
  17968. * Gets or sets the sprite size
  17969. */
  17970. get size(): number;
  17971. set size(value: number);
  17972. /**
  17973. * Creates a new Sprite
  17974. * @param name defines the name
  17975. * @param manager defines the manager
  17976. */
  17977. constructor(
  17978. /** defines the name */
  17979. name: string, manager: ISpriteManager);
  17980. /**
  17981. * Starts an animation
  17982. * @param from defines the initial key
  17983. * @param to defines the end key
  17984. * @param loop defines if the animation must loop
  17985. * @param delay defines the start delay (in ms)
  17986. * @param onAnimationEnd defines a callback to call when animation ends
  17987. */
  17988. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17989. /** Stops current animation (if any) */
  17990. stopAnimation(): void;
  17991. /** @hidden */
  17992. _animate(deltaTime: number): void;
  17993. /** Release associated resources */
  17994. dispose(): void;
  17995. }
  17996. }
  17997. declare module BABYLON {
  17998. /**
  17999. * Information about the result of picking within a scene
  18000. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18001. */
  18002. export class PickingInfo {
  18003. /** @hidden */
  18004. _pickingUnavailable: boolean;
  18005. /**
  18006. * If the pick collided with an object
  18007. */
  18008. hit: boolean;
  18009. /**
  18010. * Distance away where the pick collided
  18011. */
  18012. distance: number;
  18013. /**
  18014. * The location of pick collision
  18015. */
  18016. pickedPoint: Nullable<Vector3>;
  18017. /**
  18018. * The mesh corresponding the the pick collision
  18019. */
  18020. pickedMesh: Nullable<AbstractMesh>;
  18021. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18022. bu: number;
  18023. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18024. bv: number;
  18025. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18026. faceId: number;
  18027. /** Id of the the submesh that was picked */
  18028. subMeshId: number;
  18029. /** If a sprite was picked, this will be the sprite the pick collided with */
  18030. pickedSprite: Nullable<Sprite>;
  18031. /**
  18032. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18033. */
  18034. originMesh: Nullable<AbstractMesh>;
  18035. /**
  18036. * The ray that was used to perform the picking.
  18037. */
  18038. ray: Nullable<Ray>;
  18039. /**
  18040. * Gets the normal correspodning to the face the pick collided with
  18041. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18042. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18043. * @returns The normal correspodning to the face the pick collided with
  18044. */
  18045. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18046. /**
  18047. * Gets the texture coordinates of where the pick occured
  18048. * @returns the vector containing the coordnates of the texture
  18049. */
  18050. getTextureCoordinates(): Nullable<Vector2>;
  18051. }
  18052. }
  18053. declare module BABYLON {
  18054. /**
  18055. * Gather the list of pointer event types as constants.
  18056. */
  18057. export class PointerEventTypes {
  18058. /**
  18059. * 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.
  18060. */
  18061. static readonly POINTERDOWN: number;
  18062. /**
  18063. * The pointerup event is fired when a pointer is no longer active.
  18064. */
  18065. static readonly POINTERUP: number;
  18066. /**
  18067. * The pointermove event is fired when a pointer changes coordinates.
  18068. */
  18069. static readonly POINTERMOVE: number;
  18070. /**
  18071. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18072. */
  18073. static readonly POINTERWHEEL: number;
  18074. /**
  18075. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18076. */
  18077. static readonly POINTERPICK: number;
  18078. /**
  18079. * The pointertap event is fired when a the object has been touched and released without drag.
  18080. */
  18081. static readonly POINTERTAP: number;
  18082. /**
  18083. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18084. */
  18085. static readonly POINTERDOUBLETAP: number;
  18086. }
  18087. /**
  18088. * Base class of pointer info types.
  18089. */
  18090. export class PointerInfoBase {
  18091. /**
  18092. * Defines the type of event (PointerEventTypes)
  18093. */
  18094. type: number;
  18095. /**
  18096. * Defines the related dom event
  18097. */
  18098. event: PointerEvent | MouseWheelEvent;
  18099. /**
  18100. * Instantiates the base class of pointers info.
  18101. * @param type Defines the type of event (PointerEventTypes)
  18102. * @param event Defines the related dom event
  18103. */
  18104. constructor(
  18105. /**
  18106. * Defines the type of event (PointerEventTypes)
  18107. */
  18108. type: number,
  18109. /**
  18110. * Defines the related dom event
  18111. */
  18112. event: PointerEvent | MouseWheelEvent);
  18113. }
  18114. /**
  18115. * This class is used to store pointer related info for the onPrePointerObservable event.
  18116. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18117. */
  18118. export class PointerInfoPre extends PointerInfoBase {
  18119. /**
  18120. * Ray from a pointer if availible (eg. 6dof controller)
  18121. */
  18122. ray: Nullable<Ray>;
  18123. /**
  18124. * Defines the local position of the pointer on the canvas.
  18125. */
  18126. localPosition: Vector2;
  18127. /**
  18128. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18129. */
  18130. skipOnPointerObservable: boolean;
  18131. /**
  18132. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18133. * @param type Defines the type of event (PointerEventTypes)
  18134. * @param event Defines the related dom event
  18135. * @param localX Defines the local x coordinates of the pointer when the event occured
  18136. * @param localY Defines the local y coordinates of the pointer when the event occured
  18137. */
  18138. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18139. }
  18140. /**
  18141. * This type contains all the data related to a pointer event in Babylon.js.
  18142. * 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.
  18143. */
  18144. export class PointerInfo extends PointerInfoBase {
  18145. /**
  18146. * Defines the picking info associated to the info (if any)\
  18147. */
  18148. pickInfo: Nullable<PickingInfo>;
  18149. /**
  18150. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18151. * @param type Defines the type of event (PointerEventTypes)
  18152. * @param event Defines the related dom event
  18153. * @param pickInfo Defines the picking info associated to the info (if any)\
  18154. */
  18155. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18156. /**
  18157. * Defines the picking info associated to the info (if any)\
  18158. */
  18159. pickInfo: Nullable<PickingInfo>);
  18160. }
  18161. /**
  18162. * Data relating to a touch event on the screen.
  18163. */
  18164. export interface PointerTouch {
  18165. /**
  18166. * X coordinate of touch.
  18167. */
  18168. x: number;
  18169. /**
  18170. * Y coordinate of touch.
  18171. */
  18172. y: number;
  18173. /**
  18174. * Id of touch. Unique for each finger.
  18175. */
  18176. pointerId: number;
  18177. /**
  18178. * Event type passed from DOM.
  18179. */
  18180. type: any;
  18181. }
  18182. }
  18183. declare module BABYLON {
  18184. /**
  18185. * Manage the mouse inputs to control the movement of a free camera.
  18186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18187. */
  18188. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18189. /**
  18190. * Define if touch is enabled in the mouse input
  18191. */
  18192. touchEnabled: boolean;
  18193. /**
  18194. * Defines the camera the input is attached to.
  18195. */
  18196. camera: FreeCamera;
  18197. /**
  18198. * Defines the buttons associated with the input to handle camera move.
  18199. */
  18200. buttons: number[];
  18201. /**
  18202. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18203. */
  18204. angularSensibility: number;
  18205. private _pointerInput;
  18206. private _onMouseMove;
  18207. private _observer;
  18208. private previousPosition;
  18209. /**
  18210. * Observable for when a pointer move event occurs containing the move offset
  18211. */
  18212. onPointerMovedObservable: Observable<{
  18213. offsetX: number;
  18214. offsetY: number;
  18215. }>;
  18216. /**
  18217. * @hidden
  18218. * If the camera should be rotated automatically based on pointer movement
  18219. */
  18220. _allowCameraRotation: boolean;
  18221. /**
  18222. * Manage the mouse inputs to control the movement of a free camera.
  18223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18224. * @param touchEnabled Defines if touch is enabled or not
  18225. */
  18226. constructor(
  18227. /**
  18228. * Define if touch is enabled in the mouse input
  18229. */
  18230. touchEnabled?: boolean);
  18231. /**
  18232. * Attach the input controls to a specific dom element to get the input from.
  18233. * @param element Defines the element the controls should be listened from
  18234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18235. */
  18236. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18237. /**
  18238. * Called on JS contextmenu event.
  18239. * Override this method to provide functionality.
  18240. */
  18241. protected onContextMenu(evt: PointerEvent): void;
  18242. /**
  18243. * Detach the current controls from the specified dom element.
  18244. * @param element Defines the element to stop listening the inputs from
  18245. */
  18246. detachControl(element: Nullable<HTMLElement>): void;
  18247. /**
  18248. * Gets the class name of the current intput.
  18249. * @returns the class name
  18250. */
  18251. getClassName(): string;
  18252. /**
  18253. * Get the friendly name associated with the input class.
  18254. * @returns the input friendly name
  18255. */
  18256. getSimpleName(): string;
  18257. }
  18258. }
  18259. declare module BABYLON {
  18260. /**
  18261. * Manage the touch inputs to control the movement of a free camera.
  18262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18263. */
  18264. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18265. /**
  18266. * Defines the camera the input is attached to.
  18267. */
  18268. camera: FreeCamera;
  18269. /**
  18270. * Defines the touch sensibility for rotation.
  18271. * The higher the faster.
  18272. */
  18273. touchAngularSensibility: number;
  18274. /**
  18275. * Defines the touch sensibility for move.
  18276. * The higher the faster.
  18277. */
  18278. touchMoveSensibility: number;
  18279. private _offsetX;
  18280. private _offsetY;
  18281. private _pointerPressed;
  18282. private _pointerInput;
  18283. private _observer;
  18284. private _onLostFocus;
  18285. /**
  18286. * Attach the input controls to a specific dom element to get the input from.
  18287. * @param element Defines the element the controls should be listened from
  18288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18289. */
  18290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18291. /**
  18292. * Detach the current controls from the specified dom element.
  18293. * @param element Defines the element to stop listening the inputs from
  18294. */
  18295. detachControl(element: Nullable<HTMLElement>): void;
  18296. /**
  18297. * Update the current camera state depending on the inputs that have been used this frame.
  18298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18299. */
  18300. checkInputs(): void;
  18301. /**
  18302. * Gets the class name of the current intput.
  18303. * @returns the class name
  18304. */
  18305. getClassName(): string;
  18306. /**
  18307. * Get the friendly name associated with the input class.
  18308. * @returns the input friendly name
  18309. */
  18310. getSimpleName(): string;
  18311. }
  18312. }
  18313. declare module BABYLON {
  18314. /**
  18315. * Default Inputs manager for the FreeCamera.
  18316. * It groups all the default supported inputs for ease of use.
  18317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18318. */
  18319. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18320. /**
  18321. * @hidden
  18322. */
  18323. _mouseInput: Nullable<FreeCameraMouseInput>;
  18324. /**
  18325. * Instantiates a new FreeCameraInputsManager.
  18326. * @param camera Defines the camera the inputs belong to
  18327. */
  18328. constructor(camera: FreeCamera);
  18329. /**
  18330. * Add keyboard input support to the input manager.
  18331. * @returns the current input manager
  18332. */
  18333. addKeyboard(): FreeCameraInputsManager;
  18334. /**
  18335. * Add mouse input support to the input manager.
  18336. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18337. * @returns the current input manager
  18338. */
  18339. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18340. /**
  18341. * Removes the mouse input support from the manager
  18342. * @returns the current input manager
  18343. */
  18344. removeMouse(): FreeCameraInputsManager;
  18345. /**
  18346. * Add touch input support to the input manager.
  18347. * @returns the current input manager
  18348. */
  18349. addTouch(): FreeCameraInputsManager;
  18350. /**
  18351. * Remove all attached input methods from a camera
  18352. */
  18353. clear(): void;
  18354. }
  18355. }
  18356. declare module BABYLON {
  18357. /**
  18358. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18359. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18360. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18361. */
  18362. export class FreeCamera extends TargetCamera {
  18363. /**
  18364. * Define the collision ellipsoid of the camera.
  18365. * This is helpful to simulate a camera body like the player body around the camera
  18366. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18367. */
  18368. ellipsoid: Vector3;
  18369. /**
  18370. * Define an offset for the position of the ellipsoid around the camera.
  18371. * This can be helpful to determine the center of the body near the gravity center of the body
  18372. * instead of its head.
  18373. */
  18374. ellipsoidOffset: Vector3;
  18375. /**
  18376. * Enable or disable collisions of the camera with the rest of the scene objects.
  18377. */
  18378. checkCollisions: boolean;
  18379. /**
  18380. * Enable or disable gravity on the camera.
  18381. */
  18382. applyGravity: boolean;
  18383. /**
  18384. * Define the input manager associated to the camera.
  18385. */
  18386. inputs: FreeCameraInputsManager;
  18387. /**
  18388. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18389. * Higher values reduce sensitivity.
  18390. */
  18391. get angularSensibility(): number;
  18392. /**
  18393. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18394. * Higher values reduce sensitivity.
  18395. */
  18396. set angularSensibility(value: number);
  18397. /**
  18398. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18399. */
  18400. get keysUp(): number[];
  18401. set keysUp(value: number[]);
  18402. /**
  18403. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18404. */
  18405. get keysUpward(): number[];
  18406. set keysUpward(value: number[]);
  18407. /**
  18408. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18409. */
  18410. get keysDown(): number[];
  18411. set keysDown(value: number[]);
  18412. /**
  18413. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18414. */
  18415. get keysDownward(): number[];
  18416. set keysDownward(value: number[]);
  18417. /**
  18418. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18419. */
  18420. get keysLeft(): number[];
  18421. set keysLeft(value: number[]);
  18422. /**
  18423. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18424. */
  18425. get keysRight(): number[];
  18426. set keysRight(value: number[]);
  18427. /**
  18428. * Event raised when the camera collide with a mesh in the scene.
  18429. */
  18430. onCollide: (collidedMesh: AbstractMesh) => void;
  18431. private _collider;
  18432. private _needMoveForGravity;
  18433. private _oldPosition;
  18434. private _diffPosition;
  18435. private _newPosition;
  18436. /** @hidden */
  18437. _localDirection: Vector3;
  18438. /** @hidden */
  18439. _transformedDirection: Vector3;
  18440. /**
  18441. * Instantiates a Free Camera.
  18442. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18443. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18444. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18445. * @param name Define the name of the camera in the scene
  18446. * @param position Define the start position of the camera in the scene
  18447. * @param scene Define the scene the camera belongs to
  18448. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18449. */
  18450. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18451. /**
  18452. * Attached controls to the current camera.
  18453. * @param element Defines the element the controls should be listened from
  18454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18455. */
  18456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18457. /**
  18458. * Detach the current controls from the camera.
  18459. * The camera will stop reacting to inputs.
  18460. * @param element Defines the element to stop listening the inputs from
  18461. */
  18462. detachControl(element: HTMLElement): void;
  18463. private _collisionMask;
  18464. /**
  18465. * Define a collision mask to limit the list of object the camera can collide with
  18466. */
  18467. get collisionMask(): number;
  18468. set collisionMask(mask: number);
  18469. /** @hidden */
  18470. _collideWithWorld(displacement: Vector3): void;
  18471. private _onCollisionPositionChange;
  18472. /** @hidden */
  18473. _checkInputs(): void;
  18474. /** @hidden */
  18475. _decideIfNeedsToMove(): boolean;
  18476. /** @hidden */
  18477. _updatePosition(): void;
  18478. /**
  18479. * Destroy the camera and release the current resources hold by it.
  18480. */
  18481. dispose(): void;
  18482. /**
  18483. * Gets the current object class name.
  18484. * @return the class name
  18485. */
  18486. getClassName(): string;
  18487. }
  18488. }
  18489. declare module BABYLON {
  18490. /**
  18491. * Represents a gamepad control stick position
  18492. */
  18493. export class StickValues {
  18494. /**
  18495. * The x component of the control stick
  18496. */
  18497. x: number;
  18498. /**
  18499. * The y component of the control stick
  18500. */
  18501. y: number;
  18502. /**
  18503. * Initializes the gamepad x and y control stick values
  18504. * @param x The x component of the gamepad control stick value
  18505. * @param y The y component of the gamepad control stick value
  18506. */
  18507. constructor(
  18508. /**
  18509. * The x component of the control stick
  18510. */
  18511. x: number,
  18512. /**
  18513. * The y component of the control stick
  18514. */
  18515. y: number);
  18516. }
  18517. /**
  18518. * An interface which manages callbacks for gamepad button changes
  18519. */
  18520. export interface GamepadButtonChanges {
  18521. /**
  18522. * Called when a gamepad has been changed
  18523. */
  18524. changed: boolean;
  18525. /**
  18526. * Called when a gamepad press event has been triggered
  18527. */
  18528. pressChanged: boolean;
  18529. /**
  18530. * Called when a touch event has been triggered
  18531. */
  18532. touchChanged: boolean;
  18533. /**
  18534. * Called when a value has changed
  18535. */
  18536. valueChanged: boolean;
  18537. }
  18538. /**
  18539. * Represents a gamepad
  18540. */
  18541. export class Gamepad {
  18542. /**
  18543. * The id of the gamepad
  18544. */
  18545. id: string;
  18546. /**
  18547. * The index of the gamepad
  18548. */
  18549. index: number;
  18550. /**
  18551. * The browser gamepad
  18552. */
  18553. browserGamepad: any;
  18554. /**
  18555. * Specifies what type of gamepad this represents
  18556. */
  18557. type: number;
  18558. private _leftStick;
  18559. private _rightStick;
  18560. /** @hidden */
  18561. _isConnected: boolean;
  18562. private _leftStickAxisX;
  18563. private _leftStickAxisY;
  18564. private _rightStickAxisX;
  18565. private _rightStickAxisY;
  18566. /**
  18567. * Triggered when the left control stick has been changed
  18568. */
  18569. private _onleftstickchanged;
  18570. /**
  18571. * Triggered when the right control stick has been changed
  18572. */
  18573. private _onrightstickchanged;
  18574. /**
  18575. * Represents a gamepad controller
  18576. */
  18577. static GAMEPAD: number;
  18578. /**
  18579. * Represents a generic controller
  18580. */
  18581. static GENERIC: number;
  18582. /**
  18583. * Represents an XBox controller
  18584. */
  18585. static XBOX: number;
  18586. /**
  18587. * Represents a pose-enabled controller
  18588. */
  18589. static POSE_ENABLED: number;
  18590. /**
  18591. * Represents an Dual Shock controller
  18592. */
  18593. static DUALSHOCK: number;
  18594. /**
  18595. * Specifies whether the left control stick should be Y-inverted
  18596. */
  18597. protected _invertLeftStickY: boolean;
  18598. /**
  18599. * Specifies if the gamepad has been connected
  18600. */
  18601. get isConnected(): boolean;
  18602. /**
  18603. * Initializes the gamepad
  18604. * @param id The id of the gamepad
  18605. * @param index The index of the gamepad
  18606. * @param browserGamepad The browser gamepad
  18607. * @param leftStickX The x component of the left joystick
  18608. * @param leftStickY The y component of the left joystick
  18609. * @param rightStickX The x component of the right joystick
  18610. * @param rightStickY The y component of the right joystick
  18611. */
  18612. constructor(
  18613. /**
  18614. * The id of the gamepad
  18615. */
  18616. id: string,
  18617. /**
  18618. * The index of the gamepad
  18619. */
  18620. index: number,
  18621. /**
  18622. * The browser gamepad
  18623. */
  18624. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18625. /**
  18626. * Callback triggered when the left joystick has changed
  18627. * @param callback
  18628. */
  18629. onleftstickchanged(callback: (values: StickValues) => void): void;
  18630. /**
  18631. * Callback triggered when the right joystick has changed
  18632. * @param callback
  18633. */
  18634. onrightstickchanged(callback: (values: StickValues) => void): void;
  18635. /**
  18636. * Gets the left joystick
  18637. */
  18638. get leftStick(): StickValues;
  18639. /**
  18640. * Sets the left joystick values
  18641. */
  18642. set leftStick(newValues: StickValues);
  18643. /**
  18644. * Gets the right joystick
  18645. */
  18646. get rightStick(): StickValues;
  18647. /**
  18648. * Sets the right joystick value
  18649. */
  18650. set rightStick(newValues: StickValues);
  18651. /**
  18652. * Updates the gamepad joystick positions
  18653. */
  18654. update(): void;
  18655. /**
  18656. * Disposes the gamepad
  18657. */
  18658. dispose(): void;
  18659. }
  18660. /**
  18661. * Represents a generic gamepad
  18662. */
  18663. export class GenericPad extends Gamepad {
  18664. private _buttons;
  18665. private _onbuttondown;
  18666. private _onbuttonup;
  18667. /**
  18668. * Observable triggered when a button has been pressed
  18669. */
  18670. onButtonDownObservable: Observable<number>;
  18671. /**
  18672. * Observable triggered when a button has been released
  18673. */
  18674. onButtonUpObservable: Observable<number>;
  18675. /**
  18676. * Callback triggered when a button has been pressed
  18677. * @param callback Called when a button has been pressed
  18678. */
  18679. onbuttondown(callback: (buttonPressed: number) => void): void;
  18680. /**
  18681. * Callback triggered when a button has been released
  18682. * @param callback Called when a button has been released
  18683. */
  18684. onbuttonup(callback: (buttonReleased: number) => void): void;
  18685. /**
  18686. * Initializes the generic gamepad
  18687. * @param id The id of the generic gamepad
  18688. * @param index The index of the generic gamepad
  18689. * @param browserGamepad The browser gamepad
  18690. */
  18691. constructor(id: string, index: number, browserGamepad: any);
  18692. private _setButtonValue;
  18693. /**
  18694. * Updates the generic gamepad
  18695. */
  18696. update(): void;
  18697. /**
  18698. * Disposes the generic gamepad
  18699. */
  18700. dispose(): void;
  18701. }
  18702. }
  18703. declare module BABYLON {
  18704. /**
  18705. * Defines the types of pose enabled controllers that are supported
  18706. */
  18707. export enum PoseEnabledControllerType {
  18708. /**
  18709. * HTC Vive
  18710. */
  18711. VIVE = 0,
  18712. /**
  18713. * Oculus Rift
  18714. */
  18715. OCULUS = 1,
  18716. /**
  18717. * Windows mixed reality
  18718. */
  18719. WINDOWS = 2,
  18720. /**
  18721. * Samsung gear VR
  18722. */
  18723. GEAR_VR = 3,
  18724. /**
  18725. * Google Daydream
  18726. */
  18727. DAYDREAM = 4,
  18728. /**
  18729. * Generic
  18730. */
  18731. GENERIC = 5
  18732. }
  18733. /**
  18734. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18735. */
  18736. export interface MutableGamepadButton {
  18737. /**
  18738. * Value of the button/trigger
  18739. */
  18740. value: number;
  18741. /**
  18742. * If the button/trigger is currently touched
  18743. */
  18744. touched: boolean;
  18745. /**
  18746. * If the button/trigger is currently pressed
  18747. */
  18748. pressed: boolean;
  18749. }
  18750. /**
  18751. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18752. * @hidden
  18753. */
  18754. export interface ExtendedGamepadButton extends GamepadButton {
  18755. /**
  18756. * If the button/trigger is currently pressed
  18757. */
  18758. readonly pressed: boolean;
  18759. /**
  18760. * If the button/trigger is currently touched
  18761. */
  18762. readonly touched: boolean;
  18763. /**
  18764. * Value of the button/trigger
  18765. */
  18766. readonly value: number;
  18767. }
  18768. /** @hidden */
  18769. export interface _GamePadFactory {
  18770. /**
  18771. * Returns whether or not the current gamepad can be created for this type of controller.
  18772. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18773. * @returns true if it can be created, otherwise false
  18774. */
  18775. canCreate(gamepadInfo: any): boolean;
  18776. /**
  18777. * Creates a new instance of the Gamepad.
  18778. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18779. * @returns the new gamepad instance
  18780. */
  18781. create(gamepadInfo: any): Gamepad;
  18782. }
  18783. /**
  18784. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18785. */
  18786. export class PoseEnabledControllerHelper {
  18787. /** @hidden */
  18788. static _ControllerFactories: _GamePadFactory[];
  18789. /** @hidden */
  18790. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18791. /**
  18792. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18793. * @param vrGamepad the gamepad to initialized
  18794. * @returns a vr controller of the type the gamepad identified as
  18795. */
  18796. static InitiateController(vrGamepad: any): Gamepad;
  18797. }
  18798. /**
  18799. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18800. */
  18801. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18802. /**
  18803. * If the controller is used in a webXR session
  18804. */
  18805. isXR: boolean;
  18806. private _deviceRoomPosition;
  18807. private _deviceRoomRotationQuaternion;
  18808. /**
  18809. * The device position in babylon space
  18810. */
  18811. devicePosition: Vector3;
  18812. /**
  18813. * The device rotation in babylon space
  18814. */
  18815. deviceRotationQuaternion: Quaternion;
  18816. /**
  18817. * The scale factor of the device in babylon space
  18818. */
  18819. deviceScaleFactor: number;
  18820. /**
  18821. * (Likely devicePosition should be used instead) The device position in its room space
  18822. */
  18823. position: Vector3;
  18824. /**
  18825. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18826. */
  18827. rotationQuaternion: Quaternion;
  18828. /**
  18829. * The type of controller (Eg. Windows mixed reality)
  18830. */
  18831. controllerType: PoseEnabledControllerType;
  18832. protected _calculatedPosition: Vector3;
  18833. private _calculatedRotation;
  18834. /**
  18835. * The raw pose from the device
  18836. */
  18837. rawPose: DevicePose;
  18838. private _trackPosition;
  18839. private _maxRotationDistFromHeadset;
  18840. private _draggedRoomRotation;
  18841. /**
  18842. * @hidden
  18843. */
  18844. _disableTrackPosition(fixedPosition: Vector3): void;
  18845. /**
  18846. * Internal, the mesh attached to the controller
  18847. * @hidden
  18848. */
  18849. _mesh: Nullable<AbstractMesh>;
  18850. private _poseControlledCamera;
  18851. private _leftHandSystemQuaternion;
  18852. /**
  18853. * Internal, matrix used to convert room space to babylon space
  18854. * @hidden
  18855. */
  18856. _deviceToWorld: Matrix;
  18857. /**
  18858. * Node to be used when casting a ray from the controller
  18859. * @hidden
  18860. */
  18861. _pointingPoseNode: Nullable<TransformNode>;
  18862. /**
  18863. * Name of the child mesh that can be used to cast a ray from the controller
  18864. */
  18865. static readonly POINTING_POSE: string;
  18866. /**
  18867. * Creates a new PoseEnabledController from a gamepad
  18868. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18869. */
  18870. constructor(browserGamepad: any);
  18871. private _workingMatrix;
  18872. /**
  18873. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18874. */
  18875. update(): void;
  18876. /**
  18877. * Updates only the pose device and mesh without doing any button event checking
  18878. */
  18879. protected _updatePoseAndMesh(): void;
  18880. /**
  18881. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18882. * @param poseData raw pose fromthe device
  18883. */
  18884. updateFromDevice(poseData: DevicePose): void;
  18885. /**
  18886. * @hidden
  18887. */
  18888. _meshAttachedObservable: Observable<AbstractMesh>;
  18889. /**
  18890. * Attaches a mesh to the controller
  18891. * @param mesh the mesh to be attached
  18892. */
  18893. attachToMesh(mesh: AbstractMesh): void;
  18894. /**
  18895. * Attaches the controllers mesh to a camera
  18896. * @param camera the camera the mesh should be attached to
  18897. */
  18898. attachToPoseControlledCamera(camera: TargetCamera): void;
  18899. /**
  18900. * Disposes of the controller
  18901. */
  18902. dispose(): void;
  18903. /**
  18904. * The mesh that is attached to the controller
  18905. */
  18906. get mesh(): Nullable<AbstractMesh>;
  18907. /**
  18908. * Gets the ray of the controller in the direction the controller is pointing
  18909. * @param length the length the resulting ray should be
  18910. * @returns a ray in the direction the controller is pointing
  18911. */
  18912. getForwardRay(length?: number): Ray;
  18913. }
  18914. }
  18915. declare module BABYLON {
  18916. /**
  18917. * Defines the WebVRController object that represents controllers tracked in 3D space
  18918. */
  18919. export abstract class WebVRController extends PoseEnabledController {
  18920. /**
  18921. * Internal, the default controller model for the controller
  18922. */
  18923. protected _defaultModel: Nullable<AbstractMesh>;
  18924. /**
  18925. * Fired when the trigger state has changed
  18926. */
  18927. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18928. /**
  18929. * Fired when the main button state has changed
  18930. */
  18931. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18932. /**
  18933. * Fired when the secondary button state has changed
  18934. */
  18935. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18936. /**
  18937. * Fired when the pad state has changed
  18938. */
  18939. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18940. /**
  18941. * Fired when controllers stick values have changed
  18942. */
  18943. onPadValuesChangedObservable: Observable<StickValues>;
  18944. /**
  18945. * Array of button availible on the controller
  18946. */
  18947. protected _buttons: Array<MutableGamepadButton>;
  18948. private _onButtonStateChange;
  18949. /**
  18950. * Fired when a controller button's state has changed
  18951. * @param callback the callback containing the button that was modified
  18952. */
  18953. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18954. /**
  18955. * X and Y axis corresponding to the controllers joystick
  18956. */
  18957. pad: StickValues;
  18958. /**
  18959. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18960. */
  18961. hand: string;
  18962. /**
  18963. * The default controller model for the controller
  18964. */
  18965. get defaultModel(): Nullable<AbstractMesh>;
  18966. /**
  18967. * Creates a new WebVRController from a gamepad
  18968. * @param vrGamepad the gamepad that the WebVRController should be created from
  18969. */
  18970. constructor(vrGamepad: any);
  18971. /**
  18972. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18973. */
  18974. update(): void;
  18975. /**
  18976. * Function to be called when a button is modified
  18977. */
  18978. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18979. /**
  18980. * Loads a mesh and attaches it to the controller
  18981. * @param scene the scene the mesh should be added to
  18982. * @param meshLoaded callback for when the mesh has been loaded
  18983. */
  18984. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18985. private _setButtonValue;
  18986. private _changes;
  18987. private _checkChanges;
  18988. /**
  18989. * Disposes of th webVRCOntroller
  18990. */
  18991. dispose(): void;
  18992. }
  18993. }
  18994. declare module BABYLON {
  18995. /**
  18996. * The HemisphericLight simulates the ambient environment light,
  18997. * so the passed direction is the light reflection direction, not the incoming direction.
  18998. */
  18999. export class HemisphericLight extends Light {
  19000. /**
  19001. * The groundColor is the light in the opposite direction to the one specified during creation.
  19002. * 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.
  19003. */
  19004. groundColor: Color3;
  19005. /**
  19006. * The light reflection direction, not the incoming direction.
  19007. */
  19008. direction: Vector3;
  19009. /**
  19010. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19011. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19012. * The HemisphericLight can't cast shadows.
  19013. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19014. * @param name The friendly name of the light
  19015. * @param direction The direction of the light reflection
  19016. * @param scene The scene the light belongs to
  19017. */
  19018. constructor(name: string, direction: Vector3, scene: Scene);
  19019. protected _buildUniformLayout(): void;
  19020. /**
  19021. * Returns the string "HemisphericLight".
  19022. * @return The class name
  19023. */
  19024. getClassName(): string;
  19025. /**
  19026. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19027. * Returns the updated direction.
  19028. * @param target The target the direction should point to
  19029. * @return The computed direction
  19030. */
  19031. setDirectionToTarget(target: Vector3): Vector3;
  19032. /**
  19033. * Returns the shadow generator associated to the light.
  19034. * @returns Always null for hemispheric lights because it does not support shadows.
  19035. */
  19036. getShadowGenerator(): Nullable<IShadowGenerator>;
  19037. /**
  19038. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19039. * @param effect The effect to update
  19040. * @param lightIndex The index of the light in the effect to update
  19041. * @returns The hemispheric light
  19042. */
  19043. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19044. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19045. /**
  19046. * Computes the world matrix of the node
  19047. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19048. * @param useWasUpdatedFlag defines a reserved property
  19049. * @returns the world matrix
  19050. */
  19051. computeWorldMatrix(): Matrix;
  19052. /**
  19053. * Returns the integer 3.
  19054. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19055. */
  19056. getTypeID(): number;
  19057. /**
  19058. * Prepares the list of defines specific to the light type.
  19059. * @param defines the list of defines
  19060. * @param lightIndex defines the index of the light for the effect
  19061. */
  19062. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19063. }
  19064. }
  19065. declare module BABYLON {
  19066. /** @hidden */
  19067. export var vrMultiviewToSingleviewPixelShader: {
  19068. name: string;
  19069. shader: string;
  19070. };
  19071. }
  19072. declare module BABYLON {
  19073. /**
  19074. * Renders to multiple views with a single draw call
  19075. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19076. */
  19077. export class MultiviewRenderTarget extends RenderTargetTexture {
  19078. /**
  19079. * Creates a multiview render target
  19080. * @param scene scene used with the render target
  19081. * @param size the size of the render target (used for each view)
  19082. */
  19083. constructor(scene: Scene, size?: number | {
  19084. width: number;
  19085. height: number;
  19086. } | {
  19087. ratio: number;
  19088. });
  19089. /**
  19090. * @hidden
  19091. * @param faceIndex the face index, if its a cube texture
  19092. */
  19093. _bindFrameBuffer(faceIndex?: number): void;
  19094. /**
  19095. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19096. * @returns the view count
  19097. */
  19098. getViewCount(): number;
  19099. }
  19100. }
  19101. declare module BABYLON {
  19102. /**
  19103. * Represents a camera frustum
  19104. */
  19105. export class Frustum {
  19106. /**
  19107. * Gets the planes representing the frustum
  19108. * @param transform matrix to be applied to the returned planes
  19109. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19110. */
  19111. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19112. /**
  19113. * Gets the near frustum plane transformed by the transform matrix
  19114. * @param transform transformation matrix to be applied to the resulting frustum plane
  19115. * @param frustumPlane the resuling frustum plane
  19116. */
  19117. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19118. /**
  19119. * Gets the far frustum plane transformed by the transform matrix
  19120. * @param transform transformation matrix to be applied to the resulting frustum plane
  19121. * @param frustumPlane the resuling frustum plane
  19122. */
  19123. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19124. /**
  19125. * Gets the left frustum plane transformed by the transform matrix
  19126. * @param transform transformation matrix to be applied to the resulting frustum plane
  19127. * @param frustumPlane the resuling frustum plane
  19128. */
  19129. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19130. /**
  19131. * Gets the right frustum plane transformed by the transform matrix
  19132. * @param transform transformation matrix to be applied to the resulting frustum plane
  19133. * @param frustumPlane the resuling frustum plane
  19134. */
  19135. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19136. /**
  19137. * Gets the top frustum plane transformed by the transform matrix
  19138. * @param transform transformation matrix to be applied to the resulting frustum plane
  19139. * @param frustumPlane the resuling frustum plane
  19140. */
  19141. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19142. /**
  19143. * Gets the bottom frustum plane transformed by the transform matrix
  19144. * @param transform transformation matrix to be applied to the resulting frustum plane
  19145. * @param frustumPlane the resuling frustum plane
  19146. */
  19147. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19148. /**
  19149. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19150. * @param transform transformation matrix to be applied to the resulting frustum planes
  19151. * @param frustumPlanes the resuling frustum planes
  19152. */
  19153. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19154. }
  19155. }
  19156. declare module BABYLON {
  19157. interface Engine {
  19158. /**
  19159. * Creates a new multiview render target
  19160. * @param width defines the width of the texture
  19161. * @param height defines the height of the texture
  19162. * @returns the created multiview texture
  19163. */
  19164. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19165. /**
  19166. * Binds a multiview framebuffer to be drawn to
  19167. * @param multiviewTexture texture to bind
  19168. */
  19169. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19170. }
  19171. interface Camera {
  19172. /**
  19173. * @hidden
  19174. * 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)
  19175. */
  19176. _useMultiviewToSingleView: boolean;
  19177. /**
  19178. * @hidden
  19179. * 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)
  19180. */
  19181. _multiviewTexture: Nullable<RenderTargetTexture>;
  19182. /**
  19183. * @hidden
  19184. * ensures the multiview texture of the camera exists and has the specified width/height
  19185. * @param width height to set on the multiview texture
  19186. * @param height width to set on the multiview texture
  19187. */
  19188. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19189. }
  19190. interface Scene {
  19191. /** @hidden */
  19192. _transformMatrixR: Matrix;
  19193. /** @hidden */
  19194. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19195. /** @hidden */
  19196. _createMultiviewUbo(): void;
  19197. /** @hidden */
  19198. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19199. /** @hidden */
  19200. _renderMultiviewToSingleView(camera: Camera): void;
  19201. }
  19202. }
  19203. declare module BABYLON {
  19204. /**
  19205. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19206. * This will not be used for webXR as it supports displaying texture arrays directly
  19207. */
  19208. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19209. /**
  19210. * Initializes a VRMultiviewToSingleview
  19211. * @param name name of the post process
  19212. * @param camera camera to be applied to
  19213. * @param scaleFactor scaling factor to the size of the output texture
  19214. */
  19215. constructor(name: string, camera: Camera, scaleFactor: number);
  19216. }
  19217. }
  19218. declare module BABYLON {
  19219. /**
  19220. * Interface used to define additional presentation attributes
  19221. */
  19222. export interface IVRPresentationAttributes {
  19223. /**
  19224. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19225. */
  19226. highRefreshRate: boolean;
  19227. /**
  19228. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19229. */
  19230. foveationLevel: number;
  19231. }
  19232. interface Engine {
  19233. /** @hidden */
  19234. _vrDisplay: any;
  19235. /** @hidden */
  19236. _vrSupported: boolean;
  19237. /** @hidden */
  19238. _oldSize: Size;
  19239. /** @hidden */
  19240. _oldHardwareScaleFactor: number;
  19241. /** @hidden */
  19242. _vrExclusivePointerMode: boolean;
  19243. /** @hidden */
  19244. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19245. /** @hidden */
  19246. _onVRDisplayPointerRestricted: () => void;
  19247. /** @hidden */
  19248. _onVRDisplayPointerUnrestricted: () => void;
  19249. /** @hidden */
  19250. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19251. /** @hidden */
  19252. _onVrDisplayDisconnect: Nullable<() => void>;
  19253. /** @hidden */
  19254. _onVrDisplayPresentChange: Nullable<() => void>;
  19255. /**
  19256. * Observable signaled when VR display mode changes
  19257. */
  19258. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19259. /**
  19260. * Observable signaled when VR request present is complete
  19261. */
  19262. onVRRequestPresentComplete: Observable<boolean>;
  19263. /**
  19264. * Observable signaled when VR request present starts
  19265. */
  19266. onVRRequestPresentStart: Observable<Engine>;
  19267. /**
  19268. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19269. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19270. */
  19271. isInVRExclusivePointerMode: boolean;
  19272. /**
  19273. * Gets a boolean indicating if a webVR device was detected
  19274. * @returns true if a webVR device was detected
  19275. */
  19276. isVRDevicePresent(): boolean;
  19277. /**
  19278. * Gets the current webVR device
  19279. * @returns the current webVR device (or null)
  19280. */
  19281. getVRDevice(): any;
  19282. /**
  19283. * Initializes a webVR display and starts listening to display change events
  19284. * The onVRDisplayChangedObservable will be notified upon these changes
  19285. * @returns A promise containing a VRDisplay and if vr is supported
  19286. */
  19287. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19288. /** @hidden */
  19289. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19290. /**
  19291. * Gets or sets the presentation attributes used to configure VR rendering
  19292. */
  19293. vrPresentationAttributes?: IVRPresentationAttributes;
  19294. /**
  19295. * Call this function to switch to webVR mode
  19296. * Will do nothing if webVR is not supported or if there is no webVR device
  19297. * @param options the webvr options provided to the camera. mainly used for multiview
  19298. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19299. */
  19300. enableVR(options: WebVROptions): void;
  19301. /** @hidden */
  19302. _onVRFullScreenTriggered(): void;
  19303. }
  19304. }
  19305. declare module BABYLON {
  19306. /**
  19307. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19308. * IMPORTANT!! The data is right-hand data.
  19309. * @export
  19310. * @interface DevicePose
  19311. */
  19312. export interface DevicePose {
  19313. /**
  19314. * The position of the device, values in array are [x,y,z].
  19315. */
  19316. readonly position: Nullable<Float32Array>;
  19317. /**
  19318. * The linearVelocity of the device, values in array are [x,y,z].
  19319. */
  19320. readonly linearVelocity: Nullable<Float32Array>;
  19321. /**
  19322. * The linearAcceleration of the device, values in array are [x,y,z].
  19323. */
  19324. readonly linearAcceleration: Nullable<Float32Array>;
  19325. /**
  19326. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19327. */
  19328. readonly orientation: Nullable<Float32Array>;
  19329. /**
  19330. * The angularVelocity of the device, values in array are [x,y,z].
  19331. */
  19332. readonly angularVelocity: Nullable<Float32Array>;
  19333. /**
  19334. * The angularAcceleration of the device, values in array are [x,y,z].
  19335. */
  19336. readonly angularAcceleration: Nullable<Float32Array>;
  19337. }
  19338. /**
  19339. * Interface representing a pose controlled object in Babylon.
  19340. * A pose controlled object has both regular pose values as well as pose values
  19341. * from an external device such as a VR head mounted display
  19342. */
  19343. export interface PoseControlled {
  19344. /**
  19345. * The position of the object in babylon space.
  19346. */
  19347. position: Vector3;
  19348. /**
  19349. * The rotation quaternion of the object in babylon space.
  19350. */
  19351. rotationQuaternion: Quaternion;
  19352. /**
  19353. * The position of the device in babylon space.
  19354. */
  19355. devicePosition?: Vector3;
  19356. /**
  19357. * The rotation quaternion of the device in babylon space.
  19358. */
  19359. deviceRotationQuaternion: Quaternion;
  19360. /**
  19361. * The raw pose coming from the device.
  19362. */
  19363. rawPose: Nullable<DevicePose>;
  19364. /**
  19365. * The scale of the device to be used when translating from device space to babylon space.
  19366. */
  19367. deviceScaleFactor: number;
  19368. /**
  19369. * Updates the poseControlled values based on the input device pose.
  19370. * @param poseData the pose data to update the object with
  19371. */
  19372. updateFromDevice(poseData: DevicePose): void;
  19373. }
  19374. /**
  19375. * Set of options to customize the webVRCamera
  19376. */
  19377. export interface WebVROptions {
  19378. /**
  19379. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19380. */
  19381. trackPosition?: boolean;
  19382. /**
  19383. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19384. */
  19385. positionScale?: number;
  19386. /**
  19387. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19388. */
  19389. displayName?: string;
  19390. /**
  19391. * Should the native controller meshes be initialized. (default: true)
  19392. */
  19393. controllerMeshes?: boolean;
  19394. /**
  19395. * Creating a default HemiLight only on controllers. (default: true)
  19396. */
  19397. defaultLightingOnControllers?: boolean;
  19398. /**
  19399. * If you don't want to use the default VR button of the helper. (default: false)
  19400. */
  19401. useCustomVRButton?: boolean;
  19402. /**
  19403. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19404. */
  19405. customVRButton?: HTMLButtonElement;
  19406. /**
  19407. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19408. */
  19409. rayLength?: number;
  19410. /**
  19411. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19412. */
  19413. defaultHeight?: number;
  19414. /**
  19415. * If multiview should be used if availible (default: false)
  19416. */
  19417. useMultiview?: boolean;
  19418. }
  19419. /**
  19420. * This represents a WebVR camera.
  19421. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19422. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19423. */
  19424. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19425. private webVROptions;
  19426. /**
  19427. * @hidden
  19428. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19429. */
  19430. _vrDevice: any;
  19431. /**
  19432. * The rawPose of the vrDevice.
  19433. */
  19434. rawPose: Nullable<DevicePose>;
  19435. private _onVREnabled;
  19436. private _specsVersion;
  19437. private _attached;
  19438. private _frameData;
  19439. protected _descendants: Array<Node>;
  19440. private _deviceRoomPosition;
  19441. /** @hidden */
  19442. _deviceRoomRotationQuaternion: Quaternion;
  19443. private _standingMatrix;
  19444. /**
  19445. * Represents device position in babylon space.
  19446. */
  19447. devicePosition: Vector3;
  19448. /**
  19449. * Represents device rotation in babylon space.
  19450. */
  19451. deviceRotationQuaternion: Quaternion;
  19452. /**
  19453. * The scale of the device to be used when translating from device space to babylon space.
  19454. */
  19455. deviceScaleFactor: number;
  19456. private _deviceToWorld;
  19457. private _worldToDevice;
  19458. /**
  19459. * References to the webVR controllers for the vrDevice.
  19460. */
  19461. controllers: Array<WebVRController>;
  19462. /**
  19463. * Emits an event when a controller is attached.
  19464. */
  19465. onControllersAttachedObservable: Observable<WebVRController[]>;
  19466. /**
  19467. * Emits an event when a controller's mesh has been loaded;
  19468. */
  19469. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19470. /**
  19471. * Emits an event when the HMD's pose has been updated.
  19472. */
  19473. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19474. private _poseSet;
  19475. /**
  19476. * If the rig cameras be used as parent instead of this camera.
  19477. */
  19478. rigParenting: boolean;
  19479. private _lightOnControllers;
  19480. private _defaultHeight?;
  19481. /**
  19482. * Instantiates a WebVRFreeCamera.
  19483. * @param name The name of the WebVRFreeCamera
  19484. * @param position The starting anchor position for the camera
  19485. * @param scene The scene the camera belongs to
  19486. * @param webVROptions a set of customizable options for the webVRCamera
  19487. */
  19488. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19489. /**
  19490. * Gets the device distance from the ground in meters.
  19491. * @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.
  19492. */
  19493. deviceDistanceToRoomGround(): number;
  19494. /**
  19495. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19496. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19497. */
  19498. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19499. /**
  19500. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19501. * @returns A promise with a boolean set to if the standing matrix is supported.
  19502. */
  19503. useStandingMatrixAsync(): Promise<boolean>;
  19504. /**
  19505. * Disposes the camera
  19506. */
  19507. dispose(): void;
  19508. /**
  19509. * Gets a vrController by name.
  19510. * @param name The name of the controller to retreive
  19511. * @returns the controller matching the name specified or null if not found
  19512. */
  19513. getControllerByName(name: string): Nullable<WebVRController>;
  19514. private _leftController;
  19515. /**
  19516. * The controller corresponding to the users left hand.
  19517. */
  19518. get leftController(): Nullable<WebVRController>;
  19519. private _rightController;
  19520. /**
  19521. * The controller corresponding to the users right hand.
  19522. */
  19523. get rightController(): Nullable<WebVRController>;
  19524. /**
  19525. * Casts a ray forward from the vrCamera's gaze.
  19526. * @param length Length of the ray (default: 100)
  19527. * @returns the ray corresponding to the gaze
  19528. */
  19529. getForwardRay(length?: number): Ray;
  19530. /**
  19531. * @hidden
  19532. * Updates the camera based on device's frame data
  19533. */
  19534. _checkInputs(): void;
  19535. /**
  19536. * Updates the poseControlled values based on the input device pose.
  19537. * @param poseData Pose coming from the device
  19538. */
  19539. updateFromDevice(poseData: DevicePose): void;
  19540. private _htmlElementAttached;
  19541. private _detachIfAttached;
  19542. /**
  19543. * WebVR's attach control will start broadcasting frames to the device.
  19544. * Note that in certain browsers (chrome for example) this function must be called
  19545. * within a user-interaction callback. Example:
  19546. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19547. *
  19548. * @param element html element to attach the vrDevice to
  19549. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19550. */
  19551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19552. /**
  19553. * Detaches the camera from the html element and disables VR
  19554. *
  19555. * @param element html element to detach from
  19556. */
  19557. detachControl(element: HTMLElement): void;
  19558. /**
  19559. * @returns the name of this class
  19560. */
  19561. getClassName(): string;
  19562. /**
  19563. * Calls resetPose on the vrDisplay
  19564. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19565. */
  19566. resetToCurrentRotation(): void;
  19567. /**
  19568. * @hidden
  19569. * Updates the rig cameras (left and right eye)
  19570. */
  19571. _updateRigCameras(): void;
  19572. private _workingVector;
  19573. private _oneVector;
  19574. private _workingMatrix;
  19575. private updateCacheCalled;
  19576. private _correctPositionIfNotTrackPosition;
  19577. /**
  19578. * @hidden
  19579. * Updates the cached values of the camera
  19580. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19581. */
  19582. _updateCache(ignoreParentClass?: boolean): void;
  19583. /**
  19584. * @hidden
  19585. * Get current device position in babylon world
  19586. */
  19587. _computeDevicePosition(): void;
  19588. /**
  19589. * Updates the current device position and rotation in the babylon world
  19590. */
  19591. update(): void;
  19592. /**
  19593. * @hidden
  19594. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19595. * @returns an identity matrix
  19596. */
  19597. _getViewMatrix(): Matrix;
  19598. private _tmpMatrix;
  19599. /**
  19600. * This function is called by the two RIG cameras.
  19601. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19602. * @hidden
  19603. */
  19604. _getWebVRViewMatrix(): Matrix;
  19605. /** @hidden */
  19606. _getWebVRProjectionMatrix(): Matrix;
  19607. private _onGamepadConnectedObserver;
  19608. private _onGamepadDisconnectedObserver;
  19609. private _updateCacheWhenTrackingDisabledObserver;
  19610. /**
  19611. * Initializes the controllers and their meshes
  19612. */
  19613. initControllers(): void;
  19614. }
  19615. }
  19616. declare module BABYLON {
  19617. /**
  19618. * Size options for a post process
  19619. */
  19620. export type PostProcessOptions = {
  19621. width: number;
  19622. height: number;
  19623. };
  19624. /**
  19625. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19626. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19627. */
  19628. export class PostProcess {
  19629. /** Name of the PostProcess. */
  19630. name: string;
  19631. /**
  19632. * Gets or sets the unique id of the post process
  19633. */
  19634. uniqueId: number;
  19635. /**
  19636. * Width of the texture to apply the post process on
  19637. */
  19638. width: number;
  19639. /**
  19640. * Height of the texture to apply the post process on
  19641. */
  19642. height: number;
  19643. /**
  19644. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19645. * @hidden
  19646. */
  19647. _outputTexture: Nullable<InternalTexture>;
  19648. /**
  19649. * Sampling mode used by the shader
  19650. * See https://doc.babylonjs.com/classes/3.1/texture
  19651. */
  19652. renderTargetSamplingMode: number;
  19653. /**
  19654. * Clear color to use when screen clearing
  19655. */
  19656. clearColor: Color4;
  19657. /**
  19658. * If the buffer needs to be cleared before applying the post process. (default: true)
  19659. * Should be set to false if shader will overwrite all previous pixels.
  19660. */
  19661. autoClear: boolean;
  19662. /**
  19663. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19664. */
  19665. alphaMode: number;
  19666. /**
  19667. * Sets the setAlphaBlendConstants of the babylon engine
  19668. */
  19669. alphaConstants: Color4;
  19670. /**
  19671. * Animations to be used for the post processing
  19672. */
  19673. animations: Animation[];
  19674. /**
  19675. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19676. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19677. */
  19678. enablePixelPerfectMode: boolean;
  19679. /**
  19680. * Force the postprocess to be applied without taking in account viewport
  19681. */
  19682. forceFullscreenViewport: boolean;
  19683. /**
  19684. * List of inspectable custom properties (used by the Inspector)
  19685. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19686. */
  19687. inspectableCustomProperties: IInspectable[];
  19688. /**
  19689. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19690. *
  19691. * | Value | Type | Description |
  19692. * | ----- | ----------------------------------- | ----------- |
  19693. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19694. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19695. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19696. *
  19697. */
  19698. scaleMode: number;
  19699. /**
  19700. * Force textures to be a power of two (default: false)
  19701. */
  19702. alwaysForcePOT: boolean;
  19703. private _samples;
  19704. /**
  19705. * Number of sample textures (default: 1)
  19706. */
  19707. get samples(): number;
  19708. set samples(n: number);
  19709. /**
  19710. * Modify the scale of the post process to be the same as the viewport (default: false)
  19711. */
  19712. adaptScaleToCurrentViewport: boolean;
  19713. private _camera;
  19714. private _scene;
  19715. private _engine;
  19716. private _options;
  19717. private _reusable;
  19718. private _textureType;
  19719. private _textureFormat;
  19720. /**
  19721. * Smart array of input and output textures for the post process.
  19722. * @hidden
  19723. */
  19724. _textures: SmartArray<InternalTexture>;
  19725. /**
  19726. * The index in _textures that corresponds to the output texture.
  19727. * @hidden
  19728. */
  19729. _currentRenderTextureInd: number;
  19730. private _effect;
  19731. private _samplers;
  19732. private _fragmentUrl;
  19733. private _vertexUrl;
  19734. private _parameters;
  19735. private _scaleRatio;
  19736. protected _indexParameters: any;
  19737. private _shareOutputWithPostProcess;
  19738. private _texelSize;
  19739. private _forcedOutputTexture;
  19740. /**
  19741. * Returns the fragment url or shader name used in the post process.
  19742. * @returns the fragment url or name in the shader store.
  19743. */
  19744. getEffectName(): string;
  19745. /**
  19746. * An event triggered when the postprocess is activated.
  19747. */
  19748. onActivateObservable: Observable<Camera>;
  19749. private _onActivateObserver;
  19750. /**
  19751. * A function that is added to the onActivateObservable
  19752. */
  19753. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19754. /**
  19755. * An event triggered when the postprocess changes its size.
  19756. */
  19757. onSizeChangedObservable: Observable<PostProcess>;
  19758. private _onSizeChangedObserver;
  19759. /**
  19760. * A function that is added to the onSizeChangedObservable
  19761. */
  19762. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19763. /**
  19764. * An event triggered when the postprocess applies its effect.
  19765. */
  19766. onApplyObservable: Observable<Effect>;
  19767. private _onApplyObserver;
  19768. /**
  19769. * A function that is added to the onApplyObservable
  19770. */
  19771. set onApply(callback: (effect: Effect) => void);
  19772. /**
  19773. * An event triggered before rendering the postprocess
  19774. */
  19775. onBeforeRenderObservable: Observable<Effect>;
  19776. private _onBeforeRenderObserver;
  19777. /**
  19778. * A function that is added to the onBeforeRenderObservable
  19779. */
  19780. set onBeforeRender(callback: (effect: Effect) => void);
  19781. /**
  19782. * An event triggered after rendering the postprocess
  19783. */
  19784. onAfterRenderObservable: Observable<Effect>;
  19785. private _onAfterRenderObserver;
  19786. /**
  19787. * A function that is added to the onAfterRenderObservable
  19788. */
  19789. set onAfterRender(callback: (efect: Effect) => void);
  19790. /**
  19791. * 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
  19792. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19793. */
  19794. get inputTexture(): InternalTexture;
  19795. set inputTexture(value: InternalTexture);
  19796. /**
  19797. * Gets the camera which post process is applied to.
  19798. * @returns The camera the post process is applied to.
  19799. */
  19800. getCamera(): Camera;
  19801. /**
  19802. * Gets the texel size of the postprocess.
  19803. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19804. */
  19805. get texelSize(): Vector2;
  19806. /**
  19807. * Creates a new instance PostProcess
  19808. * @param name The name of the PostProcess.
  19809. * @param fragmentUrl The url of the fragment shader to be used.
  19810. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19811. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19812. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19813. * @param camera The camera to apply the render pass to.
  19814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19815. * @param engine The engine which the post process will be applied. (default: current engine)
  19816. * @param reusable If the post process can be reused on the same frame. (default: false)
  19817. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19818. * @param textureType Type of textures used when performing the post process. (default: 0)
  19819. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19820. * @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
  19821. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19822. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19823. */
  19824. constructor(
  19825. /** Name of the PostProcess. */
  19826. 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);
  19827. /**
  19828. * Gets a string idenfifying the name of the class
  19829. * @returns "PostProcess" string
  19830. */
  19831. getClassName(): string;
  19832. /**
  19833. * Gets the engine which this post process belongs to.
  19834. * @returns The engine the post process was enabled with.
  19835. */
  19836. getEngine(): Engine;
  19837. /**
  19838. * The effect that is created when initializing the post process.
  19839. * @returns The created effect corresponding the the postprocess.
  19840. */
  19841. getEffect(): Effect;
  19842. /**
  19843. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19844. * @param postProcess The post process to share the output with.
  19845. * @returns This post process.
  19846. */
  19847. shareOutputWith(postProcess: PostProcess): PostProcess;
  19848. /**
  19849. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19850. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19851. */
  19852. useOwnOutput(): void;
  19853. /**
  19854. * Updates the effect with the current post process compile time values and recompiles the shader.
  19855. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19856. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19857. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19858. * @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
  19859. * @param onCompiled Called when the shader has been compiled.
  19860. * @param onError Called if there is an error when compiling a shader.
  19861. */
  19862. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19863. /**
  19864. * The post process is reusable if it can be used multiple times within one frame.
  19865. * @returns If the post process is reusable
  19866. */
  19867. isReusable(): boolean;
  19868. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19869. markTextureDirty(): void;
  19870. /**
  19871. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19872. * 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.
  19873. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19874. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19875. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19876. * @returns The target texture that was bound to be written to.
  19877. */
  19878. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19879. /**
  19880. * If the post process is supported.
  19881. */
  19882. get isSupported(): boolean;
  19883. /**
  19884. * The aspect ratio of the output texture.
  19885. */
  19886. get aspectRatio(): number;
  19887. /**
  19888. * Get a value indicating if the post-process is ready to be used
  19889. * @returns true if the post-process is ready (shader is compiled)
  19890. */
  19891. isReady(): boolean;
  19892. /**
  19893. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19894. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19895. */
  19896. apply(): Nullable<Effect>;
  19897. private _disposeTextures;
  19898. /**
  19899. * Disposes the post process.
  19900. * @param camera The camera to dispose the post process on.
  19901. */
  19902. dispose(camera?: Camera): void;
  19903. }
  19904. }
  19905. declare module BABYLON {
  19906. /** @hidden */
  19907. export var kernelBlurVaryingDeclaration: {
  19908. name: string;
  19909. shader: string;
  19910. };
  19911. }
  19912. declare module BABYLON {
  19913. /** @hidden */
  19914. export var kernelBlurFragment: {
  19915. name: string;
  19916. shader: string;
  19917. };
  19918. }
  19919. declare module BABYLON {
  19920. /** @hidden */
  19921. export var kernelBlurFragment2: {
  19922. name: string;
  19923. shader: string;
  19924. };
  19925. }
  19926. declare module BABYLON {
  19927. /** @hidden */
  19928. export var kernelBlurPixelShader: {
  19929. name: string;
  19930. shader: string;
  19931. };
  19932. }
  19933. declare module BABYLON {
  19934. /** @hidden */
  19935. export var kernelBlurVertex: {
  19936. name: string;
  19937. shader: string;
  19938. };
  19939. }
  19940. declare module BABYLON {
  19941. /** @hidden */
  19942. export var kernelBlurVertexShader: {
  19943. name: string;
  19944. shader: string;
  19945. };
  19946. }
  19947. declare module BABYLON {
  19948. /**
  19949. * The Blur Post Process which blurs an image based on a kernel and direction.
  19950. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19951. */
  19952. export class BlurPostProcess extends PostProcess {
  19953. /** The direction in which to blur the image. */
  19954. direction: Vector2;
  19955. private blockCompilation;
  19956. protected _kernel: number;
  19957. protected _idealKernel: number;
  19958. protected _packedFloat: boolean;
  19959. private _staticDefines;
  19960. /**
  19961. * Sets the length in pixels of the blur sample region
  19962. */
  19963. set kernel(v: number);
  19964. /**
  19965. * Gets the length in pixels of the blur sample region
  19966. */
  19967. get kernel(): number;
  19968. /**
  19969. * Sets wether or not the blur needs to unpack/repack floats
  19970. */
  19971. set packedFloat(v: boolean);
  19972. /**
  19973. * Gets wether or not the blur is unpacking/repacking floats
  19974. */
  19975. get packedFloat(): boolean;
  19976. /**
  19977. * Creates a new instance BlurPostProcess
  19978. * @param name The name of the effect.
  19979. * @param direction The direction in which to blur the image.
  19980. * @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.
  19981. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19982. * @param camera The camera to apply the render pass to.
  19983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19984. * @param engine The engine which the post process will be applied. (default: current engine)
  19985. * @param reusable If the post process can be reused on the same frame. (default: false)
  19986. * @param textureType Type of textures used when performing the post process. (default: 0)
  19987. * @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)
  19988. */
  19989. constructor(name: string,
  19990. /** The direction in which to blur the image. */
  19991. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19992. /**
  19993. * Updates the effect with the current post process compile time values and recompiles the shader.
  19994. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19995. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19996. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19997. * @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
  19998. * @param onCompiled Called when the shader has been compiled.
  19999. * @param onError Called if there is an error when compiling a shader.
  20000. */
  20001. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20002. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20003. /**
  20004. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20005. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20006. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20007. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20008. * The gaps between physical kernels are compensated for in the weighting of the samples
  20009. * @param idealKernel Ideal blur kernel.
  20010. * @return Nearest best kernel.
  20011. */
  20012. protected _nearestBestKernel(idealKernel: number): number;
  20013. /**
  20014. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20015. * @param x The point on the Gaussian distribution to sample.
  20016. * @return the value of the Gaussian function at x.
  20017. */
  20018. protected _gaussianWeight(x: number): number;
  20019. /**
  20020. * Generates a string that can be used as a floating point number in GLSL.
  20021. * @param x Value to print.
  20022. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20023. * @return GLSL float string.
  20024. */
  20025. protected _glslFloat(x: number, decimalFigures?: number): string;
  20026. }
  20027. }
  20028. declare module BABYLON {
  20029. /**
  20030. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20031. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20032. * You can then easily use it as a reflectionTexture on a flat surface.
  20033. * In case the surface is not a plane, please consider relying on reflection probes.
  20034. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20035. */
  20036. export class MirrorTexture extends RenderTargetTexture {
  20037. private scene;
  20038. /**
  20039. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20040. * 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.
  20041. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20042. */
  20043. mirrorPlane: Plane;
  20044. /**
  20045. * Define the blur ratio used to blur the reflection if needed.
  20046. */
  20047. set blurRatio(value: number);
  20048. get blurRatio(): number;
  20049. /**
  20050. * Define the adaptive blur kernel used to blur the reflection if needed.
  20051. * This will autocompute the closest best match for the `blurKernel`
  20052. */
  20053. set adaptiveBlurKernel(value: number);
  20054. /**
  20055. * Define the blur kernel used to blur the reflection if needed.
  20056. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20057. */
  20058. set blurKernel(value: number);
  20059. /**
  20060. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20061. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20062. */
  20063. set blurKernelX(value: number);
  20064. get blurKernelX(): number;
  20065. /**
  20066. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20067. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20068. */
  20069. set blurKernelY(value: number);
  20070. get blurKernelY(): number;
  20071. private _autoComputeBlurKernel;
  20072. protected _onRatioRescale(): void;
  20073. private _updateGammaSpace;
  20074. private _imageProcessingConfigChangeObserver;
  20075. private _transformMatrix;
  20076. private _mirrorMatrix;
  20077. private _savedViewMatrix;
  20078. private _blurX;
  20079. private _blurY;
  20080. private _adaptiveBlurKernel;
  20081. private _blurKernelX;
  20082. private _blurKernelY;
  20083. private _blurRatio;
  20084. /**
  20085. * Instantiates a Mirror Texture.
  20086. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20087. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20088. * You can then easily use it as a reflectionTexture on a flat surface.
  20089. * In case the surface is not a plane, please consider relying on reflection probes.
  20090. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20091. * @param name
  20092. * @param size
  20093. * @param scene
  20094. * @param generateMipMaps
  20095. * @param type
  20096. * @param samplingMode
  20097. * @param generateDepthBuffer
  20098. */
  20099. constructor(name: string, size: number | {
  20100. width: number;
  20101. height: number;
  20102. } | {
  20103. ratio: number;
  20104. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20105. private _preparePostProcesses;
  20106. /**
  20107. * Clone the mirror texture.
  20108. * @returns the cloned texture
  20109. */
  20110. clone(): MirrorTexture;
  20111. /**
  20112. * Serialize the texture to a JSON representation you could use in Parse later on
  20113. * @returns the serialized JSON representation
  20114. */
  20115. serialize(): any;
  20116. /**
  20117. * Dispose the texture and release its associated resources.
  20118. */
  20119. dispose(): void;
  20120. }
  20121. }
  20122. declare module BABYLON {
  20123. /**
  20124. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20125. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20126. */
  20127. export class Texture extends BaseTexture {
  20128. /**
  20129. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20130. */
  20131. static SerializeBuffers: boolean;
  20132. /** @hidden */
  20133. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20134. /** @hidden */
  20135. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20136. /** @hidden */
  20137. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20138. /** nearest is mag = nearest and min = nearest and mip = linear */
  20139. static readonly NEAREST_SAMPLINGMODE: number;
  20140. /** nearest is mag = nearest and min = nearest and mip = linear */
  20141. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20142. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20143. static readonly BILINEAR_SAMPLINGMODE: number;
  20144. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20145. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20146. /** Trilinear is mag = linear and min = linear and mip = linear */
  20147. static readonly TRILINEAR_SAMPLINGMODE: number;
  20148. /** Trilinear is mag = linear and min = linear and mip = linear */
  20149. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20150. /** mag = nearest and min = nearest and mip = nearest */
  20151. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20152. /** mag = nearest and min = linear and mip = nearest */
  20153. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20154. /** mag = nearest and min = linear and mip = linear */
  20155. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20156. /** mag = nearest and min = linear and mip = none */
  20157. static readonly NEAREST_LINEAR: number;
  20158. /** mag = nearest and min = nearest and mip = none */
  20159. static readonly NEAREST_NEAREST: number;
  20160. /** mag = linear and min = nearest and mip = nearest */
  20161. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20162. /** mag = linear and min = nearest and mip = linear */
  20163. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20164. /** mag = linear and min = linear and mip = none */
  20165. static readonly LINEAR_LINEAR: number;
  20166. /** mag = linear and min = nearest and mip = none */
  20167. static readonly LINEAR_NEAREST: number;
  20168. /** Explicit coordinates mode */
  20169. static readonly EXPLICIT_MODE: number;
  20170. /** Spherical coordinates mode */
  20171. static readonly SPHERICAL_MODE: number;
  20172. /** Planar coordinates mode */
  20173. static readonly PLANAR_MODE: number;
  20174. /** Cubic coordinates mode */
  20175. static readonly CUBIC_MODE: number;
  20176. /** Projection coordinates mode */
  20177. static readonly PROJECTION_MODE: number;
  20178. /** Inverse Cubic coordinates mode */
  20179. static readonly SKYBOX_MODE: number;
  20180. /** Inverse Cubic coordinates mode */
  20181. static readonly INVCUBIC_MODE: number;
  20182. /** Equirectangular coordinates mode */
  20183. static readonly EQUIRECTANGULAR_MODE: number;
  20184. /** Equirectangular Fixed coordinates mode */
  20185. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20186. /** Equirectangular Fixed Mirrored coordinates mode */
  20187. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20188. /** Texture is not repeating outside of 0..1 UVs */
  20189. static readonly CLAMP_ADDRESSMODE: number;
  20190. /** Texture is repeating outside of 0..1 UVs */
  20191. static readonly WRAP_ADDRESSMODE: number;
  20192. /** Texture is repeating and mirrored */
  20193. static readonly MIRROR_ADDRESSMODE: number;
  20194. /**
  20195. * 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
  20196. */
  20197. static UseSerializedUrlIfAny: boolean;
  20198. /**
  20199. * Define the url of the texture.
  20200. */
  20201. url: Nullable<string>;
  20202. /**
  20203. * Define an offset on the texture to offset the u coordinates of the UVs
  20204. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20205. */
  20206. uOffset: number;
  20207. /**
  20208. * Define an offset on the texture to offset the v coordinates of the UVs
  20209. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20210. */
  20211. vOffset: number;
  20212. /**
  20213. * Define an offset on the texture to scale the u coordinates of the UVs
  20214. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20215. */
  20216. uScale: number;
  20217. /**
  20218. * Define an offset on the texture to scale the v coordinates of the UVs
  20219. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20220. */
  20221. vScale: number;
  20222. /**
  20223. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20224. * @see http://doc.babylonjs.com/how_to/more_materials
  20225. */
  20226. uAng: number;
  20227. /**
  20228. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20229. * @see http://doc.babylonjs.com/how_to/more_materials
  20230. */
  20231. vAng: number;
  20232. /**
  20233. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20234. * @see http://doc.babylonjs.com/how_to/more_materials
  20235. */
  20236. wAng: number;
  20237. /**
  20238. * Defines the center of rotation (U)
  20239. */
  20240. uRotationCenter: number;
  20241. /**
  20242. * Defines the center of rotation (V)
  20243. */
  20244. vRotationCenter: number;
  20245. /**
  20246. * Defines the center of rotation (W)
  20247. */
  20248. wRotationCenter: number;
  20249. /**
  20250. * Are mip maps generated for this texture or not.
  20251. */
  20252. get noMipmap(): boolean;
  20253. /**
  20254. * List of inspectable custom properties (used by the Inspector)
  20255. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20256. */
  20257. inspectableCustomProperties: Nullable<IInspectable[]>;
  20258. private _noMipmap;
  20259. /** @hidden */
  20260. _invertY: boolean;
  20261. private _rowGenerationMatrix;
  20262. private _cachedTextureMatrix;
  20263. private _projectionModeMatrix;
  20264. private _t0;
  20265. private _t1;
  20266. private _t2;
  20267. private _cachedUOffset;
  20268. private _cachedVOffset;
  20269. private _cachedUScale;
  20270. private _cachedVScale;
  20271. private _cachedUAng;
  20272. private _cachedVAng;
  20273. private _cachedWAng;
  20274. private _cachedProjectionMatrixId;
  20275. private _cachedCoordinatesMode;
  20276. /** @hidden */
  20277. protected _initialSamplingMode: number;
  20278. /** @hidden */
  20279. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20280. private _deleteBuffer;
  20281. protected _format: Nullable<number>;
  20282. private _delayedOnLoad;
  20283. private _delayedOnError;
  20284. private _mimeType?;
  20285. /**
  20286. * Observable triggered once the texture has been loaded.
  20287. */
  20288. onLoadObservable: Observable<Texture>;
  20289. protected _isBlocking: boolean;
  20290. /**
  20291. * Is the texture preventing material to render while loading.
  20292. * If false, a default texture will be used instead of the loading one during the preparation step.
  20293. */
  20294. set isBlocking(value: boolean);
  20295. get isBlocking(): boolean;
  20296. /**
  20297. * Get the current sampling mode associated with the texture.
  20298. */
  20299. get samplingMode(): number;
  20300. /**
  20301. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20302. */
  20303. get invertY(): boolean;
  20304. /**
  20305. * Instantiates a new texture.
  20306. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20307. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20308. * @param url defines the url of the picture to load as a texture
  20309. * @param scene defines the scene or engine the texture will belong to
  20310. * @param noMipmap defines if the texture will require mip maps or not
  20311. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20312. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20313. * @param onLoad defines a callback triggered when the texture has been loaded
  20314. * @param onError defines a callback triggered when an error occurred during the loading session
  20315. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20316. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20317. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20318. * @param mimeType defines an optional mime type information
  20319. */
  20320. 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);
  20321. /**
  20322. * Update the url (and optional buffer) of this texture if url was null during construction.
  20323. * @param url the url of the texture
  20324. * @param buffer the buffer of the texture (defaults to null)
  20325. * @param onLoad callback called when the texture is loaded (defaults to null)
  20326. */
  20327. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20328. /**
  20329. * Finish the loading sequence of a texture flagged as delayed load.
  20330. * @hidden
  20331. */
  20332. delayLoad(): void;
  20333. private _prepareRowForTextureGeneration;
  20334. /**
  20335. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20336. * @returns the transform matrix of the texture.
  20337. */
  20338. getTextureMatrix(uBase?: number): Matrix;
  20339. /**
  20340. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20341. * @returns The reflection texture transform
  20342. */
  20343. getReflectionTextureMatrix(): Matrix;
  20344. /**
  20345. * Clones the texture.
  20346. * @returns the cloned texture
  20347. */
  20348. clone(): Texture;
  20349. /**
  20350. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20351. * @returns The JSON representation of the texture
  20352. */
  20353. serialize(): any;
  20354. /**
  20355. * Get the current class name of the texture useful for serialization or dynamic coding.
  20356. * @returns "Texture"
  20357. */
  20358. getClassName(): string;
  20359. /**
  20360. * Dispose the texture and release its associated resources.
  20361. */
  20362. dispose(): void;
  20363. /**
  20364. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20365. * @param parsedTexture Define the JSON representation of the texture
  20366. * @param scene Define the scene the parsed texture should be instantiated in
  20367. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20368. * @returns The parsed texture if successful
  20369. */
  20370. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20371. /**
  20372. * Creates a texture from its base 64 representation.
  20373. * @param data Define the base64 payload without the data: prefix
  20374. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20375. * @param scene Define the scene the texture should belong to
  20376. * @param noMipmap Forces the texture to not create mip map information if true
  20377. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20378. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20379. * @param onLoad define a callback triggered when the texture has been loaded
  20380. * @param onError define a callback triggered when an error occurred during the loading session
  20381. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20382. * @returns the created texture
  20383. */
  20384. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20385. /**
  20386. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20387. * @param data Define the base64 payload without the data: prefix
  20388. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20389. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20390. * @param scene Define the scene the texture should belong to
  20391. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20392. * @param noMipmap Forces the texture to not create mip map information if true
  20393. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20394. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20395. * @param onLoad define a callback triggered when the texture has been loaded
  20396. * @param onError define a callback triggered when an error occurred during the loading session
  20397. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20398. * @returns the created texture
  20399. */
  20400. 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;
  20401. }
  20402. }
  20403. declare module BABYLON {
  20404. /**
  20405. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20406. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20407. */
  20408. export class PostProcessManager {
  20409. private _scene;
  20410. private _indexBuffer;
  20411. private _vertexBuffers;
  20412. /**
  20413. * Creates a new instance PostProcess
  20414. * @param scene The scene that the post process is associated with.
  20415. */
  20416. constructor(scene: Scene);
  20417. private _prepareBuffers;
  20418. private _buildIndexBuffer;
  20419. /**
  20420. * Rebuilds the vertex buffers of the manager.
  20421. * @hidden
  20422. */
  20423. _rebuild(): void;
  20424. /**
  20425. * Prepares a frame to be run through a post process.
  20426. * @param sourceTexture The input texture to the post procesess. (default: null)
  20427. * @param postProcesses An array of post processes to be run. (default: null)
  20428. * @returns True if the post processes were able to be run.
  20429. * @hidden
  20430. */
  20431. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20432. /**
  20433. * Manually render a set of post processes to a texture.
  20434. * @param postProcesses An array of post processes to be run.
  20435. * @param targetTexture The target texture to render to.
  20436. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20437. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20438. * @param lodLevel defines which lod of the texture to render to
  20439. */
  20440. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20441. /**
  20442. * Finalize the result of the output of the postprocesses.
  20443. * @param doNotPresent If true the result will not be displayed to the screen.
  20444. * @param targetTexture The target texture to render to.
  20445. * @param faceIndex The index of the face to bind the target texture to.
  20446. * @param postProcesses The array of post processes to render.
  20447. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20448. * @hidden
  20449. */
  20450. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20451. /**
  20452. * Disposes of the post process manager.
  20453. */
  20454. dispose(): void;
  20455. }
  20456. }
  20457. declare module BABYLON {
  20458. /**
  20459. * This Helps creating a texture that will be created from a camera in your scene.
  20460. * It is basically a dynamic texture that could be used to create special effects for instance.
  20461. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20462. */
  20463. export class RenderTargetTexture extends Texture {
  20464. isCube: boolean;
  20465. /**
  20466. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20467. */
  20468. static readonly REFRESHRATE_RENDER_ONCE: number;
  20469. /**
  20470. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20471. */
  20472. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20473. /**
  20474. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20475. * the central point of your effect and can save a lot of performances.
  20476. */
  20477. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20478. /**
  20479. * Use this predicate to dynamically define the list of mesh you want to render.
  20480. * If set, the renderList property will be overwritten.
  20481. */
  20482. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20483. private _renderList;
  20484. /**
  20485. * Use this list to define the list of mesh you want to render.
  20486. */
  20487. get renderList(): Nullable<Array<AbstractMesh>>;
  20488. set renderList(value: Nullable<Array<AbstractMesh>>);
  20489. /**
  20490. * Use this function to overload the renderList array at rendering time.
  20491. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20492. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20493. * the cube (if the RTT is a cube, else layerOrFace=0).
  20494. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20495. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20496. * hold dummy elements!
  20497. */
  20498. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20499. private _hookArray;
  20500. /**
  20501. * Define if particles should be rendered in your texture.
  20502. */
  20503. renderParticles: boolean;
  20504. /**
  20505. * Define if sprites should be rendered in your texture.
  20506. */
  20507. renderSprites: boolean;
  20508. /**
  20509. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20510. */
  20511. coordinatesMode: number;
  20512. /**
  20513. * Define the camera used to render the texture.
  20514. */
  20515. activeCamera: Nullable<Camera>;
  20516. /**
  20517. * Override the mesh isReady function with your own one.
  20518. */
  20519. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20520. /**
  20521. * Override the render function of the texture with your own one.
  20522. */
  20523. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20524. /**
  20525. * Define if camera post processes should be use while rendering the texture.
  20526. */
  20527. useCameraPostProcesses: boolean;
  20528. /**
  20529. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20530. */
  20531. ignoreCameraViewport: boolean;
  20532. private _postProcessManager;
  20533. private _postProcesses;
  20534. private _resizeObserver;
  20535. /**
  20536. * An event triggered when the texture is unbind.
  20537. */
  20538. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20539. /**
  20540. * An event triggered when the texture is unbind.
  20541. */
  20542. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20543. private _onAfterUnbindObserver;
  20544. /**
  20545. * Set a after unbind callback in the texture.
  20546. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20547. */
  20548. set onAfterUnbind(callback: () => void);
  20549. /**
  20550. * An event triggered before rendering the texture
  20551. */
  20552. onBeforeRenderObservable: Observable<number>;
  20553. private _onBeforeRenderObserver;
  20554. /**
  20555. * Set a before render callback in the texture.
  20556. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20557. */
  20558. set onBeforeRender(callback: (faceIndex: number) => void);
  20559. /**
  20560. * An event triggered after rendering the texture
  20561. */
  20562. onAfterRenderObservable: Observable<number>;
  20563. private _onAfterRenderObserver;
  20564. /**
  20565. * Set a after render callback in the texture.
  20566. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20567. */
  20568. set onAfterRender(callback: (faceIndex: number) => void);
  20569. /**
  20570. * An event triggered after the texture clear
  20571. */
  20572. onClearObservable: Observable<Engine>;
  20573. private _onClearObserver;
  20574. /**
  20575. * Set a clear callback in the texture.
  20576. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20577. */
  20578. set onClear(callback: (Engine: Engine) => void);
  20579. /**
  20580. * An event triggered when the texture is resized.
  20581. */
  20582. onResizeObservable: Observable<RenderTargetTexture>;
  20583. /**
  20584. * Define the clear color of the Render Target if it should be different from the scene.
  20585. */
  20586. clearColor: Color4;
  20587. protected _size: number | {
  20588. width: number;
  20589. height: number;
  20590. layers?: number;
  20591. };
  20592. protected _initialSizeParameter: number | {
  20593. width: number;
  20594. height: number;
  20595. } | {
  20596. ratio: number;
  20597. };
  20598. protected _sizeRatio: Nullable<number>;
  20599. /** @hidden */
  20600. _generateMipMaps: boolean;
  20601. protected _renderingManager: RenderingManager;
  20602. /** @hidden */
  20603. _waitingRenderList: string[];
  20604. protected _doNotChangeAspectRatio: boolean;
  20605. protected _currentRefreshId: number;
  20606. protected _refreshRate: number;
  20607. protected _textureMatrix: Matrix;
  20608. protected _samples: number;
  20609. protected _renderTargetOptions: RenderTargetCreationOptions;
  20610. /**
  20611. * Gets render target creation options that were used.
  20612. */
  20613. get renderTargetOptions(): RenderTargetCreationOptions;
  20614. protected _engine: Engine;
  20615. protected _onRatioRescale(): void;
  20616. /**
  20617. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20618. * It must define where the camera used to render the texture is set
  20619. */
  20620. boundingBoxPosition: Vector3;
  20621. private _boundingBoxSize;
  20622. /**
  20623. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20624. * When defined, the cubemap will switch to local mode
  20625. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20626. * @example https://www.babylonjs-playground.com/#RNASML
  20627. */
  20628. set boundingBoxSize(value: Vector3);
  20629. get boundingBoxSize(): Vector3;
  20630. /**
  20631. * In case the RTT has been created with a depth texture, get the associated
  20632. * depth texture.
  20633. * Otherwise, return null.
  20634. */
  20635. get depthStencilTexture(): Nullable<InternalTexture>;
  20636. /**
  20637. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20638. * or used a shadow, depth texture...
  20639. * @param name The friendly name of the texture
  20640. * @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)
  20641. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20642. * @param generateMipMaps True if mip maps need to be generated after render.
  20643. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20644. * @param type The type of the buffer in the RTT (int, half float, float...)
  20645. * @param isCube True if a cube texture needs to be created
  20646. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20647. * @param generateDepthBuffer True to generate a depth buffer
  20648. * @param generateStencilBuffer True to generate a stencil buffer
  20649. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20650. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20651. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20652. */
  20653. constructor(name: string, size: number | {
  20654. width: number;
  20655. height: number;
  20656. layers?: number;
  20657. } | {
  20658. ratio: number;
  20659. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20660. /**
  20661. * Creates a depth stencil texture.
  20662. * This is only available in WebGL 2 or with the depth texture extension available.
  20663. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20664. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20665. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20666. */
  20667. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20668. private _processSizeParameter;
  20669. /**
  20670. * Define the number of samples to use in case of MSAA.
  20671. * It defaults to one meaning no MSAA has been enabled.
  20672. */
  20673. get samples(): number;
  20674. set samples(value: number);
  20675. /**
  20676. * Resets the refresh counter of the texture and start bak from scratch.
  20677. * Could be useful to regenerate the texture if it is setup to render only once.
  20678. */
  20679. resetRefreshCounter(): void;
  20680. /**
  20681. * Define the refresh rate of the texture or the rendering frequency.
  20682. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20683. */
  20684. get refreshRate(): number;
  20685. set refreshRate(value: number);
  20686. /**
  20687. * Adds a post process to the render target rendering passes.
  20688. * @param postProcess define the post process to add
  20689. */
  20690. addPostProcess(postProcess: PostProcess): void;
  20691. /**
  20692. * Clear all the post processes attached to the render target
  20693. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20694. */
  20695. clearPostProcesses(dispose?: boolean): void;
  20696. /**
  20697. * Remove one of the post process from the list of attached post processes to the texture
  20698. * @param postProcess define the post process to remove from the list
  20699. */
  20700. removePostProcess(postProcess: PostProcess): void;
  20701. /** @hidden */
  20702. _shouldRender(): boolean;
  20703. /**
  20704. * Gets the actual render size of the texture.
  20705. * @returns the width of the render size
  20706. */
  20707. getRenderSize(): number;
  20708. /**
  20709. * Gets the actual render width of the texture.
  20710. * @returns the width of the render size
  20711. */
  20712. getRenderWidth(): number;
  20713. /**
  20714. * Gets the actual render height of the texture.
  20715. * @returns the height of the render size
  20716. */
  20717. getRenderHeight(): number;
  20718. /**
  20719. * Gets the actual number of layers of the texture.
  20720. * @returns the number of layers
  20721. */
  20722. getRenderLayers(): number;
  20723. /**
  20724. * Get if the texture can be rescaled or not.
  20725. */
  20726. get canRescale(): boolean;
  20727. /**
  20728. * Resize the texture using a ratio.
  20729. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20730. */
  20731. scale(ratio: number): void;
  20732. /**
  20733. * Get the texture reflection matrix used to rotate/transform the reflection.
  20734. * @returns the reflection matrix
  20735. */
  20736. getReflectionTextureMatrix(): Matrix;
  20737. /**
  20738. * Resize the texture to a new desired size.
  20739. * Be carrefull as it will recreate all the data in the new texture.
  20740. * @param size Define the new size. It can be:
  20741. * - a number for squared texture,
  20742. * - an object containing { width: number, height: number }
  20743. * - or an object containing a ratio { ratio: number }
  20744. */
  20745. resize(size: number | {
  20746. width: number;
  20747. height: number;
  20748. } | {
  20749. ratio: number;
  20750. }): void;
  20751. private _defaultRenderListPrepared;
  20752. /**
  20753. * Renders all the objects from the render list into the texture.
  20754. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20755. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20756. */
  20757. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20758. private _bestReflectionRenderTargetDimension;
  20759. private _prepareRenderingManager;
  20760. /**
  20761. * @hidden
  20762. * @param faceIndex face index to bind to if this is a cubetexture
  20763. * @param layer defines the index of the texture to bind in the array
  20764. */
  20765. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20766. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20767. private renderToTarget;
  20768. /**
  20769. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20770. * This allowed control for front to back rendering or reversly depending of the special needs.
  20771. *
  20772. * @param renderingGroupId The rendering group id corresponding to its index
  20773. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20774. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20775. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20776. */
  20777. 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;
  20778. /**
  20779. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20780. *
  20781. * @param renderingGroupId The rendering group id corresponding to its index
  20782. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20783. */
  20784. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20785. /**
  20786. * Clones the texture.
  20787. * @returns the cloned texture
  20788. */
  20789. clone(): RenderTargetTexture;
  20790. /**
  20791. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20792. * @returns The JSON representation of the texture
  20793. */
  20794. serialize(): any;
  20795. /**
  20796. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20797. */
  20798. disposeFramebufferObjects(): void;
  20799. /**
  20800. * Dispose the texture and release its associated resources.
  20801. */
  20802. dispose(): void;
  20803. /** @hidden */
  20804. _rebuild(): void;
  20805. /**
  20806. * Clear the info related to rendering groups preventing retention point in material dispose.
  20807. */
  20808. freeRenderingGroups(): void;
  20809. /**
  20810. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20811. * @returns the view count
  20812. */
  20813. getViewCount(): number;
  20814. }
  20815. }
  20816. declare module BABYLON {
  20817. /**
  20818. * Options for compiling materials.
  20819. */
  20820. export interface IMaterialCompilationOptions {
  20821. /**
  20822. * Defines whether clip planes are enabled.
  20823. */
  20824. clipPlane: boolean;
  20825. /**
  20826. * Defines whether instances are enabled.
  20827. */
  20828. useInstances: boolean;
  20829. }
  20830. /**
  20831. * Base class for the main features of a material in Babylon.js
  20832. */
  20833. export class Material implements IAnimatable {
  20834. /**
  20835. * Returns the triangle fill mode
  20836. */
  20837. static readonly TriangleFillMode: number;
  20838. /**
  20839. * Returns the wireframe mode
  20840. */
  20841. static readonly WireFrameFillMode: number;
  20842. /**
  20843. * Returns the point fill mode
  20844. */
  20845. static readonly PointFillMode: number;
  20846. /**
  20847. * Returns the point list draw mode
  20848. */
  20849. static readonly PointListDrawMode: number;
  20850. /**
  20851. * Returns the line list draw mode
  20852. */
  20853. static readonly LineListDrawMode: number;
  20854. /**
  20855. * Returns the line loop draw mode
  20856. */
  20857. static readonly LineLoopDrawMode: number;
  20858. /**
  20859. * Returns the line strip draw mode
  20860. */
  20861. static readonly LineStripDrawMode: number;
  20862. /**
  20863. * Returns the triangle strip draw mode
  20864. */
  20865. static readonly TriangleStripDrawMode: number;
  20866. /**
  20867. * Returns the triangle fan draw mode
  20868. */
  20869. static readonly TriangleFanDrawMode: number;
  20870. /**
  20871. * Stores the clock-wise side orientation
  20872. */
  20873. static readonly ClockWiseSideOrientation: number;
  20874. /**
  20875. * Stores the counter clock-wise side orientation
  20876. */
  20877. static readonly CounterClockWiseSideOrientation: number;
  20878. /**
  20879. * The dirty texture flag value
  20880. */
  20881. static readonly TextureDirtyFlag: number;
  20882. /**
  20883. * The dirty light flag value
  20884. */
  20885. static readonly LightDirtyFlag: number;
  20886. /**
  20887. * The dirty fresnel flag value
  20888. */
  20889. static readonly FresnelDirtyFlag: number;
  20890. /**
  20891. * The dirty attribute flag value
  20892. */
  20893. static readonly AttributesDirtyFlag: number;
  20894. /**
  20895. * The dirty misc flag value
  20896. */
  20897. static readonly MiscDirtyFlag: number;
  20898. /**
  20899. * The all dirty flag value
  20900. */
  20901. static readonly AllDirtyFlag: number;
  20902. /**
  20903. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  20904. */
  20905. static readonly MATERIAL_OPAQUE: number;
  20906. /**
  20907. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  20908. */
  20909. static readonly MATERIAL_ALPHATEST: number;
  20910. /**
  20911. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20912. */
  20913. static readonly MATERIAL_ALPHABLEND: number;
  20914. /**
  20915. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20916. * They are also discarded below the alpha cutoff threshold to improve performances.
  20917. */
  20918. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  20919. /**
  20920. * The ID of the material
  20921. */
  20922. id: string;
  20923. /**
  20924. * Gets or sets the unique id of the material
  20925. */
  20926. uniqueId: number;
  20927. /**
  20928. * The name of the material
  20929. */
  20930. name: string;
  20931. /**
  20932. * Gets or sets user defined metadata
  20933. */
  20934. metadata: any;
  20935. /**
  20936. * For internal use only. Please do not use.
  20937. */
  20938. reservedDataStore: any;
  20939. /**
  20940. * Specifies if the ready state should be checked on each call
  20941. */
  20942. checkReadyOnEveryCall: boolean;
  20943. /**
  20944. * Specifies if the ready state should be checked once
  20945. */
  20946. checkReadyOnlyOnce: boolean;
  20947. /**
  20948. * The state of the material
  20949. */
  20950. state: string;
  20951. /**
  20952. * The alpha value of the material
  20953. */
  20954. protected _alpha: number;
  20955. /**
  20956. * List of inspectable custom properties (used by the Inspector)
  20957. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20958. */
  20959. inspectableCustomProperties: IInspectable[];
  20960. /**
  20961. * Sets the alpha value of the material
  20962. */
  20963. set alpha(value: number);
  20964. /**
  20965. * Gets the alpha value of the material
  20966. */
  20967. get alpha(): number;
  20968. /**
  20969. * Specifies if back face culling is enabled
  20970. */
  20971. protected _backFaceCulling: boolean;
  20972. /**
  20973. * Sets the back-face culling state
  20974. */
  20975. set backFaceCulling(value: boolean);
  20976. /**
  20977. * Gets the back-face culling state
  20978. */
  20979. get backFaceCulling(): boolean;
  20980. /**
  20981. * Stores the value for side orientation
  20982. */
  20983. sideOrientation: number;
  20984. /**
  20985. * Callback triggered when the material is compiled
  20986. */
  20987. onCompiled: Nullable<(effect: Effect) => void>;
  20988. /**
  20989. * Callback triggered when an error occurs
  20990. */
  20991. onError: Nullable<(effect: Effect, errors: string) => void>;
  20992. /**
  20993. * Callback triggered to get the render target textures
  20994. */
  20995. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20996. /**
  20997. * Gets a boolean indicating that current material needs to register RTT
  20998. */
  20999. get hasRenderTargetTextures(): boolean;
  21000. /**
  21001. * Specifies if the material should be serialized
  21002. */
  21003. doNotSerialize: boolean;
  21004. /**
  21005. * @hidden
  21006. */
  21007. _storeEffectOnSubMeshes: boolean;
  21008. /**
  21009. * Stores the animations for the material
  21010. */
  21011. animations: Nullable<Array<Animation>>;
  21012. /**
  21013. * An event triggered when the material is disposed
  21014. */
  21015. onDisposeObservable: Observable<Material>;
  21016. /**
  21017. * An observer which watches for dispose events
  21018. */
  21019. private _onDisposeObserver;
  21020. private _onUnBindObservable;
  21021. /**
  21022. * Called during a dispose event
  21023. */
  21024. set onDispose(callback: () => void);
  21025. private _onBindObservable;
  21026. /**
  21027. * An event triggered when the material is bound
  21028. */
  21029. get onBindObservable(): Observable<AbstractMesh>;
  21030. /**
  21031. * An observer which watches for bind events
  21032. */
  21033. private _onBindObserver;
  21034. /**
  21035. * Called during a bind event
  21036. */
  21037. set onBind(callback: (Mesh: AbstractMesh) => void);
  21038. /**
  21039. * An event triggered when the material is unbound
  21040. */
  21041. get onUnBindObservable(): Observable<Material>;
  21042. /**
  21043. * Stores the value of the alpha mode
  21044. */
  21045. private _alphaMode;
  21046. /**
  21047. * Sets the value of the alpha mode.
  21048. *
  21049. * | Value | Type | Description |
  21050. * | --- | --- | --- |
  21051. * | 0 | ALPHA_DISABLE | |
  21052. * | 1 | ALPHA_ADD | |
  21053. * | 2 | ALPHA_COMBINE | |
  21054. * | 3 | ALPHA_SUBTRACT | |
  21055. * | 4 | ALPHA_MULTIPLY | |
  21056. * | 5 | ALPHA_MAXIMIZED | |
  21057. * | 6 | ALPHA_ONEONE | |
  21058. * | 7 | ALPHA_PREMULTIPLIED | |
  21059. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21060. * | 9 | ALPHA_INTERPOLATE | |
  21061. * | 10 | ALPHA_SCREENMODE | |
  21062. *
  21063. */
  21064. set alphaMode(value: number);
  21065. /**
  21066. * Gets the value of the alpha mode
  21067. */
  21068. get alphaMode(): number;
  21069. /**
  21070. * Stores the state of the need depth pre-pass value
  21071. */
  21072. private _needDepthPrePass;
  21073. /**
  21074. * Sets the need depth pre-pass value
  21075. */
  21076. set needDepthPrePass(value: boolean);
  21077. /**
  21078. * Gets the depth pre-pass value
  21079. */
  21080. get needDepthPrePass(): boolean;
  21081. /**
  21082. * Specifies if depth writing should be disabled
  21083. */
  21084. disableDepthWrite: boolean;
  21085. /**
  21086. * Specifies if depth writing should be forced
  21087. */
  21088. forceDepthWrite: boolean;
  21089. /**
  21090. * Specifies the depth function that should be used. 0 means the default engine function
  21091. */
  21092. depthFunction: number;
  21093. /**
  21094. * Specifies if there should be a separate pass for culling
  21095. */
  21096. separateCullingPass: boolean;
  21097. /**
  21098. * Stores the state specifing if fog should be enabled
  21099. */
  21100. private _fogEnabled;
  21101. /**
  21102. * Sets the state for enabling fog
  21103. */
  21104. set fogEnabled(value: boolean);
  21105. /**
  21106. * Gets the value of the fog enabled state
  21107. */
  21108. get fogEnabled(): boolean;
  21109. /**
  21110. * Stores the size of points
  21111. */
  21112. pointSize: number;
  21113. /**
  21114. * Stores the z offset value
  21115. */
  21116. zOffset: number;
  21117. /**
  21118. * Gets a value specifying if wireframe mode is enabled
  21119. */
  21120. get wireframe(): boolean;
  21121. /**
  21122. * Sets the state of wireframe mode
  21123. */
  21124. set wireframe(value: boolean);
  21125. /**
  21126. * Gets the value specifying if point clouds are enabled
  21127. */
  21128. get pointsCloud(): boolean;
  21129. /**
  21130. * Sets the state of point cloud mode
  21131. */
  21132. set pointsCloud(value: boolean);
  21133. /**
  21134. * Gets the material fill mode
  21135. */
  21136. get fillMode(): number;
  21137. /**
  21138. * Sets the material fill mode
  21139. */
  21140. set fillMode(value: number);
  21141. /**
  21142. * @hidden
  21143. * Stores the effects for the material
  21144. */
  21145. _effect: Nullable<Effect>;
  21146. /**
  21147. * Specifies if uniform buffers should be used
  21148. */
  21149. private _useUBO;
  21150. /**
  21151. * Stores a reference to the scene
  21152. */
  21153. private _scene;
  21154. /**
  21155. * Stores the fill mode state
  21156. */
  21157. private _fillMode;
  21158. /**
  21159. * Specifies if the depth write state should be cached
  21160. */
  21161. private _cachedDepthWriteState;
  21162. /**
  21163. * Specifies if the depth function state should be cached
  21164. */
  21165. private _cachedDepthFunctionState;
  21166. /**
  21167. * Stores the uniform buffer
  21168. */
  21169. protected _uniformBuffer: UniformBuffer;
  21170. /** @hidden */
  21171. _indexInSceneMaterialArray: number;
  21172. /** @hidden */
  21173. meshMap: Nullable<{
  21174. [id: string]: AbstractMesh | undefined;
  21175. }>;
  21176. /**
  21177. * Creates a material instance
  21178. * @param name defines the name of the material
  21179. * @param scene defines the scene to reference
  21180. * @param doNotAdd specifies if the material should be added to the scene
  21181. */
  21182. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21183. /**
  21184. * Returns a string representation of the current material
  21185. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21186. * @returns a string with material information
  21187. */
  21188. toString(fullDetails?: boolean): string;
  21189. /**
  21190. * Gets the class name of the material
  21191. * @returns a string with the class name of the material
  21192. */
  21193. getClassName(): string;
  21194. /**
  21195. * Specifies if updates for the material been locked
  21196. */
  21197. get isFrozen(): boolean;
  21198. /**
  21199. * Locks updates for the material
  21200. */
  21201. freeze(): void;
  21202. /**
  21203. * Unlocks updates for the material
  21204. */
  21205. unfreeze(): void;
  21206. /**
  21207. * Specifies if the material is ready to be used
  21208. * @param mesh defines the mesh to check
  21209. * @param useInstances specifies if instances should be used
  21210. * @returns a boolean indicating if the material is ready to be used
  21211. */
  21212. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21213. /**
  21214. * Specifies that the submesh is ready to be used
  21215. * @param mesh defines the mesh to check
  21216. * @param subMesh defines which submesh to check
  21217. * @param useInstances specifies that instances should be used
  21218. * @returns a boolean indicating that the submesh is ready or not
  21219. */
  21220. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21221. /**
  21222. * Returns the material effect
  21223. * @returns the effect associated with the material
  21224. */
  21225. getEffect(): Nullable<Effect>;
  21226. /**
  21227. * Returns the current scene
  21228. * @returns a Scene
  21229. */
  21230. getScene(): Scene;
  21231. /**
  21232. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21233. */
  21234. protected _forceAlphaTest: boolean;
  21235. /**
  21236. * The transparency mode of the material.
  21237. */
  21238. protected _transparencyMode: Nullable<number>;
  21239. /**
  21240. * Gets the current transparency mode.
  21241. */
  21242. get transparencyMode(): Nullable<number>;
  21243. /**
  21244. * Sets the transparency mode of the material.
  21245. *
  21246. * | Value | Type | Description |
  21247. * | ----- | ----------------------------------- | ----------- |
  21248. * | 0 | OPAQUE | |
  21249. * | 1 | ALPHATEST | |
  21250. * | 2 | ALPHABLEND | |
  21251. * | 3 | ALPHATESTANDBLEND | |
  21252. *
  21253. */
  21254. set transparencyMode(value: Nullable<number>);
  21255. /**
  21256. * Returns true if alpha blending should be disabled.
  21257. */
  21258. protected get _disableAlphaBlending(): boolean;
  21259. /**
  21260. * Specifies whether or not this material should be rendered in alpha blend mode.
  21261. * @returns a boolean specifying if alpha blending is needed
  21262. */
  21263. needAlphaBlending(): boolean;
  21264. /**
  21265. * Specifies if the mesh will require alpha blending
  21266. * @param mesh defines the mesh to check
  21267. * @returns a boolean specifying if alpha blending is needed for the mesh
  21268. */
  21269. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21270. /**
  21271. * Specifies whether or not this material should be rendered in alpha test mode.
  21272. * @returns a boolean specifying if an alpha test is needed.
  21273. */
  21274. needAlphaTesting(): boolean;
  21275. /**
  21276. * Specifies if material alpha testing should be turned on for the mesh
  21277. * @param mesh defines the mesh to check
  21278. */
  21279. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21280. /**
  21281. * Gets the texture used for the alpha test
  21282. * @returns the texture to use for alpha testing
  21283. */
  21284. getAlphaTestTexture(): Nullable<BaseTexture>;
  21285. /**
  21286. * Marks the material to indicate that it needs to be re-calculated
  21287. */
  21288. markDirty(): void;
  21289. /** @hidden */
  21290. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21291. /**
  21292. * Binds the material to the mesh
  21293. * @param world defines the world transformation matrix
  21294. * @param mesh defines the mesh to bind the material to
  21295. */
  21296. bind(world: Matrix, mesh?: Mesh): void;
  21297. /**
  21298. * Binds the submesh to the material
  21299. * @param world defines the world transformation matrix
  21300. * @param mesh defines the mesh containing the submesh
  21301. * @param subMesh defines the submesh to bind the material to
  21302. */
  21303. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21304. /**
  21305. * Binds the world matrix to the material
  21306. * @param world defines the world transformation matrix
  21307. */
  21308. bindOnlyWorldMatrix(world: Matrix): void;
  21309. /**
  21310. * Binds the scene's uniform buffer to the effect.
  21311. * @param effect defines the effect to bind to the scene uniform buffer
  21312. * @param sceneUbo defines the uniform buffer storing scene data
  21313. */
  21314. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21315. /**
  21316. * Binds the view matrix to the effect
  21317. * @param effect defines the effect to bind the view matrix to
  21318. */
  21319. bindView(effect: Effect): void;
  21320. /**
  21321. * Binds the view projection matrix to the effect
  21322. * @param effect defines the effect to bind the view projection matrix to
  21323. */
  21324. bindViewProjection(effect: Effect): void;
  21325. /**
  21326. * Processes to execute after binding the material to a mesh
  21327. * @param mesh defines the rendered mesh
  21328. */
  21329. protected _afterBind(mesh?: Mesh): void;
  21330. /**
  21331. * Unbinds the material from the mesh
  21332. */
  21333. unbind(): void;
  21334. /**
  21335. * Gets the active textures from the material
  21336. * @returns an array of textures
  21337. */
  21338. getActiveTextures(): BaseTexture[];
  21339. /**
  21340. * Specifies if the material uses a texture
  21341. * @param texture defines the texture to check against the material
  21342. * @returns a boolean specifying if the material uses the texture
  21343. */
  21344. hasTexture(texture: BaseTexture): boolean;
  21345. /**
  21346. * Makes a duplicate of the material, and gives it a new name
  21347. * @param name defines the new name for the duplicated material
  21348. * @returns the cloned material
  21349. */
  21350. clone(name: string): Nullable<Material>;
  21351. /**
  21352. * Gets the meshes bound to the material
  21353. * @returns an array of meshes bound to the material
  21354. */
  21355. getBindedMeshes(): AbstractMesh[];
  21356. /**
  21357. * Force shader compilation
  21358. * @param mesh defines the mesh associated with this material
  21359. * @param onCompiled defines a function to execute once the material is compiled
  21360. * @param options defines the options to configure the compilation
  21361. * @param onError defines a function to execute if the material fails compiling
  21362. */
  21363. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21364. /**
  21365. * Force shader compilation
  21366. * @param mesh defines the mesh that will use this material
  21367. * @param options defines additional options for compiling the shaders
  21368. * @returns a promise that resolves when the compilation completes
  21369. */
  21370. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21371. private static readonly _AllDirtyCallBack;
  21372. private static readonly _ImageProcessingDirtyCallBack;
  21373. private static readonly _TextureDirtyCallBack;
  21374. private static readonly _FresnelDirtyCallBack;
  21375. private static readonly _MiscDirtyCallBack;
  21376. private static readonly _LightsDirtyCallBack;
  21377. private static readonly _AttributeDirtyCallBack;
  21378. private static _FresnelAndMiscDirtyCallBack;
  21379. private static _TextureAndMiscDirtyCallBack;
  21380. private static readonly _DirtyCallbackArray;
  21381. private static readonly _RunDirtyCallBacks;
  21382. /**
  21383. * Marks a define in the material to indicate that it needs to be re-computed
  21384. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21385. */
  21386. markAsDirty(flag: number): void;
  21387. /**
  21388. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21389. * @param func defines a function which checks material defines against the submeshes
  21390. */
  21391. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21392. /**
  21393. * Indicates that we need to re-calculated for all submeshes
  21394. */
  21395. protected _markAllSubMeshesAsAllDirty(): void;
  21396. /**
  21397. * Indicates that image processing needs to be re-calculated for all submeshes
  21398. */
  21399. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21400. /**
  21401. * Indicates that textures need to be re-calculated for all submeshes
  21402. */
  21403. protected _markAllSubMeshesAsTexturesDirty(): void;
  21404. /**
  21405. * Indicates that fresnel needs to be re-calculated for all submeshes
  21406. */
  21407. protected _markAllSubMeshesAsFresnelDirty(): void;
  21408. /**
  21409. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21410. */
  21411. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21412. /**
  21413. * Indicates that lights need to be re-calculated for all submeshes
  21414. */
  21415. protected _markAllSubMeshesAsLightsDirty(): void;
  21416. /**
  21417. * Indicates that attributes need to be re-calculated for all submeshes
  21418. */
  21419. protected _markAllSubMeshesAsAttributesDirty(): void;
  21420. /**
  21421. * Indicates that misc needs to be re-calculated for all submeshes
  21422. */
  21423. protected _markAllSubMeshesAsMiscDirty(): void;
  21424. /**
  21425. * Indicates that textures and misc need to be re-calculated for all submeshes
  21426. */
  21427. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21428. /**
  21429. * Disposes the material
  21430. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21431. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21432. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21433. */
  21434. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21435. /** @hidden */
  21436. private releaseVertexArrayObject;
  21437. /**
  21438. * Serializes this material
  21439. * @returns the serialized material object
  21440. */
  21441. serialize(): any;
  21442. /**
  21443. * Creates a material from parsed material data
  21444. * @param parsedMaterial defines parsed material data
  21445. * @param scene defines the hosting scene
  21446. * @param rootUrl defines the root URL to use to load textures
  21447. * @returns a new material
  21448. */
  21449. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21450. }
  21451. }
  21452. declare module BABYLON {
  21453. /**
  21454. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21455. * separate meshes. This can be use to improve performances.
  21456. * @see http://doc.babylonjs.com/how_to/multi_materials
  21457. */
  21458. export class MultiMaterial extends Material {
  21459. private _subMaterials;
  21460. /**
  21461. * Gets or Sets the list of Materials used within the multi material.
  21462. * They need to be ordered according to the submeshes order in the associated mesh
  21463. */
  21464. get subMaterials(): Nullable<Material>[];
  21465. set subMaterials(value: Nullable<Material>[]);
  21466. /**
  21467. * Function used to align with Node.getChildren()
  21468. * @returns the list of Materials used within the multi material
  21469. */
  21470. getChildren(): Nullable<Material>[];
  21471. /**
  21472. * Instantiates a new Multi Material
  21473. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21474. * separate meshes. This can be use to improve performances.
  21475. * @see http://doc.babylonjs.com/how_to/multi_materials
  21476. * @param name Define the name in the scene
  21477. * @param scene Define the scene the material belongs to
  21478. */
  21479. constructor(name: string, scene: Scene);
  21480. private _hookArray;
  21481. /**
  21482. * Get one of the submaterial by its index in the submaterials array
  21483. * @param index The index to look the sub material at
  21484. * @returns The Material if the index has been defined
  21485. */
  21486. getSubMaterial(index: number): Nullable<Material>;
  21487. /**
  21488. * Get the list of active textures for the whole sub materials list.
  21489. * @returns All the textures that will be used during the rendering
  21490. */
  21491. getActiveTextures(): BaseTexture[];
  21492. /**
  21493. * Gets the current class name of the material e.g. "MultiMaterial"
  21494. * Mainly use in serialization.
  21495. * @returns the class name
  21496. */
  21497. getClassName(): string;
  21498. /**
  21499. * Checks if the material is ready to render the requested sub mesh
  21500. * @param mesh Define the mesh the submesh belongs to
  21501. * @param subMesh Define the sub mesh to look readyness for
  21502. * @param useInstances Define whether or not the material is used with instances
  21503. * @returns true if ready, otherwise false
  21504. */
  21505. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21506. /**
  21507. * Clones the current material and its related sub materials
  21508. * @param name Define the name of the newly cloned material
  21509. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21510. * @returns the cloned material
  21511. */
  21512. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21513. /**
  21514. * Serializes the materials into a JSON representation.
  21515. * @returns the JSON representation
  21516. */
  21517. serialize(): any;
  21518. /**
  21519. * Dispose the material and release its associated resources
  21520. * @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)
  21521. * @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)
  21522. * @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)
  21523. */
  21524. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21525. /**
  21526. * Creates a MultiMaterial from parsed MultiMaterial data.
  21527. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21528. * @param scene defines the hosting scene
  21529. * @returns a new MultiMaterial
  21530. */
  21531. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21532. }
  21533. }
  21534. declare module BABYLON {
  21535. /**
  21536. * Base class for submeshes
  21537. */
  21538. export class BaseSubMesh {
  21539. /** @hidden */
  21540. _materialDefines: Nullable<MaterialDefines>;
  21541. /** @hidden */
  21542. _materialEffect: Nullable<Effect>;
  21543. /**
  21544. * Gets material defines used by the effect associated to the sub mesh
  21545. */
  21546. get materialDefines(): Nullable<MaterialDefines>;
  21547. /**
  21548. * Sets material defines used by the effect associated to the sub mesh
  21549. */
  21550. set materialDefines(defines: Nullable<MaterialDefines>);
  21551. /**
  21552. * Gets associated effect
  21553. */
  21554. get effect(): Nullable<Effect>;
  21555. /**
  21556. * Sets associated effect (effect used to render this submesh)
  21557. * @param effect defines the effect to associate with
  21558. * @param defines defines the set of defines used to compile this effect
  21559. */
  21560. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21561. }
  21562. /**
  21563. * Defines a subdivision inside a mesh
  21564. */
  21565. export class SubMesh extends BaseSubMesh implements ICullable {
  21566. /** the material index to use */
  21567. materialIndex: number;
  21568. /** vertex index start */
  21569. verticesStart: number;
  21570. /** vertices count */
  21571. verticesCount: number;
  21572. /** index start */
  21573. indexStart: number;
  21574. /** indices count */
  21575. indexCount: number;
  21576. /** @hidden */
  21577. _linesIndexCount: number;
  21578. private _mesh;
  21579. private _renderingMesh;
  21580. private _boundingInfo;
  21581. private _linesIndexBuffer;
  21582. /** @hidden */
  21583. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21584. /** @hidden */
  21585. _trianglePlanes: Plane[];
  21586. /** @hidden */
  21587. _lastColliderTransformMatrix: Nullable<Matrix>;
  21588. /** @hidden */
  21589. _renderId: number;
  21590. /** @hidden */
  21591. _alphaIndex: number;
  21592. /** @hidden */
  21593. _distanceToCamera: number;
  21594. /** @hidden */
  21595. _id: number;
  21596. private _currentMaterial;
  21597. /**
  21598. * Add a new submesh to a mesh
  21599. * @param materialIndex defines the material index to use
  21600. * @param verticesStart defines vertex index start
  21601. * @param verticesCount defines vertices count
  21602. * @param indexStart defines index start
  21603. * @param indexCount defines indices count
  21604. * @param mesh defines the parent mesh
  21605. * @param renderingMesh defines an optional rendering mesh
  21606. * @param createBoundingBox defines if bounding box should be created for this submesh
  21607. * @returns the new submesh
  21608. */
  21609. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21610. /**
  21611. * Creates a new submesh
  21612. * @param materialIndex defines the material index to use
  21613. * @param verticesStart defines vertex index start
  21614. * @param verticesCount defines vertices count
  21615. * @param indexStart defines index start
  21616. * @param indexCount defines indices count
  21617. * @param mesh defines the parent mesh
  21618. * @param renderingMesh defines an optional rendering mesh
  21619. * @param createBoundingBox defines if bounding box should be created for this submesh
  21620. */
  21621. constructor(
  21622. /** the material index to use */
  21623. materialIndex: number,
  21624. /** vertex index start */
  21625. verticesStart: number,
  21626. /** vertices count */
  21627. verticesCount: number,
  21628. /** index start */
  21629. indexStart: number,
  21630. /** indices count */
  21631. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21632. /**
  21633. * Returns true if this submesh covers the entire parent mesh
  21634. * @ignorenaming
  21635. */
  21636. get IsGlobal(): boolean;
  21637. /**
  21638. * Returns the submesh BoudingInfo object
  21639. * @returns current bounding info (or mesh's one if the submesh is global)
  21640. */
  21641. getBoundingInfo(): BoundingInfo;
  21642. /**
  21643. * Sets the submesh BoundingInfo
  21644. * @param boundingInfo defines the new bounding info to use
  21645. * @returns the SubMesh
  21646. */
  21647. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21648. /**
  21649. * Returns the mesh of the current submesh
  21650. * @return the parent mesh
  21651. */
  21652. getMesh(): AbstractMesh;
  21653. /**
  21654. * Returns the rendering mesh of the submesh
  21655. * @returns the rendering mesh (could be different from parent mesh)
  21656. */
  21657. getRenderingMesh(): Mesh;
  21658. /**
  21659. * Returns the submesh material
  21660. * @returns null or the current material
  21661. */
  21662. getMaterial(): Nullable<Material>;
  21663. /**
  21664. * Sets a new updated BoundingInfo object to the submesh
  21665. * @param data defines an optional position array to use to determine the bounding info
  21666. * @returns the SubMesh
  21667. */
  21668. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21669. /** @hidden */
  21670. _checkCollision(collider: Collider): boolean;
  21671. /**
  21672. * Updates the submesh BoundingInfo
  21673. * @param world defines the world matrix to use to update the bounding info
  21674. * @returns the submesh
  21675. */
  21676. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21677. /**
  21678. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21679. * @param frustumPlanes defines the frustum planes
  21680. * @returns true if the submesh is intersecting with the frustum
  21681. */
  21682. isInFrustum(frustumPlanes: Plane[]): boolean;
  21683. /**
  21684. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21685. * @param frustumPlanes defines the frustum planes
  21686. * @returns true if the submesh is inside the frustum
  21687. */
  21688. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21689. /**
  21690. * Renders the submesh
  21691. * @param enableAlphaMode defines if alpha needs to be used
  21692. * @returns the submesh
  21693. */
  21694. render(enableAlphaMode: boolean): SubMesh;
  21695. /**
  21696. * @hidden
  21697. */
  21698. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21699. /**
  21700. * Checks if the submesh intersects with a ray
  21701. * @param ray defines the ray to test
  21702. * @returns true is the passed ray intersects the submesh bounding box
  21703. */
  21704. canIntersects(ray: Ray): boolean;
  21705. /**
  21706. * Intersects current submesh with a ray
  21707. * @param ray defines the ray to test
  21708. * @param positions defines mesh's positions array
  21709. * @param indices defines mesh's indices array
  21710. * @param fastCheck defines if only bounding info should be used
  21711. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21712. * @returns intersection info or null if no intersection
  21713. */
  21714. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21715. /** @hidden */
  21716. private _intersectLines;
  21717. /** @hidden */
  21718. private _intersectUnIndexedLines;
  21719. /** @hidden */
  21720. private _intersectTriangles;
  21721. /** @hidden */
  21722. private _intersectUnIndexedTriangles;
  21723. /** @hidden */
  21724. _rebuild(): void;
  21725. /**
  21726. * Creates a new submesh from the passed mesh
  21727. * @param newMesh defines the new hosting mesh
  21728. * @param newRenderingMesh defines an optional rendering mesh
  21729. * @returns the new submesh
  21730. */
  21731. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21732. /**
  21733. * Release associated resources
  21734. */
  21735. dispose(): void;
  21736. /**
  21737. * Gets the class name
  21738. * @returns the string "SubMesh".
  21739. */
  21740. getClassName(): string;
  21741. /**
  21742. * Creates a new submesh from indices data
  21743. * @param materialIndex the index of the main mesh material
  21744. * @param startIndex the index where to start the copy in the mesh indices array
  21745. * @param indexCount the number of indices to copy then from the startIndex
  21746. * @param mesh the main mesh to create the submesh from
  21747. * @param renderingMesh the optional rendering mesh
  21748. * @returns a new submesh
  21749. */
  21750. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21751. }
  21752. }
  21753. declare module BABYLON {
  21754. /**
  21755. * Class used to represent data loading progression
  21756. */
  21757. export class SceneLoaderFlags {
  21758. private static _ForceFullSceneLoadingForIncremental;
  21759. private static _ShowLoadingScreen;
  21760. private static _CleanBoneMatrixWeights;
  21761. private static _loggingLevel;
  21762. /**
  21763. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21764. */
  21765. static get ForceFullSceneLoadingForIncremental(): boolean;
  21766. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21767. /**
  21768. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21769. */
  21770. static get ShowLoadingScreen(): boolean;
  21771. static set ShowLoadingScreen(value: boolean);
  21772. /**
  21773. * Defines the current logging level (while loading the scene)
  21774. * @ignorenaming
  21775. */
  21776. static get loggingLevel(): number;
  21777. static set loggingLevel(value: number);
  21778. /**
  21779. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21780. */
  21781. static get CleanBoneMatrixWeights(): boolean;
  21782. static set CleanBoneMatrixWeights(value: boolean);
  21783. }
  21784. }
  21785. declare module BABYLON {
  21786. /**
  21787. * Class used to store geometry data (vertex buffers + index buffer)
  21788. */
  21789. export class Geometry implements IGetSetVerticesData {
  21790. /**
  21791. * Gets or sets the ID of the geometry
  21792. */
  21793. id: string;
  21794. /**
  21795. * Gets or sets the unique ID of the geometry
  21796. */
  21797. uniqueId: number;
  21798. /**
  21799. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21800. */
  21801. delayLoadState: number;
  21802. /**
  21803. * Gets the file containing the data to load when running in delay load state
  21804. */
  21805. delayLoadingFile: Nullable<string>;
  21806. /**
  21807. * Callback called when the geometry is updated
  21808. */
  21809. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21810. private _scene;
  21811. private _engine;
  21812. private _meshes;
  21813. private _totalVertices;
  21814. /** @hidden */
  21815. _indices: IndicesArray;
  21816. /** @hidden */
  21817. _vertexBuffers: {
  21818. [key: string]: VertexBuffer;
  21819. };
  21820. private _isDisposed;
  21821. private _extend;
  21822. private _boundingBias;
  21823. /** @hidden */
  21824. _delayInfo: Array<string>;
  21825. private _indexBuffer;
  21826. private _indexBufferIsUpdatable;
  21827. /** @hidden */
  21828. _boundingInfo: Nullable<BoundingInfo>;
  21829. /** @hidden */
  21830. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21831. /** @hidden */
  21832. _softwareSkinningFrameId: number;
  21833. private _vertexArrayObjects;
  21834. private _updatable;
  21835. /** @hidden */
  21836. _positions: Nullable<Vector3[]>;
  21837. /**
  21838. * 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
  21839. */
  21840. get boundingBias(): Vector2;
  21841. /**
  21842. * 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
  21843. */
  21844. set boundingBias(value: Vector2);
  21845. /**
  21846. * Static function used to attach a new empty geometry to a mesh
  21847. * @param mesh defines the mesh to attach the geometry to
  21848. * @returns the new Geometry
  21849. */
  21850. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21851. /**
  21852. * Creates a new geometry
  21853. * @param id defines the unique ID
  21854. * @param scene defines the hosting scene
  21855. * @param vertexData defines the VertexData used to get geometry data
  21856. * @param updatable defines if geometry must be updatable (false by default)
  21857. * @param mesh defines the mesh that will be associated with the geometry
  21858. */
  21859. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21860. /**
  21861. * Gets the current extend of the geometry
  21862. */
  21863. get extend(): {
  21864. minimum: Vector3;
  21865. maximum: Vector3;
  21866. };
  21867. /**
  21868. * Gets the hosting scene
  21869. * @returns the hosting Scene
  21870. */
  21871. getScene(): Scene;
  21872. /**
  21873. * Gets the hosting engine
  21874. * @returns the hosting Engine
  21875. */
  21876. getEngine(): Engine;
  21877. /**
  21878. * Defines if the geometry is ready to use
  21879. * @returns true if the geometry is ready to be used
  21880. */
  21881. isReady(): boolean;
  21882. /**
  21883. * Gets a value indicating that the geometry should not be serialized
  21884. */
  21885. get doNotSerialize(): boolean;
  21886. /** @hidden */
  21887. _rebuild(): void;
  21888. /**
  21889. * Affects all geometry data in one call
  21890. * @param vertexData defines the geometry data
  21891. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21892. */
  21893. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21894. /**
  21895. * Set specific vertex data
  21896. * @param kind defines the data kind (Position, normal, etc...)
  21897. * @param data defines the vertex data to use
  21898. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21899. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21900. */
  21901. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21902. /**
  21903. * Removes a specific vertex data
  21904. * @param kind defines the data kind (Position, normal, etc...)
  21905. */
  21906. removeVerticesData(kind: string): void;
  21907. /**
  21908. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21909. * @param buffer defines the vertex buffer to use
  21910. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21911. */
  21912. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21913. /**
  21914. * Update a specific vertex buffer
  21915. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21916. * It will do nothing if the buffer is not updatable
  21917. * @param kind defines the data kind (Position, normal, etc...)
  21918. * @param data defines the data to use
  21919. * @param offset defines the offset in the target buffer where to store the data
  21920. * @param useBytes set to true if the offset is in bytes
  21921. */
  21922. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21923. /**
  21924. * Update a specific vertex buffer
  21925. * This function will create a new buffer if the current one is not updatable
  21926. * @param kind defines the data kind (Position, normal, etc...)
  21927. * @param data defines the data to use
  21928. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21929. */
  21930. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21931. private _updateBoundingInfo;
  21932. /** @hidden */
  21933. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21934. /**
  21935. * Gets total number of vertices
  21936. * @returns the total number of vertices
  21937. */
  21938. getTotalVertices(): number;
  21939. /**
  21940. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21941. * @param kind defines the data kind (Position, normal, etc...)
  21942. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21943. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21944. * @returns a float array containing vertex data
  21945. */
  21946. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21947. /**
  21948. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21949. * @param kind defines the data kind (Position, normal, etc...)
  21950. * @returns true if the vertex buffer with the specified kind is updatable
  21951. */
  21952. isVertexBufferUpdatable(kind: string): boolean;
  21953. /**
  21954. * Gets a specific vertex buffer
  21955. * @param kind defines the data kind (Position, normal, etc...)
  21956. * @returns a VertexBuffer
  21957. */
  21958. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21959. /**
  21960. * Returns all vertex buffers
  21961. * @return an object holding all vertex buffers indexed by kind
  21962. */
  21963. getVertexBuffers(): Nullable<{
  21964. [key: string]: VertexBuffer;
  21965. }>;
  21966. /**
  21967. * Gets a boolean indicating if specific vertex buffer is present
  21968. * @param kind defines the data kind (Position, normal, etc...)
  21969. * @returns true if data is present
  21970. */
  21971. isVerticesDataPresent(kind: string): boolean;
  21972. /**
  21973. * Gets a list of all attached data kinds (Position, normal, etc...)
  21974. * @returns a list of string containing all kinds
  21975. */
  21976. getVerticesDataKinds(): string[];
  21977. /**
  21978. * Update index buffer
  21979. * @param indices defines the indices to store in the index buffer
  21980. * @param offset defines the offset in the target buffer where to store the data
  21981. * @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)
  21982. */
  21983. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21984. /**
  21985. * Creates a new index buffer
  21986. * @param indices defines the indices to store in the index buffer
  21987. * @param totalVertices defines the total number of vertices (could be null)
  21988. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21989. */
  21990. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21991. /**
  21992. * Return the total number of indices
  21993. * @returns the total number of indices
  21994. */
  21995. getTotalIndices(): number;
  21996. /**
  21997. * Gets the index buffer array
  21998. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21999. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22000. * @returns the index buffer array
  22001. */
  22002. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22003. /**
  22004. * Gets the index buffer
  22005. * @return the index buffer
  22006. */
  22007. getIndexBuffer(): Nullable<DataBuffer>;
  22008. /** @hidden */
  22009. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22010. /**
  22011. * Release the associated resources for a specific mesh
  22012. * @param mesh defines the source mesh
  22013. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22014. */
  22015. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22016. /**
  22017. * Apply current geometry to a given mesh
  22018. * @param mesh defines the mesh to apply geometry to
  22019. */
  22020. applyToMesh(mesh: Mesh): void;
  22021. private _updateExtend;
  22022. private _applyToMesh;
  22023. private notifyUpdate;
  22024. /**
  22025. * Load the geometry if it was flagged as delay loaded
  22026. * @param scene defines the hosting scene
  22027. * @param onLoaded defines a callback called when the geometry is loaded
  22028. */
  22029. load(scene: Scene, onLoaded?: () => void): void;
  22030. private _queueLoad;
  22031. /**
  22032. * Invert the geometry to move from a right handed system to a left handed one.
  22033. */
  22034. toLeftHanded(): void;
  22035. /** @hidden */
  22036. _resetPointsArrayCache(): void;
  22037. /** @hidden */
  22038. _generatePointsArray(): boolean;
  22039. /**
  22040. * Gets a value indicating if the geometry is disposed
  22041. * @returns true if the geometry was disposed
  22042. */
  22043. isDisposed(): boolean;
  22044. private _disposeVertexArrayObjects;
  22045. /**
  22046. * Free all associated resources
  22047. */
  22048. dispose(): void;
  22049. /**
  22050. * Clone the current geometry into a new geometry
  22051. * @param id defines the unique ID of the new geometry
  22052. * @returns a new geometry object
  22053. */
  22054. copy(id: string): Geometry;
  22055. /**
  22056. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22057. * @return a JSON representation of the current geometry data (without the vertices data)
  22058. */
  22059. serialize(): any;
  22060. private toNumberArray;
  22061. /**
  22062. * Serialize all vertices data into a JSON oject
  22063. * @returns a JSON representation of the current geometry data
  22064. */
  22065. serializeVerticeData(): any;
  22066. /**
  22067. * Extracts a clone of a mesh geometry
  22068. * @param mesh defines the source mesh
  22069. * @param id defines the unique ID of the new geometry object
  22070. * @returns the new geometry object
  22071. */
  22072. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22073. /**
  22074. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22075. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22076. * Be aware Math.random() could cause collisions, but:
  22077. * "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"
  22078. * @returns a string containing a new GUID
  22079. */
  22080. static RandomId(): string;
  22081. /** @hidden */
  22082. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22083. private static _CleanMatricesWeights;
  22084. /**
  22085. * Create a new geometry from persisted data (Using .babylon file format)
  22086. * @param parsedVertexData defines the persisted data
  22087. * @param scene defines the hosting scene
  22088. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22089. * @returns the new geometry object
  22090. */
  22091. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22092. }
  22093. }
  22094. declare module BABYLON {
  22095. /**
  22096. * Define an interface for all classes that will get and set the data on vertices
  22097. */
  22098. export interface IGetSetVerticesData {
  22099. /**
  22100. * Gets a boolean indicating if specific vertex data is present
  22101. * @param kind defines the vertex data kind to use
  22102. * @returns true is data kind is present
  22103. */
  22104. isVerticesDataPresent(kind: string): boolean;
  22105. /**
  22106. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22107. * @param kind defines the data kind (Position, normal, etc...)
  22108. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22109. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22110. * @returns a float array containing vertex data
  22111. */
  22112. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22113. /**
  22114. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22115. * @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.
  22116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22117. * @returns the indices array or an empty array if the mesh has no geometry
  22118. */
  22119. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22120. /**
  22121. * Set specific vertex data
  22122. * @param kind defines the data kind (Position, normal, etc...)
  22123. * @param data defines the vertex data to use
  22124. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22125. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22126. */
  22127. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22128. /**
  22129. * Update a specific associated vertex buffer
  22130. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22131. * - VertexBuffer.PositionKind
  22132. * - VertexBuffer.UVKind
  22133. * - VertexBuffer.UV2Kind
  22134. * - VertexBuffer.UV3Kind
  22135. * - VertexBuffer.UV4Kind
  22136. * - VertexBuffer.UV5Kind
  22137. * - VertexBuffer.UV6Kind
  22138. * - VertexBuffer.ColorKind
  22139. * - VertexBuffer.MatricesIndicesKind
  22140. * - VertexBuffer.MatricesIndicesExtraKind
  22141. * - VertexBuffer.MatricesWeightsKind
  22142. * - VertexBuffer.MatricesWeightsExtraKind
  22143. * @param data defines the data source
  22144. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22145. * @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)
  22146. */
  22147. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22148. /**
  22149. * Creates a new index buffer
  22150. * @param indices defines the indices to store in the index buffer
  22151. * @param totalVertices defines the total number of vertices (could be null)
  22152. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22153. */
  22154. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22155. }
  22156. /**
  22157. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22158. */
  22159. export class VertexData {
  22160. /**
  22161. * Mesh side orientation : usually the external or front surface
  22162. */
  22163. static readonly FRONTSIDE: number;
  22164. /**
  22165. * Mesh side orientation : usually the internal or back surface
  22166. */
  22167. static readonly BACKSIDE: number;
  22168. /**
  22169. * Mesh side orientation : both internal and external or front and back surfaces
  22170. */
  22171. static readonly DOUBLESIDE: number;
  22172. /**
  22173. * Mesh side orientation : by default, `FRONTSIDE`
  22174. */
  22175. static readonly DEFAULTSIDE: number;
  22176. /**
  22177. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22178. */
  22179. positions: Nullable<FloatArray>;
  22180. /**
  22181. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22182. */
  22183. normals: Nullable<FloatArray>;
  22184. /**
  22185. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22186. */
  22187. tangents: Nullable<FloatArray>;
  22188. /**
  22189. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22190. */
  22191. uvs: Nullable<FloatArray>;
  22192. /**
  22193. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22194. */
  22195. uvs2: Nullable<FloatArray>;
  22196. /**
  22197. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22198. */
  22199. uvs3: Nullable<FloatArray>;
  22200. /**
  22201. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22202. */
  22203. uvs4: Nullable<FloatArray>;
  22204. /**
  22205. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22206. */
  22207. uvs5: Nullable<FloatArray>;
  22208. /**
  22209. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22210. */
  22211. uvs6: Nullable<FloatArray>;
  22212. /**
  22213. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22214. */
  22215. colors: Nullable<FloatArray>;
  22216. /**
  22217. * 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).
  22218. */
  22219. matricesIndices: Nullable<FloatArray>;
  22220. /**
  22221. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22222. */
  22223. matricesWeights: Nullable<FloatArray>;
  22224. /**
  22225. * An array extending the number of possible indices
  22226. */
  22227. matricesIndicesExtra: Nullable<FloatArray>;
  22228. /**
  22229. * An array extending the number of possible weights when the number of indices is extended
  22230. */
  22231. matricesWeightsExtra: Nullable<FloatArray>;
  22232. /**
  22233. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22234. */
  22235. indices: Nullable<IndicesArray>;
  22236. /**
  22237. * Uses the passed data array to set the set the values for the specified kind of data
  22238. * @param data a linear array of floating numbers
  22239. * @param kind the type of data that is being set, eg positions, colors etc
  22240. */
  22241. set(data: FloatArray, kind: string): void;
  22242. /**
  22243. * Associates the vertexData to the passed Mesh.
  22244. * Sets it as updatable or not (default `false`)
  22245. * @param mesh the mesh the vertexData is applied to
  22246. * @param updatable when used and having the value true allows new data to update the vertexData
  22247. * @returns the VertexData
  22248. */
  22249. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22250. /**
  22251. * Associates the vertexData to the passed Geometry.
  22252. * Sets it as updatable or not (default `false`)
  22253. * @param geometry the geometry the vertexData is applied to
  22254. * @param updatable when used and having the value true allows new data to update the vertexData
  22255. * @returns VertexData
  22256. */
  22257. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22258. /**
  22259. * Updates the associated mesh
  22260. * @param mesh the mesh to be updated
  22261. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22262. * @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
  22263. * @returns VertexData
  22264. */
  22265. updateMesh(mesh: Mesh): VertexData;
  22266. /**
  22267. * Updates the associated geometry
  22268. * @param geometry the geometry to be updated
  22269. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22270. * @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
  22271. * @returns VertexData.
  22272. */
  22273. updateGeometry(geometry: Geometry): VertexData;
  22274. private _applyTo;
  22275. private _update;
  22276. /**
  22277. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22278. * @param matrix the transforming matrix
  22279. * @returns the VertexData
  22280. */
  22281. transform(matrix: Matrix): VertexData;
  22282. /**
  22283. * Merges the passed VertexData into the current one
  22284. * @param other the VertexData to be merged into the current one
  22285. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22286. * @returns the modified VertexData
  22287. */
  22288. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22289. private _mergeElement;
  22290. private _validate;
  22291. /**
  22292. * Serializes the VertexData
  22293. * @returns a serialized object
  22294. */
  22295. serialize(): any;
  22296. /**
  22297. * Extracts the vertexData from a mesh
  22298. * @param mesh the mesh from which to extract the VertexData
  22299. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22300. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22301. * @returns the object VertexData associated to the passed mesh
  22302. */
  22303. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22304. /**
  22305. * Extracts the vertexData from the geometry
  22306. * @param geometry the geometry from which to extract the VertexData
  22307. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22308. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22309. * @returns the object VertexData associated to the passed mesh
  22310. */
  22311. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22312. private static _ExtractFrom;
  22313. /**
  22314. * Creates the VertexData for a Ribbon
  22315. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22316. * * pathArray array of paths, each of which an array of successive Vector3
  22317. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22318. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22319. * * 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
  22320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22321. * * 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)
  22322. * * 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)
  22323. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22324. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22325. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22326. * @returns the VertexData of the ribbon
  22327. */
  22328. static CreateRibbon(options: {
  22329. pathArray: Vector3[][];
  22330. closeArray?: boolean;
  22331. closePath?: boolean;
  22332. offset?: number;
  22333. sideOrientation?: number;
  22334. frontUVs?: Vector4;
  22335. backUVs?: Vector4;
  22336. invertUV?: boolean;
  22337. uvs?: Vector2[];
  22338. colors?: Color4[];
  22339. }): VertexData;
  22340. /**
  22341. * Creates the VertexData for a box
  22342. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22343. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22344. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22345. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22346. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22347. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22348. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22350. * * 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)
  22351. * * 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)
  22352. * @returns the VertexData of the box
  22353. */
  22354. static CreateBox(options: {
  22355. size?: number;
  22356. width?: number;
  22357. height?: number;
  22358. depth?: number;
  22359. faceUV?: Vector4[];
  22360. faceColors?: Color4[];
  22361. sideOrientation?: number;
  22362. frontUVs?: Vector4;
  22363. backUVs?: Vector4;
  22364. }): VertexData;
  22365. /**
  22366. * Creates the VertexData for a tiled box
  22367. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22368. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22369. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22370. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22371. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22372. * @returns the VertexData of the box
  22373. */
  22374. static CreateTiledBox(options: {
  22375. pattern?: number;
  22376. width?: number;
  22377. height?: number;
  22378. depth?: number;
  22379. tileSize?: number;
  22380. tileWidth?: number;
  22381. tileHeight?: number;
  22382. alignHorizontal?: number;
  22383. alignVertical?: number;
  22384. faceUV?: Vector4[];
  22385. faceColors?: Color4[];
  22386. sideOrientation?: number;
  22387. }): VertexData;
  22388. /**
  22389. * Creates the VertexData for a tiled plane
  22390. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22391. * * pattern a limited pattern arrangement depending on the number
  22392. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22393. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22394. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22395. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22396. * * 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)
  22397. * * 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)
  22398. * @returns the VertexData of the tiled plane
  22399. */
  22400. static CreateTiledPlane(options: {
  22401. pattern?: number;
  22402. tileSize?: number;
  22403. tileWidth?: number;
  22404. tileHeight?: number;
  22405. size?: number;
  22406. width?: number;
  22407. height?: number;
  22408. alignHorizontal?: number;
  22409. alignVertical?: number;
  22410. sideOrientation?: number;
  22411. frontUVs?: Vector4;
  22412. backUVs?: Vector4;
  22413. }): VertexData;
  22414. /**
  22415. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22416. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22417. * * segments sets the number of horizontal strips optional, default 32
  22418. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22419. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22420. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22421. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22422. * * 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
  22423. * * 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
  22424. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22425. * * 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)
  22426. * * 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)
  22427. * @returns the VertexData of the ellipsoid
  22428. */
  22429. static CreateSphere(options: {
  22430. segments?: number;
  22431. diameter?: number;
  22432. diameterX?: number;
  22433. diameterY?: number;
  22434. diameterZ?: number;
  22435. arc?: number;
  22436. slice?: number;
  22437. sideOrientation?: number;
  22438. frontUVs?: Vector4;
  22439. backUVs?: Vector4;
  22440. }): VertexData;
  22441. /**
  22442. * Creates the VertexData for a cylinder, cone or prism
  22443. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22444. * * height sets the height (y direction) of the cylinder, optional, default 2
  22445. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22446. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22447. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22448. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22449. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22450. * * 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
  22451. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22452. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22453. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22454. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22455. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22456. * * 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)
  22457. * * 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)
  22458. * @returns the VertexData of the cylinder, cone or prism
  22459. */
  22460. static CreateCylinder(options: {
  22461. height?: number;
  22462. diameterTop?: number;
  22463. diameterBottom?: number;
  22464. diameter?: number;
  22465. tessellation?: number;
  22466. subdivisions?: number;
  22467. arc?: number;
  22468. faceColors?: Color4[];
  22469. faceUV?: Vector4[];
  22470. hasRings?: boolean;
  22471. enclose?: boolean;
  22472. sideOrientation?: number;
  22473. frontUVs?: Vector4;
  22474. backUVs?: Vector4;
  22475. }): VertexData;
  22476. /**
  22477. * Creates the VertexData for a torus
  22478. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22479. * * diameter the diameter of the torus, optional default 1
  22480. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22481. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22483. * * 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)
  22484. * * 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)
  22485. * @returns the VertexData of the torus
  22486. */
  22487. static CreateTorus(options: {
  22488. diameter?: number;
  22489. thickness?: number;
  22490. tessellation?: number;
  22491. sideOrientation?: number;
  22492. frontUVs?: Vector4;
  22493. backUVs?: Vector4;
  22494. }): VertexData;
  22495. /**
  22496. * Creates the VertexData of the LineSystem
  22497. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22498. * - lines an array of lines, each line being an array of successive Vector3
  22499. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22500. * @returns the VertexData of the LineSystem
  22501. */
  22502. static CreateLineSystem(options: {
  22503. lines: Vector3[][];
  22504. colors?: Nullable<Color4[][]>;
  22505. }): VertexData;
  22506. /**
  22507. * Create the VertexData for a DashedLines
  22508. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22509. * - points an array successive Vector3
  22510. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22511. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22512. * - dashNb the intended total number of dashes, optional, default 200
  22513. * @returns the VertexData for the DashedLines
  22514. */
  22515. static CreateDashedLines(options: {
  22516. points: Vector3[];
  22517. dashSize?: number;
  22518. gapSize?: number;
  22519. dashNb?: number;
  22520. }): VertexData;
  22521. /**
  22522. * Creates the VertexData for a Ground
  22523. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22524. * - width the width (x direction) of the ground, optional, default 1
  22525. * - height the height (z direction) of the ground, optional, default 1
  22526. * - subdivisions the number of subdivisions per side, optional, default 1
  22527. * @returns the VertexData of the Ground
  22528. */
  22529. static CreateGround(options: {
  22530. width?: number;
  22531. height?: number;
  22532. subdivisions?: number;
  22533. subdivisionsX?: number;
  22534. subdivisionsY?: number;
  22535. }): VertexData;
  22536. /**
  22537. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22538. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22539. * * xmin the ground minimum X coordinate, optional, default -1
  22540. * * zmin the ground minimum Z coordinate, optional, default -1
  22541. * * xmax the ground maximum X coordinate, optional, default 1
  22542. * * zmax the ground maximum Z coordinate, optional, default 1
  22543. * * 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}
  22544. * * 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}
  22545. * @returns the VertexData of the TiledGround
  22546. */
  22547. static CreateTiledGround(options: {
  22548. xmin: number;
  22549. zmin: number;
  22550. xmax: number;
  22551. zmax: number;
  22552. subdivisions?: {
  22553. w: number;
  22554. h: number;
  22555. };
  22556. precision?: {
  22557. w: number;
  22558. h: number;
  22559. };
  22560. }): VertexData;
  22561. /**
  22562. * Creates the VertexData of the Ground designed from a heightmap
  22563. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22564. * * width the width (x direction) of the ground
  22565. * * height the height (z direction) of the ground
  22566. * * subdivisions the number of subdivisions per side
  22567. * * minHeight the minimum altitude on the ground, optional, default 0
  22568. * * maxHeight the maximum altitude on the ground, optional default 1
  22569. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22570. * * buffer the array holding the image color data
  22571. * * bufferWidth the width of image
  22572. * * bufferHeight the height of image
  22573. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22574. * @returns the VertexData of the Ground designed from a heightmap
  22575. */
  22576. static CreateGroundFromHeightMap(options: {
  22577. width: number;
  22578. height: number;
  22579. subdivisions: number;
  22580. minHeight: number;
  22581. maxHeight: number;
  22582. colorFilter: Color3;
  22583. buffer: Uint8Array;
  22584. bufferWidth: number;
  22585. bufferHeight: number;
  22586. alphaFilter: number;
  22587. }): VertexData;
  22588. /**
  22589. * Creates the VertexData for a Plane
  22590. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22591. * * size sets the width and height of the plane to the value of size, optional default 1
  22592. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22593. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22594. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22595. * * 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)
  22596. * * 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)
  22597. * @returns the VertexData of the box
  22598. */
  22599. static CreatePlane(options: {
  22600. size?: number;
  22601. width?: number;
  22602. height?: number;
  22603. sideOrientation?: number;
  22604. frontUVs?: Vector4;
  22605. backUVs?: Vector4;
  22606. }): VertexData;
  22607. /**
  22608. * Creates the VertexData of the Disc or regular Polygon
  22609. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22610. * * radius the radius of the disc, optional default 0.5
  22611. * * tessellation the number of polygon sides, optional, default 64
  22612. * * 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
  22613. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22614. * * 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)
  22615. * * 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)
  22616. * @returns the VertexData of the box
  22617. */
  22618. static CreateDisc(options: {
  22619. radius?: number;
  22620. tessellation?: number;
  22621. arc?: number;
  22622. sideOrientation?: number;
  22623. frontUVs?: Vector4;
  22624. backUVs?: Vector4;
  22625. }): VertexData;
  22626. /**
  22627. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22628. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22629. * @param polygon a mesh built from polygonTriangulation.build()
  22630. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22631. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22632. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22633. * @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)
  22634. * @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)
  22635. * @returns the VertexData of the Polygon
  22636. */
  22637. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22638. /**
  22639. * Creates the VertexData of the IcoSphere
  22640. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22641. * * radius the radius of the IcoSphere, optional default 1
  22642. * * radiusX allows stretching in the x direction, optional, default radius
  22643. * * radiusY allows stretching in the y direction, optional, default radius
  22644. * * radiusZ allows stretching in the z direction, optional, default radius
  22645. * * flat when true creates a flat shaded mesh, optional, default true
  22646. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22647. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22648. * * 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)
  22649. * * 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)
  22650. * @returns the VertexData of the IcoSphere
  22651. */
  22652. static CreateIcoSphere(options: {
  22653. radius?: number;
  22654. radiusX?: number;
  22655. radiusY?: number;
  22656. radiusZ?: number;
  22657. flat?: boolean;
  22658. subdivisions?: number;
  22659. sideOrientation?: number;
  22660. frontUVs?: Vector4;
  22661. backUVs?: Vector4;
  22662. }): VertexData;
  22663. /**
  22664. * Creates the VertexData for a Polyhedron
  22665. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22666. * * type provided types are:
  22667. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22668. * * 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)
  22669. * * size the size of the IcoSphere, optional default 1
  22670. * * sizeX allows stretching in the x direction, optional, default size
  22671. * * sizeY allows stretching in the y direction, optional, default size
  22672. * * sizeZ allows stretching in the z direction, optional, default size
  22673. * * 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
  22674. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22675. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22676. * * flat when true creates a flat shaded mesh, optional, default true
  22677. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22679. * * 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)
  22680. * * 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)
  22681. * @returns the VertexData of the Polyhedron
  22682. */
  22683. static CreatePolyhedron(options: {
  22684. type?: number;
  22685. size?: number;
  22686. sizeX?: number;
  22687. sizeY?: number;
  22688. sizeZ?: number;
  22689. custom?: any;
  22690. faceUV?: Vector4[];
  22691. faceColors?: Color4[];
  22692. flat?: boolean;
  22693. sideOrientation?: number;
  22694. frontUVs?: Vector4;
  22695. backUVs?: Vector4;
  22696. }): VertexData;
  22697. /**
  22698. * Creates the VertexData for a TorusKnot
  22699. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22700. * * radius the radius of the torus knot, optional, default 2
  22701. * * tube the thickness of the tube, optional, default 0.5
  22702. * * radialSegments the number of sides on each tube segments, optional, default 32
  22703. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22704. * * p the number of windings around the z axis, optional, default 2
  22705. * * q the number of windings around the x axis, optional, default 3
  22706. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22707. * * 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)
  22708. * * 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)
  22709. * @returns the VertexData of the Torus Knot
  22710. */
  22711. static CreateTorusKnot(options: {
  22712. radius?: number;
  22713. tube?: number;
  22714. radialSegments?: number;
  22715. tubularSegments?: number;
  22716. p?: number;
  22717. q?: number;
  22718. sideOrientation?: number;
  22719. frontUVs?: Vector4;
  22720. backUVs?: Vector4;
  22721. }): VertexData;
  22722. /**
  22723. * Compute normals for given positions and indices
  22724. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22725. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22726. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22727. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22728. * * facetNormals : optional array of facet normals (vector3)
  22729. * * facetPositions : optional array of facet positions (vector3)
  22730. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22731. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22732. * * bInfo : optional bounding info, required for facetPartitioning computation
  22733. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22734. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22735. * * useRightHandedSystem: optional boolean to for right handed system computation
  22736. * * depthSort : optional boolean to enable the facet depth sort computation
  22737. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22738. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22739. */
  22740. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22741. facetNormals?: any;
  22742. facetPositions?: any;
  22743. facetPartitioning?: any;
  22744. ratio?: number;
  22745. bInfo?: any;
  22746. bbSize?: Vector3;
  22747. subDiv?: any;
  22748. useRightHandedSystem?: boolean;
  22749. depthSort?: boolean;
  22750. distanceTo?: Vector3;
  22751. depthSortedFacets?: any;
  22752. }): void;
  22753. /** @hidden */
  22754. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22755. /**
  22756. * Applies VertexData created from the imported parameters to the geometry
  22757. * @param parsedVertexData the parsed data from an imported file
  22758. * @param geometry the geometry to apply the VertexData to
  22759. */
  22760. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22761. }
  22762. }
  22763. declare module BABYLON {
  22764. /**
  22765. * Defines a target to use with MorphTargetManager
  22766. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22767. */
  22768. export class MorphTarget implements IAnimatable {
  22769. /** defines the name of the target */
  22770. name: string;
  22771. /**
  22772. * Gets or sets the list of animations
  22773. */
  22774. animations: Animation[];
  22775. private _scene;
  22776. private _positions;
  22777. private _normals;
  22778. private _tangents;
  22779. private _uvs;
  22780. private _influence;
  22781. private _uniqueId;
  22782. /**
  22783. * Observable raised when the influence changes
  22784. */
  22785. onInfluenceChanged: Observable<boolean>;
  22786. /** @hidden */
  22787. _onDataLayoutChanged: Observable<void>;
  22788. /**
  22789. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22790. */
  22791. get influence(): number;
  22792. set influence(influence: number);
  22793. /**
  22794. * Gets or sets the id of the morph Target
  22795. */
  22796. id: string;
  22797. private _animationPropertiesOverride;
  22798. /**
  22799. * Gets or sets the animation properties override
  22800. */
  22801. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22802. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22803. /**
  22804. * Creates a new MorphTarget
  22805. * @param name defines the name of the target
  22806. * @param influence defines the influence to use
  22807. * @param scene defines the scene the morphtarget belongs to
  22808. */
  22809. constructor(
  22810. /** defines the name of the target */
  22811. name: string, influence?: number, scene?: Nullable<Scene>);
  22812. /**
  22813. * Gets the unique ID of this manager
  22814. */
  22815. get uniqueId(): number;
  22816. /**
  22817. * Gets a boolean defining if the target contains position data
  22818. */
  22819. get hasPositions(): boolean;
  22820. /**
  22821. * Gets a boolean defining if the target contains normal data
  22822. */
  22823. get hasNormals(): boolean;
  22824. /**
  22825. * Gets a boolean defining if the target contains tangent data
  22826. */
  22827. get hasTangents(): boolean;
  22828. /**
  22829. * Gets a boolean defining if the target contains texture coordinates data
  22830. */
  22831. get hasUVs(): boolean;
  22832. /**
  22833. * Affects position data to this target
  22834. * @param data defines the position data to use
  22835. */
  22836. setPositions(data: Nullable<FloatArray>): void;
  22837. /**
  22838. * Gets the position data stored in this target
  22839. * @returns a FloatArray containing the position data (or null if not present)
  22840. */
  22841. getPositions(): Nullable<FloatArray>;
  22842. /**
  22843. * Affects normal data to this target
  22844. * @param data defines the normal data to use
  22845. */
  22846. setNormals(data: Nullable<FloatArray>): void;
  22847. /**
  22848. * Gets the normal data stored in this target
  22849. * @returns a FloatArray containing the normal data (or null if not present)
  22850. */
  22851. getNormals(): Nullable<FloatArray>;
  22852. /**
  22853. * Affects tangent data to this target
  22854. * @param data defines the tangent data to use
  22855. */
  22856. setTangents(data: Nullable<FloatArray>): void;
  22857. /**
  22858. * Gets the tangent data stored in this target
  22859. * @returns a FloatArray containing the tangent data (or null if not present)
  22860. */
  22861. getTangents(): Nullable<FloatArray>;
  22862. /**
  22863. * Affects texture coordinates data to this target
  22864. * @param data defines the texture coordinates data to use
  22865. */
  22866. setUVs(data: Nullable<FloatArray>): void;
  22867. /**
  22868. * Gets the texture coordinates data stored in this target
  22869. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22870. */
  22871. getUVs(): Nullable<FloatArray>;
  22872. /**
  22873. * Clone the current target
  22874. * @returns a new MorphTarget
  22875. */
  22876. clone(): MorphTarget;
  22877. /**
  22878. * Serializes the current target into a Serialization object
  22879. * @returns the serialized object
  22880. */
  22881. serialize(): any;
  22882. /**
  22883. * Returns the string "MorphTarget"
  22884. * @returns "MorphTarget"
  22885. */
  22886. getClassName(): string;
  22887. /**
  22888. * Creates a new target from serialized data
  22889. * @param serializationObject defines the serialized data to use
  22890. * @returns a new MorphTarget
  22891. */
  22892. static Parse(serializationObject: any): MorphTarget;
  22893. /**
  22894. * Creates a MorphTarget from mesh data
  22895. * @param mesh defines the source mesh
  22896. * @param name defines the name to use for the new target
  22897. * @param influence defines the influence to attach to the target
  22898. * @returns a new MorphTarget
  22899. */
  22900. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22901. }
  22902. }
  22903. declare module BABYLON {
  22904. /**
  22905. * This class is used to deform meshes using morphing between different targets
  22906. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22907. */
  22908. export class MorphTargetManager {
  22909. private _targets;
  22910. private _targetInfluenceChangedObservers;
  22911. private _targetDataLayoutChangedObservers;
  22912. private _activeTargets;
  22913. private _scene;
  22914. private _influences;
  22915. private _supportsNormals;
  22916. private _supportsTangents;
  22917. private _supportsUVs;
  22918. private _vertexCount;
  22919. private _uniqueId;
  22920. private _tempInfluences;
  22921. /**
  22922. * Gets or sets a boolean indicating if normals must be morphed
  22923. */
  22924. enableNormalMorphing: boolean;
  22925. /**
  22926. * Gets or sets a boolean indicating if tangents must be morphed
  22927. */
  22928. enableTangentMorphing: boolean;
  22929. /**
  22930. * Gets or sets a boolean indicating if UV must be morphed
  22931. */
  22932. enableUVMorphing: boolean;
  22933. /**
  22934. * Creates a new MorphTargetManager
  22935. * @param scene defines the current scene
  22936. */
  22937. constructor(scene?: Nullable<Scene>);
  22938. /**
  22939. * Gets the unique ID of this manager
  22940. */
  22941. get uniqueId(): number;
  22942. /**
  22943. * Gets the number of vertices handled by this manager
  22944. */
  22945. get vertexCount(): number;
  22946. /**
  22947. * Gets a boolean indicating if this manager supports morphing of normals
  22948. */
  22949. get supportsNormals(): boolean;
  22950. /**
  22951. * Gets a boolean indicating if this manager supports morphing of tangents
  22952. */
  22953. get supportsTangents(): boolean;
  22954. /**
  22955. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22956. */
  22957. get supportsUVs(): boolean;
  22958. /**
  22959. * Gets the number of targets stored in this manager
  22960. */
  22961. get numTargets(): number;
  22962. /**
  22963. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22964. */
  22965. get numInfluencers(): number;
  22966. /**
  22967. * Gets the list of influences (one per target)
  22968. */
  22969. get influences(): Float32Array;
  22970. /**
  22971. * Gets the active target at specified index. An active target is a target with an influence > 0
  22972. * @param index defines the index to check
  22973. * @returns the requested target
  22974. */
  22975. getActiveTarget(index: number): MorphTarget;
  22976. /**
  22977. * Gets the target at specified index
  22978. * @param index defines the index to check
  22979. * @returns the requested target
  22980. */
  22981. getTarget(index: number): MorphTarget;
  22982. /**
  22983. * Add a new target to this manager
  22984. * @param target defines the target to add
  22985. */
  22986. addTarget(target: MorphTarget): void;
  22987. /**
  22988. * Removes a target from the manager
  22989. * @param target defines the target to remove
  22990. */
  22991. removeTarget(target: MorphTarget): void;
  22992. /**
  22993. * Clone the current manager
  22994. * @returns a new MorphTargetManager
  22995. */
  22996. clone(): MorphTargetManager;
  22997. /**
  22998. * Serializes the current manager into a Serialization object
  22999. * @returns the serialized object
  23000. */
  23001. serialize(): any;
  23002. private _syncActiveTargets;
  23003. /**
  23004. * Syncrhonize the targets with all the meshes using this morph target manager
  23005. */
  23006. synchronize(): void;
  23007. /**
  23008. * Creates a new MorphTargetManager from serialized data
  23009. * @param serializationObject defines the serialized data
  23010. * @param scene defines the hosting scene
  23011. * @returns the new MorphTargetManager
  23012. */
  23013. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23014. }
  23015. }
  23016. declare module BABYLON {
  23017. /**
  23018. * Class used to represent a specific level of detail of a mesh
  23019. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23020. */
  23021. export class MeshLODLevel {
  23022. /** Defines the distance where this level should start being displayed */
  23023. distance: number;
  23024. /** Defines the mesh to use to render this level */
  23025. mesh: Nullable<Mesh>;
  23026. /**
  23027. * Creates a new LOD level
  23028. * @param distance defines the distance where this level should star being displayed
  23029. * @param mesh defines the mesh to use to render this level
  23030. */
  23031. constructor(
  23032. /** Defines the distance where this level should start being displayed */
  23033. distance: number,
  23034. /** Defines the mesh to use to render this level */
  23035. mesh: Nullable<Mesh>);
  23036. }
  23037. }
  23038. declare module BABYLON {
  23039. /**
  23040. * Mesh representing the gorund
  23041. */
  23042. export class GroundMesh extends Mesh {
  23043. /** If octree should be generated */
  23044. generateOctree: boolean;
  23045. private _heightQuads;
  23046. /** @hidden */
  23047. _subdivisionsX: number;
  23048. /** @hidden */
  23049. _subdivisionsY: number;
  23050. /** @hidden */
  23051. _width: number;
  23052. /** @hidden */
  23053. _height: number;
  23054. /** @hidden */
  23055. _minX: number;
  23056. /** @hidden */
  23057. _maxX: number;
  23058. /** @hidden */
  23059. _minZ: number;
  23060. /** @hidden */
  23061. _maxZ: number;
  23062. constructor(name: string, scene: Scene);
  23063. /**
  23064. * "GroundMesh"
  23065. * @returns "GroundMesh"
  23066. */
  23067. getClassName(): string;
  23068. /**
  23069. * The minimum of x and y subdivisions
  23070. */
  23071. get subdivisions(): number;
  23072. /**
  23073. * X subdivisions
  23074. */
  23075. get subdivisionsX(): number;
  23076. /**
  23077. * Y subdivisions
  23078. */
  23079. get subdivisionsY(): number;
  23080. /**
  23081. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23082. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23083. * @param chunksCount the number of subdivisions for x and y
  23084. * @param octreeBlocksSize (Default: 32)
  23085. */
  23086. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23087. /**
  23088. * Returns a height (y) value in the Worl system :
  23089. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23090. * @param x x coordinate
  23091. * @param z z coordinate
  23092. * @returns the ground y position if (x, z) are outside the ground surface.
  23093. */
  23094. getHeightAtCoordinates(x: number, z: number): number;
  23095. /**
  23096. * Returns a normalized vector (Vector3) orthogonal to the ground
  23097. * at the ground coordinates (x, z) expressed in the World system.
  23098. * @param x x coordinate
  23099. * @param z z coordinate
  23100. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23101. */
  23102. getNormalAtCoordinates(x: number, z: number): Vector3;
  23103. /**
  23104. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23105. * at the ground coordinates (x, z) expressed in the World system.
  23106. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23107. * @param x x coordinate
  23108. * @param z z coordinate
  23109. * @param ref vector to store the result
  23110. * @returns the GroundMesh.
  23111. */
  23112. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23113. /**
  23114. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23115. * if the ground has been updated.
  23116. * This can be used in the render loop.
  23117. * @returns the GroundMesh.
  23118. */
  23119. updateCoordinateHeights(): GroundMesh;
  23120. private _getFacetAt;
  23121. private _initHeightQuads;
  23122. private _computeHeightQuads;
  23123. /**
  23124. * Serializes this ground mesh
  23125. * @param serializationObject object to write serialization to
  23126. */
  23127. serialize(serializationObject: any): void;
  23128. /**
  23129. * Parses a serialized ground mesh
  23130. * @param parsedMesh the serialized mesh
  23131. * @param scene the scene to create the ground mesh in
  23132. * @returns the created ground mesh
  23133. */
  23134. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23135. }
  23136. }
  23137. declare module BABYLON {
  23138. /**
  23139. * Interface for Physics-Joint data
  23140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23141. */
  23142. export interface PhysicsJointData {
  23143. /**
  23144. * The main pivot of the joint
  23145. */
  23146. mainPivot?: Vector3;
  23147. /**
  23148. * The connected pivot of the joint
  23149. */
  23150. connectedPivot?: Vector3;
  23151. /**
  23152. * The main axis of the joint
  23153. */
  23154. mainAxis?: Vector3;
  23155. /**
  23156. * The connected axis of the joint
  23157. */
  23158. connectedAxis?: Vector3;
  23159. /**
  23160. * The collision of the joint
  23161. */
  23162. collision?: boolean;
  23163. /**
  23164. * Native Oimo/Cannon/Energy data
  23165. */
  23166. nativeParams?: any;
  23167. }
  23168. /**
  23169. * This is a holder class for the physics joint created by the physics plugin
  23170. * It holds a set of functions to control the underlying joint
  23171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23172. */
  23173. export class PhysicsJoint {
  23174. /**
  23175. * The type of the physics joint
  23176. */
  23177. type: number;
  23178. /**
  23179. * The data for the physics joint
  23180. */
  23181. jointData: PhysicsJointData;
  23182. private _physicsJoint;
  23183. protected _physicsPlugin: IPhysicsEnginePlugin;
  23184. /**
  23185. * Initializes the physics joint
  23186. * @param type The type of the physics joint
  23187. * @param jointData The data for the physics joint
  23188. */
  23189. constructor(
  23190. /**
  23191. * The type of the physics joint
  23192. */
  23193. type: number,
  23194. /**
  23195. * The data for the physics joint
  23196. */
  23197. jointData: PhysicsJointData);
  23198. /**
  23199. * Gets the physics joint
  23200. */
  23201. get physicsJoint(): any;
  23202. /**
  23203. * Sets the physics joint
  23204. */
  23205. set physicsJoint(newJoint: any);
  23206. /**
  23207. * Sets the physics plugin
  23208. */
  23209. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23210. /**
  23211. * Execute a function that is physics-plugin specific.
  23212. * @param {Function} func the function that will be executed.
  23213. * It accepts two parameters: the physics world and the physics joint
  23214. */
  23215. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23216. /**
  23217. * Distance-Joint type
  23218. */
  23219. static DistanceJoint: number;
  23220. /**
  23221. * Hinge-Joint type
  23222. */
  23223. static HingeJoint: number;
  23224. /**
  23225. * Ball-and-Socket joint type
  23226. */
  23227. static BallAndSocketJoint: number;
  23228. /**
  23229. * Wheel-Joint type
  23230. */
  23231. static WheelJoint: number;
  23232. /**
  23233. * Slider-Joint type
  23234. */
  23235. static SliderJoint: number;
  23236. /**
  23237. * Prismatic-Joint type
  23238. */
  23239. static PrismaticJoint: number;
  23240. /**
  23241. * Universal-Joint type
  23242. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23243. */
  23244. static UniversalJoint: number;
  23245. /**
  23246. * Hinge-Joint 2 type
  23247. */
  23248. static Hinge2Joint: number;
  23249. /**
  23250. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23251. */
  23252. static PointToPointJoint: number;
  23253. /**
  23254. * Spring-Joint type
  23255. */
  23256. static SpringJoint: number;
  23257. /**
  23258. * Lock-Joint type
  23259. */
  23260. static LockJoint: number;
  23261. }
  23262. /**
  23263. * A class representing a physics distance joint
  23264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23265. */
  23266. export class DistanceJoint extends PhysicsJoint {
  23267. /**
  23268. *
  23269. * @param jointData The data for the Distance-Joint
  23270. */
  23271. constructor(jointData: DistanceJointData);
  23272. /**
  23273. * Update the predefined distance.
  23274. * @param maxDistance The maximum preferred distance
  23275. * @param minDistance The minimum preferred distance
  23276. */
  23277. updateDistance(maxDistance: number, minDistance?: number): void;
  23278. }
  23279. /**
  23280. * Represents a Motor-Enabled Joint
  23281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23282. */
  23283. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23284. /**
  23285. * Initializes the Motor-Enabled Joint
  23286. * @param type The type of the joint
  23287. * @param jointData The physica joint data for the joint
  23288. */
  23289. constructor(type: number, jointData: PhysicsJointData);
  23290. /**
  23291. * Set the motor values.
  23292. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23293. * @param force the force to apply
  23294. * @param maxForce max force for this motor.
  23295. */
  23296. setMotor(force?: number, maxForce?: number): void;
  23297. /**
  23298. * Set the motor's limits.
  23299. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23300. * @param upperLimit The upper limit of the motor
  23301. * @param lowerLimit The lower limit of the motor
  23302. */
  23303. setLimit(upperLimit: number, lowerLimit?: number): void;
  23304. }
  23305. /**
  23306. * This class represents a single physics Hinge-Joint
  23307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23308. */
  23309. export class HingeJoint extends MotorEnabledJoint {
  23310. /**
  23311. * Initializes the Hinge-Joint
  23312. * @param jointData The joint data for the Hinge-Joint
  23313. */
  23314. constructor(jointData: PhysicsJointData);
  23315. /**
  23316. * Set the motor values.
  23317. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23318. * @param {number} force the force to apply
  23319. * @param {number} maxForce max force for this motor.
  23320. */
  23321. setMotor(force?: number, maxForce?: number): void;
  23322. /**
  23323. * Set the motor's limits.
  23324. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23325. * @param upperLimit The upper limit of the motor
  23326. * @param lowerLimit The lower limit of the motor
  23327. */
  23328. setLimit(upperLimit: number, lowerLimit?: number): void;
  23329. }
  23330. /**
  23331. * This class represents a dual hinge physics joint (same as wheel joint)
  23332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23333. */
  23334. export class Hinge2Joint extends MotorEnabledJoint {
  23335. /**
  23336. * Initializes the Hinge2-Joint
  23337. * @param jointData The joint data for the Hinge2-Joint
  23338. */
  23339. constructor(jointData: PhysicsJointData);
  23340. /**
  23341. * Set the motor values.
  23342. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23343. * @param {number} targetSpeed the speed the motor is to reach
  23344. * @param {number} maxForce max force for this motor.
  23345. * @param {motorIndex} the motor's index, 0 or 1.
  23346. */
  23347. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23348. /**
  23349. * Set the motor limits.
  23350. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23351. * @param {number} upperLimit the upper limit
  23352. * @param {number} lowerLimit lower limit
  23353. * @param {motorIndex} the motor's index, 0 or 1.
  23354. */
  23355. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23356. }
  23357. /**
  23358. * Interface for a motor enabled joint
  23359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23360. */
  23361. export interface IMotorEnabledJoint {
  23362. /**
  23363. * Physics joint
  23364. */
  23365. physicsJoint: any;
  23366. /**
  23367. * Sets the motor of the motor-enabled joint
  23368. * @param force The force of the motor
  23369. * @param maxForce The maximum force of the motor
  23370. * @param motorIndex The index of the motor
  23371. */
  23372. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23373. /**
  23374. * Sets the limit of the motor
  23375. * @param upperLimit The upper limit of the motor
  23376. * @param lowerLimit The lower limit of the motor
  23377. * @param motorIndex The index of the motor
  23378. */
  23379. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23380. }
  23381. /**
  23382. * Joint data for a Distance-Joint
  23383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23384. */
  23385. export interface DistanceJointData extends PhysicsJointData {
  23386. /**
  23387. * Max distance the 2 joint objects can be apart
  23388. */
  23389. maxDistance: number;
  23390. }
  23391. /**
  23392. * Joint data from a spring joint
  23393. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23394. */
  23395. export interface SpringJointData extends PhysicsJointData {
  23396. /**
  23397. * Length of the spring
  23398. */
  23399. length: number;
  23400. /**
  23401. * Stiffness of the spring
  23402. */
  23403. stiffness: number;
  23404. /**
  23405. * Damping of the spring
  23406. */
  23407. damping: number;
  23408. /** this callback will be called when applying the force to the impostors. */
  23409. forceApplicationCallback: () => void;
  23410. }
  23411. }
  23412. declare module BABYLON {
  23413. /**
  23414. * Holds the data for the raycast result
  23415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23416. */
  23417. export class PhysicsRaycastResult {
  23418. private _hasHit;
  23419. private _hitDistance;
  23420. private _hitNormalWorld;
  23421. private _hitPointWorld;
  23422. private _rayFromWorld;
  23423. private _rayToWorld;
  23424. /**
  23425. * Gets if there was a hit
  23426. */
  23427. get hasHit(): boolean;
  23428. /**
  23429. * Gets the distance from the hit
  23430. */
  23431. get hitDistance(): number;
  23432. /**
  23433. * Gets the hit normal/direction in the world
  23434. */
  23435. get hitNormalWorld(): Vector3;
  23436. /**
  23437. * Gets the hit point in the world
  23438. */
  23439. get hitPointWorld(): Vector3;
  23440. /**
  23441. * Gets the ray "start point" of the ray in the world
  23442. */
  23443. get rayFromWorld(): Vector3;
  23444. /**
  23445. * Gets the ray "end point" of the ray in the world
  23446. */
  23447. get rayToWorld(): Vector3;
  23448. /**
  23449. * Sets the hit data (normal & point in world space)
  23450. * @param hitNormalWorld defines the normal in world space
  23451. * @param hitPointWorld defines the point in world space
  23452. */
  23453. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23454. /**
  23455. * Sets the distance from the start point to the hit point
  23456. * @param distance
  23457. */
  23458. setHitDistance(distance: number): void;
  23459. /**
  23460. * Calculates the distance manually
  23461. */
  23462. calculateHitDistance(): void;
  23463. /**
  23464. * Resets all the values to default
  23465. * @param from The from point on world space
  23466. * @param to The to point on world space
  23467. */
  23468. reset(from?: Vector3, to?: Vector3): void;
  23469. }
  23470. /**
  23471. * Interface for the size containing width and height
  23472. */
  23473. interface IXYZ {
  23474. /**
  23475. * X
  23476. */
  23477. x: number;
  23478. /**
  23479. * Y
  23480. */
  23481. y: number;
  23482. /**
  23483. * Z
  23484. */
  23485. z: number;
  23486. }
  23487. }
  23488. declare module BABYLON {
  23489. /**
  23490. * Interface used to describe a physics joint
  23491. */
  23492. export interface PhysicsImpostorJoint {
  23493. /** Defines the main impostor to which the joint is linked */
  23494. mainImpostor: PhysicsImpostor;
  23495. /** Defines the impostor that is connected to the main impostor using this joint */
  23496. connectedImpostor: PhysicsImpostor;
  23497. /** Defines the joint itself */
  23498. joint: PhysicsJoint;
  23499. }
  23500. /** @hidden */
  23501. export interface IPhysicsEnginePlugin {
  23502. world: any;
  23503. name: string;
  23504. setGravity(gravity: Vector3): void;
  23505. setTimeStep(timeStep: number): void;
  23506. getTimeStep(): number;
  23507. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23508. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23509. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23510. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23511. removePhysicsBody(impostor: PhysicsImpostor): void;
  23512. generateJoint(joint: PhysicsImpostorJoint): void;
  23513. removeJoint(joint: PhysicsImpostorJoint): void;
  23514. isSupported(): boolean;
  23515. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23516. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23517. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23518. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23519. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23520. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23521. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23522. getBodyMass(impostor: PhysicsImpostor): number;
  23523. getBodyFriction(impostor: PhysicsImpostor): number;
  23524. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23525. getBodyRestitution(impostor: PhysicsImpostor): number;
  23526. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23527. getBodyPressure?(impostor: PhysicsImpostor): number;
  23528. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23529. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23530. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23531. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23532. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23533. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23534. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23535. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23536. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23537. sleepBody(impostor: PhysicsImpostor): void;
  23538. wakeUpBody(impostor: PhysicsImpostor): void;
  23539. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23540. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23541. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23542. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23543. getRadius(impostor: PhysicsImpostor): number;
  23544. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23545. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23546. dispose(): void;
  23547. }
  23548. /**
  23549. * Interface used to define a physics engine
  23550. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export interface IPhysicsEngine {
  23553. /**
  23554. * Gets the gravity vector used by the simulation
  23555. */
  23556. gravity: Vector3;
  23557. /**
  23558. * Sets the gravity vector used by the simulation
  23559. * @param gravity defines the gravity vector to use
  23560. */
  23561. setGravity(gravity: Vector3): void;
  23562. /**
  23563. * Set the time step of the physics engine.
  23564. * Default is 1/60.
  23565. * To slow it down, enter 1/600 for example.
  23566. * To speed it up, 1/30
  23567. * @param newTimeStep the new timestep to apply to this world.
  23568. */
  23569. setTimeStep(newTimeStep: number): void;
  23570. /**
  23571. * Get the time step of the physics engine.
  23572. * @returns the current time step
  23573. */
  23574. getTimeStep(): number;
  23575. /**
  23576. * Set the sub time step of the physics engine.
  23577. * Default is 0 meaning there is no sub steps
  23578. * To increase physics resolution precision, set a small value (like 1 ms)
  23579. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23580. */
  23581. setSubTimeStep(subTimeStep: number): void;
  23582. /**
  23583. * Get the sub time step of the physics engine.
  23584. * @returns the current sub time step
  23585. */
  23586. getSubTimeStep(): number;
  23587. /**
  23588. * Release all resources
  23589. */
  23590. dispose(): void;
  23591. /**
  23592. * Gets the name of the current physics plugin
  23593. * @returns the name of the plugin
  23594. */
  23595. getPhysicsPluginName(): string;
  23596. /**
  23597. * Adding a new impostor for the impostor tracking.
  23598. * This will be done by the impostor itself.
  23599. * @param impostor the impostor to add
  23600. */
  23601. addImpostor(impostor: PhysicsImpostor): void;
  23602. /**
  23603. * Remove an impostor from the engine.
  23604. * This impostor and its mesh will not longer be updated by the physics engine.
  23605. * @param impostor the impostor to remove
  23606. */
  23607. removeImpostor(impostor: PhysicsImpostor): void;
  23608. /**
  23609. * Add a joint to the physics engine
  23610. * @param mainImpostor defines the main impostor to which the joint is added.
  23611. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23612. * @param joint defines the joint that will connect both impostors.
  23613. */
  23614. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23615. /**
  23616. * Removes a joint from the simulation
  23617. * @param mainImpostor defines the impostor used with the joint
  23618. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23619. * @param joint defines the joint to remove
  23620. */
  23621. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23622. /**
  23623. * Gets the current plugin used to run the simulation
  23624. * @returns current plugin
  23625. */
  23626. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23627. /**
  23628. * Gets the list of physic impostors
  23629. * @returns an array of PhysicsImpostor
  23630. */
  23631. getImpostors(): Array<PhysicsImpostor>;
  23632. /**
  23633. * Gets the impostor for a physics enabled object
  23634. * @param object defines the object impersonated by the impostor
  23635. * @returns the PhysicsImpostor or null if not found
  23636. */
  23637. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23638. /**
  23639. * Gets the impostor for a physics body object
  23640. * @param body defines physics body used by the impostor
  23641. * @returns the PhysicsImpostor or null if not found
  23642. */
  23643. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23644. /**
  23645. * Does a raycast in the physics world
  23646. * @param from when should the ray start?
  23647. * @param to when should the ray end?
  23648. * @returns PhysicsRaycastResult
  23649. */
  23650. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23651. /**
  23652. * Called by the scene. No need to call it.
  23653. * @param delta defines the timespam between frames
  23654. */
  23655. _step(delta: number): void;
  23656. }
  23657. }
  23658. declare module BABYLON {
  23659. /**
  23660. * The interface for the physics imposter parameters
  23661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23662. */
  23663. export interface PhysicsImpostorParameters {
  23664. /**
  23665. * The mass of the physics imposter
  23666. */
  23667. mass: number;
  23668. /**
  23669. * The friction of the physics imposter
  23670. */
  23671. friction?: number;
  23672. /**
  23673. * The coefficient of restitution of the physics imposter
  23674. */
  23675. restitution?: number;
  23676. /**
  23677. * The native options of the physics imposter
  23678. */
  23679. nativeOptions?: any;
  23680. /**
  23681. * Specifies if the parent should be ignored
  23682. */
  23683. ignoreParent?: boolean;
  23684. /**
  23685. * Specifies if bi-directional transformations should be disabled
  23686. */
  23687. disableBidirectionalTransformation?: boolean;
  23688. /**
  23689. * The pressure inside the physics imposter, soft object only
  23690. */
  23691. pressure?: number;
  23692. /**
  23693. * The stiffness the physics imposter, soft object only
  23694. */
  23695. stiffness?: number;
  23696. /**
  23697. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23698. */
  23699. velocityIterations?: number;
  23700. /**
  23701. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23702. */
  23703. positionIterations?: number;
  23704. /**
  23705. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23706. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23707. * Add to fix multiple points
  23708. */
  23709. fixedPoints?: number;
  23710. /**
  23711. * The collision margin around a soft object
  23712. */
  23713. margin?: number;
  23714. /**
  23715. * The collision margin around a soft object
  23716. */
  23717. damping?: number;
  23718. /**
  23719. * The path for a rope based on an extrusion
  23720. */
  23721. path?: any;
  23722. /**
  23723. * The shape of an extrusion used for a rope based on an extrusion
  23724. */
  23725. shape?: any;
  23726. }
  23727. /**
  23728. * Interface for a physics-enabled object
  23729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23730. */
  23731. export interface IPhysicsEnabledObject {
  23732. /**
  23733. * The position of the physics-enabled object
  23734. */
  23735. position: Vector3;
  23736. /**
  23737. * The rotation of the physics-enabled object
  23738. */
  23739. rotationQuaternion: Nullable<Quaternion>;
  23740. /**
  23741. * The scale of the physics-enabled object
  23742. */
  23743. scaling: Vector3;
  23744. /**
  23745. * The rotation of the physics-enabled object
  23746. */
  23747. rotation?: Vector3;
  23748. /**
  23749. * The parent of the physics-enabled object
  23750. */
  23751. parent?: any;
  23752. /**
  23753. * The bounding info of the physics-enabled object
  23754. * @returns The bounding info of the physics-enabled object
  23755. */
  23756. getBoundingInfo(): BoundingInfo;
  23757. /**
  23758. * Computes the world matrix
  23759. * @param force Specifies if the world matrix should be computed by force
  23760. * @returns A world matrix
  23761. */
  23762. computeWorldMatrix(force: boolean): Matrix;
  23763. /**
  23764. * Gets the world matrix
  23765. * @returns A world matrix
  23766. */
  23767. getWorldMatrix?(): Matrix;
  23768. /**
  23769. * Gets the child meshes
  23770. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23771. * @returns An array of abstract meshes
  23772. */
  23773. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23774. /**
  23775. * Gets the vertex data
  23776. * @param kind The type of vertex data
  23777. * @returns A nullable array of numbers, or a float32 array
  23778. */
  23779. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23780. /**
  23781. * Gets the indices from the mesh
  23782. * @returns A nullable array of index arrays
  23783. */
  23784. getIndices?(): Nullable<IndicesArray>;
  23785. /**
  23786. * Gets the scene from the mesh
  23787. * @returns the indices array or null
  23788. */
  23789. getScene?(): Scene;
  23790. /**
  23791. * Gets the absolute position from the mesh
  23792. * @returns the absolute position
  23793. */
  23794. getAbsolutePosition(): Vector3;
  23795. /**
  23796. * Gets the absolute pivot point from the mesh
  23797. * @returns the absolute pivot point
  23798. */
  23799. getAbsolutePivotPoint(): Vector3;
  23800. /**
  23801. * Rotates the mesh
  23802. * @param axis The axis of rotation
  23803. * @param amount The amount of rotation
  23804. * @param space The space of the rotation
  23805. * @returns The rotation transform node
  23806. */
  23807. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23808. /**
  23809. * Translates the mesh
  23810. * @param axis The axis of translation
  23811. * @param distance The distance of translation
  23812. * @param space The space of the translation
  23813. * @returns The transform node
  23814. */
  23815. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23816. /**
  23817. * Sets the absolute position of the mesh
  23818. * @param absolutePosition The absolute position of the mesh
  23819. * @returns The transform node
  23820. */
  23821. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23822. /**
  23823. * Gets the class name of the mesh
  23824. * @returns The class name
  23825. */
  23826. getClassName(): string;
  23827. }
  23828. /**
  23829. * Represents a physics imposter
  23830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23831. */
  23832. export class PhysicsImpostor {
  23833. /**
  23834. * The physics-enabled object used as the physics imposter
  23835. */
  23836. object: IPhysicsEnabledObject;
  23837. /**
  23838. * The type of the physics imposter
  23839. */
  23840. type: number;
  23841. private _options;
  23842. private _scene?;
  23843. /**
  23844. * The default object size of the imposter
  23845. */
  23846. static DEFAULT_OBJECT_SIZE: Vector3;
  23847. /**
  23848. * The identity quaternion of the imposter
  23849. */
  23850. static IDENTITY_QUATERNION: Quaternion;
  23851. /** @hidden */
  23852. _pluginData: any;
  23853. private _physicsEngine;
  23854. private _physicsBody;
  23855. private _bodyUpdateRequired;
  23856. private _onBeforePhysicsStepCallbacks;
  23857. private _onAfterPhysicsStepCallbacks;
  23858. /** @hidden */
  23859. _onPhysicsCollideCallbacks: Array<{
  23860. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23861. otherImpostors: Array<PhysicsImpostor>;
  23862. }>;
  23863. private _deltaPosition;
  23864. private _deltaRotation;
  23865. private _deltaRotationConjugated;
  23866. /** @hidden */
  23867. _isFromLine: boolean;
  23868. private _parent;
  23869. private _isDisposed;
  23870. private static _tmpVecs;
  23871. private static _tmpQuat;
  23872. /**
  23873. * Specifies if the physics imposter is disposed
  23874. */
  23875. get isDisposed(): boolean;
  23876. /**
  23877. * Gets the mass of the physics imposter
  23878. */
  23879. get mass(): number;
  23880. set mass(value: number);
  23881. /**
  23882. * Gets the coefficient of friction
  23883. */
  23884. get friction(): number;
  23885. /**
  23886. * Sets the coefficient of friction
  23887. */
  23888. set friction(value: number);
  23889. /**
  23890. * Gets the coefficient of restitution
  23891. */
  23892. get restitution(): number;
  23893. /**
  23894. * Sets the coefficient of restitution
  23895. */
  23896. set restitution(value: number);
  23897. /**
  23898. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23899. */
  23900. get pressure(): number;
  23901. /**
  23902. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23903. */
  23904. set pressure(value: number);
  23905. /**
  23906. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23907. */
  23908. get stiffness(): number;
  23909. /**
  23910. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23911. */
  23912. set stiffness(value: number);
  23913. /**
  23914. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23915. */
  23916. get velocityIterations(): number;
  23917. /**
  23918. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23919. */
  23920. set velocityIterations(value: number);
  23921. /**
  23922. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23923. */
  23924. get positionIterations(): number;
  23925. /**
  23926. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23927. */
  23928. set positionIterations(value: number);
  23929. /**
  23930. * The unique id of the physics imposter
  23931. * set by the physics engine when adding this impostor to the array
  23932. */
  23933. uniqueId: number;
  23934. /**
  23935. * @hidden
  23936. */
  23937. soft: boolean;
  23938. /**
  23939. * @hidden
  23940. */
  23941. segments: number;
  23942. private _joints;
  23943. /**
  23944. * Initializes the physics imposter
  23945. * @param object The physics-enabled object used as the physics imposter
  23946. * @param type The type of the physics imposter
  23947. * @param _options The options for the physics imposter
  23948. * @param _scene The Babylon scene
  23949. */
  23950. constructor(
  23951. /**
  23952. * The physics-enabled object used as the physics imposter
  23953. */
  23954. object: IPhysicsEnabledObject,
  23955. /**
  23956. * The type of the physics imposter
  23957. */
  23958. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23959. /**
  23960. * This function will completly initialize this impostor.
  23961. * It will create a new body - but only if this mesh has no parent.
  23962. * If it has, this impostor will not be used other than to define the impostor
  23963. * of the child mesh.
  23964. * @hidden
  23965. */
  23966. _init(): void;
  23967. private _getPhysicsParent;
  23968. /**
  23969. * Should a new body be generated.
  23970. * @returns boolean specifying if body initialization is required
  23971. */
  23972. isBodyInitRequired(): boolean;
  23973. /**
  23974. * Sets the updated scaling
  23975. * @param updated Specifies if the scaling is updated
  23976. */
  23977. setScalingUpdated(): void;
  23978. /**
  23979. * Force a regeneration of this or the parent's impostor's body.
  23980. * Use under cautious - This will remove all joints already implemented.
  23981. */
  23982. forceUpdate(): void;
  23983. /**
  23984. * Gets the body that holds this impostor. Either its own, or its parent.
  23985. */
  23986. get physicsBody(): any;
  23987. /**
  23988. * Get the parent of the physics imposter
  23989. * @returns Physics imposter or null
  23990. */
  23991. get parent(): Nullable<PhysicsImpostor>;
  23992. /**
  23993. * Sets the parent of the physics imposter
  23994. */
  23995. set parent(value: Nullable<PhysicsImpostor>);
  23996. /**
  23997. * Set the physics body. Used mainly by the physics engine/plugin
  23998. */
  23999. set physicsBody(physicsBody: any);
  24000. /**
  24001. * Resets the update flags
  24002. */
  24003. resetUpdateFlags(): void;
  24004. /**
  24005. * Gets the object extend size
  24006. * @returns the object extend size
  24007. */
  24008. getObjectExtendSize(): Vector3;
  24009. /**
  24010. * Gets the object center
  24011. * @returns The object center
  24012. */
  24013. getObjectCenter(): Vector3;
  24014. /**
  24015. * Get a specific parameter from the options parameters
  24016. * @param paramName The object parameter name
  24017. * @returns The object parameter
  24018. */
  24019. getParam(paramName: string): any;
  24020. /**
  24021. * Sets a specific parameter in the options given to the physics plugin
  24022. * @param paramName The parameter name
  24023. * @param value The value of the parameter
  24024. */
  24025. setParam(paramName: string, value: number): void;
  24026. /**
  24027. * Specifically change the body's mass option. Won't recreate the physics body object
  24028. * @param mass The mass of the physics imposter
  24029. */
  24030. setMass(mass: number): void;
  24031. /**
  24032. * Gets the linear velocity
  24033. * @returns linear velocity or null
  24034. */
  24035. getLinearVelocity(): Nullable<Vector3>;
  24036. /**
  24037. * Sets the linear velocity
  24038. * @param velocity linear velocity or null
  24039. */
  24040. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24041. /**
  24042. * Gets the angular velocity
  24043. * @returns angular velocity or null
  24044. */
  24045. getAngularVelocity(): Nullable<Vector3>;
  24046. /**
  24047. * Sets the angular velocity
  24048. * @param velocity The velocity or null
  24049. */
  24050. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24051. /**
  24052. * Execute a function with the physics plugin native code
  24053. * Provide a function the will have two variables - the world object and the physics body object
  24054. * @param func The function to execute with the physics plugin native code
  24055. */
  24056. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24057. /**
  24058. * Register a function that will be executed before the physics world is stepping forward
  24059. * @param func The function to execute before the physics world is stepped forward
  24060. */
  24061. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24062. /**
  24063. * Unregister a function that will be executed before the physics world is stepping forward
  24064. * @param func The function to execute before the physics world is stepped forward
  24065. */
  24066. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24067. /**
  24068. * Register a function that will be executed after the physics step
  24069. * @param func The function to execute after physics step
  24070. */
  24071. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24072. /**
  24073. * Unregisters a function that will be executed after the physics step
  24074. * @param func The function to execute after physics step
  24075. */
  24076. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24077. /**
  24078. * register a function that will be executed when this impostor collides against a different body
  24079. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24080. * @param func Callback that is executed on collision
  24081. */
  24082. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24083. /**
  24084. * Unregisters the physics imposter on contact
  24085. * @param collideAgainst The physics object to collide against
  24086. * @param func Callback to execute on collision
  24087. */
  24088. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24089. private _tmpQuat;
  24090. private _tmpQuat2;
  24091. /**
  24092. * Get the parent rotation
  24093. * @returns The parent rotation
  24094. */
  24095. getParentsRotation(): Quaternion;
  24096. /**
  24097. * this function is executed by the physics engine.
  24098. */
  24099. beforeStep: () => void;
  24100. /**
  24101. * this function is executed by the physics engine
  24102. */
  24103. afterStep: () => void;
  24104. /**
  24105. * Legacy collision detection event support
  24106. */
  24107. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24108. /**
  24109. * event and body object due to cannon's event-based architecture.
  24110. */
  24111. onCollide: (e: {
  24112. body: any;
  24113. }) => void;
  24114. /**
  24115. * Apply a force
  24116. * @param force The force to apply
  24117. * @param contactPoint The contact point for the force
  24118. * @returns The physics imposter
  24119. */
  24120. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24121. /**
  24122. * Apply an impulse
  24123. * @param force The impulse force
  24124. * @param contactPoint The contact point for the impulse force
  24125. * @returns The physics imposter
  24126. */
  24127. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24128. /**
  24129. * A help function to create a joint
  24130. * @param otherImpostor A physics imposter used to create a joint
  24131. * @param jointType The type of joint
  24132. * @param jointData The data for the joint
  24133. * @returns The physics imposter
  24134. */
  24135. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24136. /**
  24137. * Add a joint to this impostor with a different impostor
  24138. * @param otherImpostor A physics imposter used to add a joint
  24139. * @param joint The joint to add
  24140. * @returns The physics imposter
  24141. */
  24142. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24143. /**
  24144. * Add an anchor to a cloth impostor
  24145. * @param otherImpostor rigid impostor to anchor to
  24146. * @param width ratio across width from 0 to 1
  24147. * @param height ratio up height from 0 to 1
  24148. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24149. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24150. * @returns impostor the soft imposter
  24151. */
  24152. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24153. /**
  24154. * Add a hook to a rope impostor
  24155. * @param otherImpostor rigid impostor to anchor to
  24156. * @param length ratio across rope from 0 to 1
  24157. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24158. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24159. * @returns impostor the rope imposter
  24160. */
  24161. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24162. /**
  24163. * Will keep this body still, in a sleep mode.
  24164. * @returns the physics imposter
  24165. */
  24166. sleep(): PhysicsImpostor;
  24167. /**
  24168. * Wake the body up.
  24169. * @returns The physics imposter
  24170. */
  24171. wakeUp(): PhysicsImpostor;
  24172. /**
  24173. * Clones the physics imposter
  24174. * @param newObject The physics imposter clones to this physics-enabled object
  24175. * @returns A nullable physics imposter
  24176. */
  24177. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24178. /**
  24179. * Disposes the physics imposter
  24180. */
  24181. dispose(): void;
  24182. /**
  24183. * Sets the delta position
  24184. * @param position The delta position amount
  24185. */
  24186. setDeltaPosition(position: Vector3): void;
  24187. /**
  24188. * Sets the delta rotation
  24189. * @param rotation The delta rotation amount
  24190. */
  24191. setDeltaRotation(rotation: Quaternion): void;
  24192. /**
  24193. * Gets the box size of the physics imposter and stores the result in the input parameter
  24194. * @param result Stores the box size
  24195. * @returns The physics imposter
  24196. */
  24197. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24198. /**
  24199. * Gets the radius of the physics imposter
  24200. * @returns Radius of the physics imposter
  24201. */
  24202. getRadius(): number;
  24203. /**
  24204. * Sync a bone with this impostor
  24205. * @param bone The bone to sync to the impostor.
  24206. * @param boneMesh The mesh that the bone is influencing.
  24207. * @param jointPivot The pivot of the joint / bone in local space.
  24208. * @param distToJoint Optional distance from the impostor to the joint.
  24209. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24210. */
  24211. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24212. /**
  24213. * Sync impostor to a bone
  24214. * @param bone The bone that the impostor will be synced to.
  24215. * @param boneMesh The mesh that the bone is influencing.
  24216. * @param jointPivot The pivot of the joint / bone in local space.
  24217. * @param distToJoint Optional distance from the impostor to the joint.
  24218. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24219. * @param boneAxis Optional vector3 axis the bone is aligned with
  24220. */
  24221. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24222. /**
  24223. * No-Imposter type
  24224. */
  24225. static NoImpostor: number;
  24226. /**
  24227. * Sphere-Imposter type
  24228. */
  24229. static SphereImpostor: number;
  24230. /**
  24231. * Box-Imposter type
  24232. */
  24233. static BoxImpostor: number;
  24234. /**
  24235. * Plane-Imposter type
  24236. */
  24237. static PlaneImpostor: number;
  24238. /**
  24239. * Mesh-imposter type
  24240. */
  24241. static MeshImpostor: number;
  24242. /**
  24243. * Capsule-Impostor type (Ammo.js plugin only)
  24244. */
  24245. static CapsuleImpostor: number;
  24246. /**
  24247. * Cylinder-Imposter type
  24248. */
  24249. static CylinderImpostor: number;
  24250. /**
  24251. * Particle-Imposter type
  24252. */
  24253. static ParticleImpostor: number;
  24254. /**
  24255. * Heightmap-Imposter type
  24256. */
  24257. static HeightmapImpostor: number;
  24258. /**
  24259. * ConvexHull-Impostor type (Ammo.js plugin only)
  24260. */
  24261. static ConvexHullImpostor: number;
  24262. /**
  24263. * Custom-Imposter type (Ammo.js plugin only)
  24264. */
  24265. static CustomImpostor: number;
  24266. /**
  24267. * Rope-Imposter type
  24268. */
  24269. static RopeImpostor: number;
  24270. /**
  24271. * Cloth-Imposter type
  24272. */
  24273. static ClothImpostor: number;
  24274. /**
  24275. * Softbody-Imposter type
  24276. */
  24277. static SoftbodyImpostor: number;
  24278. }
  24279. }
  24280. declare module BABYLON {
  24281. /**
  24282. * @hidden
  24283. **/
  24284. export class _CreationDataStorage {
  24285. closePath?: boolean;
  24286. closeArray?: boolean;
  24287. idx: number[];
  24288. dashSize: number;
  24289. gapSize: number;
  24290. path3D: Path3D;
  24291. pathArray: Vector3[][];
  24292. arc: number;
  24293. radius: number;
  24294. cap: number;
  24295. tessellation: number;
  24296. }
  24297. /**
  24298. * @hidden
  24299. **/
  24300. class _InstanceDataStorage {
  24301. visibleInstances: any;
  24302. batchCache: _InstancesBatch;
  24303. instancesBufferSize: number;
  24304. instancesBuffer: Nullable<Buffer>;
  24305. instancesData: Float32Array;
  24306. overridenInstanceCount: number;
  24307. isFrozen: boolean;
  24308. previousBatch: Nullable<_InstancesBatch>;
  24309. hardwareInstancedRendering: boolean;
  24310. sideOrientation: number;
  24311. manualUpdate: boolean;
  24312. }
  24313. /**
  24314. * @hidden
  24315. **/
  24316. export class _InstancesBatch {
  24317. mustReturn: boolean;
  24318. visibleInstances: Nullable<InstancedMesh[]>[];
  24319. renderSelf: boolean[];
  24320. hardwareInstancedRendering: boolean[];
  24321. }
  24322. /**
  24323. * Class used to represent renderable models
  24324. */
  24325. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24326. /**
  24327. * Mesh side orientation : usually the external or front surface
  24328. */
  24329. static readonly FRONTSIDE: number;
  24330. /**
  24331. * Mesh side orientation : usually the internal or back surface
  24332. */
  24333. static readonly BACKSIDE: number;
  24334. /**
  24335. * Mesh side orientation : both internal and external or front and back surfaces
  24336. */
  24337. static readonly DOUBLESIDE: number;
  24338. /**
  24339. * Mesh side orientation : by default, `FRONTSIDE`
  24340. */
  24341. static readonly DEFAULTSIDE: number;
  24342. /**
  24343. * Mesh cap setting : no cap
  24344. */
  24345. static readonly NO_CAP: number;
  24346. /**
  24347. * Mesh cap setting : one cap at the beginning of the mesh
  24348. */
  24349. static readonly CAP_START: number;
  24350. /**
  24351. * Mesh cap setting : one cap at the end of the mesh
  24352. */
  24353. static readonly CAP_END: number;
  24354. /**
  24355. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24356. */
  24357. static readonly CAP_ALL: number;
  24358. /**
  24359. * Mesh pattern setting : no flip or rotate
  24360. */
  24361. static readonly NO_FLIP: number;
  24362. /**
  24363. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24364. */
  24365. static readonly FLIP_TILE: number;
  24366. /**
  24367. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24368. */
  24369. static readonly ROTATE_TILE: number;
  24370. /**
  24371. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24372. */
  24373. static readonly FLIP_ROW: number;
  24374. /**
  24375. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24376. */
  24377. static readonly ROTATE_ROW: number;
  24378. /**
  24379. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24380. */
  24381. static readonly FLIP_N_ROTATE_TILE: number;
  24382. /**
  24383. * Mesh pattern setting : rotate pattern and rotate
  24384. */
  24385. static readonly FLIP_N_ROTATE_ROW: number;
  24386. /**
  24387. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24388. */
  24389. static readonly CENTER: number;
  24390. /**
  24391. * Mesh tile positioning : part tiles on left
  24392. */
  24393. static readonly LEFT: number;
  24394. /**
  24395. * Mesh tile positioning : part tiles on right
  24396. */
  24397. static readonly RIGHT: number;
  24398. /**
  24399. * Mesh tile positioning : part tiles on top
  24400. */
  24401. static readonly TOP: number;
  24402. /**
  24403. * Mesh tile positioning : part tiles on bottom
  24404. */
  24405. static readonly BOTTOM: number;
  24406. /**
  24407. * Gets the default side orientation.
  24408. * @param orientation the orientation to value to attempt to get
  24409. * @returns the default orientation
  24410. * @hidden
  24411. */
  24412. static _GetDefaultSideOrientation(orientation?: number): number;
  24413. private _internalMeshDataInfo;
  24414. /**
  24415. * An event triggered before rendering the mesh
  24416. */
  24417. get onBeforeRenderObservable(): Observable<Mesh>;
  24418. /**
  24419. * An event triggered before binding the mesh
  24420. */
  24421. get onBeforeBindObservable(): Observable<Mesh>;
  24422. /**
  24423. * An event triggered after rendering the mesh
  24424. */
  24425. get onAfterRenderObservable(): Observable<Mesh>;
  24426. /**
  24427. * An event triggered before drawing the mesh
  24428. */
  24429. get onBeforeDrawObservable(): Observable<Mesh>;
  24430. private _onBeforeDrawObserver;
  24431. /**
  24432. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24433. */
  24434. set onBeforeDraw(callback: () => void);
  24435. get hasInstances(): boolean;
  24436. /**
  24437. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24438. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24439. */
  24440. delayLoadState: number;
  24441. /**
  24442. * Gets the list of instances created from this mesh
  24443. * it is not supposed to be modified manually.
  24444. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24445. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24446. */
  24447. instances: InstancedMesh[];
  24448. /**
  24449. * Gets the file containing delay loading data for this mesh
  24450. */
  24451. delayLoadingFile: string;
  24452. /** @hidden */
  24453. _binaryInfo: any;
  24454. /**
  24455. * User defined function used to change how LOD level selection is done
  24456. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24457. */
  24458. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24459. /**
  24460. * Gets or sets the morph target manager
  24461. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24462. */
  24463. get morphTargetManager(): Nullable<MorphTargetManager>;
  24464. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24465. /** @hidden */
  24466. _creationDataStorage: Nullable<_CreationDataStorage>;
  24467. /** @hidden */
  24468. _geometry: Nullable<Geometry>;
  24469. /** @hidden */
  24470. _delayInfo: Array<string>;
  24471. /** @hidden */
  24472. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24473. /** @hidden */
  24474. _instanceDataStorage: _InstanceDataStorage;
  24475. private _effectiveMaterial;
  24476. /** @hidden */
  24477. _shouldGenerateFlatShading: boolean;
  24478. /** @hidden */
  24479. _originalBuilderSideOrientation: number;
  24480. /**
  24481. * Use this property to change the original side orientation defined at construction time
  24482. */
  24483. overrideMaterialSideOrientation: Nullable<number>;
  24484. /**
  24485. * Gets the source mesh (the one used to clone this one from)
  24486. */
  24487. get source(): Nullable<Mesh>;
  24488. /**
  24489. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24490. */
  24491. get isUnIndexed(): boolean;
  24492. set isUnIndexed(value: boolean);
  24493. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24494. get worldMatrixInstancedBuffer(): Float32Array;
  24495. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24496. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24497. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24498. /**
  24499. * @constructor
  24500. * @param name The value used by scene.getMeshByName() to do a lookup.
  24501. * @param scene The scene to add this mesh to.
  24502. * @param parent The parent of this mesh, if it has one
  24503. * @param source An optional Mesh from which geometry is shared, cloned.
  24504. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24505. * When false, achieved by calling a clone(), also passing False.
  24506. * This will make creation of children, recursive.
  24507. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24508. */
  24509. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24510. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24511. doNotInstantiate: boolean;
  24512. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24513. /**
  24514. * Gets the class name
  24515. * @returns the string "Mesh".
  24516. */
  24517. getClassName(): string;
  24518. /** @hidden */
  24519. get _isMesh(): boolean;
  24520. /**
  24521. * Returns a description of this mesh
  24522. * @param fullDetails define if full details about this mesh must be used
  24523. * @returns a descriptive string representing this mesh
  24524. */
  24525. toString(fullDetails?: boolean): string;
  24526. /** @hidden */
  24527. _unBindEffect(): void;
  24528. /**
  24529. * Gets a boolean indicating if this mesh has LOD
  24530. */
  24531. get hasLODLevels(): boolean;
  24532. /**
  24533. * Gets the list of MeshLODLevel associated with the current mesh
  24534. * @returns an array of MeshLODLevel
  24535. */
  24536. getLODLevels(): MeshLODLevel[];
  24537. private _sortLODLevels;
  24538. /**
  24539. * Add a mesh as LOD level triggered at the given distance.
  24540. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24541. * @param distance The distance from the center of the object to show this level
  24542. * @param mesh The mesh to be added as LOD level (can be null)
  24543. * @return This mesh (for chaining)
  24544. */
  24545. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24546. /**
  24547. * Returns the LOD level mesh at the passed distance or null if not found.
  24548. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24549. * @param distance The distance from the center of the object to show this level
  24550. * @returns a Mesh or `null`
  24551. */
  24552. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24553. /**
  24554. * Remove a mesh from the LOD array
  24555. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24556. * @param mesh defines the mesh to be removed
  24557. * @return This mesh (for chaining)
  24558. */
  24559. removeLODLevel(mesh: Mesh): Mesh;
  24560. /**
  24561. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24562. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24563. * @param camera defines the camera to use to compute distance
  24564. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24565. * @return This mesh (for chaining)
  24566. */
  24567. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24568. /**
  24569. * Gets the mesh internal Geometry object
  24570. */
  24571. get geometry(): Nullable<Geometry>;
  24572. /**
  24573. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24574. * @returns the total number of vertices
  24575. */
  24576. getTotalVertices(): number;
  24577. /**
  24578. * Returns the content of an associated vertex buffer
  24579. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24580. * - VertexBuffer.PositionKind
  24581. * - VertexBuffer.UVKind
  24582. * - VertexBuffer.UV2Kind
  24583. * - VertexBuffer.UV3Kind
  24584. * - VertexBuffer.UV4Kind
  24585. * - VertexBuffer.UV5Kind
  24586. * - VertexBuffer.UV6Kind
  24587. * - VertexBuffer.ColorKind
  24588. * - VertexBuffer.MatricesIndicesKind
  24589. * - VertexBuffer.MatricesIndicesExtraKind
  24590. * - VertexBuffer.MatricesWeightsKind
  24591. * - VertexBuffer.MatricesWeightsExtraKind
  24592. * @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
  24593. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24594. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24595. */
  24596. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24597. /**
  24598. * Returns the mesh VertexBuffer object from the requested `kind`
  24599. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24600. * - VertexBuffer.PositionKind
  24601. * - VertexBuffer.NormalKind
  24602. * - VertexBuffer.UVKind
  24603. * - VertexBuffer.UV2Kind
  24604. * - VertexBuffer.UV3Kind
  24605. * - VertexBuffer.UV4Kind
  24606. * - VertexBuffer.UV5Kind
  24607. * - VertexBuffer.UV6Kind
  24608. * - VertexBuffer.ColorKind
  24609. * - VertexBuffer.MatricesIndicesKind
  24610. * - VertexBuffer.MatricesIndicesExtraKind
  24611. * - VertexBuffer.MatricesWeightsKind
  24612. * - VertexBuffer.MatricesWeightsExtraKind
  24613. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24614. */
  24615. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24616. /**
  24617. * Tests if a specific vertex buffer is associated with this mesh
  24618. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24619. * - VertexBuffer.PositionKind
  24620. * - VertexBuffer.NormalKind
  24621. * - VertexBuffer.UVKind
  24622. * - VertexBuffer.UV2Kind
  24623. * - VertexBuffer.UV3Kind
  24624. * - VertexBuffer.UV4Kind
  24625. * - VertexBuffer.UV5Kind
  24626. * - VertexBuffer.UV6Kind
  24627. * - VertexBuffer.ColorKind
  24628. * - VertexBuffer.MatricesIndicesKind
  24629. * - VertexBuffer.MatricesIndicesExtraKind
  24630. * - VertexBuffer.MatricesWeightsKind
  24631. * - VertexBuffer.MatricesWeightsExtraKind
  24632. * @returns a boolean
  24633. */
  24634. isVerticesDataPresent(kind: string): boolean;
  24635. /**
  24636. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24637. * @param kind defines which buffer to check (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. * @returns a boolean
  24651. */
  24652. isVertexBufferUpdatable(kind: string): boolean;
  24653. /**
  24654. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24655. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24656. * - VertexBuffer.PositionKind
  24657. * - VertexBuffer.NormalKind
  24658. * - VertexBuffer.UVKind
  24659. * - VertexBuffer.UV2Kind
  24660. * - VertexBuffer.UV3Kind
  24661. * - VertexBuffer.UV4Kind
  24662. * - VertexBuffer.UV5Kind
  24663. * - VertexBuffer.UV6Kind
  24664. * - VertexBuffer.ColorKind
  24665. * - VertexBuffer.MatricesIndicesKind
  24666. * - VertexBuffer.MatricesIndicesExtraKind
  24667. * - VertexBuffer.MatricesWeightsKind
  24668. * - VertexBuffer.MatricesWeightsExtraKind
  24669. * @returns an array of strings
  24670. */
  24671. getVerticesDataKinds(): string[];
  24672. /**
  24673. * Returns a positive integer : the total number of indices in this mesh geometry.
  24674. * @returns the numner of indices or zero if the mesh has no geometry.
  24675. */
  24676. getTotalIndices(): number;
  24677. /**
  24678. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24679. * @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.
  24680. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24681. * @returns the indices array or an empty array if the mesh has no geometry
  24682. */
  24683. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24684. get isBlocked(): boolean;
  24685. /**
  24686. * Determine if the current mesh is ready to be rendered
  24687. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24688. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24689. * @returns true if all associated assets are ready (material, textures, shaders)
  24690. */
  24691. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24692. /**
  24693. * 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.
  24694. */
  24695. get areNormalsFrozen(): boolean;
  24696. /**
  24697. * 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.
  24698. * @returns the current mesh
  24699. */
  24700. freezeNormals(): Mesh;
  24701. /**
  24702. * 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
  24703. * @returns the current mesh
  24704. */
  24705. unfreezeNormals(): Mesh;
  24706. /**
  24707. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24708. */
  24709. set overridenInstanceCount(count: number);
  24710. /** @hidden */
  24711. _preActivate(): Mesh;
  24712. /** @hidden */
  24713. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24714. /** @hidden */
  24715. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24716. /**
  24717. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24718. * This means the mesh underlying bounding box and sphere are recomputed.
  24719. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24720. * @returns the current mesh
  24721. */
  24722. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24723. /** @hidden */
  24724. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24725. /**
  24726. * This function will subdivide the mesh into multiple submeshes
  24727. * @param count defines the expected number of submeshes
  24728. */
  24729. subdivide(count: number): void;
  24730. /**
  24731. * Copy a FloatArray into a specific associated vertex buffer
  24732. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24733. * - VertexBuffer.PositionKind
  24734. * - VertexBuffer.UVKind
  24735. * - VertexBuffer.UV2Kind
  24736. * - VertexBuffer.UV3Kind
  24737. * - VertexBuffer.UV4Kind
  24738. * - VertexBuffer.UV5Kind
  24739. * - VertexBuffer.UV6Kind
  24740. * - VertexBuffer.ColorKind
  24741. * - VertexBuffer.MatricesIndicesKind
  24742. * - VertexBuffer.MatricesIndicesExtraKind
  24743. * - VertexBuffer.MatricesWeightsKind
  24744. * - VertexBuffer.MatricesWeightsExtraKind
  24745. * @param data defines the data source
  24746. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24747. * @param stride defines the data stride size (can be null)
  24748. * @returns the current mesh
  24749. */
  24750. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24751. /**
  24752. * Delete a vertex buffer associated with this mesh
  24753. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24754. * - VertexBuffer.PositionKind
  24755. * - VertexBuffer.UVKind
  24756. * - VertexBuffer.UV2Kind
  24757. * - VertexBuffer.UV3Kind
  24758. * - VertexBuffer.UV4Kind
  24759. * - VertexBuffer.UV5Kind
  24760. * - VertexBuffer.UV6Kind
  24761. * - VertexBuffer.ColorKind
  24762. * - VertexBuffer.MatricesIndicesKind
  24763. * - VertexBuffer.MatricesIndicesExtraKind
  24764. * - VertexBuffer.MatricesWeightsKind
  24765. * - VertexBuffer.MatricesWeightsExtraKind
  24766. */
  24767. removeVerticesData(kind: string): void;
  24768. /**
  24769. * Flags an associated vertex buffer as updatable
  24770. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24771. * - VertexBuffer.PositionKind
  24772. * - VertexBuffer.UVKind
  24773. * - VertexBuffer.UV2Kind
  24774. * - VertexBuffer.UV3Kind
  24775. * - VertexBuffer.UV4Kind
  24776. * - VertexBuffer.UV5Kind
  24777. * - VertexBuffer.UV6Kind
  24778. * - VertexBuffer.ColorKind
  24779. * - VertexBuffer.MatricesIndicesKind
  24780. * - VertexBuffer.MatricesIndicesExtraKind
  24781. * - VertexBuffer.MatricesWeightsKind
  24782. * - VertexBuffer.MatricesWeightsExtraKind
  24783. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24784. */
  24785. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24786. /**
  24787. * Sets the mesh global Vertex Buffer
  24788. * @param buffer defines the buffer to use
  24789. * @returns the current mesh
  24790. */
  24791. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24792. /**
  24793. * Update a specific associated vertex buffer
  24794. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24795. * - VertexBuffer.PositionKind
  24796. * - VertexBuffer.UVKind
  24797. * - VertexBuffer.UV2Kind
  24798. * - VertexBuffer.UV3Kind
  24799. * - VertexBuffer.UV4Kind
  24800. * - VertexBuffer.UV5Kind
  24801. * - VertexBuffer.UV6Kind
  24802. * - VertexBuffer.ColorKind
  24803. * - VertexBuffer.MatricesIndicesKind
  24804. * - VertexBuffer.MatricesIndicesExtraKind
  24805. * - VertexBuffer.MatricesWeightsKind
  24806. * - VertexBuffer.MatricesWeightsExtraKind
  24807. * @param data defines the data source
  24808. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24809. * @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)
  24810. * @returns the current mesh
  24811. */
  24812. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24813. /**
  24814. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24815. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24816. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24817. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24818. * @returns the current mesh
  24819. */
  24820. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24821. /**
  24822. * Creates a un-shared specific occurence of the geometry for the mesh.
  24823. * @returns the current mesh
  24824. */
  24825. makeGeometryUnique(): Mesh;
  24826. /**
  24827. * Set the index buffer of this mesh
  24828. * @param indices defines the source data
  24829. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24830. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24831. * @returns the current mesh
  24832. */
  24833. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24834. /**
  24835. * Update the current index buffer
  24836. * @param indices defines the source data
  24837. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24838. * @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)
  24839. * @returns the current mesh
  24840. */
  24841. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24842. /**
  24843. * Invert the geometry to move from a right handed system to a left handed one.
  24844. * @returns the current mesh
  24845. */
  24846. toLeftHanded(): Mesh;
  24847. /** @hidden */
  24848. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24849. /** @hidden */
  24850. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24851. /**
  24852. * Registers for this mesh a javascript function called just before the rendering process
  24853. * @param func defines the function to call before rendering this mesh
  24854. * @returns the current mesh
  24855. */
  24856. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24857. /**
  24858. * Disposes a previously registered javascript function called before the rendering
  24859. * @param func defines the function to remove
  24860. * @returns the current mesh
  24861. */
  24862. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24863. /**
  24864. * Registers for this mesh a javascript function called just after the rendering is complete
  24865. * @param func defines the function to call after rendering this mesh
  24866. * @returns the current mesh
  24867. */
  24868. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24869. /**
  24870. * Disposes a previously registered javascript function called after the rendering.
  24871. * @param func defines the function to remove
  24872. * @returns the current mesh
  24873. */
  24874. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24875. /** @hidden */
  24876. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24877. /** @hidden */
  24878. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24879. /** @hidden */
  24880. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24881. /** @hidden */
  24882. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24883. /** @hidden */
  24884. _rebuild(): void;
  24885. /** @hidden */
  24886. _freeze(): void;
  24887. /** @hidden */
  24888. _unFreeze(): void;
  24889. /**
  24890. * 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
  24891. * @param subMesh defines the subMesh to render
  24892. * @param enableAlphaMode defines if alpha mode can be changed
  24893. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24894. * @returns the current mesh
  24895. */
  24896. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24897. private _onBeforeDraw;
  24898. /**
  24899. * Renormalize the mesh and patch it up if there are no weights
  24900. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24901. * However in the case of zero weights then we set just a single influence to 1.
  24902. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24903. */
  24904. cleanMatrixWeights(): void;
  24905. private normalizeSkinFourWeights;
  24906. private normalizeSkinWeightsAndExtra;
  24907. /**
  24908. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24909. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24910. * the user know there was an issue with importing the mesh
  24911. * @returns a validation object with skinned, valid and report string
  24912. */
  24913. validateSkinning(): {
  24914. skinned: boolean;
  24915. valid: boolean;
  24916. report: string;
  24917. };
  24918. /** @hidden */
  24919. _checkDelayState(): Mesh;
  24920. private _queueLoad;
  24921. /**
  24922. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24923. * A mesh is in the frustum if its bounding box intersects the frustum
  24924. * @param frustumPlanes defines the frustum to test
  24925. * @returns true if the mesh is in the frustum planes
  24926. */
  24927. isInFrustum(frustumPlanes: Plane[]): boolean;
  24928. /**
  24929. * Sets the mesh material by the material or multiMaterial `id` property
  24930. * @param id is a string identifying the material or the multiMaterial
  24931. * @returns the current mesh
  24932. */
  24933. setMaterialByID(id: string): Mesh;
  24934. /**
  24935. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24936. * @returns an array of IAnimatable
  24937. */
  24938. getAnimatables(): IAnimatable[];
  24939. /**
  24940. * Modifies the mesh geometry according to the passed transformation matrix.
  24941. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24942. * The mesh normals are modified using the same transformation.
  24943. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24944. * @param transform defines the transform matrix to use
  24945. * @see http://doc.babylonjs.com/resources/baking_transformations
  24946. * @returns the current mesh
  24947. */
  24948. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24949. /**
  24950. * Modifies the mesh geometry according to its own current World Matrix.
  24951. * The mesh World Matrix is then reset.
  24952. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24953. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24954. * @see http://doc.babylonjs.com/resources/baking_transformations
  24955. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24956. * @returns the current mesh
  24957. */
  24958. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24959. /** @hidden */
  24960. get _positions(): Nullable<Vector3[]>;
  24961. /** @hidden */
  24962. _resetPointsArrayCache(): Mesh;
  24963. /** @hidden */
  24964. _generatePointsArray(): boolean;
  24965. /**
  24966. * Returns a new Mesh object generated from the current mesh properties.
  24967. * This method must not get confused with createInstance()
  24968. * @param name is a string, the name given to the new mesh
  24969. * @param newParent can be any Node object (default `null`)
  24970. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24971. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24972. * @returns a new mesh
  24973. */
  24974. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24975. /**
  24976. * Releases resources associated with this mesh.
  24977. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24978. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24979. */
  24980. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24981. /** @hidden */
  24982. _disposeInstanceSpecificData(): void;
  24983. /**
  24984. * Modifies the mesh geometry according to a displacement map.
  24985. * 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.
  24986. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24987. * @param url is a string, the URL from the image file is to be downloaded.
  24988. * @param minHeight is the lower limit of the displacement.
  24989. * @param maxHeight is the upper limit of the displacement.
  24990. * @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.
  24991. * @param uvOffset is an optional vector2 used to offset UV.
  24992. * @param uvScale is an optional vector2 used to scale UV.
  24993. * @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.
  24994. * @returns the Mesh.
  24995. */
  24996. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24997. /**
  24998. * Modifies the mesh geometry according to a displacementMap buffer.
  24999. * 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.
  25000. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25001. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25002. * @param heightMapWidth is the width of the buffer image.
  25003. * @param heightMapHeight is the height of the buffer image.
  25004. * @param minHeight is the lower limit of the displacement.
  25005. * @param maxHeight is the upper limit of the displacement.
  25006. * @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.
  25007. * @param uvOffset is an optional vector2 used to offset UV.
  25008. * @param uvScale is an optional vector2 used to scale UV.
  25009. * @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.
  25010. * @returns the Mesh.
  25011. */
  25012. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25013. /**
  25014. * Modify the mesh to get a flat shading rendering.
  25015. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25016. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25017. * @returns current mesh
  25018. */
  25019. convertToFlatShadedMesh(): Mesh;
  25020. /**
  25021. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25022. * In other words, more vertices, no more indices and a single bigger VBO.
  25023. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25024. * @returns current mesh
  25025. */
  25026. convertToUnIndexedMesh(): Mesh;
  25027. /**
  25028. * Inverses facet orientations.
  25029. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25030. * @param flipNormals will also inverts the normals
  25031. * @returns current mesh
  25032. */
  25033. flipFaces(flipNormals?: boolean): Mesh;
  25034. /**
  25035. * Increase the number of facets and hence vertices in a mesh
  25036. * Vertex normals are interpolated from existing vertex normals
  25037. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25038. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25039. */
  25040. increaseVertices(numberPerEdge: number): void;
  25041. /**
  25042. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25043. * This will undo any application of covertToFlatShadedMesh
  25044. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25045. */
  25046. forceSharedVertices(): void;
  25047. /** @hidden */
  25048. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25049. /** @hidden */
  25050. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25051. /**
  25052. * Creates a new InstancedMesh object from the mesh model.
  25053. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25054. * @param name defines the name of the new instance
  25055. * @returns a new InstancedMesh
  25056. */
  25057. createInstance(name: string): InstancedMesh;
  25058. /**
  25059. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25060. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25061. * @returns the current mesh
  25062. */
  25063. synchronizeInstances(): Mesh;
  25064. /**
  25065. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25066. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25067. * This should be used together with the simplification to avoid disappearing triangles.
  25068. * @param successCallback an optional success callback to be called after the optimization finished.
  25069. * @returns the current mesh
  25070. */
  25071. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25072. /**
  25073. * Serialize current mesh
  25074. * @param serializationObject defines the object which will receive the serialization data
  25075. */
  25076. serialize(serializationObject: any): void;
  25077. /** @hidden */
  25078. _syncGeometryWithMorphTargetManager(): void;
  25079. /** @hidden */
  25080. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25081. /**
  25082. * Returns a new Mesh object parsed from the source provided.
  25083. * @param parsedMesh is the source
  25084. * @param scene defines the hosting scene
  25085. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25086. * @returns a new Mesh
  25087. */
  25088. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25089. /**
  25090. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25091. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25092. * @param name defines the name of the mesh to create
  25093. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25094. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25095. * @param closePath creates a seam between the first and the last points of each path of the path array
  25096. * @param offset is taken in account only if the `pathArray` is containing a single path
  25097. * @param scene defines the hosting scene
  25098. * @param updatable defines if the mesh must be flagged as updatable
  25099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25100. * @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)
  25101. * @returns a new Mesh
  25102. */
  25103. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25104. /**
  25105. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25106. * @param name defines the name of the mesh to create
  25107. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25108. * @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
  25109. * @param scene defines the hosting scene
  25110. * @param updatable defines if the mesh must be flagged as updatable
  25111. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25112. * @returns a new Mesh
  25113. */
  25114. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25115. /**
  25116. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25117. * @param name defines the name of the mesh to create
  25118. * @param size sets the size (float) of each box side (default 1)
  25119. * @param scene defines the hosting scene
  25120. * @param updatable defines if the mesh must be flagged as updatable
  25121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25122. * @returns a new Mesh
  25123. */
  25124. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25125. /**
  25126. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25127. * @param name defines the name of the mesh to create
  25128. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25129. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25130. * @param scene defines the hosting scene
  25131. * @param updatable defines if the mesh must be flagged as updatable
  25132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25133. * @returns a new Mesh
  25134. */
  25135. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25136. /**
  25137. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25138. * @param name defines the name of the mesh to create
  25139. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25140. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25141. * @param scene defines the hosting scene
  25142. * @returns a new Mesh
  25143. */
  25144. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25145. /**
  25146. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25147. * @param name defines the name of the mesh to create
  25148. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25149. * @param diameterTop set the top cap diameter (floats, default 1)
  25150. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25151. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25152. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25153. * @param scene defines the hosting scene
  25154. * @param updatable defines if the mesh must be flagged as updatable
  25155. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25156. * @returns a new Mesh
  25157. */
  25158. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25159. /**
  25160. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25161. * @param name defines the name of the mesh to create
  25162. * @param diameter sets the diameter size (float) of the torus (default 1)
  25163. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25164. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25165. * @param scene defines the hosting scene
  25166. * @param updatable defines if the mesh must be flagged as updatable
  25167. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25168. * @returns a new Mesh
  25169. */
  25170. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25171. /**
  25172. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25173. * @param name defines the name of the mesh to create
  25174. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25175. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25176. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25177. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25178. * @param p the number of windings on X axis (positive integers, default 2)
  25179. * @param q the number of windings on Y axis (positive integers, default 3)
  25180. * @param scene defines the hosting scene
  25181. * @param updatable defines if the mesh must be flagged as updatable
  25182. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25183. * @returns a new Mesh
  25184. */
  25185. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25186. /**
  25187. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25188. * @param name defines the name of the mesh to create
  25189. * @param points is an array successive Vector3
  25190. * @param scene defines the hosting scene
  25191. * @param updatable defines if the mesh must be flagged as updatable
  25192. * @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).
  25193. * @returns a new Mesh
  25194. */
  25195. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25196. /**
  25197. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25198. * @param name defines the name of the mesh to create
  25199. * @param points is an array successive Vector3
  25200. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25201. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25202. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25203. * @param scene defines the hosting scene
  25204. * @param updatable defines if the mesh must be flagged as updatable
  25205. * @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)
  25206. * @returns a new Mesh
  25207. */
  25208. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25209. /**
  25210. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25211. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25212. * 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.
  25213. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25214. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25215. * Remember you can only change the shape positions, not their number when updating a polygon.
  25216. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25217. * @param name defines the name of the mesh to create
  25218. * @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
  25219. * @param scene defines the hosting scene
  25220. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25221. * @param updatable defines if the mesh must be flagged as updatable
  25222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25223. * @param earcutInjection can be used to inject your own earcut reference
  25224. * @returns a new Mesh
  25225. */
  25226. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25227. /**
  25228. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25229. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25230. * @param name defines the name of the mesh to create
  25231. * @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
  25232. * @param depth defines the height of extrusion
  25233. * @param scene defines the hosting scene
  25234. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25235. * @param updatable defines if the mesh must be flagged as updatable
  25236. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25237. * @param earcutInjection can be used to inject your own earcut reference
  25238. * @returns a new Mesh
  25239. */
  25240. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25241. /**
  25242. * Creates an extruded shape mesh.
  25243. * 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
  25244. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25245. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25246. * @param name defines the name of the mesh to create
  25247. * @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
  25248. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25249. * @param scale is the value to scale the shape
  25250. * @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
  25251. * @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
  25252. * @param scene defines the hosting scene
  25253. * @param updatable defines if the mesh must be flagged as updatable
  25254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25255. * @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)
  25256. * @returns a new Mesh
  25257. */
  25258. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25259. /**
  25260. * Creates an custom extruded shape mesh.
  25261. * The custom extrusion is a parametric shape.
  25262. * It has no predefined shape. Its final shape will depend on the input parameters.
  25263. * Please consider using the same method from the MeshBuilder class instead
  25264. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25265. * @param name defines the name of the mesh to create
  25266. * @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
  25267. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25268. * @param scaleFunction is a custom Javascript function called on each path point
  25269. * @param rotationFunction is a custom Javascript function called on each path point
  25270. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25271. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25272. * @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
  25273. * @param scene defines the hosting scene
  25274. * @param updatable defines if the mesh must be flagged as updatable
  25275. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25276. * @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)
  25277. * @returns a new Mesh
  25278. */
  25279. 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;
  25280. /**
  25281. * Creates lathe mesh.
  25282. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25283. * Please consider using the same method from the MeshBuilder class instead
  25284. * @param name defines the name of the mesh to create
  25285. * @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
  25286. * @param radius is the radius value of the lathe
  25287. * @param tessellation is the side number of the lathe.
  25288. * @param scene defines the hosting scene
  25289. * @param updatable defines if the mesh must be flagged as updatable
  25290. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25291. * @returns a new Mesh
  25292. */
  25293. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25294. /**
  25295. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25296. * @param name defines the name of the mesh to create
  25297. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25298. * @param scene defines the hosting scene
  25299. * @param updatable defines if the mesh must be flagged as updatable
  25300. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25301. * @returns a new Mesh
  25302. */
  25303. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25304. /**
  25305. * Creates a ground mesh.
  25306. * Please consider using the same method from the MeshBuilder class instead
  25307. * @param name defines the name of the mesh to create
  25308. * @param width set the width of the ground
  25309. * @param height set the height of the ground
  25310. * @param subdivisions sets the number of subdivisions per side
  25311. * @param scene defines the hosting scene
  25312. * @param updatable defines if the mesh must be flagged as updatable
  25313. * @returns a new Mesh
  25314. */
  25315. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25316. /**
  25317. * Creates a tiled ground mesh.
  25318. * Please consider using the same method from the MeshBuilder class instead
  25319. * @param name defines the name of the mesh to create
  25320. * @param xmin set the ground minimum X coordinate
  25321. * @param zmin set the ground minimum Y coordinate
  25322. * @param xmax set the ground maximum X coordinate
  25323. * @param zmax set the ground maximum Z coordinate
  25324. * @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
  25325. * @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
  25326. * @param scene defines the hosting scene
  25327. * @param updatable defines if the mesh must be flagged as updatable
  25328. * @returns a new Mesh
  25329. */
  25330. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25331. w: number;
  25332. h: number;
  25333. }, precision: {
  25334. w: number;
  25335. h: number;
  25336. }, scene: Scene, updatable?: boolean): Mesh;
  25337. /**
  25338. * Creates a ground mesh from a height map.
  25339. * Please consider using the same method from the MeshBuilder class instead
  25340. * @see http://doc.babylonjs.com/babylon101/height_map
  25341. * @param name defines the name of the mesh to create
  25342. * @param url sets the URL of the height map image resource
  25343. * @param width set the ground width size
  25344. * @param height set the ground height size
  25345. * @param subdivisions sets the number of subdivision per side
  25346. * @param minHeight is the minimum altitude on the ground
  25347. * @param maxHeight is the maximum altitude on the ground
  25348. * @param scene defines the hosting scene
  25349. * @param updatable defines if the mesh must be flagged as updatable
  25350. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25351. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25352. * @returns a new Mesh
  25353. */
  25354. 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;
  25355. /**
  25356. * Creates a tube mesh.
  25357. * The tube is a parametric shape.
  25358. * It has no predefined shape. Its final shape will depend on the input parameters.
  25359. * Please consider using the same method from the MeshBuilder class instead
  25360. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25361. * @param name defines the name of the mesh to create
  25362. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25363. * @param radius sets the tube radius size
  25364. * @param tessellation is the number of sides on the tubular surface
  25365. * @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
  25366. * @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
  25367. * @param scene defines the hosting scene
  25368. * @param updatable defines if the mesh must be flagged as updatable
  25369. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25370. * @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)
  25371. * @returns a new Mesh
  25372. */
  25373. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25374. (i: number, distance: number): number;
  25375. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25376. /**
  25377. * Creates a polyhedron mesh.
  25378. * Please consider using the same method from the MeshBuilder class instead.
  25379. * * 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
  25380. * * The parameter `size` (positive float, default 1) sets the polygon size
  25381. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25382. * * 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`
  25383. * * 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
  25384. * * 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)`)
  25385. * * 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
  25386. * * 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
  25387. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25388. * * 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
  25389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25390. * @param name defines the name of the mesh to create
  25391. * @param options defines the options used to create the mesh
  25392. * @param scene defines the hosting scene
  25393. * @returns a new Mesh
  25394. */
  25395. static CreatePolyhedron(name: string, options: {
  25396. type?: number;
  25397. size?: number;
  25398. sizeX?: number;
  25399. sizeY?: number;
  25400. sizeZ?: number;
  25401. custom?: any;
  25402. faceUV?: Vector4[];
  25403. faceColors?: Color4[];
  25404. updatable?: boolean;
  25405. sideOrientation?: number;
  25406. }, scene: Scene): Mesh;
  25407. /**
  25408. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25409. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25410. * * 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`)
  25411. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25412. * * 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
  25413. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25414. * * 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
  25415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25416. * @param name defines the name of the mesh
  25417. * @param options defines the options used to create the mesh
  25418. * @param scene defines the hosting scene
  25419. * @returns a new Mesh
  25420. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25421. */
  25422. static CreateIcoSphere(name: string, options: {
  25423. radius?: number;
  25424. flat?: boolean;
  25425. subdivisions?: number;
  25426. sideOrientation?: number;
  25427. updatable?: boolean;
  25428. }, scene: Scene): Mesh;
  25429. /**
  25430. * Creates a decal mesh.
  25431. * Please consider using the same method from the MeshBuilder class instead.
  25432. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25433. * @param name defines the name of the mesh
  25434. * @param sourceMesh defines the mesh receiving the decal
  25435. * @param position sets the position of the decal in world coordinates
  25436. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25437. * @param size sets the decal scaling
  25438. * @param angle sets the angle to rotate the decal
  25439. * @returns a new Mesh
  25440. */
  25441. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25442. /**
  25443. * Prepare internal position array for software CPU skinning
  25444. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25445. */
  25446. setPositionsForCPUSkinning(): Float32Array;
  25447. /**
  25448. * Prepare internal normal array for software CPU skinning
  25449. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25450. */
  25451. setNormalsForCPUSkinning(): Float32Array;
  25452. /**
  25453. * Updates the vertex buffer by applying transformation from the bones
  25454. * @param skeleton defines the skeleton to apply to current mesh
  25455. * @returns the current mesh
  25456. */
  25457. applySkeleton(skeleton: Skeleton): Mesh;
  25458. /**
  25459. * 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
  25460. * @param meshes defines the list of meshes to scan
  25461. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25462. */
  25463. static MinMax(meshes: AbstractMesh[]): {
  25464. min: Vector3;
  25465. max: Vector3;
  25466. };
  25467. /**
  25468. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25469. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25470. * @returns a vector3
  25471. */
  25472. static Center(meshesOrMinMaxVector: {
  25473. min: Vector3;
  25474. max: Vector3;
  25475. } | AbstractMesh[]): Vector3;
  25476. /**
  25477. * Merge the array of meshes into a single mesh for performance reasons.
  25478. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25479. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25480. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25481. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25482. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25483. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25484. * @returns a new mesh
  25485. */
  25486. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25487. /** @hidden */
  25488. addInstance(instance: InstancedMesh): void;
  25489. /** @hidden */
  25490. removeInstance(instance: InstancedMesh): void;
  25491. }
  25492. }
  25493. declare module BABYLON {
  25494. /**
  25495. * This is the base class of all the camera used in the application.
  25496. * @see http://doc.babylonjs.com/features/cameras
  25497. */
  25498. export class Camera extends Node {
  25499. /** @hidden */
  25500. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25501. /**
  25502. * This is the default projection mode used by the cameras.
  25503. * It helps recreating a feeling of perspective and better appreciate depth.
  25504. * This is the best way to simulate real life cameras.
  25505. */
  25506. static readonly PERSPECTIVE_CAMERA: number;
  25507. /**
  25508. * This helps creating camera with an orthographic mode.
  25509. * 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.
  25510. */
  25511. static readonly ORTHOGRAPHIC_CAMERA: number;
  25512. /**
  25513. * This is the default FOV mode for perspective cameras.
  25514. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25515. */
  25516. static readonly FOVMODE_VERTICAL_FIXED: number;
  25517. /**
  25518. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25519. */
  25520. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25521. /**
  25522. * This specifies ther is no need for a camera rig.
  25523. * Basically only one eye is rendered corresponding to the camera.
  25524. */
  25525. static readonly RIG_MODE_NONE: number;
  25526. /**
  25527. * Simulates a camera Rig with one blue eye and one red eye.
  25528. * This can be use with 3d blue and red glasses.
  25529. */
  25530. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25531. /**
  25532. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25533. */
  25534. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25535. /**
  25536. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25537. */
  25538. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25539. /**
  25540. * Defines that both eyes of the camera will be rendered over under each other.
  25541. */
  25542. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25543. /**
  25544. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25545. */
  25546. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25547. /**
  25548. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25549. */
  25550. static readonly RIG_MODE_VR: number;
  25551. /**
  25552. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25553. */
  25554. static readonly RIG_MODE_WEBVR: number;
  25555. /**
  25556. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25557. */
  25558. static readonly RIG_MODE_CUSTOM: number;
  25559. /**
  25560. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25561. */
  25562. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25563. /**
  25564. * Define the input manager associated with the camera.
  25565. */
  25566. inputs: CameraInputsManager<Camera>;
  25567. /** @hidden */
  25568. _position: Vector3;
  25569. /**
  25570. * Define the current local position of the camera in the scene
  25571. */
  25572. get position(): Vector3;
  25573. set position(newPosition: Vector3);
  25574. /**
  25575. * The vector the camera should consider as up.
  25576. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25577. */
  25578. upVector: Vector3;
  25579. /**
  25580. * Define the current limit on the left side for an orthographic camera
  25581. * In scene unit
  25582. */
  25583. orthoLeft: Nullable<number>;
  25584. /**
  25585. * Define the current limit on the right side for an orthographic camera
  25586. * In scene unit
  25587. */
  25588. orthoRight: Nullable<number>;
  25589. /**
  25590. * Define the current limit on the bottom side for an orthographic camera
  25591. * In scene unit
  25592. */
  25593. orthoBottom: Nullable<number>;
  25594. /**
  25595. * Define the current limit on the top side for an orthographic camera
  25596. * In scene unit
  25597. */
  25598. orthoTop: Nullable<number>;
  25599. /**
  25600. * Field Of View is set in Radians. (default is 0.8)
  25601. */
  25602. fov: number;
  25603. /**
  25604. * Define the minimum distance the camera can see from.
  25605. * This is important to note that the depth buffer are not infinite and the closer it starts
  25606. * the more your scene might encounter depth fighting issue.
  25607. */
  25608. minZ: number;
  25609. /**
  25610. * Define the maximum distance the camera can see to.
  25611. * This is important to note that the depth buffer are not infinite and the further it end
  25612. * the more your scene might encounter depth fighting issue.
  25613. */
  25614. maxZ: number;
  25615. /**
  25616. * Define the default inertia of the camera.
  25617. * This helps giving a smooth feeling to the camera movement.
  25618. */
  25619. inertia: number;
  25620. /**
  25621. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25622. */
  25623. mode: number;
  25624. /**
  25625. * Define whether the camera is intermediate.
  25626. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25627. */
  25628. isIntermediate: boolean;
  25629. /**
  25630. * Define the viewport of the camera.
  25631. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25632. */
  25633. viewport: Viewport;
  25634. /**
  25635. * Restricts the camera to viewing objects with the same layerMask.
  25636. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25637. */
  25638. layerMask: number;
  25639. /**
  25640. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25641. */
  25642. fovMode: number;
  25643. /**
  25644. * Rig mode of the camera.
  25645. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25646. * This is normally controlled byt the camera themselves as internal use.
  25647. */
  25648. cameraRigMode: number;
  25649. /**
  25650. * Defines the distance between both "eyes" in case of a RIG
  25651. */
  25652. interaxialDistance: number;
  25653. /**
  25654. * Defines if stereoscopic rendering is done side by side or over under.
  25655. */
  25656. isStereoscopicSideBySide: boolean;
  25657. /**
  25658. * 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
  25659. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25660. * else in the scene. (Eg. security camera)
  25661. *
  25662. * 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)
  25663. */
  25664. customRenderTargets: RenderTargetTexture[];
  25665. /**
  25666. * When set, the camera will render to this render target instead of the default canvas
  25667. *
  25668. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25669. */
  25670. outputRenderTarget: Nullable<RenderTargetTexture>;
  25671. /**
  25672. * Observable triggered when the camera view matrix has changed.
  25673. */
  25674. onViewMatrixChangedObservable: Observable<Camera>;
  25675. /**
  25676. * Observable triggered when the camera Projection matrix has changed.
  25677. */
  25678. onProjectionMatrixChangedObservable: Observable<Camera>;
  25679. /**
  25680. * Observable triggered when the inputs have been processed.
  25681. */
  25682. onAfterCheckInputsObservable: Observable<Camera>;
  25683. /**
  25684. * Observable triggered when reset has been called and applied to the camera.
  25685. */
  25686. onRestoreStateObservable: Observable<Camera>;
  25687. /**
  25688. * Is this camera a part of a rig system?
  25689. */
  25690. isRigCamera: boolean;
  25691. /**
  25692. * If isRigCamera set to true this will be set with the parent camera.
  25693. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25694. */
  25695. rigParent?: Camera;
  25696. /** @hidden */
  25697. _cameraRigParams: any;
  25698. /** @hidden */
  25699. _rigCameras: Camera[];
  25700. /** @hidden */
  25701. _rigPostProcess: Nullable<PostProcess>;
  25702. protected _webvrViewMatrix: Matrix;
  25703. /** @hidden */
  25704. _skipRendering: boolean;
  25705. /** @hidden */
  25706. _projectionMatrix: Matrix;
  25707. /** @hidden */
  25708. _postProcesses: Nullable<PostProcess>[];
  25709. /** @hidden */
  25710. _activeMeshes: SmartArray<AbstractMesh>;
  25711. protected _globalPosition: Vector3;
  25712. /** @hidden */
  25713. _computedViewMatrix: Matrix;
  25714. private _doNotComputeProjectionMatrix;
  25715. private _transformMatrix;
  25716. private _frustumPlanes;
  25717. private _refreshFrustumPlanes;
  25718. private _storedFov;
  25719. private _stateStored;
  25720. /**
  25721. * Instantiates a new camera object.
  25722. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25723. * @see http://doc.babylonjs.com/features/cameras
  25724. * @param name Defines the name of the camera in the scene
  25725. * @param position Defines the position of the camera
  25726. * @param scene Defines the scene the camera belongs too
  25727. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25728. */
  25729. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25730. /**
  25731. * Store current camera state (fov, position, etc..)
  25732. * @returns the camera
  25733. */
  25734. storeState(): Camera;
  25735. /**
  25736. * Restores the camera state values if it has been stored. You must call storeState() first
  25737. */
  25738. protected _restoreStateValues(): boolean;
  25739. /**
  25740. * Restored camera state. You must call storeState() first.
  25741. * @returns true if restored and false otherwise
  25742. */
  25743. restoreState(): boolean;
  25744. /**
  25745. * Gets the class name of the camera.
  25746. * @returns the class name
  25747. */
  25748. getClassName(): string;
  25749. /** @hidden */
  25750. readonly _isCamera: boolean;
  25751. /**
  25752. * Gets a string representation of the camera useful for debug purpose.
  25753. * @param fullDetails Defines that a more verboe level of logging is required
  25754. * @returns the string representation
  25755. */
  25756. toString(fullDetails?: boolean): string;
  25757. /**
  25758. * Gets the current world space position of the camera.
  25759. */
  25760. get globalPosition(): Vector3;
  25761. /**
  25762. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25763. * @returns the active meshe list
  25764. */
  25765. getActiveMeshes(): SmartArray<AbstractMesh>;
  25766. /**
  25767. * Check whether a mesh is part of the current active mesh list of the camera
  25768. * @param mesh Defines the mesh to check
  25769. * @returns true if active, false otherwise
  25770. */
  25771. isActiveMesh(mesh: Mesh): boolean;
  25772. /**
  25773. * Is this camera ready to be used/rendered
  25774. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25775. * @return true if the camera is ready
  25776. */
  25777. isReady(completeCheck?: boolean): boolean;
  25778. /** @hidden */
  25779. _initCache(): void;
  25780. /** @hidden */
  25781. _updateCache(ignoreParentClass?: boolean): void;
  25782. /** @hidden */
  25783. _isSynchronized(): boolean;
  25784. /** @hidden */
  25785. _isSynchronizedViewMatrix(): boolean;
  25786. /** @hidden */
  25787. _isSynchronizedProjectionMatrix(): boolean;
  25788. /**
  25789. * Attach the input controls to a specific dom element to get the input from.
  25790. * @param element Defines the element the controls should be listened from
  25791. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25792. */
  25793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25794. /**
  25795. * Detach the current controls from the specified dom element.
  25796. * @param element Defines the element to stop listening the inputs from
  25797. */
  25798. detachControl(element: HTMLElement): void;
  25799. /**
  25800. * Update the camera state according to the different inputs gathered during the frame.
  25801. */
  25802. update(): void;
  25803. /** @hidden */
  25804. _checkInputs(): void;
  25805. /** @hidden */
  25806. get rigCameras(): Camera[];
  25807. /**
  25808. * Gets the post process used by the rig cameras
  25809. */
  25810. get rigPostProcess(): Nullable<PostProcess>;
  25811. /**
  25812. * Internal, gets the first post proces.
  25813. * @returns the first post process to be run on this camera.
  25814. */
  25815. _getFirstPostProcess(): Nullable<PostProcess>;
  25816. private _cascadePostProcessesToRigCams;
  25817. /**
  25818. * Attach a post process to the camera.
  25819. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25820. * @param postProcess The post process to attach to the camera
  25821. * @param insertAt The position of the post process in case several of them are in use in the scene
  25822. * @returns the position the post process has been inserted at
  25823. */
  25824. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25825. /**
  25826. * Detach a post process to the camera.
  25827. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25828. * @param postProcess The post process to detach from the camera
  25829. */
  25830. detachPostProcess(postProcess: PostProcess): void;
  25831. /**
  25832. * Gets the current world matrix of the camera
  25833. */
  25834. getWorldMatrix(): Matrix;
  25835. /** @hidden */
  25836. _getViewMatrix(): Matrix;
  25837. /**
  25838. * Gets the current view matrix of the camera.
  25839. * @param force forces the camera to recompute the matrix without looking at the cached state
  25840. * @returns the view matrix
  25841. */
  25842. getViewMatrix(force?: boolean): Matrix;
  25843. /**
  25844. * Freeze the projection matrix.
  25845. * It will prevent the cache check of the camera projection compute and can speed up perf
  25846. * if no parameter of the camera are meant to change
  25847. * @param projection Defines manually a projection if necessary
  25848. */
  25849. freezeProjectionMatrix(projection?: Matrix): void;
  25850. /**
  25851. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25852. */
  25853. unfreezeProjectionMatrix(): void;
  25854. /**
  25855. * Gets the current projection matrix of the camera.
  25856. * @param force forces the camera to recompute the matrix without looking at the cached state
  25857. * @returns the projection matrix
  25858. */
  25859. getProjectionMatrix(force?: boolean): Matrix;
  25860. /**
  25861. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25862. * @returns a Matrix
  25863. */
  25864. getTransformationMatrix(): Matrix;
  25865. private _updateFrustumPlanes;
  25866. /**
  25867. * Checks if a cullable object (mesh...) is in the camera frustum
  25868. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25869. * @param target The object to check
  25870. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25871. * @returns true if the object is in frustum otherwise false
  25872. */
  25873. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25874. /**
  25875. * Checks if a cullable object (mesh...) is in the camera frustum
  25876. * Unlike isInFrustum this cheks the full bounding box
  25877. * @param target The object to check
  25878. * @returns true if the object is in frustum otherwise false
  25879. */
  25880. isCompletelyInFrustum(target: ICullable): boolean;
  25881. /**
  25882. * Gets a ray in the forward direction from the camera.
  25883. * @param length Defines the length of the ray to create
  25884. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25885. * @param origin Defines the start point of the ray which defaults to the camera position
  25886. * @returns the forward ray
  25887. */
  25888. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25889. /**
  25890. * Releases resources associated with this node.
  25891. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25892. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25893. */
  25894. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25895. /** @hidden */
  25896. _isLeftCamera: boolean;
  25897. /**
  25898. * Gets the left camera of a rig setup in case of Rigged Camera
  25899. */
  25900. get isLeftCamera(): boolean;
  25901. /** @hidden */
  25902. _isRightCamera: boolean;
  25903. /**
  25904. * Gets the right camera of a rig setup in case of Rigged Camera
  25905. */
  25906. get isRightCamera(): boolean;
  25907. /**
  25908. * Gets the left camera of a rig setup in case of Rigged Camera
  25909. */
  25910. get leftCamera(): Nullable<FreeCamera>;
  25911. /**
  25912. * Gets the right camera of a rig setup in case of Rigged Camera
  25913. */
  25914. get rightCamera(): Nullable<FreeCamera>;
  25915. /**
  25916. * Gets the left camera target of a rig setup in case of Rigged Camera
  25917. * @returns the target position
  25918. */
  25919. getLeftTarget(): Nullable<Vector3>;
  25920. /**
  25921. * Gets the right camera target of a rig setup in case of Rigged Camera
  25922. * @returns the target position
  25923. */
  25924. getRightTarget(): Nullable<Vector3>;
  25925. /**
  25926. * @hidden
  25927. */
  25928. setCameraRigMode(mode: number, rigParams: any): void;
  25929. /** @hidden */
  25930. static _setStereoscopicRigMode(camera: Camera): void;
  25931. /** @hidden */
  25932. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25933. /** @hidden */
  25934. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25935. /** @hidden */
  25936. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25937. /** @hidden */
  25938. _getVRProjectionMatrix(): Matrix;
  25939. protected _updateCameraRotationMatrix(): void;
  25940. protected _updateWebVRCameraRotationMatrix(): void;
  25941. /**
  25942. * This function MUST be overwritten by the different WebVR cameras available.
  25943. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25944. * @hidden
  25945. */
  25946. _getWebVRProjectionMatrix(): Matrix;
  25947. /**
  25948. * This function MUST be overwritten by the different WebVR cameras available.
  25949. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25950. * @hidden
  25951. */
  25952. _getWebVRViewMatrix(): Matrix;
  25953. /** @hidden */
  25954. setCameraRigParameter(name: string, value: any): void;
  25955. /**
  25956. * needs to be overridden by children so sub has required properties to be copied
  25957. * @hidden
  25958. */
  25959. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25960. /**
  25961. * May need to be overridden by children
  25962. * @hidden
  25963. */
  25964. _updateRigCameras(): void;
  25965. /** @hidden */
  25966. _setupInputs(): void;
  25967. /**
  25968. * Serialiaze the camera setup to a json represention
  25969. * @returns the JSON representation
  25970. */
  25971. serialize(): any;
  25972. /**
  25973. * Clones the current camera.
  25974. * @param name The cloned camera name
  25975. * @returns the cloned camera
  25976. */
  25977. clone(name: string): Camera;
  25978. /**
  25979. * Gets the direction of the camera relative to a given local axis.
  25980. * @param localAxis Defines the reference axis to provide a relative direction.
  25981. * @return the direction
  25982. */
  25983. getDirection(localAxis: Vector3): Vector3;
  25984. /**
  25985. * Returns the current camera absolute rotation
  25986. */
  25987. get absoluteRotation(): Quaternion;
  25988. /**
  25989. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25990. * @param localAxis Defines the reference axis to provide a relative direction.
  25991. * @param result Defines the vector to store the result in
  25992. */
  25993. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25994. /**
  25995. * Gets a camera constructor for a given camera type
  25996. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25997. * @param name The name of the camera the result will be able to instantiate
  25998. * @param scene The scene the result will construct the camera in
  25999. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26000. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26001. * @returns a factory method to construc the camera
  26002. */
  26003. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26004. /**
  26005. * Compute the world matrix of the camera.
  26006. * @returns the camera world matrix
  26007. */
  26008. computeWorldMatrix(): Matrix;
  26009. /**
  26010. * Parse a JSON and creates the camera from the parsed information
  26011. * @param parsedCamera The JSON to parse
  26012. * @param scene The scene to instantiate the camera in
  26013. * @returns the newly constructed camera
  26014. */
  26015. static Parse(parsedCamera: any, scene: Scene): Camera;
  26016. }
  26017. }
  26018. declare module BABYLON {
  26019. /**
  26020. * Class containing static functions to help procedurally build meshes
  26021. */
  26022. export class DiscBuilder {
  26023. /**
  26024. * Creates a plane polygonal mesh. By default, this is a disc
  26025. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26026. * * 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
  26027. * * 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
  26028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26029. * * 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
  26030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26031. * @param name defines the name of the mesh
  26032. * @param options defines the options used to create the mesh
  26033. * @param scene defines the hosting scene
  26034. * @returns the plane polygonal mesh
  26035. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26036. */
  26037. static CreateDisc(name: string, options: {
  26038. radius?: number;
  26039. tessellation?: number;
  26040. arc?: number;
  26041. updatable?: boolean;
  26042. sideOrientation?: number;
  26043. frontUVs?: Vector4;
  26044. backUVs?: Vector4;
  26045. }, scene?: Nullable<Scene>): Mesh;
  26046. }
  26047. }
  26048. declare module BABYLON {
  26049. /**
  26050. * Options to be used when creating a FresnelParameters.
  26051. */
  26052. export type IFresnelParametersCreationOptions = {
  26053. /**
  26054. * Define the color used on edges (grazing angle)
  26055. */
  26056. leftColor?: Color3;
  26057. /**
  26058. * Define the color used on center
  26059. */
  26060. rightColor?: Color3;
  26061. /**
  26062. * Define bias applied to computed fresnel term
  26063. */
  26064. bias?: number;
  26065. /**
  26066. * Defined the power exponent applied to fresnel term
  26067. */
  26068. power?: number;
  26069. /**
  26070. * Define if the fresnel effect is enable or not.
  26071. */
  26072. isEnabled?: boolean;
  26073. };
  26074. /**
  26075. * Serialized format for FresnelParameters.
  26076. */
  26077. export type IFresnelParametersSerialized = {
  26078. /**
  26079. * Define the color used on edges (grazing angle) [as an array]
  26080. */
  26081. leftColor: number[];
  26082. /**
  26083. * Define the color used on center [as an array]
  26084. */
  26085. rightColor: number[];
  26086. /**
  26087. * Define bias applied to computed fresnel term
  26088. */
  26089. bias: number;
  26090. /**
  26091. * Defined the power exponent applied to fresnel term
  26092. */
  26093. power?: number;
  26094. /**
  26095. * Define if the fresnel effect is enable or not.
  26096. */
  26097. isEnabled: boolean;
  26098. };
  26099. /**
  26100. * This represents all the required information to add a fresnel effect on a material:
  26101. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26102. */
  26103. export class FresnelParameters {
  26104. private _isEnabled;
  26105. /**
  26106. * Define if the fresnel effect is enable or not.
  26107. */
  26108. get isEnabled(): boolean;
  26109. set isEnabled(value: boolean);
  26110. /**
  26111. * Define the color used on edges (grazing angle)
  26112. */
  26113. leftColor: Color3;
  26114. /**
  26115. * Define the color used on center
  26116. */
  26117. rightColor: Color3;
  26118. /**
  26119. * Define bias applied to computed fresnel term
  26120. */
  26121. bias: number;
  26122. /**
  26123. * Defined the power exponent applied to fresnel term
  26124. */
  26125. power: number;
  26126. /**
  26127. * Creates a new FresnelParameters object.
  26128. *
  26129. * @param options provide your own settings to optionally to override defaults
  26130. */
  26131. constructor(options?: IFresnelParametersCreationOptions);
  26132. /**
  26133. * Clones the current fresnel and its valuues
  26134. * @returns a clone fresnel configuration
  26135. */
  26136. clone(): FresnelParameters;
  26137. /**
  26138. * Determines equality between FresnelParameters objects
  26139. * @param otherFresnelParameters defines the second operand
  26140. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26141. */
  26142. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26143. /**
  26144. * Serializes the current fresnel parameters to a JSON representation.
  26145. * @return the JSON serialization
  26146. */
  26147. serialize(): IFresnelParametersSerialized;
  26148. /**
  26149. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26150. * @param parsedFresnelParameters Define the JSON representation
  26151. * @returns the parsed parameters
  26152. */
  26153. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26154. }
  26155. }
  26156. declare module BABYLON {
  26157. /**
  26158. * Base class of materials working in push mode in babylon JS
  26159. * @hidden
  26160. */
  26161. export class PushMaterial extends Material {
  26162. protected _activeEffect: Effect;
  26163. protected _normalMatrix: Matrix;
  26164. /**
  26165. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26166. * This means that the material can keep using a previous shader while a new one is being compiled.
  26167. * This is mostly used when shader parallel compilation is supported (true by default)
  26168. */
  26169. allowShaderHotSwapping: boolean;
  26170. constructor(name: string, scene: Scene);
  26171. getEffect(): Effect;
  26172. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26173. /**
  26174. * Binds the given world matrix to the active effect
  26175. *
  26176. * @param world the matrix to bind
  26177. */
  26178. bindOnlyWorldMatrix(world: Matrix): void;
  26179. /**
  26180. * Binds the given normal matrix to the active effect
  26181. *
  26182. * @param normalMatrix the matrix to bind
  26183. */
  26184. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26185. bind(world: Matrix, mesh?: Mesh): void;
  26186. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26187. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26188. }
  26189. }
  26190. declare module BABYLON {
  26191. /**
  26192. * This groups all the flags used to control the materials channel.
  26193. */
  26194. export class MaterialFlags {
  26195. private static _DiffuseTextureEnabled;
  26196. /**
  26197. * Are diffuse textures enabled in the application.
  26198. */
  26199. static get DiffuseTextureEnabled(): boolean;
  26200. static set DiffuseTextureEnabled(value: boolean);
  26201. private static _AmbientTextureEnabled;
  26202. /**
  26203. * Are ambient textures enabled in the application.
  26204. */
  26205. static get AmbientTextureEnabled(): boolean;
  26206. static set AmbientTextureEnabled(value: boolean);
  26207. private static _OpacityTextureEnabled;
  26208. /**
  26209. * Are opacity textures enabled in the application.
  26210. */
  26211. static get OpacityTextureEnabled(): boolean;
  26212. static set OpacityTextureEnabled(value: boolean);
  26213. private static _ReflectionTextureEnabled;
  26214. /**
  26215. * Are reflection textures enabled in the application.
  26216. */
  26217. static get ReflectionTextureEnabled(): boolean;
  26218. static set ReflectionTextureEnabled(value: boolean);
  26219. private static _EmissiveTextureEnabled;
  26220. /**
  26221. * Are emissive textures enabled in the application.
  26222. */
  26223. static get EmissiveTextureEnabled(): boolean;
  26224. static set EmissiveTextureEnabled(value: boolean);
  26225. private static _SpecularTextureEnabled;
  26226. /**
  26227. * Are specular textures enabled in the application.
  26228. */
  26229. static get SpecularTextureEnabled(): boolean;
  26230. static set SpecularTextureEnabled(value: boolean);
  26231. private static _BumpTextureEnabled;
  26232. /**
  26233. * Are bump textures enabled in the application.
  26234. */
  26235. static get BumpTextureEnabled(): boolean;
  26236. static set BumpTextureEnabled(value: boolean);
  26237. private static _LightmapTextureEnabled;
  26238. /**
  26239. * Are lightmap textures enabled in the application.
  26240. */
  26241. static get LightmapTextureEnabled(): boolean;
  26242. static set LightmapTextureEnabled(value: boolean);
  26243. private static _RefractionTextureEnabled;
  26244. /**
  26245. * Are refraction textures enabled in the application.
  26246. */
  26247. static get RefractionTextureEnabled(): boolean;
  26248. static set RefractionTextureEnabled(value: boolean);
  26249. private static _ColorGradingTextureEnabled;
  26250. /**
  26251. * Are color grading textures enabled in the application.
  26252. */
  26253. static get ColorGradingTextureEnabled(): boolean;
  26254. static set ColorGradingTextureEnabled(value: boolean);
  26255. private static _FresnelEnabled;
  26256. /**
  26257. * Are fresnels enabled in the application.
  26258. */
  26259. static get FresnelEnabled(): boolean;
  26260. static set FresnelEnabled(value: boolean);
  26261. private static _ClearCoatTextureEnabled;
  26262. /**
  26263. * Are clear coat textures enabled in the application.
  26264. */
  26265. static get ClearCoatTextureEnabled(): boolean;
  26266. static set ClearCoatTextureEnabled(value: boolean);
  26267. private static _ClearCoatBumpTextureEnabled;
  26268. /**
  26269. * Are clear coat bump textures enabled in the application.
  26270. */
  26271. static get ClearCoatBumpTextureEnabled(): boolean;
  26272. static set ClearCoatBumpTextureEnabled(value: boolean);
  26273. private static _ClearCoatTintTextureEnabled;
  26274. /**
  26275. * Are clear coat tint textures enabled in the application.
  26276. */
  26277. static get ClearCoatTintTextureEnabled(): boolean;
  26278. static set ClearCoatTintTextureEnabled(value: boolean);
  26279. private static _SheenTextureEnabled;
  26280. /**
  26281. * Are sheen textures enabled in the application.
  26282. */
  26283. static get SheenTextureEnabled(): boolean;
  26284. static set SheenTextureEnabled(value: boolean);
  26285. private static _AnisotropicTextureEnabled;
  26286. /**
  26287. * Are anisotropic textures enabled in the application.
  26288. */
  26289. static get AnisotropicTextureEnabled(): boolean;
  26290. static set AnisotropicTextureEnabled(value: boolean);
  26291. private static _ThicknessTextureEnabled;
  26292. /**
  26293. * Are thickness textures enabled in the application.
  26294. */
  26295. static get ThicknessTextureEnabled(): boolean;
  26296. static set ThicknessTextureEnabled(value: boolean);
  26297. }
  26298. }
  26299. declare module BABYLON {
  26300. /** @hidden */
  26301. export var defaultFragmentDeclaration: {
  26302. name: string;
  26303. shader: string;
  26304. };
  26305. }
  26306. declare module BABYLON {
  26307. /** @hidden */
  26308. export var defaultUboDeclaration: {
  26309. name: string;
  26310. shader: string;
  26311. };
  26312. }
  26313. declare module BABYLON {
  26314. /** @hidden */
  26315. export var lightFragmentDeclaration: {
  26316. name: string;
  26317. shader: string;
  26318. };
  26319. }
  26320. declare module BABYLON {
  26321. /** @hidden */
  26322. export var lightUboDeclaration: {
  26323. name: string;
  26324. shader: string;
  26325. };
  26326. }
  26327. declare module BABYLON {
  26328. /** @hidden */
  26329. export var lightsFragmentFunctions: {
  26330. name: string;
  26331. shader: string;
  26332. };
  26333. }
  26334. declare module BABYLON {
  26335. /** @hidden */
  26336. export var shadowsFragmentFunctions: {
  26337. name: string;
  26338. shader: string;
  26339. };
  26340. }
  26341. declare module BABYLON {
  26342. /** @hidden */
  26343. export var fresnelFunction: {
  26344. name: string;
  26345. shader: string;
  26346. };
  26347. }
  26348. declare module BABYLON {
  26349. /** @hidden */
  26350. export var reflectionFunction: {
  26351. name: string;
  26352. shader: string;
  26353. };
  26354. }
  26355. declare module BABYLON {
  26356. /** @hidden */
  26357. export var bumpFragmentFunctions: {
  26358. name: string;
  26359. shader: string;
  26360. };
  26361. }
  26362. declare module BABYLON {
  26363. /** @hidden */
  26364. export var logDepthDeclaration: {
  26365. name: string;
  26366. shader: string;
  26367. };
  26368. }
  26369. declare module BABYLON {
  26370. /** @hidden */
  26371. export var bumpFragment: {
  26372. name: string;
  26373. shader: string;
  26374. };
  26375. }
  26376. declare module BABYLON {
  26377. /** @hidden */
  26378. export var depthPrePass: {
  26379. name: string;
  26380. shader: string;
  26381. };
  26382. }
  26383. declare module BABYLON {
  26384. /** @hidden */
  26385. export var lightFragment: {
  26386. name: string;
  26387. shader: string;
  26388. };
  26389. }
  26390. declare module BABYLON {
  26391. /** @hidden */
  26392. export var logDepthFragment: {
  26393. name: string;
  26394. shader: string;
  26395. };
  26396. }
  26397. declare module BABYLON {
  26398. /** @hidden */
  26399. export var defaultPixelShader: {
  26400. name: string;
  26401. shader: string;
  26402. };
  26403. }
  26404. declare module BABYLON {
  26405. /** @hidden */
  26406. export var defaultVertexDeclaration: {
  26407. name: string;
  26408. shader: string;
  26409. };
  26410. }
  26411. declare module BABYLON {
  26412. /** @hidden */
  26413. export var bumpVertexDeclaration: {
  26414. name: string;
  26415. shader: string;
  26416. };
  26417. }
  26418. declare module BABYLON {
  26419. /** @hidden */
  26420. export var bumpVertex: {
  26421. name: string;
  26422. shader: string;
  26423. };
  26424. }
  26425. declare module BABYLON {
  26426. /** @hidden */
  26427. export var fogVertex: {
  26428. name: string;
  26429. shader: string;
  26430. };
  26431. }
  26432. declare module BABYLON {
  26433. /** @hidden */
  26434. export var shadowsVertex: {
  26435. name: string;
  26436. shader: string;
  26437. };
  26438. }
  26439. declare module BABYLON {
  26440. /** @hidden */
  26441. export var pointCloudVertex: {
  26442. name: string;
  26443. shader: string;
  26444. };
  26445. }
  26446. declare module BABYLON {
  26447. /** @hidden */
  26448. export var logDepthVertex: {
  26449. name: string;
  26450. shader: string;
  26451. };
  26452. }
  26453. declare module BABYLON {
  26454. /** @hidden */
  26455. export var defaultVertexShader: {
  26456. name: string;
  26457. shader: string;
  26458. };
  26459. }
  26460. declare module BABYLON {
  26461. /** @hidden */
  26462. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26463. MAINUV1: boolean;
  26464. MAINUV2: boolean;
  26465. DIFFUSE: boolean;
  26466. DIFFUSEDIRECTUV: number;
  26467. AMBIENT: boolean;
  26468. AMBIENTDIRECTUV: number;
  26469. OPACITY: boolean;
  26470. OPACITYDIRECTUV: number;
  26471. OPACITYRGB: boolean;
  26472. REFLECTION: boolean;
  26473. EMISSIVE: boolean;
  26474. EMISSIVEDIRECTUV: number;
  26475. SPECULAR: boolean;
  26476. SPECULARDIRECTUV: number;
  26477. BUMP: boolean;
  26478. BUMPDIRECTUV: number;
  26479. PARALLAX: boolean;
  26480. PARALLAXOCCLUSION: boolean;
  26481. SPECULAROVERALPHA: boolean;
  26482. CLIPPLANE: boolean;
  26483. CLIPPLANE2: boolean;
  26484. CLIPPLANE3: boolean;
  26485. CLIPPLANE4: boolean;
  26486. CLIPPLANE5: boolean;
  26487. CLIPPLANE6: boolean;
  26488. ALPHATEST: boolean;
  26489. DEPTHPREPASS: boolean;
  26490. ALPHAFROMDIFFUSE: boolean;
  26491. POINTSIZE: boolean;
  26492. FOG: boolean;
  26493. SPECULARTERM: boolean;
  26494. DIFFUSEFRESNEL: boolean;
  26495. OPACITYFRESNEL: boolean;
  26496. REFLECTIONFRESNEL: boolean;
  26497. REFRACTIONFRESNEL: boolean;
  26498. EMISSIVEFRESNEL: boolean;
  26499. FRESNEL: boolean;
  26500. NORMAL: boolean;
  26501. UV1: boolean;
  26502. UV2: boolean;
  26503. VERTEXCOLOR: boolean;
  26504. VERTEXALPHA: boolean;
  26505. NUM_BONE_INFLUENCERS: number;
  26506. BonesPerMesh: number;
  26507. BONETEXTURE: boolean;
  26508. INSTANCES: boolean;
  26509. GLOSSINESS: boolean;
  26510. ROUGHNESS: boolean;
  26511. EMISSIVEASILLUMINATION: boolean;
  26512. LINKEMISSIVEWITHDIFFUSE: boolean;
  26513. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26514. LIGHTMAP: boolean;
  26515. LIGHTMAPDIRECTUV: number;
  26516. OBJECTSPACE_NORMALMAP: boolean;
  26517. USELIGHTMAPASSHADOWMAP: boolean;
  26518. REFLECTIONMAP_3D: boolean;
  26519. REFLECTIONMAP_SPHERICAL: boolean;
  26520. REFLECTIONMAP_PLANAR: boolean;
  26521. REFLECTIONMAP_CUBIC: boolean;
  26522. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26523. REFLECTIONMAP_PROJECTION: boolean;
  26524. REFLECTIONMAP_SKYBOX: boolean;
  26525. REFLECTIONMAP_EXPLICIT: boolean;
  26526. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26527. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26528. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26529. INVERTCUBICMAP: boolean;
  26530. LOGARITHMICDEPTH: boolean;
  26531. REFRACTION: boolean;
  26532. REFRACTIONMAP_3D: boolean;
  26533. REFLECTIONOVERALPHA: boolean;
  26534. TWOSIDEDLIGHTING: boolean;
  26535. SHADOWFLOAT: boolean;
  26536. MORPHTARGETS: boolean;
  26537. MORPHTARGETS_NORMAL: boolean;
  26538. MORPHTARGETS_TANGENT: boolean;
  26539. MORPHTARGETS_UV: boolean;
  26540. NUM_MORPH_INFLUENCERS: number;
  26541. NONUNIFORMSCALING: boolean;
  26542. PREMULTIPLYALPHA: boolean;
  26543. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26544. ALPHABLEND: boolean;
  26545. IMAGEPROCESSING: boolean;
  26546. VIGNETTE: boolean;
  26547. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26548. VIGNETTEBLENDMODEOPAQUE: boolean;
  26549. TONEMAPPING: boolean;
  26550. TONEMAPPING_ACES: boolean;
  26551. CONTRAST: boolean;
  26552. COLORCURVES: boolean;
  26553. COLORGRADING: boolean;
  26554. COLORGRADING3D: boolean;
  26555. SAMPLER3DGREENDEPTH: boolean;
  26556. SAMPLER3DBGRMAP: boolean;
  26557. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26558. MULTIVIEW: boolean;
  26559. /**
  26560. * If the reflection texture on this material is in linear color space
  26561. * @hidden
  26562. */
  26563. IS_REFLECTION_LINEAR: boolean;
  26564. /**
  26565. * If the refraction texture on this material is in linear color space
  26566. * @hidden
  26567. */
  26568. IS_REFRACTION_LINEAR: boolean;
  26569. EXPOSURE: boolean;
  26570. constructor();
  26571. setReflectionMode(modeToEnable: string): void;
  26572. }
  26573. /**
  26574. * This is the default material used in Babylon. It is the best trade off between quality
  26575. * and performances.
  26576. * @see http://doc.babylonjs.com/babylon101/materials
  26577. */
  26578. export class StandardMaterial extends PushMaterial {
  26579. private _diffuseTexture;
  26580. /**
  26581. * The basic texture of the material as viewed under a light.
  26582. */
  26583. diffuseTexture: Nullable<BaseTexture>;
  26584. private _ambientTexture;
  26585. /**
  26586. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26587. */
  26588. ambientTexture: Nullable<BaseTexture>;
  26589. private _opacityTexture;
  26590. /**
  26591. * Define the transparency of the material from a texture.
  26592. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26593. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26594. */
  26595. opacityTexture: Nullable<BaseTexture>;
  26596. private _reflectionTexture;
  26597. /**
  26598. * Define the texture used to display the reflection.
  26599. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26600. */
  26601. reflectionTexture: Nullable<BaseTexture>;
  26602. private _emissiveTexture;
  26603. /**
  26604. * Define texture of the material as if self lit.
  26605. * This will be mixed in the final result even in the absence of light.
  26606. */
  26607. emissiveTexture: Nullable<BaseTexture>;
  26608. private _specularTexture;
  26609. /**
  26610. * Define how the color and intensity of the highlight given by the light in the material.
  26611. */
  26612. specularTexture: Nullable<BaseTexture>;
  26613. private _bumpTexture;
  26614. /**
  26615. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26616. * 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.
  26617. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26618. */
  26619. bumpTexture: Nullable<BaseTexture>;
  26620. private _lightmapTexture;
  26621. /**
  26622. * Complex lighting can be computationally expensive to compute at runtime.
  26623. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26624. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26625. */
  26626. lightmapTexture: Nullable<BaseTexture>;
  26627. private _refractionTexture;
  26628. /**
  26629. * Define the texture used to display the refraction.
  26630. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26631. */
  26632. refractionTexture: Nullable<BaseTexture>;
  26633. /**
  26634. * The color of the material lit by the environmental background lighting.
  26635. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26636. */
  26637. ambientColor: Color3;
  26638. /**
  26639. * The basic color of the material as viewed under a light.
  26640. */
  26641. diffuseColor: Color3;
  26642. /**
  26643. * Define how the color and intensity of the highlight given by the light in the material.
  26644. */
  26645. specularColor: Color3;
  26646. /**
  26647. * Define the color of the material as if self lit.
  26648. * This will be mixed in the final result even in the absence of light.
  26649. */
  26650. emissiveColor: Color3;
  26651. /**
  26652. * Defines how sharp are the highlights in the material.
  26653. * The bigger the value the sharper giving a more glossy feeling to the result.
  26654. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26655. */
  26656. specularPower: number;
  26657. private _useAlphaFromDiffuseTexture;
  26658. /**
  26659. * Does the transparency come from the diffuse texture alpha channel.
  26660. */
  26661. useAlphaFromDiffuseTexture: boolean;
  26662. private _useEmissiveAsIllumination;
  26663. /**
  26664. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26665. */
  26666. useEmissiveAsIllumination: boolean;
  26667. private _linkEmissiveWithDiffuse;
  26668. /**
  26669. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26670. * the emissive level when the final color is close to one.
  26671. */
  26672. linkEmissiveWithDiffuse: boolean;
  26673. private _useSpecularOverAlpha;
  26674. /**
  26675. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26676. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26677. */
  26678. useSpecularOverAlpha: boolean;
  26679. private _useReflectionOverAlpha;
  26680. /**
  26681. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26682. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26683. */
  26684. useReflectionOverAlpha: boolean;
  26685. private _disableLighting;
  26686. /**
  26687. * Does lights from the scene impacts this material.
  26688. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26689. */
  26690. disableLighting: boolean;
  26691. private _useObjectSpaceNormalMap;
  26692. /**
  26693. * Allows using an object space normal map (instead of tangent space).
  26694. */
  26695. useObjectSpaceNormalMap: boolean;
  26696. private _useParallax;
  26697. /**
  26698. * Is parallax enabled or not.
  26699. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26700. */
  26701. useParallax: boolean;
  26702. private _useParallaxOcclusion;
  26703. /**
  26704. * Is parallax occlusion enabled or not.
  26705. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26706. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26707. */
  26708. useParallaxOcclusion: boolean;
  26709. /**
  26710. * 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.
  26711. */
  26712. parallaxScaleBias: number;
  26713. private _roughness;
  26714. /**
  26715. * Helps to define how blurry the reflections should appears in the material.
  26716. */
  26717. roughness: number;
  26718. /**
  26719. * In case of refraction, define the value of the index of refraction.
  26720. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26721. */
  26722. indexOfRefraction: number;
  26723. /**
  26724. * Invert the refraction texture alongside the y axis.
  26725. * It can be useful with procedural textures or probe for instance.
  26726. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26727. */
  26728. invertRefractionY: boolean;
  26729. /**
  26730. * Defines the alpha limits in alpha test mode.
  26731. */
  26732. alphaCutOff: number;
  26733. private _useLightmapAsShadowmap;
  26734. /**
  26735. * In case of light mapping, define whether the map contains light or shadow informations.
  26736. */
  26737. useLightmapAsShadowmap: boolean;
  26738. private _diffuseFresnelParameters;
  26739. /**
  26740. * Define the diffuse fresnel parameters of the material.
  26741. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26742. */
  26743. diffuseFresnelParameters: FresnelParameters;
  26744. private _opacityFresnelParameters;
  26745. /**
  26746. * Define the opacity fresnel parameters of the material.
  26747. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26748. */
  26749. opacityFresnelParameters: FresnelParameters;
  26750. private _reflectionFresnelParameters;
  26751. /**
  26752. * Define the reflection fresnel parameters of the material.
  26753. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26754. */
  26755. reflectionFresnelParameters: FresnelParameters;
  26756. private _refractionFresnelParameters;
  26757. /**
  26758. * Define the refraction fresnel parameters of the material.
  26759. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26760. */
  26761. refractionFresnelParameters: FresnelParameters;
  26762. private _emissiveFresnelParameters;
  26763. /**
  26764. * Define the emissive fresnel parameters of the material.
  26765. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26766. */
  26767. emissiveFresnelParameters: FresnelParameters;
  26768. private _useReflectionFresnelFromSpecular;
  26769. /**
  26770. * If true automatically deducts the fresnels values from the material specularity.
  26771. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26772. */
  26773. useReflectionFresnelFromSpecular: boolean;
  26774. private _useGlossinessFromSpecularMapAlpha;
  26775. /**
  26776. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26777. */
  26778. useGlossinessFromSpecularMapAlpha: boolean;
  26779. private _maxSimultaneousLights;
  26780. /**
  26781. * Defines the maximum number of lights that can be used in the material
  26782. */
  26783. maxSimultaneousLights: number;
  26784. private _invertNormalMapX;
  26785. /**
  26786. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26787. */
  26788. invertNormalMapX: boolean;
  26789. private _invertNormalMapY;
  26790. /**
  26791. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26792. */
  26793. invertNormalMapY: boolean;
  26794. private _twoSidedLighting;
  26795. /**
  26796. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26797. */
  26798. twoSidedLighting: boolean;
  26799. /**
  26800. * Default configuration related to image processing available in the standard Material.
  26801. */
  26802. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26803. /**
  26804. * Gets the image processing configuration used either in this material.
  26805. */
  26806. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26807. /**
  26808. * Sets the Default image processing configuration used either in the this material.
  26809. *
  26810. * If sets to null, the scene one is in use.
  26811. */
  26812. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26813. /**
  26814. * Keep track of the image processing observer to allow dispose and replace.
  26815. */
  26816. private _imageProcessingObserver;
  26817. /**
  26818. * Attaches a new image processing configuration to the Standard Material.
  26819. * @param configuration
  26820. */
  26821. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26822. /**
  26823. * Gets wether the color curves effect is enabled.
  26824. */
  26825. get cameraColorCurvesEnabled(): boolean;
  26826. /**
  26827. * Sets wether the color curves effect is enabled.
  26828. */
  26829. set cameraColorCurvesEnabled(value: boolean);
  26830. /**
  26831. * Gets wether the color grading effect is enabled.
  26832. */
  26833. get cameraColorGradingEnabled(): boolean;
  26834. /**
  26835. * Gets wether the color grading effect is enabled.
  26836. */
  26837. set cameraColorGradingEnabled(value: boolean);
  26838. /**
  26839. * Gets wether tonemapping is enabled or not.
  26840. */
  26841. get cameraToneMappingEnabled(): boolean;
  26842. /**
  26843. * Sets wether tonemapping is enabled or not
  26844. */
  26845. set cameraToneMappingEnabled(value: boolean);
  26846. /**
  26847. * The camera exposure used on this material.
  26848. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26849. * This corresponds to a photographic exposure.
  26850. */
  26851. get cameraExposure(): number;
  26852. /**
  26853. * The camera exposure used on this material.
  26854. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26855. * This corresponds to a photographic exposure.
  26856. */
  26857. set cameraExposure(value: number);
  26858. /**
  26859. * Gets The camera contrast used on this material.
  26860. */
  26861. get cameraContrast(): number;
  26862. /**
  26863. * Sets The camera contrast used on this material.
  26864. */
  26865. set cameraContrast(value: number);
  26866. /**
  26867. * Gets the Color Grading 2D Lookup Texture.
  26868. */
  26869. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26870. /**
  26871. * Sets the Color Grading 2D Lookup Texture.
  26872. */
  26873. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26874. /**
  26875. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26876. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26877. * 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;
  26878. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26879. */
  26880. get cameraColorCurves(): Nullable<ColorCurves>;
  26881. /**
  26882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26884. * 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;
  26885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26886. */
  26887. set cameraColorCurves(value: Nullable<ColorCurves>);
  26888. /**
  26889. * Custom callback helping to override the default shader used in the material.
  26890. */
  26891. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26892. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26893. protected _worldViewProjectionMatrix: Matrix;
  26894. protected _globalAmbientColor: Color3;
  26895. protected _useLogarithmicDepth: boolean;
  26896. protected _rebuildInParallel: boolean;
  26897. /**
  26898. * Instantiates a new standard material.
  26899. * This is the default material used in Babylon. It is the best trade off between quality
  26900. * and performances.
  26901. * @see http://doc.babylonjs.com/babylon101/materials
  26902. * @param name Define the name of the material in the scene
  26903. * @param scene Define the scene the material belong to
  26904. */
  26905. constructor(name: string, scene: Scene);
  26906. /**
  26907. * Gets a boolean indicating that current material needs to register RTT
  26908. */
  26909. get hasRenderTargetTextures(): boolean;
  26910. /**
  26911. * Gets the current class name of the material e.g. "StandardMaterial"
  26912. * Mainly use in serialization.
  26913. * @returns the class name
  26914. */
  26915. getClassName(): string;
  26916. /**
  26917. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26918. * You can try switching to logarithmic depth.
  26919. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26920. */
  26921. get useLogarithmicDepth(): boolean;
  26922. set useLogarithmicDepth(value: boolean);
  26923. /**
  26924. * Specifies if the material will require alpha blending
  26925. * @returns a boolean specifying if alpha blending is needed
  26926. */
  26927. needAlphaBlending(): boolean;
  26928. /**
  26929. * Specifies if this material should be rendered in alpha test mode
  26930. * @returns a boolean specifying if an alpha test is needed.
  26931. */
  26932. needAlphaTesting(): boolean;
  26933. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26934. /**
  26935. * Get the texture used for alpha test purpose.
  26936. * @returns the diffuse texture in case of the standard material.
  26937. */
  26938. getAlphaTestTexture(): Nullable<BaseTexture>;
  26939. /**
  26940. * Get if the submesh is ready to be used and all its information available.
  26941. * Child classes can use it to update shaders
  26942. * @param mesh defines the mesh to check
  26943. * @param subMesh defines which submesh to check
  26944. * @param useInstances specifies that instances should be used
  26945. * @returns a boolean indicating that the submesh is ready or not
  26946. */
  26947. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26948. /**
  26949. * Builds the material UBO layouts.
  26950. * Used internally during the effect preparation.
  26951. */
  26952. buildUniformLayout(): void;
  26953. /**
  26954. * Unbinds the material from the mesh
  26955. */
  26956. unbind(): void;
  26957. /**
  26958. * Binds the submesh to this material by preparing the effect and shader to draw
  26959. * @param world defines the world transformation matrix
  26960. * @param mesh defines the mesh containing the submesh
  26961. * @param subMesh defines the submesh to bind the material to
  26962. */
  26963. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26964. /**
  26965. * Get the list of animatables in the material.
  26966. * @returns the list of animatables object used in the material
  26967. */
  26968. getAnimatables(): IAnimatable[];
  26969. /**
  26970. * Gets the active textures from the material
  26971. * @returns an array of textures
  26972. */
  26973. getActiveTextures(): BaseTexture[];
  26974. /**
  26975. * Specifies if the material uses a texture
  26976. * @param texture defines the texture to check against the material
  26977. * @returns a boolean specifying if the material uses the texture
  26978. */
  26979. hasTexture(texture: BaseTexture): boolean;
  26980. /**
  26981. * Disposes the material
  26982. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26983. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26984. */
  26985. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26986. /**
  26987. * Makes a duplicate of the material, and gives it a new name
  26988. * @param name defines the new name for the duplicated material
  26989. * @returns the cloned material
  26990. */
  26991. clone(name: string): StandardMaterial;
  26992. /**
  26993. * Serializes this material in a JSON representation
  26994. * @returns the serialized material object
  26995. */
  26996. serialize(): any;
  26997. /**
  26998. * Creates a standard material from parsed material data
  26999. * @param source defines the JSON representation of the material
  27000. * @param scene defines the hosting scene
  27001. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27002. * @returns a new standard material
  27003. */
  27004. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27005. /**
  27006. * Are diffuse textures enabled in the application.
  27007. */
  27008. static get DiffuseTextureEnabled(): boolean;
  27009. static set DiffuseTextureEnabled(value: boolean);
  27010. /**
  27011. * Are ambient textures enabled in the application.
  27012. */
  27013. static get AmbientTextureEnabled(): boolean;
  27014. static set AmbientTextureEnabled(value: boolean);
  27015. /**
  27016. * Are opacity textures enabled in the application.
  27017. */
  27018. static get OpacityTextureEnabled(): boolean;
  27019. static set OpacityTextureEnabled(value: boolean);
  27020. /**
  27021. * Are reflection textures enabled in the application.
  27022. */
  27023. static get ReflectionTextureEnabled(): boolean;
  27024. static set ReflectionTextureEnabled(value: boolean);
  27025. /**
  27026. * Are emissive textures enabled in the application.
  27027. */
  27028. static get EmissiveTextureEnabled(): boolean;
  27029. static set EmissiveTextureEnabled(value: boolean);
  27030. /**
  27031. * Are specular textures enabled in the application.
  27032. */
  27033. static get SpecularTextureEnabled(): boolean;
  27034. static set SpecularTextureEnabled(value: boolean);
  27035. /**
  27036. * Are bump textures enabled in the application.
  27037. */
  27038. static get BumpTextureEnabled(): boolean;
  27039. static set BumpTextureEnabled(value: boolean);
  27040. /**
  27041. * Are lightmap textures enabled in the application.
  27042. */
  27043. static get LightmapTextureEnabled(): boolean;
  27044. static set LightmapTextureEnabled(value: boolean);
  27045. /**
  27046. * Are refraction textures enabled in the application.
  27047. */
  27048. static get RefractionTextureEnabled(): boolean;
  27049. static set RefractionTextureEnabled(value: boolean);
  27050. /**
  27051. * Are color grading textures enabled in the application.
  27052. */
  27053. static get ColorGradingTextureEnabled(): boolean;
  27054. static set ColorGradingTextureEnabled(value: boolean);
  27055. /**
  27056. * Are fresnels enabled in the application.
  27057. */
  27058. static get FresnelEnabled(): boolean;
  27059. static set FresnelEnabled(value: boolean);
  27060. }
  27061. }
  27062. declare module BABYLON {
  27063. /**
  27064. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27065. *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.
  27066. * The SPS is also a particle system. It provides some methods to manage the particles.
  27067. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27068. *
  27069. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27070. */
  27071. export class SolidParticleSystem implements IDisposable {
  27072. /**
  27073. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27074. * Example : var p = SPS.particles[i];
  27075. */
  27076. particles: SolidParticle[];
  27077. /**
  27078. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27079. */
  27080. nbParticles: number;
  27081. /**
  27082. * If the particles must ever face the camera (default false). Useful for planar particles.
  27083. */
  27084. billboard: boolean;
  27085. /**
  27086. * Recompute normals when adding a shape
  27087. */
  27088. recomputeNormals: boolean;
  27089. /**
  27090. * This a counter ofr your own usage. It's not set by any SPS functions.
  27091. */
  27092. counter: number;
  27093. /**
  27094. * The SPS name. This name is also given to the underlying mesh.
  27095. */
  27096. name: string;
  27097. /**
  27098. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27099. */
  27100. mesh: Mesh;
  27101. /**
  27102. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27103. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27104. */
  27105. vars: any;
  27106. /**
  27107. * This array is populated when the SPS is set as 'pickable'.
  27108. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27109. * Each element of this array is an object `{idx: int, faceId: int}`.
  27110. * `idx` is the picked particle index in the `SPS.particles` array
  27111. * `faceId` is the picked face index counted within this particle.
  27112. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27113. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27114. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27115. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27116. */
  27117. pickedParticles: {
  27118. idx: number;
  27119. faceId: number;
  27120. }[];
  27121. /**
  27122. * This array is populated when the SPS is set as 'pickable'
  27123. * Each key of this array is a submesh index.
  27124. * Each element of this array is a second array defined like this :
  27125. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27126. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27127. * `idx` is the picked particle index in the `SPS.particles` array
  27128. * `faceId` is the picked face index counted within this particle.
  27129. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27130. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27131. */
  27132. pickedBySubMesh: {
  27133. idx: number;
  27134. faceId: number;
  27135. }[][];
  27136. /**
  27137. * This array is populated when `enableDepthSort` is set to true.
  27138. * Each element of this array is an instance of the class DepthSortedParticle.
  27139. */
  27140. depthSortedParticles: DepthSortedParticle[];
  27141. /**
  27142. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27143. * @hidden
  27144. */
  27145. _bSphereOnly: boolean;
  27146. /**
  27147. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27148. * @hidden
  27149. */
  27150. _bSphereRadiusFactor: number;
  27151. private _scene;
  27152. private _positions;
  27153. private _indices;
  27154. private _normals;
  27155. private _colors;
  27156. private _uvs;
  27157. private _indices32;
  27158. private _positions32;
  27159. private _normals32;
  27160. private _fixedNormal32;
  27161. private _colors32;
  27162. private _uvs32;
  27163. private _index;
  27164. private _updatable;
  27165. private _pickable;
  27166. private _isVisibilityBoxLocked;
  27167. private _alwaysVisible;
  27168. private _depthSort;
  27169. private _expandable;
  27170. private _shapeCounter;
  27171. private _copy;
  27172. private _color;
  27173. private _computeParticleColor;
  27174. private _computeParticleTexture;
  27175. private _computeParticleRotation;
  27176. private _computeParticleVertex;
  27177. private _computeBoundingBox;
  27178. private _depthSortParticles;
  27179. private _camera;
  27180. private _mustUnrotateFixedNormals;
  27181. private _particlesIntersect;
  27182. private _needs32Bits;
  27183. private _isNotBuilt;
  27184. private _lastParticleId;
  27185. private _idxOfId;
  27186. private _multimaterialEnabled;
  27187. private _useModelMaterial;
  27188. private _indicesByMaterial;
  27189. private _materialIndexes;
  27190. private _depthSortFunction;
  27191. private _materialSortFunction;
  27192. private _materials;
  27193. private _multimaterial;
  27194. private _materialIndexesById;
  27195. private _defaultMaterial;
  27196. private _autoUpdateSubMeshes;
  27197. /**
  27198. * Creates a SPS (Solid Particle System) object.
  27199. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27200. * @param scene (Scene) is the scene in which the SPS is added.
  27201. * @param options defines the options of the sps e.g.
  27202. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27203. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27204. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27205. * * 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.
  27206. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27207. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27208. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27209. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27210. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27211. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27212. */
  27213. constructor(name: string, scene: Scene, options?: {
  27214. updatable?: boolean;
  27215. isPickable?: boolean;
  27216. enableDepthSort?: boolean;
  27217. particleIntersection?: boolean;
  27218. boundingSphereOnly?: boolean;
  27219. bSphereRadiusFactor?: number;
  27220. expandable?: boolean;
  27221. useModelMaterial?: boolean;
  27222. enableMultiMaterial?: boolean;
  27223. });
  27224. /**
  27225. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27226. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27227. * @returns the created mesh
  27228. */
  27229. buildMesh(): Mesh;
  27230. /**
  27231. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27232. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27233. * Thus the particles generated from `digest()` have their property `position` set yet.
  27234. * @param mesh ( Mesh ) is the mesh to be digested
  27235. * @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
  27236. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27237. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27238. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27239. * @returns the current SPS
  27240. */
  27241. digest(mesh: Mesh, options?: {
  27242. facetNb?: number;
  27243. number?: number;
  27244. delta?: number;
  27245. storage?: [];
  27246. }): SolidParticleSystem;
  27247. /**
  27248. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27249. * @hidden
  27250. */
  27251. private _unrotateFixedNormals;
  27252. /**
  27253. * Resets the temporary working copy particle
  27254. * @hidden
  27255. */
  27256. private _resetCopy;
  27257. /**
  27258. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27259. * @param p the current index in the positions array to be updated
  27260. * @param ind the current index in the indices array
  27261. * @param shape a Vector3 array, the shape geometry
  27262. * @param positions the positions array to be updated
  27263. * @param meshInd the shape indices array
  27264. * @param indices the indices array to be updated
  27265. * @param meshUV the shape uv array
  27266. * @param uvs the uv array to be updated
  27267. * @param meshCol the shape color array
  27268. * @param colors the color array to be updated
  27269. * @param meshNor the shape normals array
  27270. * @param normals the normals array to be updated
  27271. * @param idx the particle index
  27272. * @param idxInShape the particle index in its shape
  27273. * @param options the addShape() method passed options
  27274. * @model the particle model
  27275. * @hidden
  27276. */
  27277. private _meshBuilder;
  27278. /**
  27279. * Returns a shape Vector3 array from positions float array
  27280. * @param positions float array
  27281. * @returns a vector3 array
  27282. * @hidden
  27283. */
  27284. private _posToShape;
  27285. /**
  27286. * Returns a shapeUV array from a float uvs (array deep copy)
  27287. * @param uvs as a float array
  27288. * @returns a shapeUV array
  27289. * @hidden
  27290. */
  27291. private _uvsToShapeUV;
  27292. /**
  27293. * Adds a new particle object in the particles array
  27294. * @param idx particle index in particles array
  27295. * @param id particle id
  27296. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27297. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27298. * @param model particle ModelShape object
  27299. * @param shapeId model shape identifier
  27300. * @param idxInShape index of the particle in the current model
  27301. * @param bInfo model bounding info object
  27302. * @param storage target storage array, if any
  27303. * @hidden
  27304. */
  27305. private _addParticle;
  27306. /**
  27307. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27308. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27309. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27310. * @param nb (positive integer) the number of particles to be created from this model
  27311. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27312. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27313. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27314. * @returns the number of shapes in the system
  27315. */
  27316. addShape(mesh: Mesh, nb: number, options?: {
  27317. positionFunction?: any;
  27318. vertexFunction?: any;
  27319. storage?: [];
  27320. }): number;
  27321. /**
  27322. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27323. * @hidden
  27324. */
  27325. private _rebuildParticle;
  27326. /**
  27327. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27328. * @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.
  27329. * @returns the SPS.
  27330. */
  27331. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27332. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27333. * Returns an array with the removed particles.
  27334. * 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.
  27335. * The SPS can't be empty so at least one particle needs to remain in place.
  27336. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27337. * @param start index of the first particle to remove
  27338. * @param end index of the last particle to remove (included)
  27339. * @returns an array populated with the removed particles
  27340. */
  27341. removeParticles(start: number, end: number): SolidParticle[];
  27342. /**
  27343. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27344. * @param solidParticleArray an array populated with Solid Particles objects
  27345. * @returns the SPS
  27346. */
  27347. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27348. /**
  27349. * Creates a new particle and modifies the SPS mesh geometry :
  27350. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27351. * - calls _addParticle() to populate the particle array
  27352. * factorized code from addShape() and insertParticlesFromArray()
  27353. * @param idx particle index in the particles array
  27354. * @param i particle index in its shape
  27355. * @param modelShape particle ModelShape object
  27356. * @param shape shape vertex array
  27357. * @param meshInd shape indices array
  27358. * @param meshUV shape uv array
  27359. * @param meshCol shape color array
  27360. * @param meshNor shape normals array
  27361. * @param bbInfo shape bounding info
  27362. * @param storage target particle storage
  27363. * @options addShape() passed options
  27364. * @hidden
  27365. */
  27366. private _insertNewParticle;
  27367. /**
  27368. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27369. * This method calls `updateParticle()` for each particle of the SPS.
  27370. * For an animated SPS, it is usually called within the render loop.
  27371. * 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.
  27372. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27373. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27374. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27375. * @returns the SPS.
  27376. */
  27377. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27378. /**
  27379. * Disposes the SPS.
  27380. */
  27381. dispose(): void;
  27382. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27383. * idx is the particle index in the SPS
  27384. * faceId is the picked face index counted within this particle.
  27385. * Returns null if the pickInfo can't identify a picked particle.
  27386. * @param pickingInfo (PickingInfo object)
  27387. * @returns {idx: number, faceId: number} or null
  27388. */
  27389. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27390. idx: number;
  27391. faceId: number;
  27392. }>;
  27393. /**
  27394. * Returns a SolidParticle object from its identifier : particle.id
  27395. * @param id (integer) the particle Id
  27396. * @returns the searched particle or null if not found in the SPS.
  27397. */
  27398. getParticleById(id: number): Nullable<SolidParticle>;
  27399. /**
  27400. * Returns a new array populated with the particles having the passed shapeId.
  27401. * @param shapeId (integer) the shape identifier
  27402. * @returns a new solid particle array
  27403. */
  27404. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27405. /**
  27406. * Populates the passed array "ref" with the particles having the passed shapeId.
  27407. * @param shapeId the shape identifier
  27408. * @returns the SPS
  27409. * @param ref
  27410. */
  27411. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27412. /**
  27413. * Computes the required SubMeshes according the materials assigned to the particles.
  27414. * @returns the solid particle system.
  27415. * Does nothing if called before the SPS mesh is built.
  27416. */
  27417. computeSubMeshes(): SolidParticleSystem;
  27418. /**
  27419. * Sorts the solid particles by material when MultiMaterial is enabled.
  27420. * Updates the indices32 array.
  27421. * Updates the indicesByMaterial array.
  27422. * Updates the mesh indices array.
  27423. * @returns the SPS
  27424. * @hidden
  27425. */
  27426. private _sortParticlesByMaterial;
  27427. /**
  27428. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27429. * @hidden
  27430. */
  27431. private _setMaterialIndexesById;
  27432. /**
  27433. * Returns an array with unique values of Materials from the passed array
  27434. * @param array the material array to be checked and filtered
  27435. * @hidden
  27436. */
  27437. private _filterUniqueMaterialId;
  27438. /**
  27439. * Sets a new Standard Material as _defaultMaterial if not already set.
  27440. * @hidden
  27441. */
  27442. private _setDefaultMaterial;
  27443. /**
  27444. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27445. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27446. * @returns the SPS.
  27447. */
  27448. refreshVisibleSize(): SolidParticleSystem;
  27449. /**
  27450. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27451. * @param size the size (float) of the visibility box
  27452. * note : this doesn't lock the SPS mesh bounding box.
  27453. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27454. */
  27455. setVisibilityBox(size: number): void;
  27456. /**
  27457. * Gets whether the SPS as always visible or not
  27458. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27459. */
  27460. get isAlwaysVisible(): boolean;
  27461. /**
  27462. * Sets the SPS as always visible or not
  27463. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27464. */
  27465. set isAlwaysVisible(val: boolean);
  27466. /**
  27467. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27468. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27469. */
  27470. set isVisibilityBoxLocked(val: boolean);
  27471. /**
  27472. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27473. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27474. */
  27475. get isVisibilityBoxLocked(): boolean;
  27476. /**
  27477. * Tells to `setParticles()` to compute the particle rotations or not.
  27478. * Default value : true. The SPS is faster when it's set to false.
  27479. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27480. */
  27481. set computeParticleRotation(val: boolean);
  27482. /**
  27483. * Tells to `setParticles()` to compute the particle colors or not.
  27484. * Default value : true. The SPS is faster when it's set to false.
  27485. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27486. */
  27487. set computeParticleColor(val: boolean);
  27488. set computeParticleTexture(val: boolean);
  27489. /**
  27490. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27491. * Default value : false. The SPS is faster when it's set to false.
  27492. * Note : the particle custom vertex positions aren't stored values.
  27493. */
  27494. set computeParticleVertex(val: boolean);
  27495. /**
  27496. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27497. */
  27498. set computeBoundingBox(val: boolean);
  27499. /**
  27500. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27501. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27502. * Default : `true`
  27503. */
  27504. set depthSortParticles(val: boolean);
  27505. /**
  27506. * Gets if `setParticles()` computes the particle rotations or not.
  27507. * Default value : true. The SPS is faster when it's set to false.
  27508. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27509. */
  27510. get computeParticleRotation(): boolean;
  27511. /**
  27512. * Gets if `setParticles()` computes the particle colors or not.
  27513. * Default value : true. The SPS is faster when it's set to false.
  27514. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27515. */
  27516. get computeParticleColor(): boolean;
  27517. /**
  27518. * Gets if `setParticles()` computes the particle textures or not.
  27519. * Default value : true. The SPS is faster when it's set to false.
  27520. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27521. */
  27522. get computeParticleTexture(): boolean;
  27523. /**
  27524. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27525. * Default value : false. The SPS is faster when it's set to false.
  27526. * Note : the particle custom vertex positions aren't stored values.
  27527. */
  27528. get computeParticleVertex(): boolean;
  27529. /**
  27530. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27531. */
  27532. get computeBoundingBox(): boolean;
  27533. /**
  27534. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27535. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27536. * Default : `true`
  27537. */
  27538. get depthSortParticles(): boolean;
  27539. /**
  27540. * Gets if the SPS is created as expandable at construction time.
  27541. * Default : `false`
  27542. */
  27543. get expandable(): boolean;
  27544. /**
  27545. * Gets if the SPS supports the Multi Materials
  27546. */
  27547. get multimaterialEnabled(): boolean;
  27548. /**
  27549. * Gets if the SPS uses the model materials for its own multimaterial.
  27550. */
  27551. get useModelMaterial(): boolean;
  27552. /**
  27553. * The SPS used material array.
  27554. */
  27555. get materials(): Material[];
  27556. /**
  27557. * Sets the SPS MultiMaterial from the passed materials.
  27558. * Note : the passed array is internally copied and not used then by reference.
  27559. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27560. */
  27561. setMultiMaterial(materials: Material[]): void;
  27562. /**
  27563. * The SPS computed multimaterial object
  27564. */
  27565. get multimaterial(): MultiMaterial;
  27566. set multimaterial(mm: MultiMaterial);
  27567. /**
  27568. * If the subMeshes must be updated on the next call to setParticles()
  27569. */
  27570. get autoUpdateSubMeshes(): boolean;
  27571. set autoUpdateSubMeshes(val: boolean);
  27572. /**
  27573. * This function does nothing. It may be overwritten to set all the particle first values.
  27574. * The SPS doesn't call this function, you may have to call it by your own.
  27575. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27576. */
  27577. initParticles(): void;
  27578. /**
  27579. * This function does nothing. It may be overwritten to recycle a particle.
  27580. * The SPS doesn't call this function, you may have to call it by your own.
  27581. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27582. * @param particle The particle to recycle
  27583. * @returns the recycled particle
  27584. */
  27585. recycleParticle(particle: SolidParticle): SolidParticle;
  27586. /**
  27587. * Updates a particle : this function should be overwritten by the user.
  27588. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27589. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27590. * @example : just set a particle position or velocity and recycle conditions
  27591. * @param particle The particle to update
  27592. * @returns the updated particle
  27593. */
  27594. updateParticle(particle: SolidParticle): SolidParticle;
  27595. /**
  27596. * Updates a vertex of a particle : it can be overwritten by the user.
  27597. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27598. * @param particle the current particle
  27599. * @param vertex the current index of the current particle
  27600. * @param pt the index of the current vertex in the particle shape
  27601. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27602. * @example : just set a vertex particle position
  27603. * @returns the updated vertex
  27604. */
  27605. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27606. /**
  27607. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27608. * This does nothing and may be overwritten by the user.
  27609. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27610. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27611. * @param update the boolean update value actually passed to setParticles()
  27612. */
  27613. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27614. /**
  27615. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27616. * This will be passed three parameters.
  27617. * This does nothing and may be overwritten by the user.
  27618. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27619. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27620. * @param update the boolean update value actually passed to setParticles()
  27621. */
  27622. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27623. }
  27624. }
  27625. declare module BABYLON {
  27626. /**
  27627. * Represents one particle of a solid particle system.
  27628. */
  27629. export class SolidParticle {
  27630. /**
  27631. * particle global index
  27632. */
  27633. idx: number;
  27634. /**
  27635. * particle identifier
  27636. */
  27637. id: number;
  27638. /**
  27639. * The color of the particle
  27640. */
  27641. color: Nullable<Color4>;
  27642. /**
  27643. * The world space position of the particle.
  27644. */
  27645. position: Vector3;
  27646. /**
  27647. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27648. */
  27649. rotation: Vector3;
  27650. /**
  27651. * The world space rotation quaternion of the particle.
  27652. */
  27653. rotationQuaternion: Nullable<Quaternion>;
  27654. /**
  27655. * The scaling of the particle.
  27656. */
  27657. scaling: Vector3;
  27658. /**
  27659. * The uvs of the particle.
  27660. */
  27661. uvs: Vector4;
  27662. /**
  27663. * The current speed of the particle.
  27664. */
  27665. velocity: Vector3;
  27666. /**
  27667. * The pivot point in the particle local space.
  27668. */
  27669. pivot: Vector3;
  27670. /**
  27671. * Must the particle be translated from its pivot point in its local space ?
  27672. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27673. * Default : false
  27674. */
  27675. translateFromPivot: boolean;
  27676. /**
  27677. * Is the particle active or not ?
  27678. */
  27679. alive: boolean;
  27680. /**
  27681. * Is the particle visible or not ?
  27682. */
  27683. isVisible: boolean;
  27684. /**
  27685. * Index of this particle in the global "positions" array (Internal use)
  27686. * @hidden
  27687. */
  27688. _pos: number;
  27689. /**
  27690. * @hidden Index of this particle in the global "indices" array (Internal use)
  27691. */
  27692. _ind: number;
  27693. /**
  27694. * @hidden ModelShape of this particle (Internal use)
  27695. */
  27696. _model: ModelShape;
  27697. /**
  27698. * ModelShape id of this particle
  27699. */
  27700. shapeId: number;
  27701. /**
  27702. * Index of the particle in its shape id
  27703. */
  27704. idxInShape: number;
  27705. /**
  27706. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27707. */
  27708. _modelBoundingInfo: BoundingInfo;
  27709. /**
  27710. * @hidden Particle BoundingInfo object (Internal use)
  27711. */
  27712. _boundingInfo: BoundingInfo;
  27713. /**
  27714. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27715. */
  27716. _sps: SolidParticleSystem;
  27717. /**
  27718. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27719. */
  27720. _stillInvisible: boolean;
  27721. /**
  27722. * @hidden Last computed particle rotation matrix
  27723. */
  27724. _rotationMatrix: number[];
  27725. /**
  27726. * Parent particle Id, if any.
  27727. * Default null.
  27728. */
  27729. parentId: Nullable<number>;
  27730. /**
  27731. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27732. */
  27733. materialIndex: Nullable<number>;
  27734. /**
  27735. * Custom object or properties.
  27736. */
  27737. props: Nullable<any>;
  27738. /**
  27739. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27740. * The possible values are :
  27741. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27742. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27743. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27744. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27745. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27746. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27747. * */
  27748. cullingStrategy: number;
  27749. /**
  27750. * @hidden Internal global position in the SPS.
  27751. */
  27752. _globalPosition: Vector3;
  27753. /**
  27754. * Creates a Solid Particle object.
  27755. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27756. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27757. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27758. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27759. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27760. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27761. * @param shapeId (integer) is the model shape identifier in the SPS.
  27762. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27763. * @param sps defines the sps it is associated to
  27764. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27765. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27766. */
  27767. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27768. /**
  27769. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27770. * @param target the particle target
  27771. * @returns the current particle
  27772. */
  27773. copyToRef(target: SolidParticle): SolidParticle;
  27774. /**
  27775. * Legacy support, changed scale to scaling
  27776. */
  27777. get scale(): Vector3;
  27778. /**
  27779. * Legacy support, changed scale to scaling
  27780. */
  27781. set scale(scale: Vector3);
  27782. /**
  27783. * Legacy support, changed quaternion to rotationQuaternion
  27784. */
  27785. get quaternion(): Nullable<Quaternion>;
  27786. /**
  27787. * Legacy support, changed quaternion to rotationQuaternion
  27788. */
  27789. set quaternion(q: Nullable<Quaternion>);
  27790. /**
  27791. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27792. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27793. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27794. * @returns true if it intersects
  27795. */
  27796. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27797. /**
  27798. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27799. * A particle is in the frustum if its bounding box intersects the frustum
  27800. * @param frustumPlanes defines the frustum to test
  27801. * @returns true if the particle is in the frustum planes
  27802. */
  27803. isInFrustum(frustumPlanes: Plane[]): boolean;
  27804. /**
  27805. * get the rotation matrix of the particle
  27806. * @hidden
  27807. */
  27808. getRotationMatrix(m: Matrix): void;
  27809. }
  27810. /**
  27811. * Represents the shape of the model used by one particle of a solid particle system.
  27812. * SPS internal tool, don't use it manually.
  27813. */
  27814. export class ModelShape {
  27815. /**
  27816. * The shape id
  27817. * @hidden
  27818. */
  27819. shapeID: number;
  27820. /**
  27821. * flat array of model positions (internal use)
  27822. * @hidden
  27823. */
  27824. _shape: Vector3[];
  27825. /**
  27826. * flat array of model UVs (internal use)
  27827. * @hidden
  27828. */
  27829. _shapeUV: number[];
  27830. /**
  27831. * color array of the model
  27832. * @hidden
  27833. */
  27834. _shapeColors: number[];
  27835. /**
  27836. * indices array of the model
  27837. * @hidden
  27838. */
  27839. _indices: number[];
  27840. /**
  27841. * normals array of the model
  27842. * @hidden
  27843. */
  27844. _normals: number[];
  27845. /**
  27846. * length of the shape in the model indices array (internal use)
  27847. * @hidden
  27848. */
  27849. _indicesLength: number;
  27850. /**
  27851. * Custom position function (internal use)
  27852. * @hidden
  27853. */
  27854. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27855. /**
  27856. * Custom vertex function (internal use)
  27857. * @hidden
  27858. */
  27859. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27860. /**
  27861. * Model material (internal use)
  27862. * @hidden
  27863. */
  27864. _material: Nullable<Material>;
  27865. /**
  27866. * 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.
  27867. * SPS internal tool, don't use it manually.
  27868. * @hidden
  27869. */
  27870. 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>);
  27871. }
  27872. /**
  27873. * Represents a Depth Sorted Particle in the solid particle system.
  27874. * @hidden
  27875. */
  27876. export class DepthSortedParticle {
  27877. /**
  27878. * Particle index
  27879. */
  27880. idx: number;
  27881. /**
  27882. * Index of the particle in the "indices" array
  27883. */
  27884. ind: number;
  27885. /**
  27886. * Length of the particle shape in the "indices" array
  27887. */
  27888. indicesLength: number;
  27889. /**
  27890. * Squared distance from the particle to the camera
  27891. */
  27892. sqDistance: number;
  27893. /**
  27894. * Material index when used with MultiMaterials
  27895. */
  27896. materialIndex: number;
  27897. /**
  27898. * Creates a new sorted particle
  27899. * @param materialIndex
  27900. */
  27901. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  27902. }
  27903. }
  27904. declare module BABYLON {
  27905. /**
  27906. * @hidden
  27907. */
  27908. export class _MeshCollisionData {
  27909. _checkCollisions: boolean;
  27910. _collisionMask: number;
  27911. _collisionGroup: number;
  27912. _surroundingMeshes: Nullable<AbstractMesh[]>;
  27913. _collider: Nullable<Collider>;
  27914. _oldPositionForCollisions: Vector3;
  27915. _diffPositionForCollisions: Vector3;
  27916. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27917. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27918. }
  27919. }
  27920. declare module BABYLON {
  27921. /** @hidden */
  27922. class _FacetDataStorage {
  27923. facetPositions: Vector3[];
  27924. facetNormals: Vector3[];
  27925. facetPartitioning: number[][];
  27926. facetNb: number;
  27927. partitioningSubdivisions: number;
  27928. partitioningBBoxRatio: number;
  27929. facetDataEnabled: boolean;
  27930. facetParameters: any;
  27931. bbSize: Vector3;
  27932. subDiv: {
  27933. max: number;
  27934. X: number;
  27935. Y: number;
  27936. Z: number;
  27937. };
  27938. facetDepthSort: boolean;
  27939. facetDepthSortEnabled: boolean;
  27940. depthSortedIndices: IndicesArray;
  27941. depthSortedFacets: {
  27942. ind: number;
  27943. sqDistance: number;
  27944. }[];
  27945. facetDepthSortFunction: (f1: {
  27946. ind: number;
  27947. sqDistance: number;
  27948. }, f2: {
  27949. ind: number;
  27950. sqDistance: number;
  27951. }) => number;
  27952. facetDepthSortFrom: Vector3;
  27953. facetDepthSortOrigin: Vector3;
  27954. invertedMatrix: Matrix;
  27955. }
  27956. /**
  27957. * @hidden
  27958. **/
  27959. class _InternalAbstractMeshDataInfo {
  27960. _hasVertexAlpha: boolean;
  27961. _useVertexColors: boolean;
  27962. _numBoneInfluencers: number;
  27963. _applyFog: boolean;
  27964. _receiveShadows: boolean;
  27965. _facetData: _FacetDataStorage;
  27966. _visibility: number;
  27967. _skeleton: Nullable<Skeleton>;
  27968. _layerMask: number;
  27969. _computeBonesUsingShaders: boolean;
  27970. _isActive: boolean;
  27971. _onlyForInstances: boolean;
  27972. _isActiveIntermediate: boolean;
  27973. _onlyForInstancesIntermediate: boolean;
  27974. _actAsRegularMesh: boolean;
  27975. }
  27976. /**
  27977. * Class used to store all common mesh properties
  27978. */
  27979. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27980. /** No occlusion */
  27981. static OCCLUSION_TYPE_NONE: number;
  27982. /** Occlusion set to optimisitic */
  27983. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27984. /** Occlusion set to strict */
  27985. static OCCLUSION_TYPE_STRICT: number;
  27986. /** Use an accurante occlusion algorithm */
  27987. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27988. /** Use a conservative occlusion algorithm */
  27989. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27990. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27991. * Test order :
  27992. * Is the bounding sphere outside the frustum ?
  27993. * If not, are the bounding box vertices outside the frustum ?
  27994. * It not, then the cullable object is in the frustum.
  27995. */
  27996. static readonly CULLINGSTRATEGY_STANDARD: number;
  27997. /** Culling strategy : Bounding Sphere Only.
  27998. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27999. * It's also less accurate than the standard because some not visible objects can still be selected.
  28000. * Test : is the bounding sphere outside the frustum ?
  28001. * If not, then the cullable object is in the frustum.
  28002. */
  28003. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28004. /** Culling strategy : Optimistic Inclusion.
  28005. * This in an inclusion test first, then the standard exclusion test.
  28006. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28007. * 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.
  28008. * Anyway, it's as accurate as the standard strategy.
  28009. * Test :
  28010. * Is the cullable object bounding sphere center in the frustum ?
  28011. * If not, apply the default culling strategy.
  28012. */
  28013. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28014. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28015. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28016. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28017. * 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.
  28018. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28019. * Test :
  28020. * Is the cullable object bounding sphere center in the frustum ?
  28021. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28022. */
  28023. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28024. /**
  28025. * No billboard
  28026. */
  28027. static get BILLBOARDMODE_NONE(): number;
  28028. /** Billboard on X axis */
  28029. static get BILLBOARDMODE_X(): number;
  28030. /** Billboard on Y axis */
  28031. static get BILLBOARDMODE_Y(): number;
  28032. /** Billboard on Z axis */
  28033. static get BILLBOARDMODE_Z(): number;
  28034. /** Billboard on all axes */
  28035. static get BILLBOARDMODE_ALL(): number;
  28036. /** Billboard on using position instead of orientation */
  28037. static get BILLBOARDMODE_USE_POSITION(): number;
  28038. /** @hidden */
  28039. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28040. /**
  28041. * The culling strategy to use to check whether the mesh must be rendered or not.
  28042. * This value can be changed at any time and will be used on the next render mesh selection.
  28043. * The possible values are :
  28044. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28045. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28046. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28047. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28048. * Please read each static variable documentation to get details about the culling process.
  28049. * */
  28050. cullingStrategy: number;
  28051. /**
  28052. * Gets the number of facets in the mesh
  28053. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28054. */
  28055. get facetNb(): number;
  28056. /**
  28057. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28059. */
  28060. get partitioningSubdivisions(): number;
  28061. set partitioningSubdivisions(nb: number);
  28062. /**
  28063. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28064. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28066. */
  28067. get partitioningBBoxRatio(): number;
  28068. set partitioningBBoxRatio(ratio: number);
  28069. /**
  28070. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28071. * Works only for updatable meshes.
  28072. * Doesn't work with multi-materials
  28073. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28074. */
  28075. get mustDepthSortFacets(): boolean;
  28076. set mustDepthSortFacets(sort: boolean);
  28077. /**
  28078. * The location (Vector3) where the facet depth sort must be computed from.
  28079. * By default, the active camera position.
  28080. * Used only when facet depth sort is enabled
  28081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28082. */
  28083. get facetDepthSortFrom(): Vector3;
  28084. set facetDepthSortFrom(location: Vector3);
  28085. /**
  28086. * gets a boolean indicating if facetData is enabled
  28087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28088. */
  28089. get isFacetDataEnabled(): boolean;
  28090. /** @hidden */
  28091. _updateNonUniformScalingState(value: boolean): boolean;
  28092. /**
  28093. * An event triggered when this mesh collides with another one
  28094. */
  28095. onCollideObservable: Observable<AbstractMesh>;
  28096. /** Set a function to call when this mesh collides with another one */
  28097. set onCollide(callback: () => void);
  28098. /**
  28099. * An event triggered when the collision's position changes
  28100. */
  28101. onCollisionPositionChangeObservable: Observable<Vector3>;
  28102. /** Set a function to call when the collision's position changes */
  28103. set onCollisionPositionChange(callback: () => void);
  28104. /**
  28105. * An event triggered when material is changed
  28106. */
  28107. onMaterialChangedObservable: Observable<AbstractMesh>;
  28108. /**
  28109. * Gets or sets the orientation for POV movement & rotation
  28110. */
  28111. definedFacingForward: boolean;
  28112. /** @hidden */
  28113. _occlusionQuery: Nullable<WebGLQuery>;
  28114. /** @hidden */
  28115. _renderingGroup: Nullable<RenderingGroup>;
  28116. /**
  28117. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28118. */
  28119. get visibility(): number;
  28120. /**
  28121. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28122. */
  28123. set visibility(value: number);
  28124. /** Gets or sets the alpha index used to sort transparent meshes
  28125. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28126. */
  28127. alphaIndex: number;
  28128. /**
  28129. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28130. */
  28131. isVisible: boolean;
  28132. /**
  28133. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28134. */
  28135. isPickable: boolean;
  28136. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28137. showSubMeshesBoundingBox: boolean;
  28138. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28139. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28140. */
  28141. isBlocker: boolean;
  28142. /**
  28143. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28144. */
  28145. enablePointerMoveEvents: boolean;
  28146. /**
  28147. * Specifies the rendering group id for this mesh (0 by default)
  28148. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28149. */
  28150. renderingGroupId: number;
  28151. private _material;
  28152. /** Gets or sets current material */
  28153. get material(): Nullable<Material>;
  28154. set material(value: Nullable<Material>);
  28155. /**
  28156. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28157. * @see http://doc.babylonjs.com/babylon101/shadows
  28158. */
  28159. get receiveShadows(): boolean;
  28160. set receiveShadows(value: boolean);
  28161. /** Defines color to use when rendering outline */
  28162. outlineColor: Color3;
  28163. /** Define width to use when rendering outline */
  28164. outlineWidth: number;
  28165. /** Defines color to use when rendering overlay */
  28166. overlayColor: Color3;
  28167. /** Defines alpha to use when rendering overlay */
  28168. overlayAlpha: number;
  28169. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28170. get hasVertexAlpha(): boolean;
  28171. set hasVertexAlpha(value: boolean);
  28172. /** 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) */
  28173. get useVertexColors(): boolean;
  28174. set useVertexColors(value: boolean);
  28175. /**
  28176. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28177. */
  28178. get computeBonesUsingShaders(): boolean;
  28179. set computeBonesUsingShaders(value: boolean);
  28180. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28181. get numBoneInfluencers(): number;
  28182. set numBoneInfluencers(value: number);
  28183. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28184. get applyFog(): boolean;
  28185. set applyFog(value: boolean);
  28186. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28187. useOctreeForRenderingSelection: boolean;
  28188. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28189. useOctreeForPicking: boolean;
  28190. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28191. useOctreeForCollisions: boolean;
  28192. /**
  28193. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28194. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28195. */
  28196. get layerMask(): number;
  28197. set layerMask(value: number);
  28198. /**
  28199. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28200. */
  28201. alwaysSelectAsActiveMesh: boolean;
  28202. /**
  28203. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28204. */
  28205. doNotSyncBoundingInfo: boolean;
  28206. /**
  28207. * Gets or sets the current action manager
  28208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28209. */
  28210. actionManager: Nullable<AbstractActionManager>;
  28211. private _meshCollisionData;
  28212. /**
  28213. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28215. */
  28216. ellipsoid: Vector3;
  28217. /**
  28218. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28220. */
  28221. ellipsoidOffset: Vector3;
  28222. /**
  28223. * Gets or sets a collision mask used to mask collisions (default is -1).
  28224. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28225. */
  28226. get collisionMask(): number;
  28227. set collisionMask(mask: number);
  28228. /**
  28229. * Gets or sets the current collision group mask (-1 by default).
  28230. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28231. */
  28232. get collisionGroup(): number;
  28233. set collisionGroup(mask: number);
  28234. /**
  28235. * Gets or sets current surrounding meshes (null by default).
  28236. *
  28237. * By default collision detection is tested against every mesh in the scene.
  28238. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28239. * meshes will be tested for the collision.
  28240. *
  28241. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28242. */
  28243. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28244. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28245. /**
  28246. * Defines edge width used when edgesRenderer is enabled
  28247. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28248. */
  28249. edgesWidth: number;
  28250. /**
  28251. * Defines edge color used when edgesRenderer is enabled
  28252. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28253. */
  28254. edgesColor: Color4;
  28255. /** @hidden */
  28256. _edgesRenderer: Nullable<IEdgesRenderer>;
  28257. /** @hidden */
  28258. _masterMesh: Nullable<AbstractMesh>;
  28259. /** @hidden */
  28260. _boundingInfo: Nullable<BoundingInfo>;
  28261. /** @hidden */
  28262. _renderId: number;
  28263. /**
  28264. * Gets or sets the list of subMeshes
  28265. * @see http://doc.babylonjs.com/how_to/multi_materials
  28266. */
  28267. subMeshes: SubMesh[];
  28268. /** @hidden */
  28269. _intersectionsInProgress: AbstractMesh[];
  28270. /** @hidden */
  28271. _unIndexed: boolean;
  28272. /** @hidden */
  28273. _lightSources: Light[];
  28274. /** Gets the list of lights affecting that mesh */
  28275. get lightSources(): Light[];
  28276. /** @hidden */
  28277. get _positions(): Nullable<Vector3[]>;
  28278. /** @hidden */
  28279. _waitingData: {
  28280. lods: Nullable<any>;
  28281. actions: Nullable<any>;
  28282. freezeWorldMatrix: Nullable<boolean>;
  28283. };
  28284. /** @hidden */
  28285. _bonesTransformMatrices: Nullable<Float32Array>;
  28286. /** @hidden */
  28287. _transformMatrixTexture: Nullable<RawTexture>;
  28288. /**
  28289. * Gets or sets a skeleton to apply skining transformations
  28290. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28291. */
  28292. set skeleton(value: Nullable<Skeleton>);
  28293. get skeleton(): Nullable<Skeleton>;
  28294. /**
  28295. * An event triggered when the mesh is rebuilt.
  28296. */
  28297. onRebuildObservable: Observable<AbstractMesh>;
  28298. /**
  28299. * Creates a new AbstractMesh
  28300. * @param name defines the name of the mesh
  28301. * @param scene defines the hosting scene
  28302. */
  28303. constructor(name: string, scene?: Nullable<Scene>);
  28304. /**
  28305. * Returns the string "AbstractMesh"
  28306. * @returns "AbstractMesh"
  28307. */
  28308. getClassName(): string;
  28309. /**
  28310. * Gets a string representation of the current mesh
  28311. * @param fullDetails defines a boolean indicating if full details must be included
  28312. * @returns a string representation of the current mesh
  28313. */
  28314. toString(fullDetails?: boolean): string;
  28315. /**
  28316. * @hidden
  28317. */
  28318. protected _getEffectiveParent(): Nullable<Node>;
  28319. /** @hidden */
  28320. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28321. /** @hidden */
  28322. _rebuild(): void;
  28323. /** @hidden */
  28324. _resyncLightSources(): void;
  28325. /** @hidden */
  28326. _resyncLightSource(light: Light): void;
  28327. /** @hidden */
  28328. _unBindEffect(): void;
  28329. /** @hidden */
  28330. _removeLightSource(light: Light, dispose: boolean): void;
  28331. private _markSubMeshesAsDirty;
  28332. /** @hidden */
  28333. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28334. /** @hidden */
  28335. _markSubMeshesAsAttributesDirty(): void;
  28336. /** @hidden */
  28337. _markSubMeshesAsMiscDirty(): void;
  28338. /**
  28339. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28340. */
  28341. get scaling(): Vector3;
  28342. set scaling(newScaling: Vector3);
  28343. /**
  28344. * Returns true if the mesh is blocked. Implemented by child classes
  28345. */
  28346. get isBlocked(): boolean;
  28347. /**
  28348. * Returns the mesh itself by default. Implemented by child classes
  28349. * @param camera defines the camera to use to pick the right LOD level
  28350. * @returns the currentAbstractMesh
  28351. */
  28352. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28353. /**
  28354. * Returns 0 by default. Implemented by child classes
  28355. * @returns an integer
  28356. */
  28357. getTotalVertices(): number;
  28358. /**
  28359. * Returns a positive integer : the total number of indices in this mesh geometry.
  28360. * @returns the numner of indices or zero if the mesh has no geometry.
  28361. */
  28362. getTotalIndices(): number;
  28363. /**
  28364. * Returns null by default. Implemented by child classes
  28365. * @returns null
  28366. */
  28367. getIndices(): Nullable<IndicesArray>;
  28368. /**
  28369. * Returns the array of the requested vertex data kind. Implemented by child classes
  28370. * @param kind defines the vertex data kind to use
  28371. * @returns null
  28372. */
  28373. getVerticesData(kind: string): Nullable<FloatArray>;
  28374. /**
  28375. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28376. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28377. * Note that a new underlying VertexBuffer object is created each call.
  28378. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28379. * @param kind defines vertex data kind:
  28380. * * VertexBuffer.PositionKind
  28381. * * VertexBuffer.UVKind
  28382. * * VertexBuffer.UV2Kind
  28383. * * VertexBuffer.UV3Kind
  28384. * * VertexBuffer.UV4Kind
  28385. * * VertexBuffer.UV5Kind
  28386. * * VertexBuffer.UV6Kind
  28387. * * VertexBuffer.ColorKind
  28388. * * VertexBuffer.MatricesIndicesKind
  28389. * * VertexBuffer.MatricesIndicesExtraKind
  28390. * * VertexBuffer.MatricesWeightsKind
  28391. * * VertexBuffer.MatricesWeightsExtraKind
  28392. * @param data defines the data source
  28393. * @param updatable defines if the data must be flagged as updatable (or static)
  28394. * @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
  28395. * @returns the current mesh
  28396. */
  28397. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28398. /**
  28399. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28400. * If the mesh has no geometry, it is simply returned as it is.
  28401. * @param kind defines vertex data kind:
  28402. * * VertexBuffer.PositionKind
  28403. * * VertexBuffer.UVKind
  28404. * * VertexBuffer.UV2Kind
  28405. * * VertexBuffer.UV3Kind
  28406. * * VertexBuffer.UV4Kind
  28407. * * VertexBuffer.UV5Kind
  28408. * * VertexBuffer.UV6Kind
  28409. * * VertexBuffer.ColorKind
  28410. * * VertexBuffer.MatricesIndicesKind
  28411. * * VertexBuffer.MatricesIndicesExtraKind
  28412. * * VertexBuffer.MatricesWeightsKind
  28413. * * VertexBuffer.MatricesWeightsExtraKind
  28414. * @param data defines the data source
  28415. * @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
  28416. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28417. * @returns the current mesh
  28418. */
  28419. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28420. /**
  28421. * Sets the mesh indices,
  28422. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28423. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28424. * @param totalVertices Defines the total number of vertices
  28425. * @returns the current mesh
  28426. */
  28427. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28428. /**
  28429. * Gets a boolean indicating if specific vertex data is present
  28430. * @param kind defines the vertex data kind to use
  28431. * @returns true is data kind is present
  28432. */
  28433. isVerticesDataPresent(kind: string): boolean;
  28434. /**
  28435. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28436. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28437. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28438. * @returns a BoundingInfo
  28439. */
  28440. getBoundingInfo(): BoundingInfo;
  28441. /**
  28442. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28443. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28444. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28445. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28446. * @returns the current mesh
  28447. */
  28448. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28449. /**
  28450. * Overwrite the current bounding info
  28451. * @param boundingInfo defines the new bounding info
  28452. * @returns the current mesh
  28453. */
  28454. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28455. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28456. get useBones(): boolean;
  28457. /** @hidden */
  28458. _preActivate(): void;
  28459. /** @hidden */
  28460. _preActivateForIntermediateRendering(renderId: number): void;
  28461. /** @hidden */
  28462. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28463. /** @hidden */
  28464. _postActivate(): void;
  28465. /** @hidden */
  28466. _freeze(): void;
  28467. /** @hidden */
  28468. _unFreeze(): void;
  28469. /**
  28470. * Gets the current world matrix
  28471. * @returns a Matrix
  28472. */
  28473. getWorldMatrix(): Matrix;
  28474. /** @hidden */
  28475. _getWorldMatrixDeterminant(): number;
  28476. /**
  28477. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28478. */
  28479. get isAnInstance(): boolean;
  28480. /**
  28481. * Gets a boolean indicating if this mesh has instances
  28482. */
  28483. get hasInstances(): boolean;
  28484. /**
  28485. * Perform relative position change from the point of view of behind the front of the mesh.
  28486. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28487. * Supports definition of mesh facing forward or backward
  28488. * @param amountRight defines the distance on the right axis
  28489. * @param amountUp defines the distance on the up axis
  28490. * @param amountForward defines the distance on the forward axis
  28491. * @returns the current mesh
  28492. */
  28493. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28494. /**
  28495. * Calculate relative position change from the point of view of behind the front of the mesh.
  28496. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28497. * Supports definition of mesh facing forward or backward
  28498. * @param amountRight defines the distance on the right axis
  28499. * @param amountUp defines the distance on the up axis
  28500. * @param amountForward defines the distance on the forward axis
  28501. * @returns the new displacement vector
  28502. */
  28503. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28504. /**
  28505. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28506. * Supports definition of mesh facing forward or backward
  28507. * @param flipBack defines the flip
  28508. * @param twirlClockwise defines the twirl
  28509. * @param tiltRight defines the tilt
  28510. * @returns the current mesh
  28511. */
  28512. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28513. /**
  28514. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28515. * Supports definition of mesh facing forward or backward.
  28516. * @param flipBack defines the flip
  28517. * @param twirlClockwise defines the twirl
  28518. * @param tiltRight defines the tilt
  28519. * @returns the new rotation vector
  28520. */
  28521. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28522. /**
  28523. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28524. * This means the mesh underlying bounding box and sphere are recomputed.
  28525. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28526. * @returns the current mesh
  28527. */
  28528. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28529. /** @hidden */
  28530. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28531. /** @hidden */
  28532. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28533. /** @hidden */
  28534. _updateBoundingInfo(): AbstractMesh;
  28535. /** @hidden */
  28536. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28537. /** @hidden */
  28538. protected _afterComputeWorldMatrix(): void;
  28539. /** @hidden */
  28540. get _effectiveMesh(): AbstractMesh;
  28541. /**
  28542. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28543. * A mesh is in the frustum if its bounding box intersects the frustum
  28544. * @param frustumPlanes defines the frustum to test
  28545. * @returns true if the mesh is in the frustum planes
  28546. */
  28547. isInFrustum(frustumPlanes: Plane[]): boolean;
  28548. /**
  28549. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28550. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28551. * @param frustumPlanes defines the frustum to test
  28552. * @returns true if the mesh is completely in the frustum planes
  28553. */
  28554. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28555. /**
  28556. * True if the mesh intersects another mesh or a SolidParticle object
  28557. * @param mesh defines a target mesh or SolidParticle to test
  28558. * @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)
  28559. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28560. * @returns true if there is an intersection
  28561. */
  28562. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28563. /**
  28564. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28565. * @param point defines the point to test
  28566. * @returns true if there is an intersection
  28567. */
  28568. intersectsPoint(point: Vector3): boolean;
  28569. /**
  28570. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28571. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28572. */
  28573. get checkCollisions(): boolean;
  28574. set checkCollisions(collisionEnabled: boolean);
  28575. /**
  28576. * Gets Collider object used to compute collisions (not physics)
  28577. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28578. */
  28579. get collider(): Nullable<Collider>;
  28580. /**
  28581. * Move the mesh using collision engine
  28582. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28583. * @param displacement defines the requested displacement vector
  28584. * @returns the current mesh
  28585. */
  28586. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28587. private _onCollisionPositionChange;
  28588. /** @hidden */
  28589. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28590. /** @hidden */
  28591. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28592. /** @hidden */
  28593. _checkCollision(collider: Collider): AbstractMesh;
  28594. /** @hidden */
  28595. _generatePointsArray(): boolean;
  28596. /**
  28597. * Checks if the passed Ray intersects with the mesh
  28598. * @param ray defines the ray to use
  28599. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28600. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28601. * @returns the picking info
  28602. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28603. */
  28604. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28605. /**
  28606. * Clones the current mesh
  28607. * @param name defines the mesh name
  28608. * @param newParent defines the new mesh parent
  28609. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28610. * @returns the new mesh
  28611. */
  28612. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28613. /**
  28614. * Disposes all the submeshes of the current meshnp
  28615. * @returns the current mesh
  28616. */
  28617. releaseSubMeshes(): AbstractMesh;
  28618. /**
  28619. * Releases resources associated with this abstract mesh.
  28620. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28621. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28622. */
  28623. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28624. /**
  28625. * Adds the passed mesh as a child to the current mesh
  28626. * @param mesh defines the child mesh
  28627. * @returns the current mesh
  28628. */
  28629. addChild(mesh: AbstractMesh): AbstractMesh;
  28630. /**
  28631. * Removes the passed mesh from the current mesh children list
  28632. * @param mesh defines the child mesh
  28633. * @returns the current mesh
  28634. */
  28635. removeChild(mesh: AbstractMesh): AbstractMesh;
  28636. /** @hidden */
  28637. private _initFacetData;
  28638. /**
  28639. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28640. * This method can be called within the render loop.
  28641. * 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
  28642. * @returns the current mesh
  28643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28644. */
  28645. updateFacetData(): AbstractMesh;
  28646. /**
  28647. * Returns the facetLocalNormals array.
  28648. * The normals are expressed in the mesh local spac
  28649. * @returns an array of Vector3
  28650. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28651. */
  28652. getFacetLocalNormals(): Vector3[];
  28653. /**
  28654. * Returns the facetLocalPositions array.
  28655. * The facet positions are expressed in the mesh local space
  28656. * @returns an array of Vector3
  28657. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28658. */
  28659. getFacetLocalPositions(): Vector3[];
  28660. /**
  28661. * Returns the facetLocalPartioning array
  28662. * @returns an array of array of numbers
  28663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28664. */
  28665. getFacetLocalPartitioning(): number[][];
  28666. /**
  28667. * Returns the i-th facet position in the world system.
  28668. * This method allocates a new Vector3 per call
  28669. * @param i defines the facet index
  28670. * @returns a new Vector3
  28671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28672. */
  28673. getFacetPosition(i: number): Vector3;
  28674. /**
  28675. * Sets the reference Vector3 with the i-th facet position in the world system
  28676. * @param i defines the facet index
  28677. * @param ref defines the target vector
  28678. * @returns the current mesh
  28679. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28680. */
  28681. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28682. /**
  28683. * Returns the i-th facet normal in the world system.
  28684. * This method allocates a new Vector3 per call
  28685. * @param i defines the facet index
  28686. * @returns a new Vector3
  28687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28688. */
  28689. getFacetNormal(i: number): Vector3;
  28690. /**
  28691. * Sets the reference Vector3 with the i-th facet normal in the world system
  28692. * @param i defines the facet index
  28693. * @param ref defines the target vector
  28694. * @returns the current mesh
  28695. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28696. */
  28697. getFacetNormalToRef(i: number, ref: Vector3): this;
  28698. /**
  28699. * 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)
  28700. * @param x defines x coordinate
  28701. * @param y defines y coordinate
  28702. * @param z defines z coordinate
  28703. * @returns the array of facet indexes
  28704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28705. */
  28706. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28707. /**
  28708. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28709. * @param projected sets as the (x,y,z) world projection on the facet
  28710. * @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
  28711. * @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
  28712. * @param x defines x coordinate
  28713. * @param y defines y coordinate
  28714. * @param z defines z coordinate
  28715. * @returns the face index if found (or null instead)
  28716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28717. */
  28718. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28719. /**
  28720. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28721. * @param projected sets as the (x,y,z) local projection on the facet
  28722. * @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
  28723. * @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
  28724. * @param x defines x coordinate
  28725. * @param y defines y coordinate
  28726. * @param z defines z coordinate
  28727. * @returns the face index if found (or null instead)
  28728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28729. */
  28730. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28731. /**
  28732. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28733. * @returns the parameters
  28734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28735. */
  28736. getFacetDataParameters(): any;
  28737. /**
  28738. * Disables the feature FacetData and frees the related memory
  28739. * @returns the current mesh
  28740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28741. */
  28742. disableFacetData(): AbstractMesh;
  28743. /**
  28744. * Updates the AbstractMesh indices array
  28745. * @param indices defines the data source
  28746. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28747. * @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)
  28748. * @returns the current mesh
  28749. */
  28750. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28751. /**
  28752. * Creates new normals data for the mesh
  28753. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28754. * @returns the current mesh
  28755. */
  28756. createNormals(updatable: boolean): AbstractMesh;
  28757. /**
  28758. * Align the mesh with a normal
  28759. * @param normal defines the normal to use
  28760. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28761. * @returns the current mesh
  28762. */
  28763. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28764. /** @hidden */
  28765. _checkOcclusionQuery(): boolean;
  28766. /**
  28767. * Disables the mesh edge rendering mode
  28768. * @returns the currentAbstractMesh
  28769. */
  28770. disableEdgesRendering(): AbstractMesh;
  28771. /**
  28772. * Enables the edge rendering mode on the mesh.
  28773. * This mode makes the mesh edges visible
  28774. * @param epsilon defines the maximal distance between two angles to detect a face
  28775. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28776. * @returns the currentAbstractMesh
  28777. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28778. */
  28779. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28780. }
  28781. }
  28782. declare module BABYLON {
  28783. /**
  28784. * Interface used to define ActionEvent
  28785. */
  28786. export interface IActionEvent {
  28787. /** The mesh or sprite that triggered the action */
  28788. source: any;
  28789. /** The X mouse cursor position at the time of the event */
  28790. pointerX: number;
  28791. /** The Y mouse cursor position at the time of the event */
  28792. pointerY: number;
  28793. /** The mesh that is currently pointed at (can be null) */
  28794. meshUnderPointer: Nullable<AbstractMesh>;
  28795. /** the original (browser) event that triggered the ActionEvent */
  28796. sourceEvent?: any;
  28797. /** additional data for the event */
  28798. additionalData?: any;
  28799. }
  28800. /**
  28801. * ActionEvent is the event being sent when an action is triggered.
  28802. */
  28803. export class ActionEvent implements IActionEvent {
  28804. /** The mesh or sprite that triggered the action */
  28805. source: any;
  28806. /** The X mouse cursor position at the time of the event */
  28807. pointerX: number;
  28808. /** The Y mouse cursor position at the time of the event */
  28809. pointerY: number;
  28810. /** The mesh that is currently pointed at (can be null) */
  28811. meshUnderPointer: Nullable<AbstractMesh>;
  28812. /** the original (browser) event that triggered the ActionEvent */
  28813. sourceEvent?: any;
  28814. /** additional data for the event */
  28815. additionalData?: any;
  28816. /**
  28817. * Creates a new ActionEvent
  28818. * @param source The mesh or sprite that triggered the action
  28819. * @param pointerX The X mouse cursor position at the time of the event
  28820. * @param pointerY The Y mouse cursor position at the time of the event
  28821. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28822. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28823. * @param additionalData additional data for the event
  28824. */
  28825. constructor(
  28826. /** The mesh or sprite that triggered the action */
  28827. source: any,
  28828. /** The X mouse cursor position at the time of the event */
  28829. pointerX: number,
  28830. /** The Y mouse cursor position at the time of the event */
  28831. pointerY: number,
  28832. /** The mesh that is currently pointed at (can be null) */
  28833. meshUnderPointer: Nullable<AbstractMesh>,
  28834. /** the original (browser) event that triggered the ActionEvent */
  28835. sourceEvent?: any,
  28836. /** additional data for the event */
  28837. additionalData?: any);
  28838. /**
  28839. * Helper function to auto-create an ActionEvent from a source mesh.
  28840. * @param source The source mesh that triggered the event
  28841. * @param evt The original (browser) event
  28842. * @param additionalData additional data for the event
  28843. * @returns the new ActionEvent
  28844. */
  28845. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28846. /**
  28847. * Helper function to auto-create an ActionEvent from a source sprite
  28848. * @param source The source sprite that triggered the event
  28849. * @param scene Scene associated with the sprite
  28850. * @param evt The original (browser) event
  28851. * @param additionalData additional data for the event
  28852. * @returns the new ActionEvent
  28853. */
  28854. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28855. /**
  28856. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28857. * @param scene the scene where the event occurred
  28858. * @param evt The original (browser) event
  28859. * @returns the new ActionEvent
  28860. */
  28861. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28862. /**
  28863. * Helper function to auto-create an ActionEvent from a primitive
  28864. * @param prim defines the target primitive
  28865. * @param pointerPos defines the pointer position
  28866. * @param evt The original (browser) event
  28867. * @param additionalData additional data for the event
  28868. * @returns the new ActionEvent
  28869. */
  28870. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28871. }
  28872. }
  28873. declare module BABYLON {
  28874. /**
  28875. * Abstract class used to decouple action Manager from scene and meshes.
  28876. * Do not instantiate.
  28877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28878. */
  28879. export abstract class AbstractActionManager implements IDisposable {
  28880. /** Gets the list of active triggers */
  28881. static Triggers: {
  28882. [key: string]: number;
  28883. };
  28884. /** Gets the cursor to use when hovering items */
  28885. hoverCursor: string;
  28886. /** Gets the list of actions */
  28887. actions: IAction[];
  28888. /**
  28889. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28890. */
  28891. isRecursive: boolean;
  28892. /**
  28893. * Releases all associated resources
  28894. */
  28895. abstract dispose(): void;
  28896. /**
  28897. * Does this action manager has pointer triggers
  28898. */
  28899. abstract get hasPointerTriggers(): boolean;
  28900. /**
  28901. * Does this action manager has pick triggers
  28902. */
  28903. abstract get hasPickTriggers(): boolean;
  28904. /**
  28905. * Process a specific trigger
  28906. * @param trigger defines the trigger to process
  28907. * @param evt defines the event details to be processed
  28908. */
  28909. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28910. /**
  28911. * Does this action manager handles actions of any of the given triggers
  28912. * @param triggers defines the triggers to be tested
  28913. * @return a boolean indicating whether one (or more) of the triggers is handled
  28914. */
  28915. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28916. /**
  28917. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28918. * speed.
  28919. * @param triggerA defines the trigger to be tested
  28920. * @param triggerB defines the trigger to be tested
  28921. * @return a boolean indicating whether one (or more) of the triggers is handled
  28922. */
  28923. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28924. /**
  28925. * Does this action manager handles actions of a given trigger
  28926. * @param trigger defines the trigger to be tested
  28927. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28928. * @return whether the trigger is handled
  28929. */
  28930. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28931. /**
  28932. * Serialize this manager to a JSON object
  28933. * @param name defines the property name to store this manager
  28934. * @returns a JSON representation of this manager
  28935. */
  28936. abstract serialize(name: string): any;
  28937. /**
  28938. * Registers an action to this action manager
  28939. * @param action defines the action to be registered
  28940. * @return the action amended (prepared) after registration
  28941. */
  28942. abstract registerAction(action: IAction): Nullable<IAction>;
  28943. /**
  28944. * Unregisters an action to this action manager
  28945. * @param action defines the action to be unregistered
  28946. * @return a boolean indicating whether the action has been unregistered
  28947. */
  28948. abstract unregisterAction(action: IAction): Boolean;
  28949. /**
  28950. * Does exist one action manager with at least one trigger
  28951. **/
  28952. static get HasTriggers(): boolean;
  28953. /**
  28954. * Does exist one action manager with at least one pick trigger
  28955. **/
  28956. static get HasPickTriggers(): boolean;
  28957. /**
  28958. * Does exist one action manager that handles actions of a given trigger
  28959. * @param trigger defines the trigger to be tested
  28960. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28961. **/
  28962. static HasSpecificTrigger(trigger: number): boolean;
  28963. }
  28964. }
  28965. declare module BABYLON {
  28966. /**
  28967. * Defines how a node can be built from a string name.
  28968. */
  28969. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28970. /**
  28971. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28972. */
  28973. export class Node implements IBehaviorAware<Node> {
  28974. /** @hidden */
  28975. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28976. private static _NodeConstructors;
  28977. /**
  28978. * Add a new node constructor
  28979. * @param type defines the type name of the node to construct
  28980. * @param constructorFunc defines the constructor function
  28981. */
  28982. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28983. /**
  28984. * Returns a node constructor based on type name
  28985. * @param type defines the type name
  28986. * @param name defines the new node name
  28987. * @param scene defines the hosting scene
  28988. * @param options defines optional options to transmit to constructors
  28989. * @returns the new constructor or null
  28990. */
  28991. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28992. /**
  28993. * Gets or sets the name of the node
  28994. */
  28995. name: string;
  28996. /**
  28997. * Gets or sets the id of the node
  28998. */
  28999. id: string;
  29000. /**
  29001. * Gets or sets the unique id of the node
  29002. */
  29003. uniqueId: number;
  29004. /**
  29005. * Gets or sets a string used to store user defined state for the node
  29006. */
  29007. state: string;
  29008. /**
  29009. * Gets or sets an object used to store user defined information for the node
  29010. */
  29011. metadata: any;
  29012. /**
  29013. * For internal use only. Please do not use.
  29014. */
  29015. reservedDataStore: any;
  29016. /**
  29017. * List of inspectable custom properties (used by the Inspector)
  29018. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29019. */
  29020. inspectableCustomProperties: IInspectable[];
  29021. private _doNotSerialize;
  29022. /**
  29023. * Gets or sets a boolean used to define if the node must be serialized
  29024. */
  29025. get doNotSerialize(): boolean;
  29026. set doNotSerialize(value: boolean);
  29027. /** @hidden */
  29028. _isDisposed: boolean;
  29029. /**
  29030. * Gets a list of Animations associated with the node
  29031. */
  29032. animations: Animation[];
  29033. protected _ranges: {
  29034. [name: string]: Nullable<AnimationRange>;
  29035. };
  29036. /**
  29037. * Callback raised when the node is ready to be used
  29038. */
  29039. onReady: Nullable<(node: Node) => void>;
  29040. private _isEnabled;
  29041. private _isParentEnabled;
  29042. private _isReady;
  29043. /** @hidden */
  29044. _currentRenderId: number;
  29045. private _parentUpdateId;
  29046. /** @hidden */
  29047. _childUpdateId: number;
  29048. /** @hidden */
  29049. _waitingParentId: Nullable<string>;
  29050. /** @hidden */
  29051. _scene: Scene;
  29052. /** @hidden */
  29053. _cache: any;
  29054. private _parentNode;
  29055. private _children;
  29056. /** @hidden */
  29057. _worldMatrix: Matrix;
  29058. /** @hidden */
  29059. _worldMatrixDeterminant: number;
  29060. /** @hidden */
  29061. _worldMatrixDeterminantIsDirty: boolean;
  29062. /** @hidden */
  29063. private _sceneRootNodesIndex;
  29064. /**
  29065. * Gets a boolean indicating if the node has been disposed
  29066. * @returns true if the node was disposed
  29067. */
  29068. isDisposed(): boolean;
  29069. /**
  29070. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29071. * @see https://doc.babylonjs.com/how_to/parenting
  29072. */
  29073. set parent(parent: Nullable<Node>);
  29074. get parent(): Nullable<Node>;
  29075. /** @hidden */
  29076. _addToSceneRootNodes(): void;
  29077. /** @hidden */
  29078. _removeFromSceneRootNodes(): void;
  29079. private _animationPropertiesOverride;
  29080. /**
  29081. * Gets or sets the animation properties override
  29082. */
  29083. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29084. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29085. /**
  29086. * Gets a string idenfifying the name of the class
  29087. * @returns "Node" string
  29088. */
  29089. getClassName(): string;
  29090. /** @hidden */
  29091. readonly _isNode: boolean;
  29092. /**
  29093. * An event triggered when the mesh is disposed
  29094. */
  29095. onDisposeObservable: Observable<Node>;
  29096. private _onDisposeObserver;
  29097. /**
  29098. * Sets a callback that will be raised when the node will be disposed
  29099. */
  29100. set onDispose(callback: () => void);
  29101. /**
  29102. * Creates a new Node
  29103. * @param name the name and id to be given to this node
  29104. * @param scene the scene this node will be added to
  29105. */
  29106. constructor(name: string, scene?: Nullable<Scene>);
  29107. /**
  29108. * Gets the scene of the node
  29109. * @returns a scene
  29110. */
  29111. getScene(): Scene;
  29112. /**
  29113. * Gets the engine of the node
  29114. * @returns a Engine
  29115. */
  29116. getEngine(): Engine;
  29117. private _behaviors;
  29118. /**
  29119. * Attach a behavior to the node
  29120. * @see http://doc.babylonjs.com/features/behaviour
  29121. * @param behavior defines the behavior to attach
  29122. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29123. * @returns the current Node
  29124. */
  29125. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29126. /**
  29127. * Remove an attached behavior
  29128. * @see http://doc.babylonjs.com/features/behaviour
  29129. * @param behavior defines the behavior to attach
  29130. * @returns the current Node
  29131. */
  29132. removeBehavior(behavior: Behavior<Node>): Node;
  29133. /**
  29134. * Gets the list of attached behaviors
  29135. * @see http://doc.babylonjs.com/features/behaviour
  29136. */
  29137. get behaviors(): Behavior<Node>[];
  29138. /**
  29139. * Gets an attached behavior by name
  29140. * @param name defines the name of the behavior to look for
  29141. * @see http://doc.babylonjs.com/features/behaviour
  29142. * @returns null if behavior was not found else the requested behavior
  29143. */
  29144. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29145. /**
  29146. * Returns the latest update of the World matrix
  29147. * @returns a Matrix
  29148. */
  29149. getWorldMatrix(): Matrix;
  29150. /** @hidden */
  29151. _getWorldMatrixDeterminant(): number;
  29152. /**
  29153. * Returns directly the latest state of the mesh World matrix.
  29154. * A Matrix is returned.
  29155. */
  29156. get worldMatrixFromCache(): Matrix;
  29157. /** @hidden */
  29158. _initCache(): void;
  29159. /** @hidden */
  29160. updateCache(force?: boolean): void;
  29161. /** @hidden */
  29162. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29163. /** @hidden */
  29164. _updateCache(ignoreParentClass?: boolean): void;
  29165. /** @hidden */
  29166. _isSynchronized(): boolean;
  29167. /** @hidden */
  29168. _markSyncedWithParent(): void;
  29169. /** @hidden */
  29170. isSynchronizedWithParent(): boolean;
  29171. /** @hidden */
  29172. isSynchronized(): boolean;
  29173. /**
  29174. * Is this node ready to be used/rendered
  29175. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29176. * @return true if the node is ready
  29177. */
  29178. isReady(completeCheck?: boolean): boolean;
  29179. /**
  29180. * Is this node enabled?
  29181. * 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
  29182. * @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
  29183. * @return whether this node (and its parent) is enabled
  29184. */
  29185. isEnabled(checkAncestors?: boolean): boolean;
  29186. /** @hidden */
  29187. protected _syncParentEnabledState(): void;
  29188. /**
  29189. * Set the enabled state of this node
  29190. * @param value defines the new enabled state
  29191. */
  29192. setEnabled(value: boolean): void;
  29193. /**
  29194. * Is this node a descendant of the given node?
  29195. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29196. * @param ancestor defines the parent node to inspect
  29197. * @returns a boolean indicating if this node is a descendant of the given node
  29198. */
  29199. isDescendantOf(ancestor: Node): boolean;
  29200. /** @hidden */
  29201. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29202. /**
  29203. * Will return all nodes that have this node as ascendant
  29204. * @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
  29205. * @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
  29206. * @return all children nodes of all types
  29207. */
  29208. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29209. /**
  29210. * Get all child-meshes of this node
  29211. * @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)
  29212. * @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
  29213. * @returns an array of AbstractMesh
  29214. */
  29215. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29216. /**
  29217. * Get all direct children of this node
  29218. * @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
  29219. * @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)
  29220. * @returns an array of Node
  29221. */
  29222. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29223. /** @hidden */
  29224. _setReady(state: boolean): void;
  29225. /**
  29226. * Get an animation by name
  29227. * @param name defines the name of the animation to look for
  29228. * @returns null if not found else the requested animation
  29229. */
  29230. getAnimationByName(name: string): Nullable<Animation>;
  29231. /**
  29232. * Creates an animation range for this node
  29233. * @param name defines the name of the range
  29234. * @param from defines the starting key
  29235. * @param to defines the end key
  29236. */
  29237. createAnimationRange(name: string, from: number, to: number): void;
  29238. /**
  29239. * Delete a specific animation range
  29240. * @param name defines the name of the range to delete
  29241. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29242. */
  29243. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29244. /**
  29245. * Get an animation range by name
  29246. * @param name defines the name of the animation range to look for
  29247. * @returns null if not found else the requested animation range
  29248. */
  29249. getAnimationRange(name: string): Nullable<AnimationRange>;
  29250. /**
  29251. * Gets the list of all animation ranges defined on this node
  29252. * @returns an array
  29253. */
  29254. getAnimationRanges(): Nullable<AnimationRange>[];
  29255. /**
  29256. * Will start the animation sequence
  29257. * @param name defines the range frames for animation sequence
  29258. * @param loop defines if the animation should loop (false by default)
  29259. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29260. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29261. * @returns the object created for this animation. If range does not exist, it will return null
  29262. */
  29263. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29264. /**
  29265. * Serialize animation ranges into a JSON compatible object
  29266. * @returns serialization object
  29267. */
  29268. serializeAnimationRanges(): any;
  29269. /**
  29270. * Computes the world matrix of the node
  29271. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29272. * @returns the world matrix
  29273. */
  29274. computeWorldMatrix(force?: boolean): Matrix;
  29275. /**
  29276. * Releases resources associated with this node.
  29277. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29278. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29279. */
  29280. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29281. /**
  29282. * Parse animation range data from a serialization object and store them into a given node
  29283. * @param node defines where to store the animation ranges
  29284. * @param parsedNode defines the serialization object to read data from
  29285. * @param scene defines the hosting scene
  29286. */
  29287. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29288. /**
  29289. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29290. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29291. * @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
  29292. * @returns the new bounding vectors
  29293. */
  29294. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29295. min: Vector3;
  29296. max: Vector3;
  29297. };
  29298. }
  29299. }
  29300. declare module BABYLON {
  29301. /**
  29302. * @hidden
  29303. */
  29304. export class _IAnimationState {
  29305. key: number;
  29306. repeatCount: number;
  29307. workValue?: any;
  29308. loopMode?: number;
  29309. offsetValue?: any;
  29310. highLimitValue?: any;
  29311. }
  29312. /**
  29313. * Class used to store any kind of animation
  29314. */
  29315. export class Animation {
  29316. /**Name of the animation */
  29317. name: string;
  29318. /**Property to animate */
  29319. targetProperty: string;
  29320. /**The frames per second of the animation */
  29321. framePerSecond: number;
  29322. /**The data type of the animation */
  29323. dataType: number;
  29324. /**The loop mode of the animation */
  29325. loopMode?: number | undefined;
  29326. /**Specifies if blending should be enabled */
  29327. enableBlending?: boolean | undefined;
  29328. /**
  29329. * Use matrix interpolation instead of using direct key value when animating matrices
  29330. */
  29331. static AllowMatricesInterpolation: boolean;
  29332. /**
  29333. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29334. */
  29335. static AllowMatrixDecomposeForInterpolation: boolean;
  29336. /**
  29337. * Stores the key frames of the animation
  29338. */
  29339. private _keys;
  29340. /**
  29341. * Stores the easing function of the animation
  29342. */
  29343. private _easingFunction;
  29344. /**
  29345. * @hidden Internal use only
  29346. */
  29347. _runtimeAnimations: RuntimeAnimation[];
  29348. /**
  29349. * The set of event that will be linked to this animation
  29350. */
  29351. private _events;
  29352. /**
  29353. * Stores an array of target property paths
  29354. */
  29355. targetPropertyPath: string[];
  29356. /**
  29357. * Stores the blending speed of the animation
  29358. */
  29359. blendingSpeed: number;
  29360. /**
  29361. * Stores the animation ranges for the animation
  29362. */
  29363. private _ranges;
  29364. /**
  29365. * @hidden Internal use
  29366. */
  29367. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29368. /**
  29369. * Sets up an animation
  29370. * @param property The property to animate
  29371. * @param animationType The animation type to apply
  29372. * @param framePerSecond The frames per second of the animation
  29373. * @param easingFunction The easing function used in the animation
  29374. * @returns The created animation
  29375. */
  29376. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29377. /**
  29378. * Create and start an animation on a node
  29379. * @param name defines the name of the global animation that will be run on all nodes
  29380. * @param node defines the root node where the animation will take place
  29381. * @param targetProperty defines property to animate
  29382. * @param framePerSecond defines the number of frame per second yo use
  29383. * @param totalFrame defines the number of frames in total
  29384. * @param from defines the initial value
  29385. * @param to defines the final value
  29386. * @param loopMode defines which loop mode you want to use (off by default)
  29387. * @param easingFunction defines the easing function to use (linear by default)
  29388. * @param onAnimationEnd defines the callback to call when animation end
  29389. * @returns the animatable created for this animation
  29390. */
  29391. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29392. /**
  29393. * Create and start an animation on a node and its descendants
  29394. * @param name defines the name of the global animation that will be run on all nodes
  29395. * @param node defines the root node where the animation will take place
  29396. * @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
  29397. * @param targetProperty defines property to animate
  29398. * @param framePerSecond defines the number of frame per second to use
  29399. * @param totalFrame defines the number of frames in total
  29400. * @param from defines the initial value
  29401. * @param to defines the final value
  29402. * @param loopMode defines which loop mode you want to use (off by default)
  29403. * @param easingFunction defines the easing function to use (linear by default)
  29404. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29405. * @returns the list of animatables created for all nodes
  29406. * @example https://www.babylonjs-playground.com/#MH0VLI
  29407. */
  29408. 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[]>;
  29409. /**
  29410. * Creates a new animation, merges it with the existing animations and starts it
  29411. * @param name Name of the animation
  29412. * @param node Node which contains the scene that begins the animations
  29413. * @param targetProperty Specifies which property to animate
  29414. * @param framePerSecond The frames per second of the animation
  29415. * @param totalFrame The total number of frames
  29416. * @param from The frame at the beginning of the animation
  29417. * @param to The frame at the end of the animation
  29418. * @param loopMode Specifies the loop mode of the animation
  29419. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29420. * @param onAnimationEnd Callback to run once the animation is complete
  29421. * @returns Nullable animation
  29422. */
  29423. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29424. /**
  29425. * Transition property of an host to the target Value
  29426. * @param property The property to transition
  29427. * @param targetValue The target Value of the property
  29428. * @param host The object where the property to animate belongs
  29429. * @param scene Scene used to run the animation
  29430. * @param frameRate Framerate (in frame/s) to use
  29431. * @param transition The transition type we want to use
  29432. * @param duration The duration of the animation, in milliseconds
  29433. * @param onAnimationEnd Callback trigger at the end of the animation
  29434. * @returns Nullable animation
  29435. */
  29436. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29437. /**
  29438. * Return the array of runtime animations currently using this animation
  29439. */
  29440. get runtimeAnimations(): RuntimeAnimation[];
  29441. /**
  29442. * Specifies if any of the runtime animations are currently running
  29443. */
  29444. get hasRunningRuntimeAnimations(): boolean;
  29445. /**
  29446. * Initializes the animation
  29447. * @param name Name of the animation
  29448. * @param targetProperty Property to animate
  29449. * @param framePerSecond The frames per second of the animation
  29450. * @param dataType The data type of the animation
  29451. * @param loopMode The loop mode of the animation
  29452. * @param enableBlending Specifies if blending should be enabled
  29453. */
  29454. constructor(
  29455. /**Name of the animation */
  29456. name: string,
  29457. /**Property to animate */
  29458. targetProperty: string,
  29459. /**The frames per second of the animation */
  29460. framePerSecond: number,
  29461. /**The data type of the animation */
  29462. dataType: number,
  29463. /**The loop mode of the animation */
  29464. loopMode?: number | undefined,
  29465. /**Specifies if blending should be enabled */
  29466. enableBlending?: boolean | undefined);
  29467. /**
  29468. * Converts the animation to a string
  29469. * @param fullDetails support for multiple levels of logging within scene loading
  29470. * @returns String form of the animation
  29471. */
  29472. toString(fullDetails?: boolean): string;
  29473. /**
  29474. * Add an event to this animation
  29475. * @param event Event to add
  29476. */
  29477. addEvent(event: AnimationEvent): void;
  29478. /**
  29479. * Remove all events found at the given frame
  29480. * @param frame The frame to remove events from
  29481. */
  29482. removeEvents(frame: number): void;
  29483. /**
  29484. * Retrieves all the events from the animation
  29485. * @returns Events from the animation
  29486. */
  29487. getEvents(): AnimationEvent[];
  29488. /**
  29489. * Creates an animation range
  29490. * @param name Name of the animation range
  29491. * @param from Starting frame of the animation range
  29492. * @param to Ending frame of the animation
  29493. */
  29494. createRange(name: string, from: number, to: number): void;
  29495. /**
  29496. * Deletes an animation range by name
  29497. * @param name Name of the animation range to delete
  29498. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29499. */
  29500. deleteRange(name: string, deleteFrames?: boolean): void;
  29501. /**
  29502. * Gets the animation range by name, or null if not defined
  29503. * @param name Name of the animation range
  29504. * @returns Nullable animation range
  29505. */
  29506. getRange(name: string): Nullable<AnimationRange>;
  29507. /**
  29508. * Gets the key frames from the animation
  29509. * @returns The key frames of the animation
  29510. */
  29511. getKeys(): Array<IAnimationKey>;
  29512. /**
  29513. * Gets the highest frame rate of the animation
  29514. * @returns Highest frame rate of the animation
  29515. */
  29516. getHighestFrame(): number;
  29517. /**
  29518. * Gets the easing function of the animation
  29519. * @returns Easing function of the animation
  29520. */
  29521. getEasingFunction(): IEasingFunction;
  29522. /**
  29523. * Sets the easing function of the animation
  29524. * @param easingFunction A custom mathematical formula for animation
  29525. */
  29526. setEasingFunction(easingFunction: EasingFunction): void;
  29527. /**
  29528. * Interpolates a scalar linearly
  29529. * @param startValue Start value of the animation curve
  29530. * @param endValue End value of the animation curve
  29531. * @param gradient Scalar amount to interpolate
  29532. * @returns Interpolated scalar value
  29533. */
  29534. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29535. /**
  29536. * Interpolates a scalar cubically
  29537. * @param startValue Start value of the animation curve
  29538. * @param outTangent End tangent of the animation
  29539. * @param endValue End value of the animation curve
  29540. * @param inTangent Start tangent of the animation curve
  29541. * @param gradient Scalar amount to interpolate
  29542. * @returns Interpolated scalar value
  29543. */
  29544. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29545. /**
  29546. * Interpolates a quaternion using a spherical linear interpolation
  29547. * @param startValue Start value of the animation curve
  29548. * @param endValue End value of the animation curve
  29549. * @param gradient Scalar amount to interpolate
  29550. * @returns Interpolated quaternion value
  29551. */
  29552. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29553. /**
  29554. * Interpolates a quaternion cubically
  29555. * @param startValue Start value of the animation curve
  29556. * @param outTangent End tangent of the animation curve
  29557. * @param endValue End value of the animation curve
  29558. * @param inTangent Start tangent of the animation curve
  29559. * @param gradient Scalar amount to interpolate
  29560. * @returns Interpolated quaternion value
  29561. */
  29562. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29563. /**
  29564. * Interpolates a Vector3 linearl
  29565. * @param startValue Start value of the animation curve
  29566. * @param endValue End value of the animation curve
  29567. * @param gradient Scalar amount to interpolate
  29568. * @returns Interpolated scalar value
  29569. */
  29570. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29571. /**
  29572. * Interpolates a Vector3 cubically
  29573. * @param startValue Start value of the animation curve
  29574. * @param outTangent End tangent of the animation
  29575. * @param endValue End value of the animation curve
  29576. * @param inTangent Start tangent of the animation curve
  29577. * @param gradient Scalar amount to interpolate
  29578. * @returns InterpolatedVector3 value
  29579. */
  29580. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29581. /**
  29582. * Interpolates a Vector2 linearly
  29583. * @param startValue Start value of the animation curve
  29584. * @param endValue End value of the animation curve
  29585. * @param gradient Scalar amount to interpolate
  29586. * @returns Interpolated Vector2 value
  29587. */
  29588. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29589. /**
  29590. * Interpolates a Vector2 cubically
  29591. * @param startValue Start value of the animation curve
  29592. * @param outTangent End tangent of the animation
  29593. * @param endValue End value of the animation curve
  29594. * @param inTangent Start tangent of the animation curve
  29595. * @param gradient Scalar amount to interpolate
  29596. * @returns Interpolated Vector2 value
  29597. */
  29598. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29599. /**
  29600. * Interpolates a size linearly
  29601. * @param startValue Start value of the animation curve
  29602. * @param endValue End value of the animation curve
  29603. * @param gradient Scalar amount to interpolate
  29604. * @returns Interpolated Size value
  29605. */
  29606. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29607. /**
  29608. * Interpolates a Color3 linearly
  29609. * @param startValue Start value of the animation curve
  29610. * @param endValue End value of the animation curve
  29611. * @param gradient Scalar amount to interpolate
  29612. * @returns Interpolated Color3 value
  29613. */
  29614. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29615. /**
  29616. * Interpolates a Color4 linearly
  29617. * @param startValue Start value of the animation curve
  29618. * @param endValue End value of the animation curve
  29619. * @param gradient Scalar amount to interpolate
  29620. * @returns Interpolated Color3 value
  29621. */
  29622. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29623. /**
  29624. * @hidden Internal use only
  29625. */
  29626. _getKeyValue(value: any): any;
  29627. /**
  29628. * @hidden Internal use only
  29629. */
  29630. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29631. /**
  29632. * Defines the function to use to interpolate matrices
  29633. * @param startValue defines the start matrix
  29634. * @param endValue defines the end matrix
  29635. * @param gradient defines the gradient between both matrices
  29636. * @param result defines an optional target matrix where to store the interpolation
  29637. * @returns the interpolated matrix
  29638. */
  29639. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29640. /**
  29641. * Makes a copy of the animation
  29642. * @returns Cloned animation
  29643. */
  29644. clone(): Animation;
  29645. /**
  29646. * Sets the key frames of the animation
  29647. * @param values The animation key frames to set
  29648. */
  29649. setKeys(values: Array<IAnimationKey>): void;
  29650. /**
  29651. * Serializes the animation to an object
  29652. * @returns Serialized object
  29653. */
  29654. serialize(): any;
  29655. /**
  29656. * Float animation type
  29657. */
  29658. static readonly ANIMATIONTYPE_FLOAT: number;
  29659. /**
  29660. * Vector3 animation type
  29661. */
  29662. static readonly ANIMATIONTYPE_VECTOR3: number;
  29663. /**
  29664. * Quaternion animation type
  29665. */
  29666. static readonly ANIMATIONTYPE_QUATERNION: number;
  29667. /**
  29668. * Matrix animation type
  29669. */
  29670. static readonly ANIMATIONTYPE_MATRIX: number;
  29671. /**
  29672. * Color3 animation type
  29673. */
  29674. static readonly ANIMATIONTYPE_COLOR3: number;
  29675. /**
  29676. * Color3 animation type
  29677. */
  29678. static readonly ANIMATIONTYPE_COLOR4: number;
  29679. /**
  29680. * Vector2 animation type
  29681. */
  29682. static readonly ANIMATIONTYPE_VECTOR2: number;
  29683. /**
  29684. * Size animation type
  29685. */
  29686. static readonly ANIMATIONTYPE_SIZE: number;
  29687. /**
  29688. * Relative Loop Mode
  29689. */
  29690. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29691. /**
  29692. * Cycle Loop Mode
  29693. */
  29694. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29695. /**
  29696. * Constant Loop Mode
  29697. */
  29698. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29699. /** @hidden */
  29700. static _UniversalLerp(left: any, right: any, amount: number): any;
  29701. /**
  29702. * Parses an animation object and creates an animation
  29703. * @param parsedAnimation Parsed animation object
  29704. * @returns Animation object
  29705. */
  29706. static Parse(parsedAnimation: any): Animation;
  29707. /**
  29708. * Appends the serialized animations from the source animations
  29709. * @param source Source containing the animations
  29710. * @param destination Target to store the animations
  29711. */
  29712. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29713. }
  29714. }
  29715. declare module BABYLON {
  29716. /**
  29717. * Interface containing an array of animations
  29718. */
  29719. export interface IAnimatable {
  29720. /**
  29721. * Array of animations
  29722. */
  29723. animations: Nullable<Array<Animation>>;
  29724. }
  29725. }
  29726. declare module BABYLON {
  29727. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29728. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29729. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29730. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29731. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29732. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29733. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29734. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29735. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29736. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29737. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29738. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29739. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29740. /**
  29741. * Decorator used to define property that can be serialized as reference to a camera
  29742. * @param sourceName defines the name of the property to decorate
  29743. */
  29744. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29745. /**
  29746. * Class used to help serialization objects
  29747. */
  29748. export class SerializationHelper {
  29749. /** @hidden */
  29750. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29751. /** @hidden */
  29752. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29753. /** @hidden */
  29754. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29755. /** @hidden */
  29756. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29757. /**
  29758. * Appends the serialized animations from the source animations
  29759. * @param source Source containing the animations
  29760. * @param destination Target to store the animations
  29761. */
  29762. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29763. /**
  29764. * Static function used to serialized a specific entity
  29765. * @param entity defines the entity to serialize
  29766. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29767. * @returns a JSON compatible object representing the serialization of the entity
  29768. */
  29769. static Serialize<T>(entity: T, serializationObject?: any): any;
  29770. /**
  29771. * Creates a new entity from a serialization data object
  29772. * @param creationFunction defines a function used to instanciated the new entity
  29773. * @param source defines the source serialization data
  29774. * @param scene defines the hosting scene
  29775. * @param rootUrl defines the root url for resources
  29776. * @returns a new entity
  29777. */
  29778. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29779. /**
  29780. * Clones an object
  29781. * @param creationFunction defines the function used to instanciate the new object
  29782. * @param source defines the source object
  29783. * @returns the cloned object
  29784. */
  29785. static Clone<T>(creationFunction: () => T, source: T): T;
  29786. /**
  29787. * Instanciates a new object based on a source one (some data will be shared between both object)
  29788. * @param creationFunction defines the function used to instanciate the new object
  29789. * @param source defines the source object
  29790. * @returns the new object
  29791. */
  29792. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29793. }
  29794. }
  29795. declare module BABYLON {
  29796. /**
  29797. * Class used to manipulate GUIDs
  29798. */
  29799. export class GUID {
  29800. /**
  29801. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29802. * Be aware Math.random() could cause collisions, but:
  29803. * "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"
  29804. * @returns a pseudo random id
  29805. */
  29806. static RandomId(): string;
  29807. }
  29808. }
  29809. declare module BABYLON {
  29810. /**
  29811. * Base class of all the textures in babylon.
  29812. * It groups all the common properties the materials, post process, lights... might need
  29813. * in order to make a correct use of the texture.
  29814. */
  29815. export class BaseTexture implements IAnimatable {
  29816. /**
  29817. * Default anisotropic filtering level for the application.
  29818. * It is set to 4 as a good tradeoff between perf and quality.
  29819. */
  29820. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29821. /**
  29822. * Gets or sets the unique id of the texture
  29823. */
  29824. uniqueId: number;
  29825. /**
  29826. * Define the name of the texture.
  29827. */
  29828. name: string;
  29829. /**
  29830. * Gets or sets an object used to store user defined information.
  29831. */
  29832. metadata: any;
  29833. /**
  29834. * For internal use only. Please do not use.
  29835. */
  29836. reservedDataStore: any;
  29837. private _hasAlpha;
  29838. /**
  29839. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29840. */
  29841. set hasAlpha(value: boolean);
  29842. get hasAlpha(): boolean;
  29843. /**
  29844. * Defines if the alpha value should be determined via the rgb values.
  29845. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29846. */
  29847. getAlphaFromRGB: boolean;
  29848. /**
  29849. * Intensity or strength of the texture.
  29850. * It is commonly used by materials to fine tune the intensity of the texture
  29851. */
  29852. level: number;
  29853. /**
  29854. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29855. * This is part of the texture as textures usually maps to one uv set.
  29856. */
  29857. coordinatesIndex: number;
  29858. private _coordinatesMode;
  29859. /**
  29860. * How a texture is mapped.
  29861. *
  29862. * | Value | Type | Description |
  29863. * | ----- | ----------------------------------- | ----------- |
  29864. * | 0 | EXPLICIT_MODE | |
  29865. * | 1 | SPHERICAL_MODE | |
  29866. * | 2 | PLANAR_MODE | |
  29867. * | 3 | CUBIC_MODE | |
  29868. * | 4 | PROJECTION_MODE | |
  29869. * | 5 | SKYBOX_MODE | |
  29870. * | 6 | INVCUBIC_MODE | |
  29871. * | 7 | EQUIRECTANGULAR_MODE | |
  29872. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29873. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29874. */
  29875. set coordinatesMode(value: number);
  29876. get coordinatesMode(): number;
  29877. /**
  29878. * | Value | Type | Description |
  29879. * | ----- | ------------------ | ----------- |
  29880. * | 0 | CLAMP_ADDRESSMODE | |
  29881. * | 1 | WRAP_ADDRESSMODE | |
  29882. * | 2 | MIRROR_ADDRESSMODE | |
  29883. */
  29884. wrapU: number;
  29885. /**
  29886. * | Value | Type | Description |
  29887. * | ----- | ------------------ | ----------- |
  29888. * | 0 | CLAMP_ADDRESSMODE | |
  29889. * | 1 | WRAP_ADDRESSMODE | |
  29890. * | 2 | MIRROR_ADDRESSMODE | |
  29891. */
  29892. wrapV: number;
  29893. /**
  29894. * | Value | Type | Description |
  29895. * | ----- | ------------------ | ----------- |
  29896. * | 0 | CLAMP_ADDRESSMODE | |
  29897. * | 1 | WRAP_ADDRESSMODE | |
  29898. * | 2 | MIRROR_ADDRESSMODE | |
  29899. */
  29900. wrapR: number;
  29901. /**
  29902. * With compliant hardware and browser (supporting anisotropic filtering)
  29903. * this defines the level of anisotropic filtering in the texture.
  29904. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29905. */
  29906. anisotropicFilteringLevel: number;
  29907. /**
  29908. * Define if the texture is a cube texture or if false a 2d texture.
  29909. */
  29910. get isCube(): boolean;
  29911. set isCube(value: boolean);
  29912. /**
  29913. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29914. */
  29915. get is3D(): boolean;
  29916. set is3D(value: boolean);
  29917. /**
  29918. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29919. */
  29920. get is2DArray(): boolean;
  29921. set is2DArray(value: boolean);
  29922. /**
  29923. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29924. * HDR texture are usually stored in linear space.
  29925. * This only impacts the PBR and Background materials
  29926. */
  29927. gammaSpace: boolean;
  29928. /**
  29929. * Gets or sets whether or not the texture contains RGBD data.
  29930. */
  29931. get isRGBD(): boolean;
  29932. set isRGBD(value: boolean);
  29933. /**
  29934. * Is Z inverted in the texture (useful in a cube texture).
  29935. */
  29936. invertZ: boolean;
  29937. /**
  29938. * Are mip maps generated for this texture or not.
  29939. */
  29940. get noMipmap(): boolean;
  29941. /**
  29942. * @hidden
  29943. */
  29944. lodLevelInAlpha: boolean;
  29945. /**
  29946. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29947. */
  29948. get lodGenerationOffset(): number;
  29949. set lodGenerationOffset(value: number);
  29950. /**
  29951. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29952. */
  29953. get lodGenerationScale(): number;
  29954. set lodGenerationScale(value: number);
  29955. /**
  29956. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29957. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29958. * average roughness values.
  29959. */
  29960. get linearSpecularLOD(): boolean;
  29961. set linearSpecularLOD(value: boolean);
  29962. /**
  29963. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29964. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29965. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29966. */
  29967. get irradianceTexture(): Nullable<BaseTexture>;
  29968. set irradianceTexture(value: Nullable<BaseTexture>);
  29969. /**
  29970. * Define if the texture is a render target.
  29971. */
  29972. isRenderTarget: boolean;
  29973. /**
  29974. * Define the unique id of the texture in the scene.
  29975. */
  29976. get uid(): string;
  29977. /**
  29978. * Return a string representation of the texture.
  29979. * @returns the texture as a string
  29980. */
  29981. toString(): string;
  29982. /**
  29983. * Get the class name of the texture.
  29984. * @returns "BaseTexture"
  29985. */
  29986. getClassName(): string;
  29987. /**
  29988. * Define the list of animation attached to the texture.
  29989. */
  29990. animations: Animation[];
  29991. /**
  29992. * An event triggered when the texture is disposed.
  29993. */
  29994. onDisposeObservable: Observable<BaseTexture>;
  29995. private _onDisposeObserver;
  29996. /**
  29997. * Callback triggered when the texture has been disposed.
  29998. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29999. */
  30000. set onDispose(callback: () => void);
  30001. /**
  30002. * Define the current state of the loading sequence when in delayed load mode.
  30003. */
  30004. delayLoadState: number;
  30005. private _scene;
  30006. /** @hidden */
  30007. _texture: Nullable<InternalTexture>;
  30008. private _uid;
  30009. /**
  30010. * Define if the texture is preventinga material to render or not.
  30011. * If not and the texture is not ready, the engine will use a default black texture instead.
  30012. */
  30013. get isBlocking(): boolean;
  30014. /**
  30015. * Instantiates a new BaseTexture.
  30016. * Base class of all the textures in babylon.
  30017. * It groups all the common properties the materials, post process, lights... might need
  30018. * in order to make a correct use of the texture.
  30019. * @param scene Define the scene the texture blongs to
  30020. */
  30021. constructor(scene: Nullable<Scene>);
  30022. /**
  30023. * Get the scene the texture belongs to.
  30024. * @returns the scene or null if undefined
  30025. */
  30026. getScene(): Nullable<Scene>;
  30027. /**
  30028. * Get the texture transform matrix used to offset tile the texture for istance.
  30029. * @returns the transformation matrix
  30030. */
  30031. getTextureMatrix(): Matrix;
  30032. /**
  30033. * Get the texture reflection matrix used to rotate/transform the reflection.
  30034. * @returns the reflection matrix
  30035. */
  30036. getReflectionTextureMatrix(): Matrix;
  30037. /**
  30038. * Get the underlying lower level texture from Babylon.
  30039. * @returns the insternal texture
  30040. */
  30041. getInternalTexture(): Nullable<InternalTexture>;
  30042. /**
  30043. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30044. * @returns true if ready or not blocking
  30045. */
  30046. isReadyOrNotBlocking(): boolean;
  30047. /**
  30048. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30049. * @returns true if fully ready
  30050. */
  30051. isReady(): boolean;
  30052. private _cachedSize;
  30053. /**
  30054. * Get the size of the texture.
  30055. * @returns the texture size.
  30056. */
  30057. getSize(): ISize;
  30058. /**
  30059. * Get the base size of the texture.
  30060. * It can be different from the size if the texture has been resized for POT for instance
  30061. * @returns the base size
  30062. */
  30063. getBaseSize(): ISize;
  30064. /**
  30065. * Update the sampling mode of the texture.
  30066. * Default is Trilinear mode.
  30067. *
  30068. * | Value | Type | Description |
  30069. * | ----- | ------------------ | ----------- |
  30070. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30071. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30072. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30073. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30074. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30075. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30076. * | 7 | NEAREST_LINEAR | |
  30077. * | 8 | NEAREST_NEAREST | |
  30078. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30079. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30080. * | 11 | LINEAR_LINEAR | |
  30081. * | 12 | LINEAR_NEAREST | |
  30082. *
  30083. * > _mag_: magnification filter (close to the viewer)
  30084. * > _min_: minification filter (far from the viewer)
  30085. * > _mip_: filter used between mip map levels
  30086. *@param samplingMode Define the new sampling mode of the texture
  30087. */
  30088. updateSamplingMode(samplingMode: number): void;
  30089. /**
  30090. * Scales the texture if is `canRescale()`
  30091. * @param ratio the resize factor we want to use to rescale
  30092. */
  30093. scale(ratio: number): void;
  30094. /**
  30095. * Get if the texture can rescale.
  30096. */
  30097. get canRescale(): boolean;
  30098. /** @hidden */
  30099. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30100. /** @hidden */
  30101. _rebuild(): void;
  30102. /**
  30103. * Triggers the load sequence in delayed load mode.
  30104. */
  30105. delayLoad(): void;
  30106. /**
  30107. * Clones the texture.
  30108. * @returns the cloned texture
  30109. */
  30110. clone(): Nullable<BaseTexture>;
  30111. /**
  30112. * Get the texture underlying type (INT, FLOAT...)
  30113. */
  30114. get textureType(): number;
  30115. /**
  30116. * Get the texture underlying format (RGB, RGBA...)
  30117. */
  30118. get textureFormat(): number;
  30119. /**
  30120. * Indicates that textures need to be re-calculated for all materials
  30121. */
  30122. protected _markAllSubMeshesAsTexturesDirty(): void;
  30123. /**
  30124. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30125. * This will returns an RGBA array buffer containing either in values (0-255) or
  30126. * float values (0-1) depending of the underlying buffer type.
  30127. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30128. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30129. * @param buffer defines a user defined buffer to fill with data (can be null)
  30130. * @returns The Array buffer containing the pixels data.
  30131. */
  30132. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30133. /**
  30134. * Release and destroy the underlying lower level texture aka internalTexture.
  30135. */
  30136. releaseInternalTexture(): void;
  30137. /** @hidden */
  30138. get _lodTextureHigh(): Nullable<BaseTexture>;
  30139. /** @hidden */
  30140. get _lodTextureMid(): Nullable<BaseTexture>;
  30141. /** @hidden */
  30142. get _lodTextureLow(): Nullable<BaseTexture>;
  30143. /**
  30144. * Dispose the texture and release its associated resources.
  30145. */
  30146. dispose(): void;
  30147. /**
  30148. * Serialize the texture into a JSON representation that can be parsed later on.
  30149. * @returns the JSON representation of the texture
  30150. */
  30151. serialize(): any;
  30152. /**
  30153. * Helper function to be called back once a list of texture contains only ready textures.
  30154. * @param textures Define the list of textures to wait for
  30155. * @param callback Define the callback triggered once the entire list will be ready
  30156. */
  30157. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30158. }
  30159. }
  30160. declare module BABYLON {
  30161. /**
  30162. * Options to be used when creating an effect.
  30163. */
  30164. export interface IEffectCreationOptions {
  30165. /**
  30166. * Atrributes that will be used in the shader.
  30167. */
  30168. attributes: string[];
  30169. /**
  30170. * Uniform varible names that will be set in the shader.
  30171. */
  30172. uniformsNames: string[];
  30173. /**
  30174. * Uniform buffer variable names that will be set in the shader.
  30175. */
  30176. uniformBuffersNames: string[];
  30177. /**
  30178. * Sampler texture variable names that will be set in the shader.
  30179. */
  30180. samplers: string[];
  30181. /**
  30182. * Define statements that will be set in the shader.
  30183. */
  30184. defines: any;
  30185. /**
  30186. * Possible fallbacks for this effect to improve performance when needed.
  30187. */
  30188. fallbacks: Nullable<IEffectFallbacks>;
  30189. /**
  30190. * Callback that will be called when the shader is compiled.
  30191. */
  30192. onCompiled: Nullable<(effect: Effect) => void>;
  30193. /**
  30194. * Callback that will be called if an error occurs during shader compilation.
  30195. */
  30196. onError: Nullable<(effect: Effect, errors: string) => void>;
  30197. /**
  30198. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30199. */
  30200. indexParameters?: any;
  30201. /**
  30202. * Max number of lights that can be used in the shader.
  30203. */
  30204. maxSimultaneousLights?: number;
  30205. /**
  30206. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30207. */
  30208. transformFeedbackVaryings?: Nullable<string[]>;
  30209. }
  30210. /**
  30211. * Effect containing vertex and fragment shader that can be executed on an object.
  30212. */
  30213. export class Effect implements IDisposable {
  30214. /**
  30215. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30216. */
  30217. static ShadersRepository: string;
  30218. /**
  30219. * Enable logging of the shader code when a compilation error occurs
  30220. */
  30221. static LogShaderCodeOnCompilationError: boolean;
  30222. /**
  30223. * Name of the effect.
  30224. */
  30225. name: any;
  30226. /**
  30227. * String container all the define statements that should be set on the shader.
  30228. */
  30229. defines: string;
  30230. /**
  30231. * Callback that will be called when the shader is compiled.
  30232. */
  30233. onCompiled: Nullable<(effect: Effect) => void>;
  30234. /**
  30235. * Callback that will be called if an error occurs during shader compilation.
  30236. */
  30237. onError: Nullable<(effect: Effect, errors: string) => void>;
  30238. /**
  30239. * Callback that will be called when effect is bound.
  30240. */
  30241. onBind: Nullable<(effect: Effect) => void>;
  30242. /**
  30243. * Unique ID of the effect.
  30244. */
  30245. uniqueId: number;
  30246. /**
  30247. * Observable that will be called when the shader is compiled.
  30248. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30249. */
  30250. onCompileObservable: Observable<Effect>;
  30251. /**
  30252. * Observable that will be called if an error occurs during shader compilation.
  30253. */
  30254. onErrorObservable: Observable<Effect>;
  30255. /** @hidden */
  30256. _onBindObservable: Nullable<Observable<Effect>>;
  30257. /**
  30258. * @hidden
  30259. * Specifies if the effect was previously ready
  30260. */
  30261. _wasPreviouslyReady: boolean;
  30262. /**
  30263. * Observable that will be called when effect is bound.
  30264. */
  30265. get onBindObservable(): Observable<Effect>;
  30266. /** @hidden */
  30267. _bonesComputationForcedToCPU: boolean;
  30268. private static _uniqueIdSeed;
  30269. private _engine;
  30270. private _uniformBuffersNames;
  30271. private _uniformsNames;
  30272. private _samplerList;
  30273. private _samplers;
  30274. private _isReady;
  30275. private _compilationError;
  30276. private _allFallbacksProcessed;
  30277. private _attributesNames;
  30278. private _attributes;
  30279. private _attributeLocationByName;
  30280. private _uniforms;
  30281. /**
  30282. * Key for the effect.
  30283. * @hidden
  30284. */
  30285. _key: string;
  30286. private _indexParameters;
  30287. private _fallbacks;
  30288. private _vertexSourceCode;
  30289. private _fragmentSourceCode;
  30290. private _vertexSourceCodeOverride;
  30291. private _fragmentSourceCodeOverride;
  30292. private _transformFeedbackVaryings;
  30293. /**
  30294. * Compiled shader to webGL program.
  30295. * @hidden
  30296. */
  30297. _pipelineContext: Nullable<IPipelineContext>;
  30298. private _valueCache;
  30299. private static _baseCache;
  30300. /**
  30301. * Instantiates an effect.
  30302. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30303. * @param baseName Name of the effect.
  30304. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30305. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30306. * @param samplers List of sampler variables that will be passed to the shader.
  30307. * @param engine Engine to be used to render the effect
  30308. * @param defines Define statements to be added to the shader.
  30309. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30310. * @param onCompiled Callback that will be called when the shader is compiled.
  30311. * @param onError Callback that will be called if an error occurs during shader compilation.
  30312. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30313. */
  30314. 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);
  30315. private _useFinalCode;
  30316. /**
  30317. * Unique key for this effect
  30318. */
  30319. get key(): string;
  30320. /**
  30321. * If the effect has been compiled and prepared.
  30322. * @returns if the effect is compiled and prepared.
  30323. */
  30324. isReady(): boolean;
  30325. private _isReadyInternal;
  30326. /**
  30327. * The engine the effect was initialized with.
  30328. * @returns the engine.
  30329. */
  30330. getEngine(): Engine;
  30331. /**
  30332. * The pipeline context for this effect
  30333. * @returns the associated pipeline context
  30334. */
  30335. getPipelineContext(): Nullable<IPipelineContext>;
  30336. /**
  30337. * The set of names of attribute variables for the shader.
  30338. * @returns An array of attribute names.
  30339. */
  30340. getAttributesNames(): string[];
  30341. /**
  30342. * Returns the attribute at the given index.
  30343. * @param index The index of the attribute.
  30344. * @returns The location of the attribute.
  30345. */
  30346. getAttributeLocation(index: number): number;
  30347. /**
  30348. * Returns the attribute based on the name of the variable.
  30349. * @param name of the attribute to look up.
  30350. * @returns the attribute location.
  30351. */
  30352. getAttributeLocationByName(name: string): number;
  30353. /**
  30354. * The number of attributes.
  30355. * @returns the numnber of attributes.
  30356. */
  30357. getAttributesCount(): number;
  30358. /**
  30359. * Gets the index of a uniform variable.
  30360. * @param uniformName of the uniform to look up.
  30361. * @returns the index.
  30362. */
  30363. getUniformIndex(uniformName: string): number;
  30364. /**
  30365. * Returns the attribute based on the name of the variable.
  30366. * @param uniformName of the uniform to look up.
  30367. * @returns the location of the uniform.
  30368. */
  30369. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30370. /**
  30371. * Returns an array of sampler variable names
  30372. * @returns The array of sampler variable neames.
  30373. */
  30374. getSamplers(): string[];
  30375. /**
  30376. * The error from the last compilation.
  30377. * @returns the error string.
  30378. */
  30379. getCompilationError(): string;
  30380. /**
  30381. * Gets a boolean indicating that all fallbacks were used during compilation
  30382. * @returns true if all fallbacks were used
  30383. */
  30384. allFallbacksProcessed(): boolean;
  30385. /**
  30386. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30387. * @param func The callback to be used.
  30388. */
  30389. executeWhenCompiled(func: (effect: Effect) => void): void;
  30390. private _checkIsReady;
  30391. private _loadShader;
  30392. /**
  30393. * Recompiles the webGL program
  30394. * @param vertexSourceCode The source code for the vertex shader.
  30395. * @param fragmentSourceCode The source code for the fragment shader.
  30396. * @param onCompiled Callback called when completed.
  30397. * @param onError Callback called on error.
  30398. * @hidden
  30399. */
  30400. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30401. /**
  30402. * Prepares the effect
  30403. * @hidden
  30404. */
  30405. _prepareEffect(): void;
  30406. private _getShaderCodeAndErrorLine;
  30407. private _processCompilationErrors;
  30408. /**
  30409. * Checks if the effect is supported. (Must be called after compilation)
  30410. */
  30411. get isSupported(): boolean;
  30412. /**
  30413. * Binds a texture to the engine to be used as output of the shader.
  30414. * @param channel Name of the output variable.
  30415. * @param texture Texture to bind.
  30416. * @hidden
  30417. */
  30418. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30419. /**
  30420. * Sets a texture on the engine to be used in the shader.
  30421. * @param channel Name of the sampler variable.
  30422. * @param texture Texture to set.
  30423. */
  30424. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30425. /**
  30426. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30427. * @param channel Name of the sampler variable.
  30428. * @param texture Texture to set.
  30429. */
  30430. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30431. /**
  30432. * Sets an array of textures on the engine to be used in the shader.
  30433. * @param channel Name of the variable.
  30434. * @param textures Textures to set.
  30435. */
  30436. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30437. /**
  30438. * 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)
  30439. * @param channel Name of the sampler variable.
  30440. * @param postProcess Post process to get the input texture from.
  30441. */
  30442. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30443. /**
  30444. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30445. * 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)
  30446. * @param channel Name of the sampler variable.
  30447. * @param postProcess Post process to get the output texture from.
  30448. */
  30449. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30450. /** @hidden */
  30451. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30452. /** @hidden */
  30453. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30454. /** @hidden */
  30455. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30456. /** @hidden */
  30457. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30458. /**
  30459. * Binds a buffer to a uniform.
  30460. * @param buffer Buffer to bind.
  30461. * @param name Name of the uniform variable to bind to.
  30462. */
  30463. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30464. /**
  30465. * Binds block to a uniform.
  30466. * @param blockName Name of the block to bind.
  30467. * @param index Index to bind.
  30468. */
  30469. bindUniformBlock(blockName: string, index: number): void;
  30470. /**
  30471. * Sets an interger value on a uniform variable.
  30472. * @param uniformName Name of the variable.
  30473. * @param value Value to be set.
  30474. * @returns this effect.
  30475. */
  30476. setInt(uniformName: string, value: number): Effect;
  30477. /**
  30478. * Sets an int array on a uniform variable.
  30479. * @param uniformName Name of the variable.
  30480. * @param array array to be set.
  30481. * @returns this effect.
  30482. */
  30483. setIntArray(uniformName: string, array: Int32Array): Effect;
  30484. /**
  30485. * 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)
  30486. * @param uniformName Name of the variable.
  30487. * @param array array to be set.
  30488. * @returns this effect.
  30489. */
  30490. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30491. /**
  30492. * 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)
  30493. * @param uniformName Name of the variable.
  30494. * @param array array to be set.
  30495. * @returns this effect.
  30496. */
  30497. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30498. /**
  30499. * 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)
  30500. * @param uniformName Name of the variable.
  30501. * @param array array to be set.
  30502. * @returns this effect.
  30503. */
  30504. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30505. /**
  30506. * Sets an float array on a uniform variable.
  30507. * @param uniformName Name of the variable.
  30508. * @param array array to be set.
  30509. * @returns this effect.
  30510. */
  30511. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30512. /**
  30513. * 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)
  30514. * @param uniformName Name of the variable.
  30515. * @param array array to be set.
  30516. * @returns this effect.
  30517. */
  30518. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30519. /**
  30520. * 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)
  30521. * @param uniformName Name of the variable.
  30522. * @param array array to be set.
  30523. * @returns this effect.
  30524. */
  30525. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30526. /**
  30527. * 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)
  30528. * @param uniformName Name of the variable.
  30529. * @param array array to be set.
  30530. * @returns this effect.
  30531. */
  30532. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30533. /**
  30534. * Sets an array on a uniform variable.
  30535. * @param uniformName Name of the variable.
  30536. * @param array array to be set.
  30537. * @returns this effect.
  30538. */
  30539. setArray(uniformName: string, array: number[]): Effect;
  30540. /**
  30541. * 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)
  30542. * @param uniformName Name of the variable.
  30543. * @param array array to be set.
  30544. * @returns this effect.
  30545. */
  30546. setArray2(uniformName: string, array: number[]): Effect;
  30547. /**
  30548. * 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)
  30549. * @param uniformName Name of the variable.
  30550. * @param array array to be set.
  30551. * @returns this effect.
  30552. */
  30553. setArray3(uniformName: string, array: number[]): Effect;
  30554. /**
  30555. * 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)
  30556. * @param uniformName Name of the variable.
  30557. * @param array array to be set.
  30558. * @returns this effect.
  30559. */
  30560. setArray4(uniformName: string, array: number[]): Effect;
  30561. /**
  30562. * Sets matrices on a uniform variable.
  30563. * @param uniformName Name of the variable.
  30564. * @param matrices matrices to be set.
  30565. * @returns this effect.
  30566. */
  30567. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30568. /**
  30569. * Sets matrix on a uniform variable.
  30570. * @param uniformName Name of the variable.
  30571. * @param matrix matrix to be set.
  30572. * @returns this effect.
  30573. */
  30574. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30575. /**
  30576. * 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)
  30577. * @param uniformName Name of the variable.
  30578. * @param matrix matrix to be set.
  30579. * @returns this effect.
  30580. */
  30581. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30582. /**
  30583. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30584. * @param uniformName Name of the variable.
  30585. * @param matrix matrix to be set.
  30586. * @returns this effect.
  30587. */
  30588. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30589. /**
  30590. * Sets a float on a uniform variable.
  30591. * @param uniformName Name of the variable.
  30592. * @param value value to be set.
  30593. * @returns this effect.
  30594. */
  30595. setFloat(uniformName: string, value: number): Effect;
  30596. /**
  30597. * Sets a boolean on a uniform variable.
  30598. * @param uniformName Name of the variable.
  30599. * @param bool value to be set.
  30600. * @returns this effect.
  30601. */
  30602. setBool(uniformName: string, bool: boolean): Effect;
  30603. /**
  30604. * Sets a Vector2 on a uniform variable.
  30605. * @param uniformName Name of the variable.
  30606. * @param vector2 vector2 to be set.
  30607. * @returns this effect.
  30608. */
  30609. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30610. /**
  30611. * Sets a float2 on a uniform variable.
  30612. * @param uniformName Name of the variable.
  30613. * @param x First float in float2.
  30614. * @param y Second float in float2.
  30615. * @returns this effect.
  30616. */
  30617. setFloat2(uniformName: string, x: number, y: number): Effect;
  30618. /**
  30619. * Sets a Vector3 on a uniform variable.
  30620. * @param uniformName Name of the variable.
  30621. * @param vector3 Value to be set.
  30622. * @returns this effect.
  30623. */
  30624. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30625. /**
  30626. * Sets a float3 on a uniform variable.
  30627. * @param uniformName Name of the variable.
  30628. * @param x First float in float3.
  30629. * @param y Second float in float3.
  30630. * @param z Third float in float3.
  30631. * @returns this effect.
  30632. */
  30633. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30634. /**
  30635. * Sets a Vector4 on a uniform variable.
  30636. * @param uniformName Name of the variable.
  30637. * @param vector4 Value to be set.
  30638. * @returns this effect.
  30639. */
  30640. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30641. /**
  30642. * Sets a float4 on a uniform variable.
  30643. * @param uniformName Name of the variable.
  30644. * @param x First float in float4.
  30645. * @param y Second float in float4.
  30646. * @param z Third float in float4.
  30647. * @param w Fourth float in float4.
  30648. * @returns this effect.
  30649. */
  30650. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30651. /**
  30652. * Sets a Color3 on a uniform variable.
  30653. * @param uniformName Name of the variable.
  30654. * @param color3 Value to be set.
  30655. * @returns this effect.
  30656. */
  30657. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30658. /**
  30659. * Sets a Color4 on a uniform variable.
  30660. * @param uniformName Name of the variable.
  30661. * @param color3 Value to be set.
  30662. * @param alpha Alpha value to be set.
  30663. * @returns this effect.
  30664. */
  30665. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30666. /**
  30667. * Sets a Color4 on a uniform variable
  30668. * @param uniformName defines the name of the variable
  30669. * @param color4 defines the value to be set
  30670. * @returns this effect.
  30671. */
  30672. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30673. /** Release all associated resources */
  30674. dispose(): void;
  30675. /**
  30676. * This function will add a new shader to the shader store
  30677. * @param name the name of the shader
  30678. * @param pixelShader optional pixel shader content
  30679. * @param vertexShader optional vertex shader content
  30680. */
  30681. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30682. /**
  30683. * Store of each shader (The can be looked up using effect.key)
  30684. */
  30685. static ShadersStore: {
  30686. [key: string]: string;
  30687. };
  30688. /**
  30689. * Store of each included file for a shader (The can be looked up using effect.key)
  30690. */
  30691. static IncludesShadersStore: {
  30692. [key: string]: string;
  30693. };
  30694. /**
  30695. * Resets the cache of effects.
  30696. */
  30697. static ResetCache(): void;
  30698. }
  30699. }
  30700. declare module BABYLON {
  30701. /**
  30702. * Interface used to describe the capabilities of the engine relatively to the current browser
  30703. */
  30704. export interface EngineCapabilities {
  30705. /** Maximum textures units per fragment shader */
  30706. maxTexturesImageUnits: number;
  30707. /** Maximum texture units per vertex shader */
  30708. maxVertexTextureImageUnits: number;
  30709. /** Maximum textures units in the entire pipeline */
  30710. maxCombinedTexturesImageUnits: number;
  30711. /** Maximum texture size */
  30712. maxTextureSize: number;
  30713. /** Maximum texture samples */
  30714. maxSamples?: number;
  30715. /** Maximum cube texture size */
  30716. maxCubemapTextureSize: number;
  30717. /** Maximum render texture size */
  30718. maxRenderTextureSize: number;
  30719. /** Maximum number of vertex attributes */
  30720. maxVertexAttribs: number;
  30721. /** Maximum number of varyings */
  30722. maxVaryingVectors: number;
  30723. /** Maximum number of uniforms per vertex shader */
  30724. maxVertexUniformVectors: number;
  30725. /** Maximum number of uniforms per fragment shader */
  30726. maxFragmentUniformVectors: number;
  30727. /** Defines if standard derivates (dx/dy) are supported */
  30728. standardDerivatives: boolean;
  30729. /** Defines if s3tc texture compression is supported */
  30730. s3tc?: WEBGL_compressed_texture_s3tc;
  30731. /** Defines if pvrtc texture compression is supported */
  30732. pvrtc: any;
  30733. /** Defines if etc1 texture compression is supported */
  30734. etc1: any;
  30735. /** Defines if etc2 texture compression is supported */
  30736. etc2: any;
  30737. /** Defines if astc texture compression is supported */
  30738. astc: any;
  30739. /** Defines if float textures are supported */
  30740. textureFloat: boolean;
  30741. /** Defines if vertex array objects are supported */
  30742. vertexArrayObject: boolean;
  30743. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30744. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30745. /** Gets the maximum level of anisotropy supported */
  30746. maxAnisotropy: number;
  30747. /** Defines if instancing is supported */
  30748. instancedArrays: boolean;
  30749. /** Defines if 32 bits indices are supported */
  30750. uintIndices: boolean;
  30751. /** Defines if high precision shaders are supported */
  30752. highPrecisionShaderSupported: boolean;
  30753. /** Defines if depth reading in the fragment shader is supported */
  30754. fragmentDepthSupported: boolean;
  30755. /** Defines if float texture linear filtering is supported*/
  30756. textureFloatLinearFiltering: boolean;
  30757. /** Defines if rendering to float textures is supported */
  30758. textureFloatRender: boolean;
  30759. /** Defines if half float textures are supported*/
  30760. textureHalfFloat: boolean;
  30761. /** Defines if half float texture linear filtering is supported*/
  30762. textureHalfFloatLinearFiltering: boolean;
  30763. /** Defines if rendering to half float textures is supported */
  30764. textureHalfFloatRender: boolean;
  30765. /** Defines if textureLOD shader command is supported */
  30766. textureLOD: boolean;
  30767. /** Defines if draw buffers extension is supported */
  30768. drawBuffersExtension: boolean;
  30769. /** Defines if depth textures are supported */
  30770. depthTextureExtension: boolean;
  30771. /** Defines if float color buffer are supported */
  30772. colorBufferFloat: boolean;
  30773. /** Gets disjoint timer query extension (null if not supported) */
  30774. timerQuery?: EXT_disjoint_timer_query;
  30775. /** Defines if timestamp can be used with timer query */
  30776. canUseTimestampForTimerQuery: boolean;
  30777. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30778. multiview?: any;
  30779. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30780. oculusMultiview?: any;
  30781. /** Function used to let the system compiles shaders in background */
  30782. parallelShaderCompile?: {
  30783. COMPLETION_STATUS_KHR: number;
  30784. };
  30785. /** Max number of texture samples for MSAA */
  30786. maxMSAASamples: number;
  30787. /** Defines if the blend min max extension is supported */
  30788. blendMinMax: boolean;
  30789. }
  30790. }
  30791. declare module BABYLON {
  30792. /**
  30793. * @hidden
  30794. **/
  30795. export class DepthCullingState {
  30796. private _isDepthTestDirty;
  30797. private _isDepthMaskDirty;
  30798. private _isDepthFuncDirty;
  30799. private _isCullFaceDirty;
  30800. private _isCullDirty;
  30801. private _isZOffsetDirty;
  30802. private _isFrontFaceDirty;
  30803. private _depthTest;
  30804. private _depthMask;
  30805. private _depthFunc;
  30806. private _cull;
  30807. private _cullFace;
  30808. private _zOffset;
  30809. private _frontFace;
  30810. /**
  30811. * Initializes the state.
  30812. */
  30813. constructor();
  30814. get isDirty(): boolean;
  30815. get zOffset(): number;
  30816. set zOffset(value: number);
  30817. get cullFace(): Nullable<number>;
  30818. set cullFace(value: Nullable<number>);
  30819. get cull(): Nullable<boolean>;
  30820. set cull(value: Nullable<boolean>);
  30821. get depthFunc(): Nullable<number>;
  30822. set depthFunc(value: Nullable<number>);
  30823. get depthMask(): boolean;
  30824. set depthMask(value: boolean);
  30825. get depthTest(): boolean;
  30826. set depthTest(value: boolean);
  30827. get frontFace(): Nullable<number>;
  30828. set frontFace(value: Nullable<number>);
  30829. reset(): void;
  30830. apply(gl: WebGLRenderingContext): void;
  30831. }
  30832. }
  30833. declare module BABYLON {
  30834. /**
  30835. * @hidden
  30836. **/
  30837. export class StencilState {
  30838. /** 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 */
  30839. static readonly ALWAYS: number;
  30840. /** Passed to stencilOperation to specify that stencil value must be kept */
  30841. static readonly KEEP: number;
  30842. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30843. static readonly REPLACE: number;
  30844. private _isStencilTestDirty;
  30845. private _isStencilMaskDirty;
  30846. private _isStencilFuncDirty;
  30847. private _isStencilOpDirty;
  30848. private _stencilTest;
  30849. private _stencilMask;
  30850. private _stencilFunc;
  30851. private _stencilFuncRef;
  30852. private _stencilFuncMask;
  30853. private _stencilOpStencilFail;
  30854. private _stencilOpDepthFail;
  30855. private _stencilOpStencilDepthPass;
  30856. get isDirty(): boolean;
  30857. get stencilFunc(): number;
  30858. set stencilFunc(value: number);
  30859. get stencilFuncRef(): number;
  30860. set stencilFuncRef(value: number);
  30861. get stencilFuncMask(): number;
  30862. set stencilFuncMask(value: number);
  30863. get stencilOpStencilFail(): number;
  30864. set stencilOpStencilFail(value: number);
  30865. get stencilOpDepthFail(): number;
  30866. set stencilOpDepthFail(value: number);
  30867. get stencilOpStencilDepthPass(): number;
  30868. set stencilOpStencilDepthPass(value: number);
  30869. get stencilMask(): number;
  30870. set stencilMask(value: number);
  30871. get stencilTest(): boolean;
  30872. set stencilTest(value: boolean);
  30873. constructor();
  30874. reset(): void;
  30875. apply(gl: WebGLRenderingContext): void;
  30876. }
  30877. }
  30878. declare module BABYLON {
  30879. /**
  30880. * @hidden
  30881. **/
  30882. export class AlphaState {
  30883. private _isAlphaBlendDirty;
  30884. private _isBlendFunctionParametersDirty;
  30885. private _isBlendEquationParametersDirty;
  30886. private _isBlendConstantsDirty;
  30887. private _alphaBlend;
  30888. private _blendFunctionParameters;
  30889. private _blendEquationParameters;
  30890. private _blendConstants;
  30891. /**
  30892. * Initializes the state.
  30893. */
  30894. constructor();
  30895. get isDirty(): boolean;
  30896. get alphaBlend(): boolean;
  30897. set alphaBlend(value: boolean);
  30898. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30899. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30900. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30901. reset(): void;
  30902. apply(gl: WebGLRenderingContext): void;
  30903. }
  30904. }
  30905. declare module BABYLON {
  30906. /** @hidden */
  30907. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30908. attributeProcessor(attribute: string): string;
  30909. varyingProcessor(varying: string, isFragment: boolean): string;
  30910. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30911. }
  30912. }
  30913. declare module BABYLON {
  30914. /**
  30915. * Interface for attribute information associated with buffer instanciation
  30916. */
  30917. export interface InstancingAttributeInfo {
  30918. /**
  30919. * Name of the GLSL attribute
  30920. * if attribute index is not specified, this is used to retrieve the index from the effect
  30921. */
  30922. attributeName: string;
  30923. /**
  30924. * Index/offset of the attribute in the vertex shader
  30925. * if not specified, this will be computes from the name.
  30926. */
  30927. index?: number;
  30928. /**
  30929. * size of the attribute, 1, 2, 3 or 4
  30930. */
  30931. attributeSize: number;
  30932. /**
  30933. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30934. */
  30935. offset: number;
  30936. /**
  30937. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30938. * default to 1
  30939. */
  30940. divisor?: number;
  30941. /**
  30942. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30943. * default is FLOAT
  30944. */
  30945. attributeType?: number;
  30946. /**
  30947. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30948. */
  30949. normalized?: boolean;
  30950. }
  30951. }
  30952. declare module BABYLON {
  30953. interface ThinEngine {
  30954. /**
  30955. * Update a video texture
  30956. * @param texture defines the texture to update
  30957. * @param video defines the video element to use
  30958. * @param invertY defines if data must be stored with Y axis inverted
  30959. */
  30960. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30961. }
  30962. }
  30963. declare module BABYLON {
  30964. /**
  30965. * Settings for finer control over video usage
  30966. */
  30967. export interface VideoTextureSettings {
  30968. /**
  30969. * Applies `autoplay` to video, if specified
  30970. */
  30971. autoPlay?: boolean;
  30972. /**
  30973. * Applies `loop` to video, if specified
  30974. */
  30975. loop?: boolean;
  30976. /**
  30977. * Automatically updates internal texture from video at every frame in the render loop
  30978. */
  30979. autoUpdateTexture: boolean;
  30980. /**
  30981. * Image src displayed during the video loading or until the user interacts with the video.
  30982. */
  30983. poster?: string;
  30984. }
  30985. /**
  30986. * If you want to display a video in your scene, this is the special texture for that.
  30987. * This special texture works similar to other textures, with the exception of a few parameters.
  30988. * @see https://doc.babylonjs.com/how_to/video_texture
  30989. */
  30990. export class VideoTexture extends Texture {
  30991. /**
  30992. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30993. */
  30994. readonly autoUpdateTexture: boolean;
  30995. /**
  30996. * The video instance used by the texture internally
  30997. */
  30998. readonly video: HTMLVideoElement;
  30999. private _onUserActionRequestedObservable;
  31000. /**
  31001. * Event triggerd when a dom action is required by the user to play the video.
  31002. * This happens due to recent changes in browser policies preventing video to auto start.
  31003. */
  31004. get onUserActionRequestedObservable(): Observable<Texture>;
  31005. private _generateMipMaps;
  31006. private _engine;
  31007. private _stillImageCaptured;
  31008. private _displayingPosterTexture;
  31009. private _settings;
  31010. private _createInternalTextureOnEvent;
  31011. private _frameId;
  31012. private _currentSrc;
  31013. /**
  31014. * Creates a video texture.
  31015. * If you want to display a video in your scene, this is the special texture for that.
  31016. * This special texture works similar to other textures, with the exception of a few parameters.
  31017. * @see https://doc.babylonjs.com/how_to/video_texture
  31018. * @param name optional name, will detect from video source, if not defined
  31019. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31020. * @param scene is obviously the current scene.
  31021. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31022. * @param invertY is false by default but can be used to invert video on Y axis
  31023. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31024. * @param settings allows finer control over video usage
  31025. */
  31026. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31027. private _getName;
  31028. private _getVideo;
  31029. private _createInternalTexture;
  31030. private reset;
  31031. /**
  31032. * @hidden Internal method to initiate `update`.
  31033. */
  31034. _rebuild(): void;
  31035. /**
  31036. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31037. */
  31038. update(): void;
  31039. /**
  31040. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31041. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31042. */
  31043. updateTexture(isVisible: boolean): void;
  31044. protected _updateInternalTexture: () => void;
  31045. /**
  31046. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31047. * @param url New url.
  31048. */
  31049. updateURL(url: string): void;
  31050. /**
  31051. * Clones the texture.
  31052. * @returns the cloned texture
  31053. */
  31054. clone(): VideoTexture;
  31055. /**
  31056. * Dispose the texture and release its associated resources.
  31057. */
  31058. dispose(): void;
  31059. /**
  31060. * Creates a video texture straight from a stream.
  31061. * @param scene Define the scene the texture should be created in
  31062. * @param stream Define the stream the texture should be created from
  31063. * @returns The created video texture as a promise
  31064. */
  31065. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31066. /**
  31067. * Creates a video texture straight from your WebCam video feed.
  31068. * @param scene Define the scene the texture should be created in
  31069. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31070. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31071. * @returns The created video texture as a promise
  31072. */
  31073. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31074. minWidth: number;
  31075. maxWidth: number;
  31076. minHeight: number;
  31077. maxHeight: number;
  31078. deviceId: string;
  31079. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31080. /**
  31081. * Creates a video texture straight from your WebCam video feed.
  31082. * @param scene Define the scene the texture should be created in
  31083. * @param onReady Define a callback to triggered once the texture will be ready
  31084. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31085. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31086. */
  31087. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31088. minWidth: number;
  31089. maxWidth: number;
  31090. minHeight: number;
  31091. maxHeight: number;
  31092. deviceId: string;
  31093. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31094. }
  31095. }
  31096. declare module BABYLON {
  31097. /**
  31098. * Defines the interface used by objects working like Scene
  31099. * @hidden
  31100. */
  31101. export interface ISceneLike {
  31102. _addPendingData(data: any): void;
  31103. _removePendingData(data: any): void;
  31104. offlineProvider: IOfflineProvider;
  31105. }
  31106. /** Interface defining initialization parameters for Engine class */
  31107. export interface EngineOptions extends WebGLContextAttributes {
  31108. /**
  31109. * Defines if the engine should no exceed a specified device ratio
  31110. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31111. */
  31112. limitDeviceRatio?: number;
  31113. /**
  31114. * Defines if webvr should be enabled automatically
  31115. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31116. */
  31117. autoEnableWebVR?: boolean;
  31118. /**
  31119. * Defines if webgl2 should be turned off even if supported
  31120. * @see http://doc.babylonjs.com/features/webgl2
  31121. */
  31122. disableWebGL2Support?: boolean;
  31123. /**
  31124. * Defines if webaudio should be initialized as well
  31125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31126. */
  31127. audioEngine?: boolean;
  31128. /**
  31129. * Defines if animations should run using a deterministic lock step
  31130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31131. */
  31132. deterministicLockstep?: boolean;
  31133. /** Defines the maximum steps to use with deterministic lock step mode */
  31134. lockstepMaxSteps?: number;
  31135. /** Defines the seconds between each deterministic lock step */
  31136. timeStep?: number;
  31137. /**
  31138. * Defines that engine should ignore context lost events
  31139. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31140. */
  31141. doNotHandleContextLost?: boolean;
  31142. /**
  31143. * Defines that engine should ignore modifying touch action attribute and style
  31144. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31145. */
  31146. doNotHandleTouchAction?: boolean;
  31147. /**
  31148. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31149. */
  31150. useHighPrecisionFloats?: boolean;
  31151. }
  31152. /**
  31153. * The base engine class (root of all engines)
  31154. */
  31155. export class ThinEngine {
  31156. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31157. static ExceptionList: ({
  31158. key: string;
  31159. capture: string;
  31160. captureConstraint: number;
  31161. targets: string[];
  31162. } | {
  31163. key: string;
  31164. capture: null;
  31165. captureConstraint: null;
  31166. targets: string[];
  31167. })[];
  31168. /** @hidden */
  31169. static _TextureLoaders: IInternalTextureLoader[];
  31170. /**
  31171. * Returns the current npm package of the sdk
  31172. */
  31173. static get NpmPackage(): string;
  31174. /**
  31175. * Returns the current version of the framework
  31176. */
  31177. static get Version(): string;
  31178. /**
  31179. * Returns a string describing the current engine
  31180. */
  31181. get description(): string;
  31182. /**
  31183. * Gets or sets the epsilon value used by collision engine
  31184. */
  31185. static CollisionsEpsilon: number;
  31186. /**
  31187. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31188. */
  31189. static get ShadersRepository(): string;
  31190. static set ShadersRepository(value: string);
  31191. /** @hidden */
  31192. _shaderProcessor: IShaderProcessor;
  31193. /**
  31194. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31195. */
  31196. forcePOTTextures: boolean;
  31197. /**
  31198. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31199. */
  31200. isFullscreen: boolean;
  31201. /**
  31202. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31203. */
  31204. cullBackFaces: boolean;
  31205. /**
  31206. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31207. */
  31208. renderEvenInBackground: boolean;
  31209. /**
  31210. * Gets or sets a boolean indicating that cache can be kept between frames
  31211. */
  31212. preventCacheWipeBetweenFrames: boolean;
  31213. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31214. validateShaderPrograms: boolean;
  31215. /**
  31216. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31217. * This can provide greater z depth for distant objects.
  31218. */
  31219. useReverseDepthBuffer: boolean;
  31220. /**
  31221. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31222. */
  31223. disableUniformBuffers: boolean;
  31224. /** @hidden */
  31225. _uniformBuffers: UniformBuffer[];
  31226. /**
  31227. * Gets a boolean indicating that the engine supports uniform buffers
  31228. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31229. */
  31230. get supportsUniformBuffers(): boolean;
  31231. /** @hidden */
  31232. _gl: WebGLRenderingContext;
  31233. /** @hidden */
  31234. _webGLVersion: number;
  31235. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31236. protected _windowIsBackground: boolean;
  31237. protected _creationOptions: EngineOptions;
  31238. protected _highPrecisionShadersAllowed: boolean;
  31239. /** @hidden */
  31240. get _shouldUseHighPrecisionShader(): boolean;
  31241. /**
  31242. * Gets a boolean indicating that only power of 2 textures are supported
  31243. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31244. */
  31245. get needPOTTextures(): boolean;
  31246. /** @hidden */
  31247. _badOS: boolean;
  31248. /** @hidden */
  31249. _badDesktopOS: boolean;
  31250. private _hardwareScalingLevel;
  31251. /** @hidden */
  31252. _caps: EngineCapabilities;
  31253. private _isStencilEnable;
  31254. private _glVersion;
  31255. private _glRenderer;
  31256. private _glVendor;
  31257. /** @hidden */
  31258. _videoTextureSupported: boolean;
  31259. protected _renderingQueueLaunched: boolean;
  31260. protected _activeRenderLoops: (() => void)[];
  31261. /**
  31262. * Observable signaled when a context lost event is raised
  31263. */
  31264. onContextLostObservable: Observable<ThinEngine>;
  31265. /**
  31266. * Observable signaled when a context restored event is raised
  31267. */
  31268. onContextRestoredObservable: Observable<ThinEngine>;
  31269. private _onContextLost;
  31270. private _onContextRestored;
  31271. protected _contextWasLost: boolean;
  31272. /** @hidden */
  31273. _doNotHandleContextLost: boolean;
  31274. /**
  31275. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31276. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31277. */
  31278. get doNotHandleContextLost(): boolean;
  31279. set doNotHandleContextLost(value: boolean);
  31280. /**
  31281. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31282. */
  31283. disableVertexArrayObjects: boolean;
  31284. /** @hidden */
  31285. protected _colorWrite: boolean;
  31286. /** @hidden */
  31287. protected _colorWriteChanged: boolean;
  31288. /** @hidden */
  31289. protected _depthCullingState: DepthCullingState;
  31290. /** @hidden */
  31291. protected _stencilState: StencilState;
  31292. /** @hidden */
  31293. _alphaState: AlphaState;
  31294. /** @hidden */
  31295. _alphaMode: number;
  31296. /** @hidden */
  31297. _alphaEquation: number;
  31298. /** @hidden */
  31299. _internalTexturesCache: InternalTexture[];
  31300. /** @hidden */
  31301. protected _activeChannel: number;
  31302. private _currentTextureChannel;
  31303. /** @hidden */
  31304. protected _boundTexturesCache: {
  31305. [key: string]: Nullable<InternalTexture>;
  31306. };
  31307. /** @hidden */
  31308. protected _currentEffect: Nullable<Effect>;
  31309. /** @hidden */
  31310. protected _currentProgram: Nullable<WebGLProgram>;
  31311. private _compiledEffects;
  31312. private _vertexAttribArraysEnabled;
  31313. /** @hidden */
  31314. protected _cachedViewport: Nullable<IViewportLike>;
  31315. private _cachedVertexArrayObject;
  31316. /** @hidden */
  31317. protected _cachedVertexBuffers: any;
  31318. /** @hidden */
  31319. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31320. /** @hidden */
  31321. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31322. /** @hidden */
  31323. _currentRenderTarget: Nullable<InternalTexture>;
  31324. private _uintIndicesCurrentlySet;
  31325. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31326. /** @hidden */
  31327. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31328. private _currentBufferPointers;
  31329. private _currentInstanceLocations;
  31330. private _currentInstanceBuffers;
  31331. private _textureUnits;
  31332. /** @hidden */
  31333. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31334. /** @hidden */
  31335. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31336. /** @hidden */
  31337. _boundRenderFunction: any;
  31338. private _vaoRecordInProgress;
  31339. private _mustWipeVertexAttributes;
  31340. private _emptyTexture;
  31341. private _emptyCubeTexture;
  31342. private _emptyTexture3D;
  31343. private _emptyTexture2DArray;
  31344. /** @hidden */
  31345. _frameHandler: number;
  31346. private _nextFreeTextureSlots;
  31347. private _maxSimultaneousTextures;
  31348. private _activeRequests;
  31349. /** @hidden */
  31350. _transformTextureUrl: Nullable<(url: string) => string>;
  31351. protected get _supportsHardwareTextureRescaling(): boolean;
  31352. private _framebufferDimensionsObject;
  31353. /**
  31354. * sets the object from which width and height will be taken from when getting render width and height
  31355. * Will fallback to the gl object
  31356. * @param dimensions the framebuffer width and height that will be used.
  31357. */
  31358. set framebufferDimensionsObject(dimensions: Nullable<{
  31359. framebufferWidth: number;
  31360. framebufferHeight: number;
  31361. }>);
  31362. /**
  31363. * Gets the current viewport
  31364. */
  31365. get currentViewport(): Nullable<IViewportLike>;
  31366. /**
  31367. * Gets the default empty texture
  31368. */
  31369. get emptyTexture(): InternalTexture;
  31370. /**
  31371. * Gets the default empty 3D texture
  31372. */
  31373. get emptyTexture3D(): InternalTexture;
  31374. /**
  31375. * Gets the default empty 2D array texture
  31376. */
  31377. get emptyTexture2DArray(): InternalTexture;
  31378. /**
  31379. * Gets the default empty cube texture
  31380. */
  31381. get emptyCubeTexture(): InternalTexture;
  31382. /**
  31383. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31384. */
  31385. readonly premultipliedAlpha: boolean;
  31386. /**
  31387. * Observable event triggered before each texture is initialized
  31388. */
  31389. onBeforeTextureInitObservable: Observable<Texture>;
  31390. /**
  31391. * Creates a new engine
  31392. * @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
  31393. * @param antialias defines enable antialiasing (default: false)
  31394. * @param options defines further options to be sent to the getContext() function
  31395. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31396. */
  31397. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31398. private _rebuildInternalTextures;
  31399. private _rebuildEffects;
  31400. /**
  31401. * Gets a boolean indicating if all created effects are ready
  31402. * @returns true if all effects are ready
  31403. */
  31404. areAllEffectsReady(): boolean;
  31405. protected _rebuildBuffers(): void;
  31406. protected _initGLContext(): void;
  31407. /**
  31408. * Gets version of the current webGL context
  31409. */
  31410. get webGLVersion(): number;
  31411. /**
  31412. * Gets a string idenfifying the name of the class
  31413. * @returns "Engine" string
  31414. */
  31415. getClassName(): string;
  31416. /**
  31417. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31418. */
  31419. get isStencilEnable(): boolean;
  31420. /** @hidden */
  31421. _prepareWorkingCanvas(): void;
  31422. /**
  31423. * Reset the texture cache to empty state
  31424. */
  31425. resetTextureCache(): void;
  31426. /**
  31427. * Gets an object containing information about the current webGL context
  31428. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31429. */
  31430. getGlInfo(): {
  31431. vendor: string;
  31432. renderer: string;
  31433. version: string;
  31434. };
  31435. /**
  31436. * Defines the hardware scaling level.
  31437. * By default the hardware scaling level is computed from the window device ratio.
  31438. * 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.
  31439. * @param level defines the level to use
  31440. */
  31441. setHardwareScalingLevel(level: number): void;
  31442. /**
  31443. * Gets the current hardware scaling level.
  31444. * By default the hardware scaling level is computed from the window device ratio.
  31445. * 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.
  31446. * @returns a number indicating the current hardware scaling level
  31447. */
  31448. getHardwareScalingLevel(): number;
  31449. /**
  31450. * Gets the list of loaded textures
  31451. * @returns an array containing all loaded textures
  31452. */
  31453. getLoadedTexturesCache(): InternalTexture[];
  31454. /**
  31455. * Gets the object containing all engine capabilities
  31456. * @returns the EngineCapabilities object
  31457. */
  31458. getCaps(): EngineCapabilities;
  31459. /**
  31460. * stop executing a render loop function and remove it from the execution array
  31461. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31462. */
  31463. stopRenderLoop(renderFunction?: () => void): void;
  31464. /** @hidden */
  31465. _renderLoop(): void;
  31466. /**
  31467. * Gets the HTML canvas attached with the current webGL context
  31468. * @returns a HTML canvas
  31469. */
  31470. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31471. /**
  31472. * Gets host window
  31473. * @returns the host window object
  31474. */
  31475. getHostWindow(): Nullable<Window>;
  31476. /**
  31477. * Gets the current render width
  31478. * @param useScreen defines if screen size must be used (or the current render target if any)
  31479. * @returns a number defining the current render width
  31480. */
  31481. getRenderWidth(useScreen?: boolean): number;
  31482. /**
  31483. * Gets the current render height
  31484. * @param useScreen defines if screen size must be used (or the current render target if any)
  31485. * @returns a number defining the current render height
  31486. */
  31487. getRenderHeight(useScreen?: boolean): number;
  31488. /**
  31489. * Can be used to override the current requestAnimationFrame requester.
  31490. * @hidden
  31491. */
  31492. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31493. /**
  31494. * Register and execute a render loop. The engine can have more than one render function
  31495. * @param renderFunction defines the function to continuously execute
  31496. */
  31497. runRenderLoop(renderFunction: () => void): void;
  31498. /**
  31499. * Clear the current render buffer or the current render target (if any is set up)
  31500. * @param color defines the color to use
  31501. * @param backBuffer defines if the back buffer must be cleared
  31502. * @param depth defines if the depth buffer must be cleared
  31503. * @param stencil defines if the stencil buffer must be cleared
  31504. */
  31505. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31506. private _viewportCached;
  31507. /** @hidden */
  31508. _viewport(x: number, y: number, width: number, height: number): void;
  31509. /**
  31510. * Set the WebGL's viewport
  31511. * @param viewport defines the viewport element to be used
  31512. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31513. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31514. */
  31515. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31516. /**
  31517. * Begin a new frame
  31518. */
  31519. beginFrame(): void;
  31520. /**
  31521. * Enf the current frame
  31522. */
  31523. endFrame(): void;
  31524. /**
  31525. * Resize the view according to the canvas' size
  31526. */
  31527. resize(): void;
  31528. /**
  31529. * Force a specific size of the canvas
  31530. * @param width defines the new canvas' width
  31531. * @param height defines the new canvas' height
  31532. */
  31533. setSize(width: number, height: number): void;
  31534. /**
  31535. * Binds the frame buffer to the specified texture.
  31536. * @param texture The texture to render to or null for the default canvas
  31537. * @param faceIndex The face of the texture to render to in case of cube texture
  31538. * @param requiredWidth The width of the target to render to
  31539. * @param requiredHeight The height of the target to render to
  31540. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31541. * @param lodLevel defines the lod level to bind to the frame buffer
  31542. * @param layer defines the 2d array index to bind to frame buffer to
  31543. */
  31544. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31545. /** @hidden */
  31546. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31547. /**
  31548. * Unbind the current render target texture from the webGL context
  31549. * @param texture defines the render target texture to unbind
  31550. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31551. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31552. */
  31553. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31554. /**
  31555. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31556. */
  31557. flushFramebuffer(): void;
  31558. /**
  31559. * Unbind the current render target and bind the default framebuffer
  31560. */
  31561. restoreDefaultFramebuffer(): void;
  31562. /** @hidden */
  31563. protected _resetVertexBufferBinding(): void;
  31564. /**
  31565. * Creates a vertex buffer
  31566. * @param data the data for the vertex buffer
  31567. * @returns the new WebGL static buffer
  31568. */
  31569. createVertexBuffer(data: DataArray): DataBuffer;
  31570. private _createVertexBuffer;
  31571. /**
  31572. * Creates a dynamic vertex buffer
  31573. * @param data the data for the dynamic vertex buffer
  31574. * @returns the new WebGL dynamic buffer
  31575. */
  31576. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31577. protected _resetIndexBufferBinding(): void;
  31578. /**
  31579. * Creates a new index buffer
  31580. * @param indices defines the content of the index buffer
  31581. * @param updatable defines if the index buffer must be updatable
  31582. * @returns a new webGL buffer
  31583. */
  31584. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31585. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31586. /**
  31587. * Bind a webGL buffer to the webGL context
  31588. * @param buffer defines the buffer to bind
  31589. */
  31590. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31591. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31592. private bindBuffer;
  31593. /**
  31594. * update the bound buffer with the given data
  31595. * @param data defines the data to update
  31596. */
  31597. updateArrayBuffer(data: Float32Array): void;
  31598. private _vertexAttribPointer;
  31599. /** @hidden */
  31600. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31601. private _bindVertexBuffersAttributes;
  31602. /**
  31603. * Records a vertex array object
  31604. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31605. * @param vertexBuffers defines the list of vertex buffers to store
  31606. * @param indexBuffer defines the index buffer to store
  31607. * @param effect defines the effect to store
  31608. * @returns the new vertex array object
  31609. */
  31610. recordVertexArrayObject(vertexBuffers: {
  31611. [key: string]: VertexBuffer;
  31612. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31613. /**
  31614. * Bind a specific vertex array object
  31615. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31616. * @param vertexArrayObject defines the vertex array object to bind
  31617. * @param indexBuffer defines the index buffer to bind
  31618. */
  31619. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31620. /**
  31621. * Bind webGl buffers directly to the webGL context
  31622. * @param vertexBuffer defines the vertex buffer to bind
  31623. * @param indexBuffer defines the index buffer to bind
  31624. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31625. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31626. * @param effect defines the effect associated with the vertex buffer
  31627. */
  31628. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31629. private _unbindVertexArrayObject;
  31630. /**
  31631. * Bind a list of vertex buffers to the webGL context
  31632. * @param vertexBuffers defines the list of vertex buffers to bind
  31633. * @param indexBuffer defines the index buffer to bind
  31634. * @param effect defines the effect associated with the vertex buffers
  31635. */
  31636. bindBuffers(vertexBuffers: {
  31637. [key: string]: Nullable<VertexBuffer>;
  31638. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31639. /**
  31640. * Unbind all instance attributes
  31641. */
  31642. unbindInstanceAttributes(): void;
  31643. /**
  31644. * Release and free the memory of a vertex array object
  31645. * @param vao defines the vertex array object to delete
  31646. */
  31647. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31648. /** @hidden */
  31649. _releaseBuffer(buffer: DataBuffer): boolean;
  31650. protected _deleteBuffer(buffer: DataBuffer): void;
  31651. /**
  31652. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31653. * @param instancesBuffer defines the webGL buffer to update and bind
  31654. * @param data defines the data to store in the buffer
  31655. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31656. */
  31657. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31658. /**
  31659. * Bind the content of a webGL buffer used with instantiation
  31660. * @param instancesBuffer defines the webGL buffer to bind
  31661. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31662. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31663. */
  31664. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31665. /**
  31666. * Disable the instance attribute corresponding to the name in parameter
  31667. * @param name defines the name of the attribute to disable
  31668. */
  31669. disableInstanceAttributeByName(name: string): void;
  31670. /**
  31671. * Disable the instance attribute corresponding to the location in parameter
  31672. * @param attributeLocation defines the attribute location of the attribute to disable
  31673. */
  31674. disableInstanceAttribute(attributeLocation: number): void;
  31675. /**
  31676. * Disable the attribute corresponding to the location in parameter
  31677. * @param attributeLocation defines the attribute location of the attribute to disable
  31678. */
  31679. disableAttributeByIndex(attributeLocation: number): void;
  31680. /**
  31681. * Send a draw order
  31682. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31683. * @param indexStart defines the starting index
  31684. * @param indexCount defines the number of index to draw
  31685. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31686. */
  31687. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31688. /**
  31689. * Draw a list of points
  31690. * @param verticesStart defines the index of first vertex to draw
  31691. * @param verticesCount defines the count of vertices to draw
  31692. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31693. */
  31694. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31695. /**
  31696. * Draw a list of unindexed primitives
  31697. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31698. * @param verticesStart defines the index of first vertex to draw
  31699. * @param verticesCount defines the count of vertices to draw
  31700. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31701. */
  31702. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31703. /**
  31704. * Draw a list of indexed primitives
  31705. * @param fillMode defines the primitive to use
  31706. * @param indexStart defines the starting index
  31707. * @param indexCount defines the number of index to draw
  31708. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31709. */
  31710. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31711. /**
  31712. * Draw a list of unindexed primitives
  31713. * @param fillMode defines the primitive to use
  31714. * @param verticesStart defines the index of first vertex to draw
  31715. * @param verticesCount defines the count of vertices to draw
  31716. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31717. */
  31718. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31719. private _drawMode;
  31720. /** @hidden */
  31721. protected _reportDrawCall(): void;
  31722. /** @hidden */
  31723. _releaseEffect(effect: Effect): void;
  31724. /** @hidden */
  31725. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31726. /**
  31727. * Create a new effect (used to store vertex/fragment shaders)
  31728. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31729. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31730. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31731. * @param samplers defines an array of string used to represent textures
  31732. * @param defines defines the string containing the defines to use to compile the shaders
  31733. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31734. * @param onCompiled defines a function to call when the effect creation is successful
  31735. * @param onError defines a function to call when the effect creation has failed
  31736. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31737. * @returns the new Effect
  31738. */
  31739. 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;
  31740. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31741. private _compileShader;
  31742. private _compileRawShader;
  31743. /** @hidden */
  31744. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31745. /**
  31746. * Directly creates a webGL program
  31747. * @param pipelineContext defines the pipeline context to attach to
  31748. * @param vertexCode defines the vertex shader code to use
  31749. * @param fragmentCode defines the fragment shader code to use
  31750. * @param context defines the webGL context to use (if not set, the current one will be used)
  31751. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31752. * @returns the new webGL program
  31753. */
  31754. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31755. /**
  31756. * Creates a webGL program
  31757. * @param pipelineContext defines the pipeline context to attach to
  31758. * @param vertexCode defines the vertex shader code to use
  31759. * @param fragmentCode defines the fragment shader code to use
  31760. * @param defines defines the string containing the defines to use to compile the shaders
  31761. * @param context defines the webGL context to use (if not set, the current one will be used)
  31762. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31763. * @returns the new webGL program
  31764. */
  31765. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31766. /**
  31767. * Creates a new pipeline context
  31768. * @returns the new pipeline
  31769. */
  31770. createPipelineContext(): IPipelineContext;
  31771. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31772. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31773. /** @hidden */
  31774. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31775. /** @hidden */
  31776. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31777. /** @hidden */
  31778. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31779. /**
  31780. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31781. * @param pipelineContext defines the pipeline context to use
  31782. * @param uniformsNames defines the list of uniform names
  31783. * @returns an array of webGL uniform locations
  31784. */
  31785. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31786. /**
  31787. * Gets the lsit of active attributes for a given webGL program
  31788. * @param pipelineContext defines the pipeline context to use
  31789. * @param attributesNames defines the list of attribute names to get
  31790. * @returns an array of indices indicating the offset of each attribute
  31791. */
  31792. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31793. /**
  31794. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31795. * @param effect defines the effect to activate
  31796. */
  31797. enableEffect(effect: Nullable<Effect>): void;
  31798. /**
  31799. * Set the value of an uniform to a number (int)
  31800. * @param uniform defines the webGL uniform location where to store the value
  31801. * @param value defines the int number to store
  31802. */
  31803. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31804. /**
  31805. * Set the value of an uniform to an array of int32
  31806. * @param uniform defines the webGL uniform location where to store the value
  31807. * @param array defines the array of int32 to store
  31808. */
  31809. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31810. /**
  31811. * Set the value of an uniform to an array of int32 (stored as vec2)
  31812. * @param uniform defines the webGL uniform location where to store the value
  31813. * @param array defines the array of int32 to store
  31814. */
  31815. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31816. /**
  31817. * Set the value of an uniform to an array of int32 (stored as vec3)
  31818. * @param uniform defines the webGL uniform location where to store the value
  31819. * @param array defines the array of int32 to store
  31820. */
  31821. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31822. /**
  31823. * Set the value of an uniform to an array of int32 (stored as vec4)
  31824. * @param uniform defines the webGL uniform location where to store the value
  31825. * @param array defines the array of int32 to store
  31826. */
  31827. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31828. /**
  31829. * Set the value of an uniform to an array of number
  31830. * @param uniform defines the webGL uniform location where to store the value
  31831. * @param array defines the array of number to store
  31832. */
  31833. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31834. /**
  31835. * Set the value of an uniform to an array of number (stored as vec2)
  31836. * @param uniform defines the webGL uniform location where to store the value
  31837. * @param array defines the array of number to store
  31838. */
  31839. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31840. /**
  31841. * Set the value of an uniform to an array of number (stored as vec3)
  31842. * @param uniform defines the webGL uniform location where to store the value
  31843. * @param array defines the array of number to store
  31844. */
  31845. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31846. /**
  31847. * Set the value of an uniform to an array of number (stored as vec4)
  31848. * @param uniform defines the webGL uniform location where to store the value
  31849. * @param array defines the array of number to store
  31850. */
  31851. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31852. /**
  31853. * Set the value of an uniform to an array of float32 (stored as matrices)
  31854. * @param uniform defines the webGL uniform location where to store the value
  31855. * @param matrices defines the array of float32 to store
  31856. */
  31857. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31858. /**
  31859. * Set the value of an uniform to a matrix (3x3)
  31860. * @param uniform defines the webGL uniform location where to store the value
  31861. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31862. */
  31863. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31864. /**
  31865. * Set the value of an uniform to a matrix (2x2)
  31866. * @param uniform defines the webGL uniform location where to store the value
  31867. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31868. */
  31869. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31870. /**
  31871. * Set the value of an uniform to a number (float)
  31872. * @param uniform defines the webGL uniform location where to store the value
  31873. * @param value defines the float number to store
  31874. */
  31875. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31876. /**
  31877. * Set the value of an uniform to a vec2
  31878. * @param uniform defines the webGL uniform location where to store the value
  31879. * @param x defines the 1st component of the value
  31880. * @param y defines the 2nd component of the value
  31881. */
  31882. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31883. /**
  31884. * Set the value of an uniform to a vec3
  31885. * @param uniform defines the webGL uniform location where to store the value
  31886. * @param x defines the 1st component of the value
  31887. * @param y defines the 2nd component of the value
  31888. * @param z defines the 3rd component of the value
  31889. */
  31890. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31891. /**
  31892. * Set the value of an uniform to a vec4
  31893. * @param uniform defines the webGL uniform location where to store the value
  31894. * @param x defines the 1st component of the value
  31895. * @param y defines the 2nd component of the value
  31896. * @param z defines the 3rd component of the value
  31897. * @param w defines the 4th component of the value
  31898. */
  31899. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31900. /**
  31901. * Apply all cached states (depth, culling, stencil and alpha)
  31902. */
  31903. applyStates(): void;
  31904. /**
  31905. * Enable or disable color writing
  31906. * @param enable defines the state to set
  31907. */
  31908. setColorWrite(enable: boolean): void;
  31909. /**
  31910. * Gets a boolean indicating if color writing is enabled
  31911. * @returns the current color writing state
  31912. */
  31913. getColorWrite(): boolean;
  31914. /**
  31915. * Gets the depth culling state manager
  31916. */
  31917. get depthCullingState(): DepthCullingState;
  31918. /**
  31919. * Gets the alpha state manager
  31920. */
  31921. get alphaState(): AlphaState;
  31922. /**
  31923. * Gets the stencil state manager
  31924. */
  31925. get stencilState(): StencilState;
  31926. /**
  31927. * Clears the list of texture accessible through engine.
  31928. * This can help preventing texture load conflict due to name collision.
  31929. */
  31930. clearInternalTexturesCache(): void;
  31931. /**
  31932. * Force the entire cache to be cleared
  31933. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31934. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31935. */
  31936. wipeCaches(bruteForce?: boolean): void;
  31937. /** @hidden */
  31938. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31939. min: number;
  31940. mag: number;
  31941. };
  31942. /** @hidden */
  31943. _createTexture(): WebGLTexture;
  31944. /**
  31945. * Usually called from Texture.ts.
  31946. * Passed information to create a WebGLTexture
  31947. * @param url defines a value which contains one of the following:
  31948. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31949. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31950. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31951. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31952. * @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)
  31953. * @param scene needed for loading to the correct scene
  31954. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31955. * @param onLoad optional callback to be called upon successful completion
  31956. * @param onError optional callback to be called upon failure
  31957. * @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
  31958. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31959. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31960. * @param forcedExtension defines the extension to use to pick the right loader
  31961. * @param mimeType defines an optional mime type
  31962. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31963. */
  31964. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  31965. /**
  31966. * Loads an image as an HTMLImageElement.
  31967. * @param input url string, ArrayBuffer, or Blob to load
  31968. * @param onLoad callback called when the image successfully loads
  31969. * @param onError callback called when the image fails to load
  31970. * @param offlineProvider offline provider for caching
  31971. * @param mimeType optional mime type
  31972. * @returns the HTMLImageElement of the loaded image
  31973. * @hidden
  31974. */
  31975. 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>;
  31976. /**
  31977. * @hidden
  31978. */
  31979. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31980. /**
  31981. * Creates a raw texture
  31982. * @param data defines the data to store in the texture
  31983. * @param width defines the width of the texture
  31984. * @param height defines the height of the texture
  31985. * @param format defines the format of the data
  31986. * @param generateMipMaps defines if the engine should generate the mip levels
  31987. * @param invertY defines if data must be stored with Y axis inverted
  31988. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31989. * @param compression defines the compression used (null by default)
  31990. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31991. * @returns the raw texture inside an InternalTexture
  31992. */
  31993. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31994. /**
  31995. * Creates a new raw cube texture
  31996. * @param data defines the array of data to use to create each face
  31997. * @param size defines the size of the textures
  31998. * @param format defines the format of the data
  31999. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32000. * @param generateMipMaps defines if the engine should generate the mip levels
  32001. * @param invertY defines if data must be stored with Y axis inverted
  32002. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32003. * @param compression defines the compression used (null by default)
  32004. * @returns the cube texture as an InternalTexture
  32005. */
  32006. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32007. /**
  32008. * Creates a new raw 3D texture
  32009. * @param data defines the data used to create the texture
  32010. * @param width defines the width of the texture
  32011. * @param height defines the height of the texture
  32012. * @param depth defines the depth of the texture
  32013. * @param format defines the format of the texture
  32014. * @param generateMipMaps defines if the engine must generate mip levels
  32015. * @param invertY defines if data must be stored with Y axis inverted
  32016. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32017. * @param compression defines the compressed used (can be null)
  32018. * @param textureType defines the compressed used (can be null)
  32019. * @returns a new raw 3D texture (stored in an InternalTexture)
  32020. */
  32021. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32022. /**
  32023. * Creates a new raw 2D array texture
  32024. * @param data defines the data used to create the texture
  32025. * @param width defines the width of the texture
  32026. * @param height defines the height of the texture
  32027. * @param depth defines the number of layers of the texture
  32028. * @param format defines the format of the texture
  32029. * @param generateMipMaps defines if the engine must generate mip levels
  32030. * @param invertY defines if data must be stored with Y axis inverted
  32031. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32032. * @param compression defines the compressed used (can be null)
  32033. * @param textureType defines the compressed used (can be null)
  32034. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32035. */
  32036. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32037. private _unpackFlipYCached;
  32038. /**
  32039. * In case you are sharing the context with other applications, it might
  32040. * be interested to not cache the unpack flip y state to ensure a consistent
  32041. * value would be set.
  32042. */
  32043. enableUnpackFlipYCached: boolean;
  32044. /** @hidden */
  32045. _unpackFlipY(value: boolean): void;
  32046. /** @hidden */
  32047. _getUnpackAlignement(): number;
  32048. private _getTextureTarget;
  32049. /**
  32050. * Update the sampling mode of a given texture
  32051. * @param samplingMode defines the required sampling mode
  32052. * @param texture defines the texture to update
  32053. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32054. */
  32055. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32056. /**
  32057. * Update the sampling mode of a given texture
  32058. * @param texture defines the texture to update
  32059. * @param wrapU defines the texture wrap mode of the u coordinates
  32060. * @param wrapV defines the texture wrap mode of the v coordinates
  32061. * @param wrapR defines the texture wrap mode of the r coordinates
  32062. */
  32063. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32064. /** @hidden */
  32065. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32066. width: number;
  32067. height: number;
  32068. layers?: number;
  32069. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32070. /** @hidden */
  32071. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32072. /** @hidden */
  32073. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32074. /**
  32075. * Update a portion of an internal texture
  32076. * @param texture defines the texture to update
  32077. * @param imageData defines the data to store into the texture
  32078. * @param xOffset defines the x coordinates of the update rectangle
  32079. * @param yOffset defines the y coordinates of the update rectangle
  32080. * @param width defines the width of the update rectangle
  32081. * @param height defines the height of the update rectangle
  32082. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32083. * @param lod defines the lod level to update (0 by default)
  32084. */
  32085. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32086. /** @hidden */
  32087. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32088. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32089. private _prepareWebGLTexture;
  32090. /** @hidden */
  32091. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32092. private _getDepthStencilBuffer;
  32093. /** @hidden */
  32094. _releaseFramebufferObjects(texture: InternalTexture): void;
  32095. /** @hidden */
  32096. _releaseTexture(texture: InternalTexture): void;
  32097. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32098. protected _setProgram(program: WebGLProgram): void;
  32099. protected _boundUniforms: {
  32100. [key: number]: WebGLUniformLocation;
  32101. };
  32102. /**
  32103. * Binds an effect to the webGL context
  32104. * @param effect defines the effect to bind
  32105. */
  32106. bindSamplers(effect: Effect): void;
  32107. private _activateCurrentTexture;
  32108. /** @hidden */
  32109. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32110. /** @hidden */
  32111. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32112. /**
  32113. * Unbind all textures from the webGL context
  32114. */
  32115. unbindAllTextures(): void;
  32116. /**
  32117. * Sets a texture to the according uniform.
  32118. * @param channel The texture channel
  32119. * @param uniform The uniform to set
  32120. * @param texture The texture to apply
  32121. */
  32122. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32123. private _bindSamplerUniformToChannel;
  32124. private _getTextureWrapMode;
  32125. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32126. /**
  32127. * Sets an array of texture to the webGL context
  32128. * @param channel defines the channel where the texture array must be set
  32129. * @param uniform defines the associated uniform location
  32130. * @param textures defines the array of textures to bind
  32131. */
  32132. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32133. /** @hidden */
  32134. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32135. private _setTextureParameterFloat;
  32136. private _setTextureParameterInteger;
  32137. /**
  32138. * Unbind all vertex attributes from the webGL context
  32139. */
  32140. unbindAllAttributes(): void;
  32141. /**
  32142. * 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
  32143. */
  32144. releaseEffects(): void;
  32145. /**
  32146. * Dispose and release all associated resources
  32147. */
  32148. dispose(): void;
  32149. /**
  32150. * Attach a new callback raised when context lost event is fired
  32151. * @param callback defines the callback to call
  32152. */
  32153. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32154. /**
  32155. * Attach a new callback raised when context restored event is fired
  32156. * @param callback defines the callback to call
  32157. */
  32158. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32159. /**
  32160. * Get the current error code of the webGL context
  32161. * @returns the error code
  32162. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32163. */
  32164. getError(): number;
  32165. private _canRenderToFloatFramebuffer;
  32166. private _canRenderToHalfFloatFramebuffer;
  32167. private _canRenderToFramebuffer;
  32168. /** @hidden */
  32169. _getWebGLTextureType(type: number): number;
  32170. /** @hidden */
  32171. _getInternalFormat(format: number): number;
  32172. /** @hidden */
  32173. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32174. /** @hidden */
  32175. _getRGBAMultiSampleBufferFormat(type: number): number;
  32176. /** @hidden */
  32177. _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;
  32178. /**
  32179. * Loads a file from a url
  32180. * @param url url to load
  32181. * @param onSuccess callback called when the file successfully loads
  32182. * @param onProgress callback called while file is loading (if the server supports this mode)
  32183. * @param offlineProvider defines the offline provider for caching
  32184. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32185. * @param onError callback called when the file fails to load
  32186. * @returns a file request object
  32187. * @hidden
  32188. */
  32189. 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;
  32190. /**
  32191. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32192. * @param x defines the x coordinate of the rectangle where pixels must be read
  32193. * @param y defines the y coordinate of the rectangle where pixels must be read
  32194. * @param width defines the width of the rectangle where pixels must be read
  32195. * @param height defines the height of the rectangle where pixels must be read
  32196. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32197. * @returns a Uint8Array containing RGBA colors
  32198. */
  32199. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32200. private static _isSupported;
  32201. /**
  32202. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32203. * @returns true if the engine can be created
  32204. * @ignorenaming
  32205. */
  32206. static isSupported(): boolean;
  32207. /**
  32208. * Find the next highest power of two.
  32209. * @param x Number to start search from.
  32210. * @return Next highest power of two.
  32211. */
  32212. static CeilingPOT(x: number): number;
  32213. /**
  32214. * Find the next lowest power of two.
  32215. * @param x Number to start search from.
  32216. * @return Next lowest power of two.
  32217. */
  32218. static FloorPOT(x: number): number;
  32219. /**
  32220. * Find the nearest power of two.
  32221. * @param x Number to start search from.
  32222. * @return Next nearest power of two.
  32223. */
  32224. static NearestPOT(x: number): number;
  32225. /**
  32226. * Get the closest exponent of two
  32227. * @param value defines the value to approximate
  32228. * @param max defines the maximum value to return
  32229. * @param mode defines how to define the closest value
  32230. * @returns closest exponent of two of the given value
  32231. */
  32232. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32233. /**
  32234. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32235. * @param func - the function to be called
  32236. * @param requester - the object that will request the next frame. Falls back to window.
  32237. * @returns frame number
  32238. */
  32239. static QueueNewFrame(func: () => void, requester?: any): number;
  32240. /**
  32241. * Gets host document
  32242. * @returns the host document object
  32243. */
  32244. getHostDocument(): Nullable<Document>;
  32245. }
  32246. }
  32247. declare module BABYLON {
  32248. /**
  32249. * Class representing spherical harmonics coefficients to the 3rd degree
  32250. */
  32251. export class SphericalHarmonics {
  32252. /**
  32253. * Defines whether or not the harmonics have been prescaled for rendering.
  32254. */
  32255. preScaled: boolean;
  32256. /**
  32257. * The l0,0 coefficients of the spherical harmonics
  32258. */
  32259. l00: Vector3;
  32260. /**
  32261. * The l1,-1 coefficients of the spherical harmonics
  32262. */
  32263. l1_1: Vector3;
  32264. /**
  32265. * The l1,0 coefficients of the spherical harmonics
  32266. */
  32267. l10: Vector3;
  32268. /**
  32269. * The l1,1 coefficients of the spherical harmonics
  32270. */
  32271. l11: Vector3;
  32272. /**
  32273. * The l2,-2 coefficients of the spherical harmonics
  32274. */
  32275. l2_2: Vector3;
  32276. /**
  32277. * The l2,-1 coefficients of the spherical harmonics
  32278. */
  32279. l2_1: Vector3;
  32280. /**
  32281. * The l2,0 coefficients of the spherical harmonics
  32282. */
  32283. l20: Vector3;
  32284. /**
  32285. * The l2,1 coefficients of the spherical harmonics
  32286. */
  32287. l21: Vector3;
  32288. /**
  32289. * The l2,2 coefficients of the spherical harmonics
  32290. */
  32291. l22: Vector3;
  32292. /**
  32293. * Adds a light to the spherical harmonics
  32294. * @param direction the direction of the light
  32295. * @param color the color of the light
  32296. * @param deltaSolidAngle the delta solid angle of the light
  32297. */
  32298. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32299. /**
  32300. * Scales the spherical harmonics by the given amount
  32301. * @param scale the amount to scale
  32302. */
  32303. scaleInPlace(scale: number): void;
  32304. /**
  32305. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32306. *
  32307. * ```
  32308. * E_lm = A_l * L_lm
  32309. * ```
  32310. *
  32311. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32312. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32313. * the scaling factors are given in equation 9.
  32314. */
  32315. convertIncidentRadianceToIrradiance(): void;
  32316. /**
  32317. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32318. *
  32319. * ```
  32320. * L = (1/pi) * E * rho
  32321. * ```
  32322. *
  32323. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32324. */
  32325. convertIrradianceToLambertianRadiance(): void;
  32326. /**
  32327. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32328. * required operations at run time.
  32329. *
  32330. * This is simply done by scaling back the SH with Ylm constants parameter.
  32331. * The trigonometric part being applied by the shader at run time.
  32332. */
  32333. preScaleForRendering(): void;
  32334. /**
  32335. * Constructs a spherical harmonics from an array.
  32336. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32337. * @returns the spherical harmonics
  32338. */
  32339. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32340. /**
  32341. * Gets the spherical harmonics from polynomial
  32342. * @param polynomial the spherical polynomial
  32343. * @returns the spherical harmonics
  32344. */
  32345. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32346. }
  32347. /**
  32348. * Class representing spherical polynomial coefficients to the 3rd degree
  32349. */
  32350. export class SphericalPolynomial {
  32351. private _harmonics;
  32352. /**
  32353. * The spherical harmonics used to create the polynomials.
  32354. */
  32355. get preScaledHarmonics(): SphericalHarmonics;
  32356. /**
  32357. * The x coefficients of the spherical polynomial
  32358. */
  32359. x: Vector3;
  32360. /**
  32361. * The y coefficients of the spherical polynomial
  32362. */
  32363. y: Vector3;
  32364. /**
  32365. * The z coefficients of the spherical polynomial
  32366. */
  32367. z: Vector3;
  32368. /**
  32369. * The xx coefficients of the spherical polynomial
  32370. */
  32371. xx: Vector3;
  32372. /**
  32373. * The yy coefficients of the spherical polynomial
  32374. */
  32375. yy: Vector3;
  32376. /**
  32377. * The zz coefficients of the spherical polynomial
  32378. */
  32379. zz: Vector3;
  32380. /**
  32381. * The xy coefficients of the spherical polynomial
  32382. */
  32383. xy: Vector3;
  32384. /**
  32385. * The yz coefficients of the spherical polynomial
  32386. */
  32387. yz: Vector3;
  32388. /**
  32389. * The zx coefficients of the spherical polynomial
  32390. */
  32391. zx: Vector3;
  32392. /**
  32393. * Adds an ambient color to the spherical polynomial
  32394. * @param color the color to add
  32395. */
  32396. addAmbient(color: Color3): void;
  32397. /**
  32398. * Scales the spherical polynomial by the given amount
  32399. * @param scale the amount to scale
  32400. */
  32401. scaleInPlace(scale: number): void;
  32402. /**
  32403. * Gets the spherical polynomial from harmonics
  32404. * @param harmonics the spherical harmonics
  32405. * @returns the spherical polynomial
  32406. */
  32407. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32408. /**
  32409. * Constructs a spherical polynomial from an array.
  32410. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32411. * @returns the spherical polynomial
  32412. */
  32413. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32414. }
  32415. }
  32416. declare module BABYLON {
  32417. /**
  32418. * Defines the source of the internal texture
  32419. */
  32420. export enum InternalTextureSource {
  32421. /**
  32422. * The source of the texture data is unknown
  32423. */
  32424. Unknown = 0,
  32425. /**
  32426. * Texture data comes from an URL
  32427. */
  32428. Url = 1,
  32429. /**
  32430. * Texture data is only used for temporary storage
  32431. */
  32432. Temp = 2,
  32433. /**
  32434. * Texture data comes from raw data (ArrayBuffer)
  32435. */
  32436. Raw = 3,
  32437. /**
  32438. * Texture content is dynamic (video or dynamic texture)
  32439. */
  32440. Dynamic = 4,
  32441. /**
  32442. * Texture content is generated by rendering to it
  32443. */
  32444. RenderTarget = 5,
  32445. /**
  32446. * Texture content is part of a multi render target process
  32447. */
  32448. MultiRenderTarget = 6,
  32449. /**
  32450. * Texture data comes from a cube data file
  32451. */
  32452. Cube = 7,
  32453. /**
  32454. * Texture data comes from a raw cube data
  32455. */
  32456. CubeRaw = 8,
  32457. /**
  32458. * Texture data come from a prefiltered cube data file
  32459. */
  32460. CubePrefiltered = 9,
  32461. /**
  32462. * Texture content is raw 3D data
  32463. */
  32464. Raw3D = 10,
  32465. /**
  32466. * Texture content is raw 2D array data
  32467. */
  32468. Raw2DArray = 11,
  32469. /**
  32470. * Texture content is a depth texture
  32471. */
  32472. Depth = 12,
  32473. /**
  32474. * Texture data comes from a raw cube data encoded with RGBD
  32475. */
  32476. CubeRawRGBD = 13
  32477. }
  32478. /**
  32479. * Class used to store data associated with WebGL texture data for the engine
  32480. * This class should not be used directly
  32481. */
  32482. export class InternalTexture {
  32483. /** @hidden */
  32484. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32485. /**
  32486. * Defines if the texture is ready
  32487. */
  32488. isReady: boolean;
  32489. /**
  32490. * Defines if the texture is a cube texture
  32491. */
  32492. isCube: boolean;
  32493. /**
  32494. * Defines if the texture contains 3D data
  32495. */
  32496. is3D: boolean;
  32497. /**
  32498. * Defines if the texture contains 2D array data
  32499. */
  32500. is2DArray: boolean;
  32501. /**
  32502. * Defines if the texture contains multiview data
  32503. */
  32504. isMultiview: boolean;
  32505. /**
  32506. * Gets the URL used to load this texture
  32507. */
  32508. url: string;
  32509. /**
  32510. * Gets the sampling mode of the texture
  32511. */
  32512. samplingMode: number;
  32513. /**
  32514. * Gets a boolean indicating if the texture needs mipmaps generation
  32515. */
  32516. generateMipMaps: boolean;
  32517. /**
  32518. * Gets the number of samples used by the texture (WebGL2+ only)
  32519. */
  32520. samples: number;
  32521. /**
  32522. * Gets the type of the texture (int, float...)
  32523. */
  32524. type: number;
  32525. /**
  32526. * Gets the format of the texture (RGB, RGBA...)
  32527. */
  32528. format: number;
  32529. /**
  32530. * Observable called when the texture is loaded
  32531. */
  32532. onLoadedObservable: Observable<InternalTexture>;
  32533. /**
  32534. * Gets the width of the texture
  32535. */
  32536. width: number;
  32537. /**
  32538. * Gets the height of the texture
  32539. */
  32540. height: number;
  32541. /**
  32542. * Gets the depth of the texture
  32543. */
  32544. depth: number;
  32545. /**
  32546. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32547. */
  32548. baseWidth: number;
  32549. /**
  32550. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32551. */
  32552. baseHeight: number;
  32553. /**
  32554. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32555. */
  32556. baseDepth: number;
  32557. /**
  32558. * Gets a boolean indicating if the texture is inverted on Y axis
  32559. */
  32560. invertY: boolean;
  32561. /** @hidden */
  32562. _invertVScale: boolean;
  32563. /** @hidden */
  32564. _associatedChannel: number;
  32565. /** @hidden */
  32566. _source: InternalTextureSource;
  32567. /** @hidden */
  32568. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32569. /** @hidden */
  32570. _bufferView: Nullable<ArrayBufferView>;
  32571. /** @hidden */
  32572. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32573. /** @hidden */
  32574. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32575. /** @hidden */
  32576. _size: number;
  32577. /** @hidden */
  32578. _extension: string;
  32579. /** @hidden */
  32580. _files: Nullable<string[]>;
  32581. /** @hidden */
  32582. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32583. /** @hidden */
  32584. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32585. /** @hidden */
  32586. _framebuffer: Nullable<WebGLFramebuffer>;
  32587. /** @hidden */
  32588. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32589. /** @hidden */
  32590. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32591. /** @hidden */
  32592. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32593. /** @hidden */
  32594. _attachments: Nullable<number[]>;
  32595. /** @hidden */
  32596. _cachedCoordinatesMode: Nullable<number>;
  32597. /** @hidden */
  32598. _cachedWrapU: Nullable<number>;
  32599. /** @hidden */
  32600. _cachedWrapV: Nullable<number>;
  32601. /** @hidden */
  32602. _cachedWrapR: Nullable<number>;
  32603. /** @hidden */
  32604. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32605. /** @hidden */
  32606. _isDisabled: boolean;
  32607. /** @hidden */
  32608. _compression: Nullable<string>;
  32609. /** @hidden */
  32610. _generateStencilBuffer: boolean;
  32611. /** @hidden */
  32612. _generateDepthBuffer: boolean;
  32613. /** @hidden */
  32614. _comparisonFunction: number;
  32615. /** @hidden */
  32616. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32617. /** @hidden */
  32618. _lodGenerationScale: number;
  32619. /** @hidden */
  32620. _lodGenerationOffset: number;
  32621. /** @hidden */
  32622. _depthStencilTexture: Nullable<InternalTexture>;
  32623. /** @hidden */
  32624. _colorTextureArray: Nullable<WebGLTexture>;
  32625. /** @hidden */
  32626. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32627. /** @hidden */
  32628. _lodTextureHigh: Nullable<BaseTexture>;
  32629. /** @hidden */
  32630. _lodTextureMid: Nullable<BaseTexture>;
  32631. /** @hidden */
  32632. _lodTextureLow: Nullable<BaseTexture>;
  32633. /** @hidden */
  32634. _isRGBD: boolean;
  32635. /** @hidden */
  32636. _linearSpecularLOD: boolean;
  32637. /** @hidden */
  32638. _irradianceTexture: Nullable<BaseTexture>;
  32639. /** @hidden */
  32640. _webGLTexture: Nullable<WebGLTexture>;
  32641. /** @hidden */
  32642. _references: number;
  32643. private _engine;
  32644. /**
  32645. * Gets the Engine the texture belongs to.
  32646. * @returns The babylon engine
  32647. */
  32648. getEngine(): ThinEngine;
  32649. /**
  32650. * Gets the data source type of the texture
  32651. */
  32652. get source(): InternalTextureSource;
  32653. /**
  32654. * Creates a new InternalTexture
  32655. * @param engine defines the engine to use
  32656. * @param source defines the type of data that will be used
  32657. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32658. */
  32659. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32660. /**
  32661. * Increments the number of references (ie. the number of Texture that point to it)
  32662. */
  32663. incrementReferences(): void;
  32664. /**
  32665. * Change the size of the texture (not the size of the content)
  32666. * @param width defines the new width
  32667. * @param height defines the new height
  32668. * @param depth defines the new depth (1 by default)
  32669. */
  32670. updateSize(width: int, height: int, depth?: int): void;
  32671. /** @hidden */
  32672. _rebuild(): void;
  32673. /** @hidden */
  32674. _swapAndDie(target: InternalTexture): void;
  32675. /**
  32676. * Dispose the current allocated resources
  32677. */
  32678. dispose(): void;
  32679. }
  32680. }
  32681. declare module BABYLON {
  32682. /**
  32683. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32685. */
  32686. export class Analyser {
  32687. /**
  32688. * Gets or sets the smoothing
  32689. * @ignorenaming
  32690. */
  32691. SMOOTHING: number;
  32692. /**
  32693. * Gets or sets the FFT table size
  32694. * @ignorenaming
  32695. */
  32696. FFT_SIZE: number;
  32697. /**
  32698. * Gets or sets the bar graph amplitude
  32699. * @ignorenaming
  32700. */
  32701. BARGRAPHAMPLITUDE: number;
  32702. /**
  32703. * Gets or sets the position of the debug canvas
  32704. * @ignorenaming
  32705. */
  32706. DEBUGCANVASPOS: {
  32707. x: number;
  32708. y: number;
  32709. };
  32710. /**
  32711. * Gets or sets the debug canvas size
  32712. * @ignorenaming
  32713. */
  32714. DEBUGCANVASSIZE: {
  32715. width: number;
  32716. height: number;
  32717. };
  32718. private _byteFreqs;
  32719. private _byteTime;
  32720. private _floatFreqs;
  32721. private _webAudioAnalyser;
  32722. private _debugCanvas;
  32723. private _debugCanvasContext;
  32724. private _scene;
  32725. private _registerFunc;
  32726. private _audioEngine;
  32727. /**
  32728. * Creates a new analyser
  32729. * @param scene defines hosting scene
  32730. */
  32731. constructor(scene: Scene);
  32732. /**
  32733. * Get the number of data values you will have to play with for the visualization
  32734. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32735. * @returns a number
  32736. */
  32737. getFrequencyBinCount(): number;
  32738. /**
  32739. * Gets the current frequency data as a byte array
  32740. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32741. * @returns a Uint8Array
  32742. */
  32743. getByteFrequencyData(): Uint8Array;
  32744. /**
  32745. * Gets the current waveform as a byte array
  32746. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32747. * @returns a Uint8Array
  32748. */
  32749. getByteTimeDomainData(): Uint8Array;
  32750. /**
  32751. * Gets the current frequency data as a float array
  32752. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32753. * @returns a Float32Array
  32754. */
  32755. getFloatFrequencyData(): Float32Array;
  32756. /**
  32757. * Renders the debug canvas
  32758. */
  32759. drawDebugCanvas(): void;
  32760. /**
  32761. * Stops rendering the debug canvas and removes it
  32762. */
  32763. stopDebugCanvas(): void;
  32764. /**
  32765. * Connects two audio nodes
  32766. * @param inputAudioNode defines first node to connect
  32767. * @param outputAudioNode defines second node to connect
  32768. */
  32769. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32770. /**
  32771. * Releases all associated resources
  32772. */
  32773. dispose(): void;
  32774. }
  32775. }
  32776. declare module BABYLON {
  32777. /**
  32778. * This represents an audio engine and it is responsible
  32779. * to play, synchronize and analyse sounds throughout the application.
  32780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32781. */
  32782. export interface IAudioEngine extends IDisposable {
  32783. /**
  32784. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32785. */
  32786. readonly canUseWebAudio: boolean;
  32787. /**
  32788. * Gets the current AudioContext if available.
  32789. */
  32790. readonly audioContext: Nullable<AudioContext>;
  32791. /**
  32792. * The master gain node defines the global audio volume of your audio engine.
  32793. */
  32794. readonly masterGain: GainNode;
  32795. /**
  32796. * Gets whether or not mp3 are supported by your browser.
  32797. */
  32798. readonly isMP3supported: boolean;
  32799. /**
  32800. * Gets whether or not ogg are supported by your browser.
  32801. */
  32802. readonly isOGGsupported: boolean;
  32803. /**
  32804. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32805. * @ignoreNaming
  32806. */
  32807. WarnedWebAudioUnsupported: boolean;
  32808. /**
  32809. * Defines if the audio engine relies on a custom unlocked button.
  32810. * In this case, the embedded button will not be displayed.
  32811. */
  32812. useCustomUnlockedButton: boolean;
  32813. /**
  32814. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32815. */
  32816. readonly unlocked: boolean;
  32817. /**
  32818. * Event raised when audio has been unlocked on the browser.
  32819. */
  32820. onAudioUnlockedObservable: Observable<AudioEngine>;
  32821. /**
  32822. * Event raised when audio has been locked on the browser.
  32823. */
  32824. onAudioLockedObservable: Observable<AudioEngine>;
  32825. /**
  32826. * Flags the audio engine in Locked state.
  32827. * This happens due to new browser policies preventing audio to autoplay.
  32828. */
  32829. lock(): void;
  32830. /**
  32831. * Unlocks the audio engine once a user action has been done on the dom.
  32832. * This is helpful to resume play once browser policies have been satisfied.
  32833. */
  32834. unlock(): void;
  32835. /**
  32836. * Gets the global volume sets on the master gain.
  32837. * @returns the global volume if set or -1 otherwise
  32838. */
  32839. getGlobalVolume(): number;
  32840. /**
  32841. * Sets the global volume of your experience (sets on the master gain).
  32842. * @param newVolume Defines the new global volume of the application
  32843. */
  32844. setGlobalVolume(newVolume: number): void;
  32845. /**
  32846. * Connect the audio engine to an audio analyser allowing some amazing
  32847. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32849. * @param analyser The analyser to connect to the engine
  32850. */
  32851. connectToAnalyser(analyser: Analyser): void;
  32852. }
  32853. /**
  32854. * This represents the default audio engine used in babylon.
  32855. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32857. */
  32858. export class AudioEngine implements IAudioEngine {
  32859. private _audioContext;
  32860. private _audioContextInitialized;
  32861. private _muteButton;
  32862. private _hostElement;
  32863. /**
  32864. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32865. */
  32866. canUseWebAudio: boolean;
  32867. /**
  32868. * The master gain node defines the global audio volume of your audio engine.
  32869. */
  32870. masterGain: GainNode;
  32871. /**
  32872. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32873. * @ignoreNaming
  32874. */
  32875. WarnedWebAudioUnsupported: boolean;
  32876. /**
  32877. * Gets whether or not mp3 are supported by your browser.
  32878. */
  32879. isMP3supported: boolean;
  32880. /**
  32881. * Gets whether or not ogg are supported by your browser.
  32882. */
  32883. isOGGsupported: boolean;
  32884. /**
  32885. * Gets whether audio has been unlocked on the device.
  32886. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32887. * a user interaction has happened.
  32888. */
  32889. unlocked: boolean;
  32890. /**
  32891. * Defines if the audio engine relies on a custom unlocked button.
  32892. * In this case, the embedded button will not be displayed.
  32893. */
  32894. useCustomUnlockedButton: boolean;
  32895. /**
  32896. * Event raised when audio has been unlocked on the browser.
  32897. */
  32898. onAudioUnlockedObservable: Observable<AudioEngine>;
  32899. /**
  32900. * Event raised when audio has been locked on the browser.
  32901. */
  32902. onAudioLockedObservable: Observable<AudioEngine>;
  32903. /**
  32904. * Gets the current AudioContext if available.
  32905. */
  32906. get audioContext(): Nullable<AudioContext>;
  32907. private _connectedAnalyser;
  32908. /**
  32909. * Instantiates a new audio engine.
  32910. *
  32911. * There should be only one per page as some browsers restrict the number
  32912. * of audio contexts you can create.
  32913. * @param hostElement defines the host element where to display the mute icon if necessary
  32914. */
  32915. constructor(hostElement?: Nullable<HTMLElement>);
  32916. /**
  32917. * Flags the audio engine in Locked state.
  32918. * This happens due to new browser policies preventing audio to autoplay.
  32919. */
  32920. lock(): void;
  32921. /**
  32922. * Unlocks the audio engine once a user action has been done on the dom.
  32923. * This is helpful to resume play once browser policies have been satisfied.
  32924. */
  32925. unlock(): void;
  32926. private _resumeAudioContext;
  32927. private _initializeAudioContext;
  32928. private _tryToRun;
  32929. private _triggerRunningState;
  32930. private _triggerSuspendedState;
  32931. private _displayMuteButton;
  32932. private _moveButtonToTopLeft;
  32933. private _onResize;
  32934. private _hideMuteButton;
  32935. /**
  32936. * Destroy and release the resources associated with the audio ccontext.
  32937. */
  32938. dispose(): void;
  32939. /**
  32940. * Gets the global volume sets on the master gain.
  32941. * @returns the global volume if set or -1 otherwise
  32942. */
  32943. getGlobalVolume(): number;
  32944. /**
  32945. * Sets the global volume of your experience (sets on the master gain).
  32946. * @param newVolume Defines the new global volume of the application
  32947. */
  32948. setGlobalVolume(newVolume: number): void;
  32949. /**
  32950. * Connect the audio engine to an audio analyser allowing some amazing
  32951. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32953. * @param analyser The analyser to connect to the engine
  32954. */
  32955. connectToAnalyser(analyser: Analyser): void;
  32956. }
  32957. }
  32958. declare module BABYLON {
  32959. /**
  32960. * Interface used to present a loading screen while loading a scene
  32961. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32962. */
  32963. export interface ILoadingScreen {
  32964. /**
  32965. * Function called to display the loading screen
  32966. */
  32967. displayLoadingUI: () => void;
  32968. /**
  32969. * Function called to hide the loading screen
  32970. */
  32971. hideLoadingUI: () => void;
  32972. /**
  32973. * Gets or sets the color to use for the background
  32974. */
  32975. loadingUIBackgroundColor: string;
  32976. /**
  32977. * Gets or sets the text to display while loading
  32978. */
  32979. loadingUIText: string;
  32980. }
  32981. /**
  32982. * Class used for the default loading screen
  32983. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32984. */
  32985. export class DefaultLoadingScreen implements ILoadingScreen {
  32986. private _renderingCanvas;
  32987. private _loadingText;
  32988. private _loadingDivBackgroundColor;
  32989. private _loadingDiv;
  32990. private _loadingTextDiv;
  32991. /** Gets or sets the logo url to use for the default loading screen */
  32992. static DefaultLogoUrl: string;
  32993. /** Gets or sets the spinner url to use for the default loading screen */
  32994. static DefaultSpinnerUrl: string;
  32995. /**
  32996. * Creates a new default loading screen
  32997. * @param _renderingCanvas defines the canvas used to render the scene
  32998. * @param _loadingText defines the default text to display
  32999. * @param _loadingDivBackgroundColor defines the default background color
  33000. */
  33001. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33002. /**
  33003. * Function called to display the loading screen
  33004. */
  33005. displayLoadingUI(): void;
  33006. /**
  33007. * Function called to hide the loading screen
  33008. */
  33009. hideLoadingUI(): void;
  33010. /**
  33011. * Gets or sets the text to display while loading
  33012. */
  33013. set loadingUIText(text: string);
  33014. get loadingUIText(): string;
  33015. /**
  33016. * Gets or sets the color to use for the background
  33017. */
  33018. get loadingUIBackgroundColor(): string;
  33019. set loadingUIBackgroundColor(color: string);
  33020. private _resizeLoadingUI;
  33021. }
  33022. }
  33023. declare module BABYLON {
  33024. /**
  33025. * Interface for any object that can request an animation frame
  33026. */
  33027. export interface ICustomAnimationFrameRequester {
  33028. /**
  33029. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33030. */
  33031. renderFunction?: Function;
  33032. /**
  33033. * Called to request the next frame to render to
  33034. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33035. */
  33036. requestAnimationFrame: Function;
  33037. /**
  33038. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33039. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33040. */
  33041. requestID?: number;
  33042. }
  33043. }
  33044. declare module BABYLON {
  33045. /**
  33046. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33047. */
  33048. export class PerformanceMonitor {
  33049. private _enabled;
  33050. private _rollingFrameTime;
  33051. private _lastFrameTimeMs;
  33052. /**
  33053. * constructor
  33054. * @param frameSampleSize The number of samples required to saturate the sliding window
  33055. */
  33056. constructor(frameSampleSize?: number);
  33057. /**
  33058. * Samples current frame
  33059. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33060. */
  33061. sampleFrame(timeMs?: number): void;
  33062. /**
  33063. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33064. */
  33065. get averageFrameTime(): number;
  33066. /**
  33067. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33068. */
  33069. get averageFrameTimeVariance(): number;
  33070. /**
  33071. * Returns the frame time of the most recent frame
  33072. */
  33073. get instantaneousFrameTime(): number;
  33074. /**
  33075. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33076. */
  33077. get averageFPS(): number;
  33078. /**
  33079. * Returns the average framerate in frames per second using the most recent frame time
  33080. */
  33081. get instantaneousFPS(): number;
  33082. /**
  33083. * Returns true if enough samples have been taken to completely fill the sliding window
  33084. */
  33085. get isSaturated(): boolean;
  33086. /**
  33087. * Enables contributions to the sliding window sample set
  33088. */
  33089. enable(): void;
  33090. /**
  33091. * Disables contributions to the sliding window sample set
  33092. * Samples will not be interpolated over the disabled period
  33093. */
  33094. disable(): void;
  33095. /**
  33096. * Returns true if sampling is enabled
  33097. */
  33098. get isEnabled(): boolean;
  33099. /**
  33100. * Resets performance monitor
  33101. */
  33102. reset(): void;
  33103. }
  33104. /**
  33105. * RollingAverage
  33106. *
  33107. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33108. */
  33109. export class RollingAverage {
  33110. /**
  33111. * Current average
  33112. */
  33113. average: number;
  33114. /**
  33115. * Current variance
  33116. */
  33117. variance: number;
  33118. protected _samples: Array<number>;
  33119. protected _sampleCount: number;
  33120. protected _pos: number;
  33121. protected _m2: number;
  33122. /**
  33123. * constructor
  33124. * @param length The number of samples required to saturate the sliding window
  33125. */
  33126. constructor(length: number);
  33127. /**
  33128. * Adds a sample to the sample set
  33129. * @param v The sample value
  33130. */
  33131. add(v: number): void;
  33132. /**
  33133. * Returns previously added values or null if outside of history or outside the sliding window domain
  33134. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33135. * @return Value previously recorded with add() or null if outside of range
  33136. */
  33137. history(i: number): number;
  33138. /**
  33139. * Returns true if enough samples have been taken to completely fill the sliding window
  33140. * @return true if sample-set saturated
  33141. */
  33142. isSaturated(): boolean;
  33143. /**
  33144. * Resets the rolling average (equivalent to 0 samples taken so far)
  33145. */
  33146. reset(): void;
  33147. /**
  33148. * Wraps a value around the sample range boundaries
  33149. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33150. * @return Wrapped position in sample range
  33151. */
  33152. protected _wrapPosition(i: number): number;
  33153. }
  33154. }
  33155. declare module BABYLON {
  33156. /**
  33157. * This class is used to track a performance counter which is number based.
  33158. * The user has access to many properties which give statistics of different nature.
  33159. *
  33160. * The implementer can track two kinds of Performance Counter: time and count.
  33161. * 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.
  33162. * 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.
  33163. */
  33164. export class PerfCounter {
  33165. /**
  33166. * Gets or sets a global boolean to turn on and off all the counters
  33167. */
  33168. static Enabled: boolean;
  33169. /**
  33170. * Returns the smallest value ever
  33171. */
  33172. get min(): number;
  33173. /**
  33174. * Returns the biggest value ever
  33175. */
  33176. get max(): number;
  33177. /**
  33178. * Returns the average value since the performance counter is running
  33179. */
  33180. get average(): number;
  33181. /**
  33182. * Returns the average value of the last second the counter was monitored
  33183. */
  33184. get lastSecAverage(): number;
  33185. /**
  33186. * Returns the current value
  33187. */
  33188. get current(): number;
  33189. /**
  33190. * Gets the accumulated total
  33191. */
  33192. get total(): number;
  33193. /**
  33194. * Gets the total value count
  33195. */
  33196. get count(): number;
  33197. /**
  33198. * Creates a new counter
  33199. */
  33200. constructor();
  33201. /**
  33202. * Call this method to start monitoring a new frame.
  33203. * 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.
  33204. */
  33205. fetchNewFrame(): void;
  33206. /**
  33207. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33208. * @param newCount the count value to add to the monitored count
  33209. * @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.
  33210. */
  33211. addCount(newCount: number, fetchResult: boolean): void;
  33212. /**
  33213. * Start monitoring this performance counter
  33214. */
  33215. beginMonitoring(): void;
  33216. /**
  33217. * Compute the time lapsed since the previous beginMonitoring() call.
  33218. * @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
  33219. */
  33220. endMonitoring(newFrame?: boolean): void;
  33221. private _fetchResult;
  33222. private _startMonitoringTime;
  33223. private _min;
  33224. private _max;
  33225. private _average;
  33226. private _current;
  33227. private _totalValueCount;
  33228. private _totalAccumulated;
  33229. private _lastSecAverage;
  33230. private _lastSecAccumulated;
  33231. private _lastSecTime;
  33232. private _lastSecValueCount;
  33233. }
  33234. }
  33235. declare module BABYLON {
  33236. interface ThinEngine {
  33237. /**
  33238. * Sets alpha constants used by some alpha blending modes
  33239. * @param r defines the red component
  33240. * @param g defines the green component
  33241. * @param b defines the blue component
  33242. * @param a defines the alpha component
  33243. */
  33244. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33245. /**
  33246. * Sets the current alpha mode
  33247. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33248. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33249. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33250. */
  33251. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33252. /**
  33253. * Gets the current alpha mode
  33254. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33255. * @returns the current alpha mode
  33256. */
  33257. getAlphaMode(): number;
  33258. /**
  33259. * Sets the current alpha equation
  33260. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33261. */
  33262. setAlphaEquation(equation: number): void;
  33263. /**
  33264. * Gets the current alpha equation.
  33265. * @returns the current alpha equation
  33266. */
  33267. getAlphaEquation(): number;
  33268. }
  33269. }
  33270. declare module BABYLON {
  33271. /**
  33272. * Defines the interface used by display changed events
  33273. */
  33274. export interface IDisplayChangedEventArgs {
  33275. /** Gets the vrDisplay object (if any) */
  33276. vrDisplay: Nullable<any>;
  33277. /** Gets a boolean indicating if webVR is supported */
  33278. vrSupported: boolean;
  33279. }
  33280. /**
  33281. * Defines the interface used by objects containing a viewport (like a camera)
  33282. */
  33283. interface IViewportOwnerLike {
  33284. /**
  33285. * Gets or sets the viewport
  33286. */
  33287. viewport: IViewportLike;
  33288. }
  33289. /**
  33290. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33291. */
  33292. export class Engine extends ThinEngine {
  33293. /** Defines that alpha blending is disabled */
  33294. static readonly ALPHA_DISABLE: number;
  33295. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33296. static readonly ALPHA_ADD: number;
  33297. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33298. static readonly ALPHA_COMBINE: number;
  33299. /** Defines that alpha blending to DEST - SRC * DEST */
  33300. static readonly ALPHA_SUBTRACT: number;
  33301. /** Defines that alpha blending to SRC * DEST */
  33302. static readonly ALPHA_MULTIPLY: number;
  33303. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33304. static readonly ALPHA_MAXIMIZED: number;
  33305. /** Defines that alpha blending to SRC + DEST */
  33306. static readonly ALPHA_ONEONE: number;
  33307. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33308. static readonly ALPHA_PREMULTIPLIED: number;
  33309. /**
  33310. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33311. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33312. */
  33313. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33314. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33315. static readonly ALPHA_INTERPOLATE: number;
  33316. /**
  33317. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33318. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33319. */
  33320. static readonly ALPHA_SCREENMODE: number;
  33321. /** Defines that the ressource is not delayed*/
  33322. static readonly DELAYLOADSTATE_NONE: number;
  33323. /** Defines that the ressource was successfully delay loaded */
  33324. static readonly DELAYLOADSTATE_LOADED: number;
  33325. /** Defines that the ressource is currently delay loading */
  33326. static readonly DELAYLOADSTATE_LOADING: number;
  33327. /** Defines that the ressource is delayed and has not started loading */
  33328. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33329. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33330. static readonly NEVER: number;
  33331. /** 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 */
  33332. static readonly ALWAYS: number;
  33333. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33334. static readonly LESS: number;
  33335. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33336. static readonly EQUAL: number;
  33337. /** 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 */
  33338. static readonly LEQUAL: number;
  33339. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33340. static readonly GREATER: number;
  33341. /** 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 */
  33342. static readonly GEQUAL: number;
  33343. /** 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 */
  33344. static readonly NOTEQUAL: number;
  33345. /** Passed to stencilOperation to specify that stencil value must be kept */
  33346. static readonly KEEP: number;
  33347. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33348. static readonly REPLACE: number;
  33349. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33350. static readonly INCR: number;
  33351. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33352. static readonly DECR: number;
  33353. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33354. static readonly INVERT: number;
  33355. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33356. static readonly INCR_WRAP: number;
  33357. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33358. static readonly DECR_WRAP: number;
  33359. /** Texture is not repeating outside of 0..1 UVs */
  33360. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33361. /** Texture is repeating outside of 0..1 UVs */
  33362. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33363. /** Texture is repeating and mirrored */
  33364. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33365. /** ALPHA */
  33366. static readonly TEXTUREFORMAT_ALPHA: number;
  33367. /** LUMINANCE */
  33368. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33369. /** LUMINANCE_ALPHA */
  33370. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33371. /** RGB */
  33372. static readonly TEXTUREFORMAT_RGB: number;
  33373. /** RGBA */
  33374. static readonly TEXTUREFORMAT_RGBA: number;
  33375. /** RED */
  33376. static readonly TEXTUREFORMAT_RED: number;
  33377. /** RED (2nd reference) */
  33378. static readonly TEXTUREFORMAT_R: number;
  33379. /** RG */
  33380. static readonly TEXTUREFORMAT_RG: number;
  33381. /** RED_INTEGER */
  33382. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33383. /** RED_INTEGER (2nd reference) */
  33384. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33385. /** RG_INTEGER */
  33386. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33387. /** RGB_INTEGER */
  33388. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33389. /** RGBA_INTEGER */
  33390. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33391. /** UNSIGNED_BYTE */
  33392. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33393. /** UNSIGNED_BYTE (2nd reference) */
  33394. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33395. /** FLOAT */
  33396. static readonly TEXTURETYPE_FLOAT: number;
  33397. /** HALF_FLOAT */
  33398. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33399. /** BYTE */
  33400. static readonly TEXTURETYPE_BYTE: number;
  33401. /** SHORT */
  33402. static readonly TEXTURETYPE_SHORT: number;
  33403. /** UNSIGNED_SHORT */
  33404. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33405. /** INT */
  33406. static readonly TEXTURETYPE_INT: number;
  33407. /** UNSIGNED_INT */
  33408. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33409. /** UNSIGNED_SHORT_4_4_4_4 */
  33410. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33411. /** UNSIGNED_SHORT_5_5_5_1 */
  33412. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33413. /** UNSIGNED_SHORT_5_6_5 */
  33414. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33415. /** UNSIGNED_INT_2_10_10_10_REV */
  33416. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33417. /** UNSIGNED_INT_24_8 */
  33418. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33419. /** UNSIGNED_INT_10F_11F_11F_REV */
  33420. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33421. /** UNSIGNED_INT_5_9_9_9_REV */
  33422. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33423. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33424. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33425. /** nearest is mag = nearest and min = nearest and mip = linear */
  33426. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33427. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33428. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33429. /** Trilinear is mag = linear and min = linear and mip = linear */
  33430. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33431. /** nearest is mag = nearest and min = nearest and mip = linear */
  33432. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33433. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33434. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33435. /** Trilinear is mag = linear and min = linear and mip = linear */
  33436. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33437. /** mag = nearest and min = nearest and mip = nearest */
  33438. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33439. /** mag = nearest and min = linear and mip = nearest */
  33440. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33441. /** mag = nearest and min = linear and mip = linear */
  33442. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33443. /** mag = nearest and min = linear and mip = none */
  33444. static readonly TEXTURE_NEAREST_LINEAR: number;
  33445. /** mag = nearest and min = nearest and mip = none */
  33446. static readonly TEXTURE_NEAREST_NEAREST: number;
  33447. /** mag = linear and min = nearest and mip = nearest */
  33448. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33449. /** mag = linear and min = nearest and mip = linear */
  33450. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33451. /** mag = linear and min = linear and mip = none */
  33452. static readonly TEXTURE_LINEAR_LINEAR: number;
  33453. /** mag = linear and min = nearest and mip = none */
  33454. static readonly TEXTURE_LINEAR_NEAREST: number;
  33455. /** Explicit coordinates mode */
  33456. static readonly TEXTURE_EXPLICIT_MODE: number;
  33457. /** Spherical coordinates mode */
  33458. static readonly TEXTURE_SPHERICAL_MODE: number;
  33459. /** Planar coordinates mode */
  33460. static readonly TEXTURE_PLANAR_MODE: number;
  33461. /** Cubic coordinates mode */
  33462. static readonly TEXTURE_CUBIC_MODE: number;
  33463. /** Projection coordinates mode */
  33464. static readonly TEXTURE_PROJECTION_MODE: number;
  33465. /** Skybox coordinates mode */
  33466. static readonly TEXTURE_SKYBOX_MODE: number;
  33467. /** Inverse Cubic coordinates mode */
  33468. static readonly TEXTURE_INVCUBIC_MODE: number;
  33469. /** Equirectangular coordinates mode */
  33470. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33471. /** Equirectangular Fixed coordinates mode */
  33472. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33473. /** Equirectangular Fixed Mirrored coordinates mode */
  33474. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33475. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33476. static readonly SCALEMODE_FLOOR: number;
  33477. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33478. static readonly SCALEMODE_NEAREST: number;
  33479. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33480. static readonly SCALEMODE_CEILING: number;
  33481. /**
  33482. * Returns the current npm package of the sdk
  33483. */
  33484. static get NpmPackage(): string;
  33485. /**
  33486. * Returns the current version of the framework
  33487. */
  33488. static get Version(): string;
  33489. /** Gets the list of created engines */
  33490. static get Instances(): Engine[];
  33491. /**
  33492. * Gets the latest created engine
  33493. */
  33494. static get LastCreatedEngine(): Nullable<Engine>;
  33495. /**
  33496. * Gets the latest created scene
  33497. */
  33498. static get LastCreatedScene(): Nullable<Scene>;
  33499. /**
  33500. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33501. * @param flag defines which part of the materials must be marked as dirty
  33502. * @param predicate defines a predicate used to filter which materials should be affected
  33503. */
  33504. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33505. /**
  33506. * Method called to create the default loading screen.
  33507. * This can be overriden in your own app.
  33508. * @param canvas The rendering canvas element
  33509. * @returns The loading screen
  33510. */
  33511. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33512. /**
  33513. * Method called to create the default rescale post process on each engine.
  33514. */
  33515. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33516. /**
  33517. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33518. **/
  33519. enableOfflineSupport: boolean;
  33520. /**
  33521. * 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)
  33522. **/
  33523. disableManifestCheck: boolean;
  33524. /**
  33525. * Gets the list of created scenes
  33526. */
  33527. scenes: Scene[];
  33528. /**
  33529. * Event raised when a new scene is created
  33530. */
  33531. onNewSceneAddedObservable: Observable<Scene>;
  33532. /**
  33533. * Gets the list of created postprocesses
  33534. */
  33535. postProcesses: PostProcess[];
  33536. /**
  33537. * Gets a boolean indicating if the pointer is currently locked
  33538. */
  33539. isPointerLock: boolean;
  33540. /**
  33541. * Observable event triggered each time the rendering canvas is resized
  33542. */
  33543. onResizeObservable: Observable<Engine>;
  33544. /**
  33545. * Observable event triggered each time the canvas loses focus
  33546. */
  33547. onCanvasBlurObservable: Observable<Engine>;
  33548. /**
  33549. * Observable event triggered each time the canvas gains focus
  33550. */
  33551. onCanvasFocusObservable: Observable<Engine>;
  33552. /**
  33553. * Observable event triggered each time the canvas receives pointerout event
  33554. */
  33555. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33556. /**
  33557. * Observable raised when the engine begins a new frame
  33558. */
  33559. onBeginFrameObservable: Observable<Engine>;
  33560. /**
  33561. * If set, will be used to request the next animation frame for the render loop
  33562. */
  33563. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33564. /**
  33565. * Observable raised when the engine ends the current frame
  33566. */
  33567. onEndFrameObservable: Observable<Engine>;
  33568. /**
  33569. * Observable raised when the engine is about to compile a shader
  33570. */
  33571. onBeforeShaderCompilationObservable: Observable<Engine>;
  33572. /**
  33573. * Observable raised when the engine has jsut compiled a shader
  33574. */
  33575. onAfterShaderCompilationObservable: Observable<Engine>;
  33576. /**
  33577. * Gets the audio engine
  33578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33579. * @ignorenaming
  33580. */
  33581. static audioEngine: IAudioEngine;
  33582. /**
  33583. * Default AudioEngine factory responsible of creating the Audio Engine.
  33584. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33585. */
  33586. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33587. /**
  33588. * Default offline support factory responsible of creating a tool used to store data locally.
  33589. * By default, this will create a Database object if the workload has been embedded.
  33590. */
  33591. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33592. private _loadingScreen;
  33593. private _pointerLockRequested;
  33594. private _dummyFramebuffer;
  33595. private _rescalePostProcess;
  33596. private _deterministicLockstep;
  33597. private _lockstepMaxSteps;
  33598. private _timeStep;
  33599. protected get _supportsHardwareTextureRescaling(): boolean;
  33600. private _fps;
  33601. private _deltaTime;
  33602. /** @hidden */
  33603. _drawCalls: PerfCounter;
  33604. /** 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 */
  33605. canvasTabIndex: number;
  33606. /**
  33607. * Turn this value on if you want to pause FPS computation when in background
  33608. */
  33609. disablePerformanceMonitorInBackground: boolean;
  33610. private _performanceMonitor;
  33611. /**
  33612. * Gets the performance monitor attached to this engine
  33613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33614. */
  33615. get performanceMonitor(): PerformanceMonitor;
  33616. private _onFocus;
  33617. private _onBlur;
  33618. private _onCanvasPointerOut;
  33619. private _onCanvasBlur;
  33620. private _onCanvasFocus;
  33621. private _onFullscreenChange;
  33622. private _onPointerLockChange;
  33623. /**
  33624. * Gets the HTML element used to attach event listeners
  33625. * @returns a HTML element
  33626. */
  33627. getInputElement(): Nullable<HTMLElement>;
  33628. /**
  33629. * Creates a new engine
  33630. * @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
  33631. * @param antialias defines enable antialiasing (default: false)
  33632. * @param options defines further options to be sent to the getContext() function
  33633. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33634. */
  33635. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33636. /**
  33637. * Gets current aspect ratio
  33638. * @param viewportOwner defines the camera to use to get the aspect ratio
  33639. * @param useScreen defines if screen size must be used (or the current render target if any)
  33640. * @returns a number defining the aspect ratio
  33641. */
  33642. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33643. /**
  33644. * Gets current screen aspect ratio
  33645. * @returns a number defining the aspect ratio
  33646. */
  33647. getScreenAspectRatio(): number;
  33648. /**
  33649. * Gets the client rect of the HTML canvas attached with the current webGL context
  33650. * @returns a client rectanglee
  33651. */
  33652. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33653. /**
  33654. * Gets the client rect of the HTML element used for events
  33655. * @returns a client rectanglee
  33656. */
  33657. getInputElementClientRect(): Nullable<ClientRect>;
  33658. /**
  33659. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33660. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33661. * @returns true if engine is in deterministic lock step mode
  33662. */
  33663. isDeterministicLockStep(): boolean;
  33664. /**
  33665. * Gets the max steps when engine is running in deterministic lock step
  33666. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33667. * @returns the max steps
  33668. */
  33669. getLockstepMaxSteps(): number;
  33670. /**
  33671. * Returns the time in ms between steps when using deterministic lock step.
  33672. * @returns time step in (ms)
  33673. */
  33674. getTimeStep(): number;
  33675. /**
  33676. * Force the mipmap generation for the given render target texture
  33677. * @param texture defines the render target texture to use
  33678. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33679. */
  33680. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33681. /** States */
  33682. /**
  33683. * Set various states to the webGL context
  33684. * @param culling defines backface culling state
  33685. * @param zOffset defines the value to apply to zOffset (0 by default)
  33686. * @param force defines if states must be applied even if cache is up to date
  33687. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33688. */
  33689. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33690. /**
  33691. * Set the z offset to apply to current rendering
  33692. * @param value defines the offset to apply
  33693. */
  33694. setZOffset(value: number): void;
  33695. /**
  33696. * Gets the current value of the zOffset
  33697. * @returns the current zOffset state
  33698. */
  33699. getZOffset(): number;
  33700. /**
  33701. * Enable or disable depth buffering
  33702. * @param enable defines the state to set
  33703. */
  33704. setDepthBuffer(enable: boolean): void;
  33705. /**
  33706. * Gets a boolean indicating if depth writing is enabled
  33707. * @returns the current depth writing state
  33708. */
  33709. getDepthWrite(): boolean;
  33710. /**
  33711. * Enable or disable depth writing
  33712. * @param enable defines the state to set
  33713. */
  33714. setDepthWrite(enable: boolean): void;
  33715. /**
  33716. * Gets a boolean indicating if stencil buffer is enabled
  33717. * @returns the current stencil buffer state
  33718. */
  33719. getStencilBuffer(): boolean;
  33720. /**
  33721. * Enable or disable the stencil buffer
  33722. * @param enable defines if the stencil buffer must be enabled or disabled
  33723. */
  33724. setStencilBuffer(enable: boolean): void;
  33725. /**
  33726. * Gets the current stencil mask
  33727. * @returns a number defining the new stencil mask to use
  33728. */
  33729. getStencilMask(): number;
  33730. /**
  33731. * Sets the current stencil mask
  33732. * @param mask defines the new stencil mask to use
  33733. */
  33734. setStencilMask(mask: number): void;
  33735. /**
  33736. * Gets the current stencil function
  33737. * @returns a number defining the stencil function to use
  33738. */
  33739. getStencilFunction(): number;
  33740. /**
  33741. * Gets the current stencil reference value
  33742. * @returns a number defining the stencil reference value to use
  33743. */
  33744. getStencilFunctionReference(): number;
  33745. /**
  33746. * Gets the current stencil mask
  33747. * @returns a number defining the stencil mask to use
  33748. */
  33749. getStencilFunctionMask(): number;
  33750. /**
  33751. * Sets the current stencil function
  33752. * @param stencilFunc defines the new stencil function to use
  33753. */
  33754. setStencilFunction(stencilFunc: number): void;
  33755. /**
  33756. * Sets the current stencil reference
  33757. * @param reference defines the new stencil reference to use
  33758. */
  33759. setStencilFunctionReference(reference: number): void;
  33760. /**
  33761. * Sets the current stencil mask
  33762. * @param mask defines the new stencil mask to use
  33763. */
  33764. setStencilFunctionMask(mask: number): void;
  33765. /**
  33766. * Gets the current stencil operation when stencil fails
  33767. * @returns a number defining stencil operation to use when stencil fails
  33768. */
  33769. getStencilOperationFail(): number;
  33770. /**
  33771. * Gets the current stencil operation when depth fails
  33772. * @returns a number defining stencil operation to use when depth fails
  33773. */
  33774. getStencilOperationDepthFail(): number;
  33775. /**
  33776. * Gets the current stencil operation when stencil passes
  33777. * @returns a number defining stencil operation to use when stencil passes
  33778. */
  33779. getStencilOperationPass(): number;
  33780. /**
  33781. * Sets the stencil operation to use when stencil fails
  33782. * @param operation defines the stencil operation to use when stencil fails
  33783. */
  33784. setStencilOperationFail(operation: number): void;
  33785. /**
  33786. * Sets the stencil operation to use when depth fails
  33787. * @param operation defines the stencil operation to use when depth fails
  33788. */
  33789. setStencilOperationDepthFail(operation: number): void;
  33790. /**
  33791. * Sets the stencil operation to use when stencil passes
  33792. * @param operation defines the stencil operation to use when stencil passes
  33793. */
  33794. setStencilOperationPass(operation: number): void;
  33795. /**
  33796. * Sets a boolean indicating if the dithering state is enabled or disabled
  33797. * @param value defines the dithering state
  33798. */
  33799. setDitheringState(value: boolean): void;
  33800. /**
  33801. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33802. * @param value defines the rasterizer state
  33803. */
  33804. setRasterizerState(value: boolean): void;
  33805. /**
  33806. * Gets the current depth function
  33807. * @returns a number defining the depth function
  33808. */
  33809. getDepthFunction(): Nullable<number>;
  33810. /**
  33811. * Sets the current depth function
  33812. * @param depthFunc defines the function to use
  33813. */
  33814. setDepthFunction(depthFunc: number): void;
  33815. /**
  33816. * Sets the current depth function to GREATER
  33817. */
  33818. setDepthFunctionToGreater(): void;
  33819. /**
  33820. * Sets the current depth function to GEQUAL
  33821. */
  33822. setDepthFunctionToGreaterOrEqual(): void;
  33823. /**
  33824. * Sets the current depth function to LESS
  33825. */
  33826. setDepthFunctionToLess(): void;
  33827. /**
  33828. * Sets the current depth function to LEQUAL
  33829. */
  33830. setDepthFunctionToLessOrEqual(): void;
  33831. private _cachedStencilBuffer;
  33832. private _cachedStencilFunction;
  33833. private _cachedStencilMask;
  33834. private _cachedStencilOperationPass;
  33835. private _cachedStencilOperationFail;
  33836. private _cachedStencilOperationDepthFail;
  33837. private _cachedStencilReference;
  33838. /**
  33839. * Caches the the state of the stencil buffer
  33840. */
  33841. cacheStencilState(): void;
  33842. /**
  33843. * Restores the state of the stencil buffer
  33844. */
  33845. restoreStencilState(): void;
  33846. /**
  33847. * Directly set the WebGL Viewport
  33848. * @param x defines the x coordinate of the viewport (in screen space)
  33849. * @param y defines the y coordinate of the viewport (in screen space)
  33850. * @param width defines the width of the viewport (in screen space)
  33851. * @param height defines the height of the viewport (in screen space)
  33852. * @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
  33853. */
  33854. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33855. /**
  33856. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33857. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33858. * @param y defines the y-coordinate of the corner of the clear rectangle
  33859. * @param width defines the width of the clear rectangle
  33860. * @param height defines the height of the clear rectangle
  33861. * @param clearColor defines the clear color
  33862. */
  33863. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33864. /**
  33865. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33866. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33867. * @param y defines the y-coordinate of the corner of the clear rectangle
  33868. * @param width defines the width of the clear rectangle
  33869. * @param height defines the height of the clear rectangle
  33870. */
  33871. enableScissor(x: number, y: number, width: number, height: number): void;
  33872. /**
  33873. * Disable previously set scissor test rectangle
  33874. */
  33875. disableScissor(): void;
  33876. protected _reportDrawCall(): void;
  33877. /**
  33878. * Initializes a webVR display and starts listening to display change events
  33879. * The onVRDisplayChangedObservable will be notified upon these changes
  33880. * @returns The onVRDisplayChangedObservable
  33881. */
  33882. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33883. /** @hidden */
  33884. _prepareVRComponent(): void;
  33885. /** @hidden */
  33886. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33887. /** @hidden */
  33888. _submitVRFrame(): void;
  33889. /**
  33890. * Call this function to leave webVR mode
  33891. * Will do nothing if webVR is not supported or if there is no webVR device
  33892. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33893. */
  33894. disableVR(): void;
  33895. /**
  33896. * Gets a boolean indicating that the system is in VR mode and is presenting
  33897. * @returns true if VR mode is engaged
  33898. */
  33899. isVRPresenting(): boolean;
  33900. /** @hidden */
  33901. _requestVRFrame(): void;
  33902. /** @hidden */
  33903. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33904. /**
  33905. * Gets the source code of the vertex shader associated with a specific webGL program
  33906. * @param program defines the program to use
  33907. * @returns a string containing the source code of the vertex shader associated with the program
  33908. */
  33909. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33910. /**
  33911. * Gets the source code of the fragment shader associated with a specific webGL program
  33912. * @param program defines the program to use
  33913. * @returns a string containing the source code of the fragment shader associated with the program
  33914. */
  33915. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33916. /**
  33917. * Sets a depth stencil texture from a render target to the according uniform.
  33918. * @param channel The texture channel
  33919. * @param uniform The uniform to set
  33920. * @param texture The render target texture containing the depth stencil texture to apply
  33921. */
  33922. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33923. /**
  33924. * Sets a texture to the webGL context from a postprocess
  33925. * @param channel defines the channel to use
  33926. * @param postProcess defines the source postprocess
  33927. */
  33928. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33929. /**
  33930. * Binds the output of the passed in post process to the texture channel specified
  33931. * @param channel The channel the texture should be bound to
  33932. * @param postProcess The post process which's output should be bound
  33933. */
  33934. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33935. /** @hidden */
  33936. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33937. protected _rebuildBuffers(): void;
  33938. /** @hidden */
  33939. _renderFrame(): void;
  33940. _renderLoop(): void;
  33941. /** @hidden */
  33942. _renderViews(): boolean;
  33943. /**
  33944. * Toggle full screen mode
  33945. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33946. */
  33947. switchFullscreen(requestPointerLock: boolean): void;
  33948. /**
  33949. * Enters full screen mode
  33950. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33951. */
  33952. enterFullscreen(requestPointerLock: boolean): void;
  33953. /**
  33954. * Exits full screen mode
  33955. */
  33956. exitFullscreen(): void;
  33957. /**
  33958. * Enters Pointerlock mode
  33959. */
  33960. enterPointerlock(): void;
  33961. /**
  33962. * Exits Pointerlock mode
  33963. */
  33964. exitPointerlock(): void;
  33965. /**
  33966. * Begin a new frame
  33967. */
  33968. beginFrame(): void;
  33969. /**
  33970. * Enf the current frame
  33971. */
  33972. endFrame(): void;
  33973. resize(): void;
  33974. /**
  33975. * Force a specific size of the canvas
  33976. * @param width defines the new canvas' width
  33977. * @param height defines the new canvas' height
  33978. */
  33979. setSize(width: number, height: number): void;
  33980. /**
  33981. * Updates a dynamic vertex buffer.
  33982. * @param vertexBuffer the vertex buffer to update
  33983. * @param data the data used to update the vertex buffer
  33984. * @param byteOffset the byte offset of the data
  33985. * @param byteLength the byte length of the data
  33986. */
  33987. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33988. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33989. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33990. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33991. _releaseTexture(texture: InternalTexture): void;
  33992. /**
  33993. * @hidden
  33994. * Rescales a texture
  33995. * @param source input texutre
  33996. * @param destination destination texture
  33997. * @param scene scene to use to render the resize
  33998. * @param internalFormat format to use when resizing
  33999. * @param onComplete callback to be called when resize has completed
  34000. */
  34001. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34002. /**
  34003. * Gets the current framerate
  34004. * @returns a number representing the framerate
  34005. */
  34006. getFps(): number;
  34007. /**
  34008. * Gets the time spent between current and previous frame
  34009. * @returns a number representing the delta time in ms
  34010. */
  34011. getDeltaTime(): number;
  34012. private _measureFps;
  34013. /** @hidden */
  34014. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34015. /**
  34016. * Update a dynamic index buffer
  34017. * @param indexBuffer defines the target index buffer
  34018. * @param indices defines the data to update
  34019. * @param offset defines the offset in the target index buffer where update should start
  34020. */
  34021. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34022. /**
  34023. * Updates the sample count of a render target texture
  34024. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34025. * @param texture defines the texture to update
  34026. * @param samples defines the sample count to set
  34027. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34028. */
  34029. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34030. /**
  34031. * Updates a depth texture Comparison Mode and Function.
  34032. * If the comparison Function is equal to 0, the mode will be set to none.
  34033. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34034. * @param texture The texture to set the comparison function for
  34035. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34036. */
  34037. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34038. /**
  34039. * Creates a webGL buffer to use with instanciation
  34040. * @param capacity defines the size of the buffer
  34041. * @returns the webGL buffer
  34042. */
  34043. createInstancesBuffer(capacity: number): DataBuffer;
  34044. /**
  34045. * Delete a webGL buffer used with instanciation
  34046. * @param buffer defines the webGL buffer to delete
  34047. */
  34048. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34049. private _clientWaitAsync;
  34050. /** @hidden */
  34051. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34052. /** @hidden */
  34053. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34054. dispose(): void;
  34055. private _disableTouchAction;
  34056. /**
  34057. * Display the loading screen
  34058. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34059. */
  34060. displayLoadingUI(): void;
  34061. /**
  34062. * Hide the loading screen
  34063. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34064. */
  34065. hideLoadingUI(): void;
  34066. /**
  34067. * Gets the current loading screen object
  34068. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34069. */
  34070. get loadingScreen(): ILoadingScreen;
  34071. /**
  34072. * Sets the current loading screen object
  34073. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34074. */
  34075. set loadingScreen(loadingScreen: ILoadingScreen);
  34076. /**
  34077. * Sets the current loading screen text
  34078. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34079. */
  34080. set loadingUIText(text: string);
  34081. /**
  34082. * Sets the current loading screen background color
  34083. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34084. */
  34085. set loadingUIBackgroundColor(color: string);
  34086. /** Pointerlock and fullscreen */
  34087. /**
  34088. * Ask the browser to promote the current element to pointerlock mode
  34089. * @param element defines the DOM element to promote
  34090. */
  34091. static _RequestPointerlock(element: HTMLElement): void;
  34092. /**
  34093. * Asks the browser to exit pointerlock mode
  34094. */
  34095. static _ExitPointerlock(): void;
  34096. /**
  34097. * Ask the browser to promote the current element to fullscreen rendering mode
  34098. * @param element defines the DOM element to promote
  34099. */
  34100. static _RequestFullscreen(element: HTMLElement): void;
  34101. /**
  34102. * Asks the browser to exit fullscreen mode
  34103. */
  34104. static _ExitFullscreen(): void;
  34105. }
  34106. }
  34107. declare module BABYLON {
  34108. /**
  34109. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34110. * during the life time of the application.
  34111. */
  34112. export class EngineStore {
  34113. /** Gets the list of created engines */
  34114. static Instances: Engine[];
  34115. /** @hidden */
  34116. static _LastCreatedScene: Nullable<Scene>;
  34117. /**
  34118. * Gets the latest created engine
  34119. */
  34120. static get LastCreatedEngine(): Nullable<Engine>;
  34121. /**
  34122. * Gets the latest created scene
  34123. */
  34124. static get LastCreatedScene(): Nullable<Scene>;
  34125. /**
  34126. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34127. * @ignorenaming
  34128. */
  34129. static UseFallbackTexture: boolean;
  34130. /**
  34131. * Texture content used if a texture cannot loaded
  34132. * @ignorenaming
  34133. */
  34134. static FallbackTexture: string;
  34135. }
  34136. }
  34137. declare module BABYLON {
  34138. /**
  34139. * Helper class that provides a small promise polyfill
  34140. */
  34141. export class PromisePolyfill {
  34142. /**
  34143. * Static function used to check if the polyfill is required
  34144. * If this is the case then the function will inject the polyfill to window.Promise
  34145. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34146. */
  34147. static Apply(force?: boolean): void;
  34148. }
  34149. }
  34150. declare module BABYLON {
  34151. /**
  34152. * Interface for screenshot methods with describe argument called `size` as object with options
  34153. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34154. */
  34155. export interface IScreenshotSize {
  34156. /**
  34157. * number in pixels for canvas height
  34158. */
  34159. height?: number;
  34160. /**
  34161. * multiplier allowing render at a higher or lower resolution
  34162. * If value is defined then height and width will be ignored and taken from camera
  34163. */
  34164. precision?: number;
  34165. /**
  34166. * number in pixels for canvas width
  34167. */
  34168. width?: number;
  34169. }
  34170. }
  34171. declare module BABYLON {
  34172. interface IColor4Like {
  34173. r: float;
  34174. g: float;
  34175. b: float;
  34176. a: float;
  34177. }
  34178. /**
  34179. * Class containing a set of static utilities functions
  34180. */
  34181. export class Tools {
  34182. /**
  34183. * Gets or sets the base URL to use to load assets
  34184. */
  34185. static get BaseUrl(): string;
  34186. static set BaseUrl(value: string);
  34187. /**
  34188. * Enable/Disable Custom HTTP Request Headers globally.
  34189. * default = false
  34190. * @see CustomRequestHeaders
  34191. */
  34192. static UseCustomRequestHeaders: boolean;
  34193. /**
  34194. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34195. * i.e. when loading files, where the server/service expects an Authorization header
  34196. */
  34197. static CustomRequestHeaders: {
  34198. [key: string]: string;
  34199. };
  34200. /**
  34201. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34202. */
  34203. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34204. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34205. /**
  34206. * Default behaviour for cors in the application.
  34207. * It can be a string if the expected behavior is identical in the entire app.
  34208. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34209. */
  34210. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34211. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34212. /**
  34213. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34214. * @ignorenaming
  34215. */
  34216. static get UseFallbackTexture(): boolean;
  34217. static set UseFallbackTexture(value: boolean);
  34218. /**
  34219. * Use this object to register external classes like custom textures or material
  34220. * to allow the laoders to instantiate them
  34221. */
  34222. static get RegisteredExternalClasses(): {
  34223. [key: string]: Object;
  34224. };
  34225. static set RegisteredExternalClasses(classes: {
  34226. [key: string]: Object;
  34227. });
  34228. /**
  34229. * Texture content used if a texture cannot loaded
  34230. * @ignorenaming
  34231. */
  34232. static get fallbackTexture(): string;
  34233. static set fallbackTexture(value: string);
  34234. /**
  34235. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34236. * @param u defines the coordinate on X axis
  34237. * @param v defines the coordinate on Y axis
  34238. * @param width defines the width of the source data
  34239. * @param height defines the height of the source data
  34240. * @param pixels defines the source byte array
  34241. * @param color defines the output color
  34242. */
  34243. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34244. /**
  34245. * Interpolates between a and b via alpha
  34246. * @param a The lower value (returned when alpha = 0)
  34247. * @param b The upper value (returned when alpha = 1)
  34248. * @param alpha The interpolation-factor
  34249. * @return The mixed value
  34250. */
  34251. static Mix(a: number, b: number, alpha: number): number;
  34252. /**
  34253. * Tries to instantiate a new object from a given class name
  34254. * @param className defines the class name to instantiate
  34255. * @returns the new object or null if the system was not able to do the instantiation
  34256. */
  34257. static Instantiate(className: string): any;
  34258. /**
  34259. * Provides a slice function that will work even on IE
  34260. * @param data defines the array to slice
  34261. * @param start defines the start of the data (optional)
  34262. * @param end defines the end of the data (optional)
  34263. * @returns the new sliced array
  34264. */
  34265. static Slice<T>(data: T, start?: number, end?: number): T;
  34266. /**
  34267. * Polyfill for setImmediate
  34268. * @param action defines the action to execute after the current execution block
  34269. */
  34270. static SetImmediate(action: () => void): void;
  34271. /**
  34272. * Function indicating if a number is an exponent of 2
  34273. * @param value defines the value to test
  34274. * @returns true if the value is an exponent of 2
  34275. */
  34276. static IsExponentOfTwo(value: number): boolean;
  34277. private static _tmpFloatArray;
  34278. /**
  34279. * Returns the nearest 32-bit single precision float representation of a Number
  34280. * @param value A Number. If the parameter is of a different type, it will get converted
  34281. * to a number or to NaN if it cannot be converted
  34282. * @returns number
  34283. */
  34284. static FloatRound(value: number): number;
  34285. /**
  34286. * Extracts the filename from a path
  34287. * @param path defines the path to use
  34288. * @returns the filename
  34289. */
  34290. static GetFilename(path: string): string;
  34291. /**
  34292. * Extracts the "folder" part of a path (everything before the filename).
  34293. * @param uri The URI to extract the info from
  34294. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34295. * @returns The "folder" part of the path
  34296. */
  34297. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34298. /**
  34299. * Extracts text content from a DOM element hierarchy
  34300. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34301. */
  34302. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34303. /**
  34304. * Convert an angle in radians to degrees
  34305. * @param angle defines the angle to convert
  34306. * @returns the angle in degrees
  34307. */
  34308. static ToDegrees(angle: number): number;
  34309. /**
  34310. * Convert an angle in degrees to radians
  34311. * @param angle defines the angle to convert
  34312. * @returns the angle in radians
  34313. */
  34314. static ToRadians(angle: number): number;
  34315. /**
  34316. * Returns an array if obj is not an array
  34317. * @param obj defines the object to evaluate as an array
  34318. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34319. * @returns either obj directly if obj is an array or a new array containing obj
  34320. */
  34321. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34322. /**
  34323. * Gets the pointer prefix to use
  34324. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34325. */
  34326. static GetPointerPrefix(): string;
  34327. /**
  34328. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34329. * @param url define the url we are trying
  34330. * @param element define the dom element where to configure the cors policy
  34331. */
  34332. static SetCorsBehavior(url: string | string[], element: {
  34333. crossOrigin: string | null;
  34334. }): void;
  34335. /**
  34336. * Removes unwanted characters from an url
  34337. * @param url defines the url to clean
  34338. * @returns the cleaned url
  34339. */
  34340. static CleanUrl(url: string): string;
  34341. /**
  34342. * Gets or sets a function used to pre-process url before using them to load assets
  34343. */
  34344. static get PreprocessUrl(): (url: string) => string;
  34345. static set PreprocessUrl(processor: (url: string) => string);
  34346. /**
  34347. * Loads an image as an HTMLImageElement.
  34348. * @param input url string, ArrayBuffer, or Blob to load
  34349. * @param onLoad callback called when the image successfully loads
  34350. * @param onError callback called when the image fails to load
  34351. * @param offlineProvider offline provider for caching
  34352. * @param mimeType optional mime type
  34353. * @returns the HTMLImageElement of the loaded image
  34354. */
  34355. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34356. /**
  34357. * Loads a file from a url
  34358. * @param url url string, ArrayBuffer, or Blob to load
  34359. * @param onSuccess callback called when the file successfully loads
  34360. * @param onProgress callback called while file is loading (if the server supports this mode)
  34361. * @param offlineProvider defines the offline provider for caching
  34362. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34363. * @param onError callback called when the file fails to load
  34364. * @returns a file request object
  34365. */
  34366. 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;
  34367. /**
  34368. * Loads a file from a url
  34369. * @param url the file url to load
  34370. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34371. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34372. */
  34373. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34374. /**
  34375. * Load a script (identified by an url). When the url returns, the
  34376. * content of this file is added into a new script element, attached to the DOM (body element)
  34377. * @param scriptUrl defines the url of the script to laod
  34378. * @param onSuccess defines the callback called when the script is loaded
  34379. * @param onError defines the callback to call if an error occurs
  34380. * @param scriptId defines the id of the script element
  34381. */
  34382. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34383. /**
  34384. * Load an asynchronous script (identified by an url). When the url returns, the
  34385. * content of this file is added into a new script element, attached to the DOM (body element)
  34386. * @param scriptUrl defines the url of the script to laod
  34387. * @param scriptId defines the id of the script element
  34388. * @returns a promise request object
  34389. */
  34390. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34391. /**
  34392. * Loads a file from a blob
  34393. * @param fileToLoad defines the blob to use
  34394. * @param callback defines the callback to call when data is loaded
  34395. * @param progressCallback defines the callback to call during loading process
  34396. * @returns a file request object
  34397. */
  34398. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34399. /**
  34400. * Reads a file from a File object
  34401. * @param file defines the file to load
  34402. * @param onSuccess defines the callback to call when data is loaded
  34403. * @param onProgress defines the callback to call during loading process
  34404. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34405. * @param onError defines the callback to call when an error occurs
  34406. * @returns a file request object
  34407. */
  34408. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34409. /**
  34410. * Creates a data url from a given string content
  34411. * @param content defines the content to convert
  34412. * @returns the new data url link
  34413. */
  34414. static FileAsURL(content: string): string;
  34415. /**
  34416. * Format the given number to a specific decimal format
  34417. * @param value defines the number to format
  34418. * @param decimals defines the number of decimals to use
  34419. * @returns the formatted string
  34420. */
  34421. static Format(value: number, decimals?: number): string;
  34422. /**
  34423. * Tries to copy an object by duplicating every property
  34424. * @param source defines the source object
  34425. * @param destination defines the target object
  34426. * @param doNotCopyList defines a list of properties to avoid
  34427. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34428. */
  34429. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34430. /**
  34431. * Gets a boolean indicating if the given object has no own property
  34432. * @param obj defines the object to test
  34433. * @returns true if object has no own property
  34434. */
  34435. static IsEmpty(obj: any): boolean;
  34436. /**
  34437. * Function used to register events at window level
  34438. * @param windowElement defines the Window object to use
  34439. * @param events defines the events to register
  34440. */
  34441. static RegisterTopRootEvents(windowElement: Window, events: {
  34442. name: string;
  34443. handler: Nullable<(e: FocusEvent) => any>;
  34444. }[]): void;
  34445. /**
  34446. * Function used to unregister events from window level
  34447. * @param windowElement defines the Window object to use
  34448. * @param events defines the events to unregister
  34449. */
  34450. static UnregisterTopRootEvents(windowElement: Window, events: {
  34451. name: string;
  34452. handler: Nullable<(e: FocusEvent) => any>;
  34453. }[]): void;
  34454. /**
  34455. * @ignore
  34456. */
  34457. static _ScreenshotCanvas: HTMLCanvasElement;
  34458. /**
  34459. * Dumps the current bound framebuffer
  34460. * @param width defines the rendering width
  34461. * @param height defines the rendering height
  34462. * @param engine defines the hosting engine
  34463. * @param successCallback defines the callback triggered once the data are available
  34464. * @param mimeType defines the mime type of the result
  34465. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34466. */
  34467. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34468. /**
  34469. * Converts the canvas data to blob.
  34470. * This acts as a polyfill for browsers not supporting the to blob function.
  34471. * @param canvas Defines the canvas to extract the data from
  34472. * @param successCallback Defines the callback triggered once the data are available
  34473. * @param mimeType Defines the mime type of the result
  34474. */
  34475. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34476. /**
  34477. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34478. * @param successCallback defines the callback triggered once the data are available
  34479. * @param mimeType defines the mime type of the result
  34480. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34481. */
  34482. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34483. /**
  34484. * Downloads a blob in the browser
  34485. * @param blob defines the blob to download
  34486. * @param fileName defines the name of the downloaded file
  34487. */
  34488. static Download(blob: Blob, fileName: string): void;
  34489. /**
  34490. * Captures a screenshot of the current rendering
  34491. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34492. * @param engine defines the rendering engine
  34493. * @param camera defines the source camera
  34494. * @param size This parameter can be set to a single number or to an object with the
  34495. * following (optional) properties: precision, width, height. If a single number is passed,
  34496. * it will be used for both width and height. If an object is passed, the screenshot size
  34497. * will be derived from the parameters. The precision property is a multiplier allowing
  34498. * rendering at a higher or lower resolution
  34499. * @param successCallback defines the callback receives a single parameter which contains the
  34500. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34501. * src parameter of an <img> to display it
  34502. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34503. * Check your browser for supported MIME types
  34504. */
  34505. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34506. /**
  34507. * Captures a screenshot of the current rendering
  34508. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34509. * @param engine defines the rendering engine
  34510. * @param camera defines the source camera
  34511. * @param size This parameter can be set to a single number or to an object with the
  34512. * following (optional) properties: precision, width, height. If a single number is passed,
  34513. * it will be used for both width and height. If an object is passed, the screenshot size
  34514. * will be derived from the parameters. The precision property is a multiplier allowing
  34515. * rendering at a higher or lower resolution
  34516. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34517. * Check your browser for supported MIME types
  34518. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34519. * to the src parameter of an <img> to display it
  34520. */
  34521. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34522. /**
  34523. * Generates an image screenshot from the specified camera.
  34524. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34525. * @param engine The engine to use for rendering
  34526. * @param camera The camera to use for rendering
  34527. * @param size This parameter can be set to a single number or to an object with the
  34528. * following (optional) properties: precision, width, height. If a single number is passed,
  34529. * it will be used for both width and height. If an object is passed, the screenshot size
  34530. * will be derived from the parameters. The precision property is a multiplier allowing
  34531. * rendering at a higher or lower resolution
  34532. * @param successCallback The callback receives a single parameter which contains the
  34533. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34534. * src parameter of an <img> to display it
  34535. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34536. * Check your browser for supported MIME types
  34537. * @param samples Texture samples (default: 1)
  34538. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34539. * @param fileName A name for for the downloaded file.
  34540. */
  34541. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34542. /**
  34543. * Generates an image screenshot from the specified camera.
  34544. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34545. * @param engine The engine to use for rendering
  34546. * @param camera The camera to use for rendering
  34547. * @param size This parameter can be set to a single number or to an object with the
  34548. * following (optional) properties: precision, width, height. If a single number is passed,
  34549. * it will be used for both width and height. If an object is passed, the screenshot size
  34550. * will be derived from the parameters. The precision property is a multiplier allowing
  34551. * rendering at a higher or lower resolution
  34552. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34553. * Check your browser for supported MIME types
  34554. * @param samples Texture samples (default: 1)
  34555. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34556. * @param fileName A name for for the downloaded file.
  34557. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34558. * to the src parameter of an <img> to display it
  34559. */
  34560. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34561. /**
  34562. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34563. * Be aware Math.random() could cause collisions, but:
  34564. * "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"
  34565. * @returns a pseudo random id
  34566. */
  34567. static RandomId(): string;
  34568. /**
  34569. * Test if the given uri is a base64 string
  34570. * @param uri The uri to test
  34571. * @return True if the uri is a base64 string or false otherwise
  34572. */
  34573. static IsBase64(uri: string): boolean;
  34574. /**
  34575. * Decode the given base64 uri.
  34576. * @param uri The uri to decode
  34577. * @return The decoded base64 data.
  34578. */
  34579. static DecodeBase64(uri: string): ArrayBuffer;
  34580. /**
  34581. * Gets the absolute url.
  34582. * @param url the input url
  34583. * @return the absolute url
  34584. */
  34585. static GetAbsoluteUrl(url: string): string;
  34586. /**
  34587. * No log
  34588. */
  34589. static readonly NoneLogLevel: number;
  34590. /**
  34591. * Only message logs
  34592. */
  34593. static readonly MessageLogLevel: number;
  34594. /**
  34595. * Only warning logs
  34596. */
  34597. static readonly WarningLogLevel: number;
  34598. /**
  34599. * Only error logs
  34600. */
  34601. static readonly ErrorLogLevel: number;
  34602. /**
  34603. * All logs
  34604. */
  34605. static readonly AllLogLevel: number;
  34606. /**
  34607. * Gets a value indicating the number of loading errors
  34608. * @ignorenaming
  34609. */
  34610. static get errorsCount(): number;
  34611. /**
  34612. * Callback called when a new log is added
  34613. */
  34614. static OnNewCacheEntry: (entry: string) => void;
  34615. /**
  34616. * Log a message to the console
  34617. * @param message defines the message to log
  34618. */
  34619. static Log(message: string): void;
  34620. /**
  34621. * Write a warning message to the console
  34622. * @param message defines the message to log
  34623. */
  34624. static Warn(message: string): void;
  34625. /**
  34626. * Write an error message to the console
  34627. * @param message defines the message to log
  34628. */
  34629. static Error(message: string): void;
  34630. /**
  34631. * Gets current log cache (list of logs)
  34632. */
  34633. static get LogCache(): string;
  34634. /**
  34635. * Clears the log cache
  34636. */
  34637. static ClearLogCache(): void;
  34638. /**
  34639. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34640. */
  34641. static set LogLevels(level: number);
  34642. /**
  34643. * Checks if the window object exists
  34644. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34645. */
  34646. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34647. /**
  34648. * No performance log
  34649. */
  34650. static readonly PerformanceNoneLogLevel: number;
  34651. /**
  34652. * Use user marks to log performance
  34653. */
  34654. static readonly PerformanceUserMarkLogLevel: number;
  34655. /**
  34656. * Log performance to the console
  34657. */
  34658. static readonly PerformanceConsoleLogLevel: number;
  34659. private static _performance;
  34660. /**
  34661. * Sets the current performance log level
  34662. */
  34663. static set PerformanceLogLevel(level: number);
  34664. private static _StartPerformanceCounterDisabled;
  34665. private static _EndPerformanceCounterDisabled;
  34666. private static _StartUserMark;
  34667. private static _EndUserMark;
  34668. private static _StartPerformanceConsole;
  34669. private static _EndPerformanceConsole;
  34670. /**
  34671. * Starts a performance counter
  34672. */
  34673. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34674. /**
  34675. * Ends a specific performance coutner
  34676. */
  34677. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34678. /**
  34679. * Gets either window.performance.now() if supported or Date.now() else
  34680. */
  34681. static get Now(): number;
  34682. /**
  34683. * This method will return the name of the class used to create the instance of the given object.
  34684. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34685. * @param object the object to get the class name from
  34686. * @param isType defines if the object is actually a type
  34687. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34688. */
  34689. static GetClassName(object: any, isType?: boolean): string;
  34690. /**
  34691. * Gets the first element of an array satisfying a given predicate
  34692. * @param array defines the array to browse
  34693. * @param predicate defines the predicate to use
  34694. * @returns null if not found or the element
  34695. */
  34696. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34697. /**
  34698. * This method will return the name of the full name of the class, including its owning module (if any).
  34699. * 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).
  34700. * @param object the object to get the class name from
  34701. * @param isType defines if the object is actually a type
  34702. * @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.
  34703. * @ignorenaming
  34704. */
  34705. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34706. /**
  34707. * Returns a promise that resolves after the given amount of time.
  34708. * @param delay Number of milliseconds to delay
  34709. * @returns Promise that resolves after the given amount of time
  34710. */
  34711. static DelayAsync(delay: number): Promise<void>;
  34712. /**
  34713. * Utility function to detect if the current user agent is Safari
  34714. * @returns whether or not the current user agent is safari
  34715. */
  34716. static IsSafari(): boolean;
  34717. }
  34718. /**
  34719. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34720. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34721. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34722. * @param name The name of the class, case should be preserved
  34723. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34724. */
  34725. export function className(name: string, module?: string): (target: Object) => void;
  34726. /**
  34727. * An implementation of a loop for asynchronous functions.
  34728. */
  34729. export class AsyncLoop {
  34730. /**
  34731. * Defines the number of iterations for the loop
  34732. */
  34733. iterations: number;
  34734. /**
  34735. * Defines the current index of the loop.
  34736. */
  34737. index: number;
  34738. private _done;
  34739. private _fn;
  34740. private _successCallback;
  34741. /**
  34742. * Constructor.
  34743. * @param iterations the number of iterations.
  34744. * @param func the function to run each iteration
  34745. * @param successCallback the callback that will be called upon succesful execution
  34746. * @param offset starting offset.
  34747. */
  34748. constructor(
  34749. /**
  34750. * Defines the number of iterations for the loop
  34751. */
  34752. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34753. /**
  34754. * Execute the next iteration. Must be called after the last iteration was finished.
  34755. */
  34756. executeNext(): void;
  34757. /**
  34758. * Break the loop and run the success callback.
  34759. */
  34760. breakLoop(): void;
  34761. /**
  34762. * Create and run an async loop.
  34763. * @param iterations the number of iterations.
  34764. * @param fn the function to run each iteration
  34765. * @param successCallback the callback that will be called upon succesful execution
  34766. * @param offset starting offset.
  34767. * @returns the created async loop object
  34768. */
  34769. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34770. /**
  34771. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34772. * @param iterations total number of iterations
  34773. * @param syncedIterations number of synchronous iterations in each async iteration.
  34774. * @param fn the function to call each iteration.
  34775. * @param callback a success call back that will be called when iterating stops.
  34776. * @param breakFunction a break condition (optional)
  34777. * @param timeout timeout settings for the setTimeout function. default - 0.
  34778. * @returns the created async loop object
  34779. */
  34780. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34781. }
  34782. }
  34783. declare module BABYLON {
  34784. /**
  34785. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34786. * The underlying implementation relies on an associative array to ensure the best performances.
  34787. * The value can be anything including 'null' but except 'undefined'
  34788. */
  34789. export class StringDictionary<T> {
  34790. /**
  34791. * This will clear this dictionary and copy the content from the 'source' one.
  34792. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34793. * @param source the dictionary to take the content from and copy to this dictionary
  34794. */
  34795. copyFrom(source: StringDictionary<T>): void;
  34796. /**
  34797. * Get a value based from its key
  34798. * @param key the given key to get the matching value from
  34799. * @return the value if found, otherwise undefined is returned
  34800. */
  34801. get(key: string): T | undefined;
  34802. /**
  34803. * Get a value from its key or add it if it doesn't exist.
  34804. * This method will ensure you that a given key/data will be present in the dictionary.
  34805. * @param key the given key to get the matching value from
  34806. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34807. * The factory will only be invoked if there's no data for the given key.
  34808. * @return the value corresponding to the key.
  34809. */
  34810. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34811. /**
  34812. * Get a value from its key if present in the dictionary otherwise add it
  34813. * @param key the key to get the value from
  34814. * @param val if there's no such key/value pair in the dictionary add it with this value
  34815. * @return the value corresponding to the key
  34816. */
  34817. getOrAdd(key: string, val: T): T;
  34818. /**
  34819. * Check if there's a given key in the dictionary
  34820. * @param key the key to check for
  34821. * @return true if the key is present, false otherwise
  34822. */
  34823. contains(key: string): boolean;
  34824. /**
  34825. * Add a new key and its corresponding value
  34826. * @param key the key to add
  34827. * @param value the value corresponding to the key
  34828. * @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
  34829. */
  34830. add(key: string, value: T): boolean;
  34831. /**
  34832. * Update a specific value associated to a key
  34833. * @param key defines the key to use
  34834. * @param value defines the value to store
  34835. * @returns true if the value was updated (or false if the key was not found)
  34836. */
  34837. set(key: string, value: T): boolean;
  34838. /**
  34839. * Get the element of the given key and remove it from the dictionary
  34840. * @param key defines the key to search
  34841. * @returns the value associated with the key or null if not found
  34842. */
  34843. getAndRemove(key: string): Nullable<T>;
  34844. /**
  34845. * Remove a key/value from the dictionary.
  34846. * @param key the key to remove
  34847. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34848. */
  34849. remove(key: string): boolean;
  34850. /**
  34851. * Clear the whole content of the dictionary
  34852. */
  34853. clear(): void;
  34854. /**
  34855. * Gets the current count
  34856. */
  34857. get count(): number;
  34858. /**
  34859. * Execute a callback on each key/val of the dictionary.
  34860. * Note that you can remove any element in this dictionary in the callback implementation
  34861. * @param callback the callback to execute on a given key/value pair
  34862. */
  34863. forEach(callback: (key: string, val: T) => void): void;
  34864. /**
  34865. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34866. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34867. * Note that you can remove any element in this dictionary in the callback implementation
  34868. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34869. * @returns the first item
  34870. */
  34871. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34872. private _count;
  34873. private _data;
  34874. }
  34875. }
  34876. declare module BABYLON {
  34877. /** @hidden */
  34878. export interface ICollisionCoordinator {
  34879. createCollider(): Collider;
  34880. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34881. init(scene: Scene): void;
  34882. }
  34883. /** @hidden */
  34884. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34885. private _scene;
  34886. private _scaledPosition;
  34887. private _scaledVelocity;
  34888. private _finalPosition;
  34889. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34890. createCollider(): Collider;
  34891. init(scene: Scene): void;
  34892. private _collideWithWorld;
  34893. }
  34894. }
  34895. declare module BABYLON {
  34896. /**
  34897. * Class used to manage all inputs for the scene.
  34898. */
  34899. export class InputManager {
  34900. /** The distance in pixel that you have to move to prevent some events */
  34901. static DragMovementThreshold: number;
  34902. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34903. static LongPressDelay: number;
  34904. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34905. static DoubleClickDelay: number;
  34906. /** If you need to check double click without raising a single click at first click, enable this flag */
  34907. static ExclusiveDoubleClickMode: boolean;
  34908. private _wheelEventName;
  34909. private _onPointerMove;
  34910. private _onPointerDown;
  34911. private _onPointerUp;
  34912. private _initClickEvent;
  34913. private _initActionManager;
  34914. private _delayedSimpleClick;
  34915. private _delayedSimpleClickTimeout;
  34916. private _previousDelayedSimpleClickTimeout;
  34917. private _meshPickProceed;
  34918. private _previousButtonPressed;
  34919. private _currentPickResult;
  34920. private _previousPickResult;
  34921. private _totalPointersPressed;
  34922. private _doubleClickOccured;
  34923. private _pointerOverMesh;
  34924. private _pickedDownMesh;
  34925. private _pickedUpMesh;
  34926. private _pointerX;
  34927. private _pointerY;
  34928. private _unTranslatedPointerX;
  34929. private _unTranslatedPointerY;
  34930. private _startingPointerPosition;
  34931. private _previousStartingPointerPosition;
  34932. private _startingPointerTime;
  34933. private _previousStartingPointerTime;
  34934. private _pointerCaptures;
  34935. private _onKeyDown;
  34936. private _onKeyUp;
  34937. private _onCanvasFocusObserver;
  34938. private _onCanvasBlurObserver;
  34939. private _scene;
  34940. /**
  34941. * Creates a new InputManager
  34942. * @param scene defines the hosting scene
  34943. */
  34944. constructor(scene: Scene);
  34945. /**
  34946. * Gets the mesh that is currently under the pointer
  34947. */
  34948. get meshUnderPointer(): Nullable<AbstractMesh>;
  34949. /**
  34950. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34951. */
  34952. get unTranslatedPointer(): Vector2;
  34953. /**
  34954. * Gets or sets the current on-screen X position of the pointer
  34955. */
  34956. get pointerX(): number;
  34957. set pointerX(value: number);
  34958. /**
  34959. * Gets or sets the current on-screen Y position of the pointer
  34960. */
  34961. get pointerY(): number;
  34962. set pointerY(value: number);
  34963. private _updatePointerPosition;
  34964. private _processPointerMove;
  34965. private _setRayOnPointerInfo;
  34966. private _checkPrePointerObservable;
  34967. /**
  34968. * Use this method to simulate a pointer move on a mesh
  34969. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34970. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34971. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34972. */
  34973. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34974. /**
  34975. * Use this method to simulate a pointer down on a mesh
  34976. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34977. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34978. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34979. */
  34980. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34981. private _processPointerDown;
  34982. /** @hidden */
  34983. _isPointerSwiping(): boolean;
  34984. /**
  34985. * Use this method to simulate a pointer up on a mesh
  34986. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34987. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34988. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34989. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34990. */
  34991. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34992. private _processPointerUp;
  34993. /**
  34994. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34995. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34996. * @returns true if the pointer was captured
  34997. */
  34998. isPointerCaptured(pointerId?: number): boolean;
  34999. /**
  35000. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35001. * @param attachUp defines if you want to attach events to pointerup
  35002. * @param attachDown defines if you want to attach events to pointerdown
  35003. * @param attachMove defines if you want to attach events to pointermove
  35004. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35005. */
  35006. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35007. /**
  35008. * Detaches all event handlers
  35009. */
  35010. detachControl(): void;
  35011. /**
  35012. * Force the value of meshUnderPointer
  35013. * @param mesh defines the mesh to use
  35014. */
  35015. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35016. /**
  35017. * Gets the mesh under the pointer
  35018. * @returns a Mesh or null if no mesh is under the pointer
  35019. */
  35020. getPointerOverMesh(): Nullable<AbstractMesh>;
  35021. }
  35022. }
  35023. declare module BABYLON {
  35024. /**
  35025. * Helper class used to generate session unique ID
  35026. */
  35027. export class UniqueIdGenerator {
  35028. private static _UniqueIdCounter;
  35029. /**
  35030. * Gets an unique (relatively to the current scene) Id
  35031. */
  35032. static get UniqueId(): number;
  35033. }
  35034. }
  35035. declare module BABYLON {
  35036. /**
  35037. * This class defines the direct association between an animation and a target
  35038. */
  35039. export class TargetedAnimation {
  35040. /**
  35041. * Animation to perform
  35042. */
  35043. animation: Animation;
  35044. /**
  35045. * Target to animate
  35046. */
  35047. target: any;
  35048. /**
  35049. * Serialize the object
  35050. * @returns the JSON object representing the current entity
  35051. */
  35052. serialize(): any;
  35053. }
  35054. /**
  35055. * Use this class to create coordinated animations on multiple targets
  35056. */
  35057. export class AnimationGroup implements IDisposable {
  35058. /** The name of the animation group */
  35059. name: string;
  35060. private _scene;
  35061. private _targetedAnimations;
  35062. private _animatables;
  35063. private _from;
  35064. private _to;
  35065. private _isStarted;
  35066. private _isPaused;
  35067. private _speedRatio;
  35068. private _loopAnimation;
  35069. /**
  35070. * Gets or sets the unique id of the node
  35071. */
  35072. uniqueId: number;
  35073. /**
  35074. * This observable will notify when one animation have ended
  35075. */
  35076. onAnimationEndObservable: Observable<TargetedAnimation>;
  35077. /**
  35078. * Observer raised when one animation loops
  35079. */
  35080. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35081. /**
  35082. * Observer raised when all animations have looped
  35083. */
  35084. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35085. /**
  35086. * This observable will notify when all animations have ended.
  35087. */
  35088. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35089. /**
  35090. * This observable will notify when all animations have paused.
  35091. */
  35092. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35093. /**
  35094. * This observable will notify when all animations are playing.
  35095. */
  35096. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35097. /**
  35098. * Gets the first frame
  35099. */
  35100. get from(): number;
  35101. /**
  35102. * Gets the last frame
  35103. */
  35104. get to(): number;
  35105. /**
  35106. * Define if the animations are started
  35107. */
  35108. get isStarted(): boolean;
  35109. /**
  35110. * Gets a value indicating that the current group is playing
  35111. */
  35112. get isPlaying(): boolean;
  35113. /**
  35114. * Gets or sets the speed ratio to use for all animations
  35115. */
  35116. get speedRatio(): number;
  35117. /**
  35118. * Gets or sets the speed ratio to use for all animations
  35119. */
  35120. set speedRatio(value: number);
  35121. /**
  35122. * Gets or sets if all animations should loop or not
  35123. */
  35124. get loopAnimation(): boolean;
  35125. set loopAnimation(value: boolean);
  35126. /**
  35127. * Gets the targeted animations for this animation group
  35128. */
  35129. get targetedAnimations(): Array<TargetedAnimation>;
  35130. /**
  35131. * returning the list of animatables controlled by this animation group.
  35132. */
  35133. get animatables(): Array<Animatable>;
  35134. /**
  35135. * Instantiates a new Animation Group.
  35136. * This helps managing several animations at once.
  35137. * @see http://doc.babylonjs.com/how_to/group
  35138. * @param name Defines the name of the group
  35139. * @param scene Defines the scene the group belongs to
  35140. */
  35141. constructor(
  35142. /** The name of the animation group */
  35143. name: string, scene?: Nullable<Scene>);
  35144. /**
  35145. * Add an animation (with its target) in the group
  35146. * @param animation defines the animation we want to add
  35147. * @param target defines the target of the animation
  35148. * @returns the TargetedAnimation object
  35149. */
  35150. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35151. /**
  35152. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35153. * It can add constant keys at begin or end
  35154. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35155. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35156. * @returns the animation group
  35157. */
  35158. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35159. private _animationLoopCount;
  35160. private _animationLoopFlags;
  35161. private _processLoop;
  35162. /**
  35163. * Start all animations on given targets
  35164. * @param loop defines if animations must loop
  35165. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35166. * @param from defines the from key (optional)
  35167. * @param to defines the to key (optional)
  35168. * @returns the current animation group
  35169. */
  35170. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35171. /**
  35172. * Pause all animations
  35173. * @returns the animation group
  35174. */
  35175. pause(): AnimationGroup;
  35176. /**
  35177. * Play all animations to initial state
  35178. * This function will start() the animations if they were not started or will restart() them if they were paused
  35179. * @param loop defines if animations must loop
  35180. * @returns the animation group
  35181. */
  35182. play(loop?: boolean): AnimationGroup;
  35183. /**
  35184. * Reset all animations to initial state
  35185. * @returns the animation group
  35186. */
  35187. reset(): AnimationGroup;
  35188. /**
  35189. * Restart animations from key 0
  35190. * @returns the animation group
  35191. */
  35192. restart(): AnimationGroup;
  35193. /**
  35194. * Stop all animations
  35195. * @returns the animation group
  35196. */
  35197. stop(): AnimationGroup;
  35198. /**
  35199. * Set animation weight for all animatables
  35200. * @param weight defines the weight to use
  35201. * @return the animationGroup
  35202. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35203. */
  35204. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35205. /**
  35206. * Synchronize and normalize all animatables with a source animatable
  35207. * @param root defines the root animatable to synchronize with
  35208. * @return the animationGroup
  35209. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35210. */
  35211. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35212. /**
  35213. * Goes to a specific frame in this animation group
  35214. * @param frame the frame number to go to
  35215. * @return the animationGroup
  35216. */
  35217. goToFrame(frame: number): AnimationGroup;
  35218. /**
  35219. * Dispose all associated resources
  35220. */
  35221. dispose(): void;
  35222. private _checkAnimationGroupEnded;
  35223. /**
  35224. * Clone the current animation group and returns a copy
  35225. * @param newName defines the name of the new group
  35226. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35227. * @returns the new aniamtion group
  35228. */
  35229. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35230. /**
  35231. * Serializes the animationGroup to an object
  35232. * @returns Serialized object
  35233. */
  35234. serialize(): any;
  35235. /**
  35236. * Returns a new AnimationGroup object parsed from the source provided.
  35237. * @param parsedAnimationGroup defines the source
  35238. * @param scene defines the scene that will receive the animationGroup
  35239. * @returns a new AnimationGroup
  35240. */
  35241. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35242. /**
  35243. * Returns the string "AnimationGroup"
  35244. * @returns "AnimationGroup"
  35245. */
  35246. getClassName(): string;
  35247. /**
  35248. * Creates a detailled string about the object
  35249. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35250. * @returns a string representing the object
  35251. */
  35252. toString(fullDetails?: boolean): string;
  35253. }
  35254. }
  35255. declare module BABYLON {
  35256. /**
  35257. * Define an interface for all classes that will hold resources
  35258. */
  35259. export interface IDisposable {
  35260. /**
  35261. * Releases all held resources
  35262. */
  35263. dispose(): void;
  35264. }
  35265. /** Interface defining initialization parameters for Scene class */
  35266. export interface SceneOptions {
  35267. /**
  35268. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35269. * It will improve performance when the number of geometries becomes important.
  35270. */
  35271. useGeometryUniqueIdsMap?: boolean;
  35272. /**
  35273. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35274. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35275. */
  35276. useMaterialMeshMap?: boolean;
  35277. /**
  35278. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35279. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35280. */
  35281. useClonedMeshMap?: boolean;
  35282. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35283. virtual?: boolean;
  35284. }
  35285. /**
  35286. * Represents a scene to be rendered by the engine.
  35287. * @see http://doc.babylonjs.com/features/scene
  35288. */
  35289. export class Scene extends AbstractScene implements IAnimatable {
  35290. /** The fog is deactivated */
  35291. static readonly FOGMODE_NONE: number;
  35292. /** The fog density is following an exponential function */
  35293. static readonly FOGMODE_EXP: number;
  35294. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35295. static readonly FOGMODE_EXP2: number;
  35296. /** The fog density is following a linear function. */
  35297. static readonly FOGMODE_LINEAR: number;
  35298. /**
  35299. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35300. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35301. */
  35302. static MinDeltaTime: number;
  35303. /**
  35304. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35306. */
  35307. static MaxDeltaTime: number;
  35308. /**
  35309. * Factory used to create the default material.
  35310. * @param name The name of the material to create
  35311. * @param scene The scene to create the material for
  35312. * @returns The default material
  35313. */
  35314. static DefaultMaterialFactory(scene: Scene): Material;
  35315. /**
  35316. * Factory used to create the a collision coordinator.
  35317. * @returns The collision coordinator
  35318. */
  35319. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35320. /** @hidden */
  35321. _inputManager: InputManager;
  35322. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35323. cameraToUseForPointers: Nullable<Camera>;
  35324. /** @hidden */
  35325. readonly _isScene: boolean;
  35326. /** @hidden */
  35327. _blockEntityCollection: boolean;
  35328. /**
  35329. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35330. */
  35331. autoClear: boolean;
  35332. /**
  35333. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35334. */
  35335. autoClearDepthAndStencil: boolean;
  35336. /**
  35337. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35338. */
  35339. clearColor: Color4;
  35340. /**
  35341. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35342. */
  35343. ambientColor: Color3;
  35344. /**
  35345. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35346. * It should only be one of the following (if not the default embedded one):
  35347. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35348. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35349. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35350. * The material properties need to be setup according to the type of texture in use.
  35351. */
  35352. environmentBRDFTexture: BaseTexture;
  35353. /** @hidden */
  35354. protected _environmentTexture: Nullable<BaseTexture>;
  35355. /**
  35356. * Texture used in all pbr material as the reflection texture.
  35357. * As in the majority of the scene they are the same (exception for multi room and so on),
  35358. * this is easier to reference from here than from all the materials.
  35359. */
  35360. get environmentTexture(): Nullable<BaseTexture>;
  35361. /**
  35362. * Texture used in all pbr material as the reflection texture.
  35363. * As in the majority of the scene they are the same (exception for multi room and so on),
  35364. * this is easier to set here than in all the materials.
  35365. */
  35366. set environmentTexture(value: Nullable<BaseTexture>);
  35367. /** @hidden */
  35368. protected _environmentIntensity: number;
  35369. /**
  35370. * Intensity of the environment in all pbr material.
  35371. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35372. * As in the majority of the scene they are the same (exception for multi room and so on),
  35373. * this is easier to reference from here than from all the materials.
  35374. */
  35375. get environmentIntensity(): number;
  35376. /**
  35377. * Intensity of the environment in all pbr material.
  35378. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35379. * As in the majority of the scene they are the same (exception for multi room and so on),
  35380. * this is easier to set here than in all the materials.
  35381. */
  35382. set environmentIntensity(value: number);
  35383. /** @hidden */
  35384. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35385. /**
  35386. * Default image processing configuration used either in the rendering
  35387. * Forward main pass or through the imageProcessingPostProcess if present.
  35388. * As in the majority of the scene they are the same (exception for multi camera),
  35389. * this is easier to reference from here than from all the materials and post process.
  35390. *
  35391. * No setter as we it is a shared configuration, you can set the values instead.
  35392. */
  35393. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35394. private _forceWireframe;
  35395. /**
  35396. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35397. */
  35398. set forceWireframe(value: boolean);
  35399. get forceWireframe(): boolean;
  35400. private _skipFrustumClipping;
  35401. /**
  35402. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35403. */
  35404. set skipFrustumClipping(value: boolean);
  35405. get skipFrustumClipping(): boolean;
  35406. private _forcePointsCloud;
  35407. /**
  35408. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35409. */
  35410. set forcePointsCloud(value: boolean);
  35411. get forcePointsCloud(): boolean;
  35412. /**
  35413. * Gets or sets the active clipplane 1
  35414. */
  35415. clipPlane: Nullable<Plane>;
  35416. /**
  35417. * Gets or sets the active clipplane 2
  35418. */
  35419. clipPlane2: Nullable<Plane>;
  35420. /**
  35421. * Gets or sets the active clipplane 3
  35422. */
  35423. clipPlane3: Nullable<Plane>;
  35424. /**
  35425. * Gets or sets the active clipplane 4
  35426. */
  35427. clipPlane4: Nullable<Plane>;
  35428. /**
  35429. * Gets or sets the active clipplane 5
  35430. */
  35431. clipPlane5: Nullable<Plane>;
  35432. /**
  35433. * Gets or sets the active clipplane 6
  35434. */
  35435. clipPlane6: Nullable<Plane>;
  35436. /**
  35437. * Gets or sets a boolean indicating if animations are enabled
  35438. */
  35439. animationsEnabled: boolean;
  35440. private _animationPropertiesOverride;
  35441. /**
  35442. * Gets or sets the animation properties override
  35443. */
  35444. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35445. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35446. /**
  35447. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35448. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35449. */
  35450. useConstantAnimationDeltaTime: boolean;
  35451. /**
  35452. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35453. * Please note that it requires to run a ray cast through the scene on every frame
  35454. */
  35455. constantlyUpdateMeshUnderPointer: boolean;
  35456. /**
  35457. * Defines the HTML cursor to use when hovering over interactive elements
  35458. */
  35459. hoverCursor: string;
  35460. /**
  35461. * Defines the HTML default cursor to use (empty by default)
  35462. */
  35463. defaultCursor: string;
  35464. /**
  35465. * Defines whether cursors are handled by the scene.
  35466. */
  35467. doNotHandleCursors: boolean;
  35468. /**
  35469. * This is used to call preventDefault() on pointer down
  35470. * in order to block unwanted artifacts like system double clicks
  35471. */
  35472. preventDefaultOnPointerDown: boolean;
  35473. /**
  35474. * This is used to call preventDefault() on pointer up
  35475. * in order to block unwanted artifacts like system double clicks
  35476. */
  35477. preventDefaultOnPointerUp: boolean;
  35478. /**
  35479. * Gets or sets user defined metadata
  35480. */
  35481. metadata: any;
  35482. /**
  35483. * For internal use only. Please do not use.
  35484. */
  35485. reservedDataStore: any;
  35486. /**
  35487. * Gets the name of the plugin used to load this scene (null by default)
  35488. */
  35489. loadingPluginName: string;
  35490. /**
  35491. * Use this array to add regular expressions used to disable offline support for specific urls
  35492. */
  35493. disableOfflineSupportExceptionRules: RegExp[];
  35494. /**
  35495. * An event triggered when the scene is disposed.
  35496. */
  35497. onDisposeObservable: Observable<Scene>;
  35498. private _onDisposeObserver;
  35499. /** Sets a function to be executed when this scene is disposed. */
  35500. set onDispose(callback: () => void);
  35501. /**
  35502. * An event triggered before rendering the scene (right after animations and physics)
  35503. */
  35504. onBeforeRenderObservable: Observable<Scene>;
  35505. private _onBeforeRenderObserver;
  35506. /** Sets a function to be executed before rendering this scene */
  35507. set beforeRender(callback: Nullable<() => void>);
  35508. /**
  35509. * An event triggered after rendering the scene
  35510. */
  35511. onAfterRenderObservable: Observable<Scene>;
  35512. /**
  35513. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35514. */
  35515. onAfterRenderCameraObservable: Observable<Camera>;
  35516. private _onAfterRenderObserver;
  35517. /** Sets a function to be executed after rendering this scene */
  35518. set afterRender(callback: Nullable<() => void>);
  35519. /**
  35520. * An event triggered before animating the scene
  35521. */
  35522. onBeforeAnimationsObservable: Observable<Scene>;
  35523. /**
  35524. * An event triggered after animations processing
  35525. */
  35526. onAfterAnimationsObservable: Observable<Scene>;
  35527. /**
  35528. * An event triggered before draw calls are ready to be sent
  35529. */
  35530. onBeforeDrawPhaseObservable: Observable<Scene>;
  35531. /**
  35532. * An event triggered after draw calls have been sent
  35533. */
  35534. onAfterDrawPhaseObservable: Observable<Scene>;
  35535. /**
  35536. * An event triggered when the scene is ready
  35537. */
  35538. onReadyObservable: Observable<Scene>;
  35539. /**
  35540. * An event triggered before rendering a camera
  35541. */
  35542. onBeforeCameraRenderObservable: Observable<Camera>;
  35543. private _onBeforeCameraRenderObserver;
  35544. /** Sets a function to be executed before rendering a camera*/
  35545. set beforeCameraRender(callback: () => void);
  35546. /**
  35547. * An event triggered after rendering a camera
  35548. */
  35549. onAfterCameraRenderObservable: Observable<Camera>;
  35550. private _onAfterCameraRenderObserver;
  35551. /** Sets a function to be executed after rendering a camera*/
  35552. set afterCameraRender(callback: () => void);
  35553. /**
  35554. * An event triggered when active meshes evaluation is about to start
  35555. */
  35556. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35557. /**
  35558. * An event triggered when active meshes evaluation is done
  35559. */
  35560. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35561. /**
  35562. * An event triggered when particles rendering is about to start
  35563. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35564. */
  35565. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35566. /**
  35567. * An event triggered when particles rendering is done
  35568. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35569. */
  35570. onAfterParticlesRenderingObservable: Observable<Scene>;
  35571. /**
  35572. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35573. */
  35574. onDataLoadedObservable: Observable<Scene>;
  35575. /**
  35576. * An event triggered when a camera is created
  35577. */
  35578. onNewCameraAddedObservable: Observable<Camera>;
  35579. /**
  35580. * An event triggered when a camera is removed
  35581. */
  35582. onCameraRemovedObservable: Observable<Camera>;
  35583. /**
  35584. * An event triggered when a light is created
  35585. */
  35586. onNewLightAddedObservable: Observable<Light>;
  35587. /**
  35588. * An event triggered when a light is removed
  35589. */
  35590. onLightRemovedObservable: Observable<Light>;
  35591. /**
  35592. * An event triggered when a geometry is created
  35593. */
  35594. onNewGeometryAddedObservable: Observable<Geometry>;
  35595. /**
  35596. * An event triggered when a geometry is removed
  35597. */
  35598. onGeometryRemovedObservable: Observable<Geometry>;
  35599. /**
  35600. * An event triggered when a transform node is created
  35601. */
  35602. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35603. /**
  35604. * An event triggered when a transform node is removed
  35605. */
  35606. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35607. /**
  35608. * An event triggered when a mesh is created
  35609. */
  35610. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35611. /**
  35612. * An event triggered when a mesh is removed
  35613. */
  35614. onMeshRemovedObservable: Observable<AbstractMesh>;
  35615. /**
  35616. * An event triggered when a skeleton is created
  35617. */
  35618. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35619. /**
  35620. * An event triggered when a skeleton is removed
  35621. */
  35622. onSkeletonRemovedObservable: Observable<Skeleton>;
  35623. /**
  35624. * An event triggered when a material is created
  35625. */
  35626. onNewMaterialAddedObservable: Observable<Material>;
  35627. /**
  35628. * An event triggered when a material is removed
  35629. */
  35630. onMaterialRemovedObservable: Observable<Material>;
  35631. /**
  35632. * An event triggered when a texture is created
  35633. */
  35634. onNewTextureAddedObservable: Observable<BaseTexture>;
  35635. /**
  35636. * An event triggered when a texture is removed
  35637. */
  35638. onTextureRemovedObservable: Observable<BaseTexture>;
  35639. /**
  35640. * An event triggered when render targets are about to be rendered
  35641. * Can happen multiple times per frame.
  35642. */
  35643. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35644. /**
  35645. * An event triggered when render targets were rendered.
  35646. * Can happen multiple times per frame.
  35647. */
  35648. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35649. /**
  35650. * An event triggered before calculating deterministic simulation step
  35651. */
  35652. onBeforeStepObservable: Observable<Scene>;
  35653. /**
  35654. * An event triggered after calculating deterministic simulation step
  35655. */
  35656. onAfterStepObservable: Observable<Scene>;
  35657. /**
  35658. * An event triggered when the activeCamera property is updated
  35659. */
  35660. onActiveCameraChanged: Observable<Scene>;
  35661. /**
  35662. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35663. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35664. * 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)
  35665. */
  35666. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35667. /**
  35668. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35669. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35670. * 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)
  35671. */
  35672. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35673. /**
  35674. * This Observable will when a mesh has been imported into the scene.
  35675. */
  35676. onMeshImportedObservable: Observable<AbstractMesh>;
  35677. /**
  35678. * This Observable will when an animation file has been imported into the scene.
  35679. */
  35680. onAnimationFileImportedObservable: Observable<Scene>;
  35681. /**
  35682. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35683. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35684. */
  35685. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35686. /** @hidden */
  35687. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35688. /**
  35689. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35690. */
  35691. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35692. /**
  35693. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35694. */
  35695. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35696. /**
  35697. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35698. */
  35699. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35700. /** Callback called when a pointer move is detected */
  35701. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35702. /** Callback called when a pointer down is detected */
  35703. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35704. /** Callback called when a pointer up is detected */
  35705. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35706. /** Callback called when a pointer pick is detected */
  35707. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35708. /**
  35709. * 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).
  35710. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35711. */
  35712. onPrePointerObservable: Observable<PointerInfoPre>;
  35713. /**
  35714. * Observable event triggered each time an input event is received from the rendering canvas
  35715. */
  35716. onPointerObservable: Observable<PointerInfo>;
  35717. /**
  35718. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35719. */
  35720. get unTranslatedPointer(): Vector2;
  35721. /**
  35722. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35723. */
  35724. static get DragMovementThreshold(): number;
  35725. static set DragMovementThreshold(value: number);
  35726. /**
  35727. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35728. */
  35729. static get LongPressDelay(): number;
  35730. static set LongPressDelay(value: number);
  35731. /**
  35732. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35733. */
  35734. static get DoubleClickDelay(): number;
  35735. static set DoubleClickDelay(value: number);
  35736. /** If you need to check double click without raising a single click at first click, enable this flag */
  35737. static get ExclusiveDoubleClickMode(): boolean;
  35738. static set ExclusiveDoubleClickMode(value: boolean);
  35739. /** @hidden */
  35740. _mirroredCameraPosition: Nullable<Vector3>;
  35741. /**
  35742. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35743. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35744. */
  35745. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35746. /**
  35747. * Observable event triggered each time an keyboard event is received from the hosting window
  35748. */
  35749. onKeyboardObservable: Observable<KeyboardInfo>;
  35750. private _useRightHandedSystem;
  35751. /**
  35752. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35753. */
  35754. set useRightHandedSystem(value: boolean);
  35755. get useRightHandedSystem(): boolean;
  35756. private _timeAccumulator;
  35757. private _currentStepId;
  35758. private _currentInternalStep;
  35759. /**
  35760. * Sets the step Id used by deterministic lock step
  35761. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35762. * @param newStepId defines the step Id
  35763. */
  35764. setStepId(newStepId: number): void;
  35765. /**
  35766. * Gets the step Id used by deterministic lock step
  35767. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35768. * @returns the step Id
  35769. */
  35770. getStepId(): number;
  35771. /**
  35772. * Gets the internal step used by deterministic lock step
  35773. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35774. * @returns the internal step
  35775. */
  35776. getInternalStep(): number;
  35777. private _fogEnabled;
  35778. /**
  35779. * Gets or sets a boolean indicating if fog is enabled on this scene
  35780. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35781. * (Default is true)
  35782. */
  35783. set fogEnabled(value: boolean);
  35784. get fogEnabled(): boolean;
  35785. private _fogMode;
  35786. /**
  35787. * Gets or sets the fog mode to use
  35788. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35789. * | mode | value |
  35790. * | --- | --- |
  35791. * | FOGMODE_NONE | 0 |
  35792. * | FOGMODE_EXP | 1 |
  35793. * | FOGMODE_EXP2 | 2 |
  35794. * | FOGMODE_LINEAR | 3 |
  35795. */
  35796. set fogMode(value: number);
  35797. get fogMode(): number;
  35798. /**
  35799. * Gets or sets the fog color to use
  35800. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35801. * (Default is Color3(0.2, 0.2, 0.3))
  35802. */
  35803. fogColor: Color3;
  35804. /**
  35805. * Gets or sets the fog density to use
  35806. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35807. * (Default is 0.1)
  35808. */
  35809. fogDensity: number;
  35810. /**
  35811. * Gets or sets the fog start distance to use
  35812. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35813. * (Default is 0)
  35814. */
  35815. fogStart: number;
  35816. /**
  35817. * Gets or sets the fog end distance to use
  35818. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35819. * (Default is 1000)
  35820. */
  35821. fogEnd: number;
  35822. private _shadowsEnabled;
  35823. /**
  35824. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35825. */
  35826. set shadowsEnabled(value: boolean);
  35827. get shadowsEnabled(): boolean;
  35828. private _lightsEnabled;
  35829. /**
  35830. * Gets or sets a boolean indicating if lights are enabled on this scene
  35831. */
  35832. set lightsEnabled(value: boolean);
  35833. get lightsEnabled(): boolean;
  35834. /** All of the active cameras added to this scene. */
  35835. activeCameras: Camera[];
  35836. /** @hidden */
  35837. _activeCamera: Nullable<Camera>;
  35838. /** Gets or sets the current active camera */
  35839. get activeCamera(): Nullable<Camera>;
  35840. set activeCamera(value: Nullable<Camera>);
  35841. private _defaultMaterial;
  35842. /** The default material used on meshes when no material is affected */
  35843. get defaultMaterial(): Material;
  35844. /** The default material used on meshes when no material is affected */
  35845. set defaultMaterial(value: Material);
  35846. private _texturesEnabled;
  35847. /**
  35848. * Gets or sets a boolean indicating if textures are enabled on this scene
  35849. */
  35850. set texturesEnabled(value: boolean);
  35851. get texturesEnabled(): boolean;
  35852. /**
  35853. * Gets or sets a boolean indicating if particles are enabled on this scene
  35854. */
  35855. particlesEnabled: boolean;
  35856. /**
  35857. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35858. */
  35859. spritesEnabled: boolean;
  35860. private _skeletonsEnabled;
  35861. /**
  35862. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35863. */
  35864. set skeletonsEnabled(value: boolean);
  35865. get skeletonsEnabled(): boolean;
  35866. /**
  35867. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35868. */
  35869. lensFlaresEnabled: boolean;
  35870. /**
  35871. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35872. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35873. */
  35874. collisionsEnabled: boolean;
  35875. private _collisionCoordinator;
  35876. /** @hidden */
  35877. get collisionCoordinator(): ICollisionCoordinator;
  35878. /**
  35879. * Defines the gravity applied to this scene (used only for collisions)
  35880. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35881. */
  35882. gravity: Vector3;
  35883. /**
  35884. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35885. */
  35886. postProcessesEnabled: boolean;
  35887. /**
  35888. * The list of postprocesses added to the scene
  35889. */
  35890. postProcesses: PostProcess[];
  35891. /**
  35892. * Gets the current postprocess manager
  35893. */
  35894. postProcessManager: PostProcessManager;
  35895. /**
  35896. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35897. */
  35898. renderTargetsEnabled: boolean;
  35899. /**
  35900. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35901. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35902. */
  35903. dumpNextRenderTargets: boolean;
  35904. /**
  35905. * The list of user defined render targets added to the scene
  35906. */
  35907. customRenderTargets: RenderTargetTexture[];
  35908. /**
  35909. * Defines if texture loading must be delayed
  35910. * If true, textures will only be loaded when they need to be rendered
  35911. */
  35912. useDelayedTextureLoading: boolean;
  35913. /**
  35914. * Gets the list of meshes imported to the scene through SceneLoader
  35915. */
  35916. importedMeshesFiles: String[];
  35917. /**
  35918. * Gets or sets a boolean indicating if probes are enabled on this scene
  35919. */
  35920. probesEnabled: boolean;
  35921. /**
  35922. * Gets or sets the current offline provider to use to store scene data
  35923. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35924. */
  35925. offlineProvider: IOfflineProvider;
  35926. /**
  35927. * Gets or sets the action manager associated with the scene
  35928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35929. */
  35930. actionManager: AbstractActionManager;
  35931. private _meshesForIntersections;
  35932. /**
  35933. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35934. */
  35935. proceduralTexturesEnabled: boolean;
  35936. private _engine;
  35937. private _totalVertices;
  35938. /** @hidden */
  35939. _activeIndices: PerfCounter;
  35940. /** @hidden */
  35941. _activeParticles: PerfCounter;
  35942. /** @hidden */
  35943. _activeBones: PerfCounter;
  35944. private _animationRatio;
  35945. /** @hidden */
  35946. _animationTimeLast: number;
  35947. /** @hidden */
  35948. _animationTime: number;
  35949. /**
  35950. * Gets or sets a general scale for animation speed
  35951. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35952. */
  35953. animationTimeScale: number;
  35954. /** @hidden */
  35955. _cachedMaterial: Nullable<Material>;
  35956. /** @hidden */
  35957. _cachedEffect: Nullable<Effect>;
  35958. /** @hidden */
  35959. _cachedVisibility: Nullable<number>;
  35960. private _renderId;
  35961. private _frameId;
  35962. private _executeWhenReadyTimeoutId;
  35963. private _intermediateRendering;
  35964. private _viewUpdateFlag;
  35965. private _projectionUpdateFlag;
  35966. /** @hidden */
  35967. _toBeDisposed: Nullable<IDisposable>[];
  35968. private _activeRequests;
  35969. /** @hidden */
  35970. _pendingData: any[];
  35971. private _isDisposed;
  35972. /**
  35973. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35974. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35975. */
  35976. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35977. private _activeMeshes;
  35978. private _processedMaterials;
  35979. private _renderTargets;
  35980. /** @hidden */
  35981. _activeParticleSystems: SmartArray<IParticleSystem>;
  35982. private _activeSkeletons;
  35983. private _softwareSkinnedMeshes;
  35984. private _renderingManager;
  35985. /** @hidden */
  35986. _activeAnimatables: Animatable[];
  35987. private _transformMatrix;
  35988. private _sceneUbo;
  35989. /** @hidden */
  35990. _viewMatrix: Matrix;
  35991. private _projectionMatrix;
  35992. /** @hidden */
  35993. _forcedViewPosition: Nullable<Vector3>;
  35994. /** @hidden */
  35995. _frustumPlanes: Plane[];
  35996. /**
  35997. * Gets the list of frustum planes (built from the active camera)
  35998. */
  35999. get frustumPlanes(): Plane[];
  36000. /**
  36001. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36002. * This is useful if there are more lights that the maximum simulteanous authorized
  36003. */
  36004. requireLightSorting: boolean;
  36005. /** @hidden */
  36006. readonly useMaterialMeshMap: boolean;
  36007. /** @hidden */
  36008. readonly useClonedMeshMap: boolean;
  36009. private _externalData;
  36010. private _uid;
  36011. /**
  36012. * @hidden
  36013. * Backing store of defined scene components.
  36014. */
  36015. _components: ISceneComponent[];
  36016. /**
  36017. * @hidden
  36018. * Backing store of defined scene components.
  36019. */
  36020. _serializableComponents: ISceneSerializableComponent[];
  36021. /**
  36022. * List of components to register on the next registration step.
  36023. */
  36024. private _transientComponents;
  36025. /**
  36026. * Registers the transient components if needed.
  36027. */
  36028. private _registerTransientComponents;
  36029. /**
  36030. * @hidden
  36031. * Add a component to the scene.
  36032. * Note that the ccomponent could be registered on th next frame if this is called after
  36033. * the register component stage.
  36034. * @param component Defines the component to add to the scene
  36035. */
  36036. _addComponent(component: ISceneComponent): void;
  36037. /**
  36038. * @hidden
  36039. * Gets a component from the scene.
  36040. * @param name defines the name of the component to retrieve
  36041. * @returns the component or null if not present
  36042. */
  36043. _getComponent(name: string): Nullable<ISceneComponent>;
  36044. /**
  36045. * @hidden
  36046. * Defines the actions happening before camera updates.
  36047. */
  36048. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36049. /**
  36050. * @hidden
  36051. * Defines the actions happening before clear the canvas.
  36052. */
  36053. _beforeClearStage: Stage<SimpleStageAction>;
  36054. /**
  36055. * @hidden
  36056. * Defines the actions when collecting render targets for the frame.
  36057. */
  36058. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36059. /**
  36060. * @hidden
  36061. * Defines the actions happening for one camera in the frame.
  36062. */
  36063. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36064. /**
  36065. * @hidden
  36066. * Defines the actions happening during the per mesh ready checks.
  36067. */
  36068. _isReadyForMeshStage: Stage<MeshStageAction>;
  36069. /**
  36070. * @hidden
  36071. * Defines the actions happening before evaluate active mesh checks.
  36072. */
  36073. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36074. /**
  36075. * @hidden
  36076. * Defines the actions happening during the evaluate sub mesh checks.
  36077. */
  36078. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36079. /**
  36080. * @hidden
  36081. * Defines the actions happening during the active mesh stage.
  36082. */
  36083. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36084. /**
  36085. * @hidden
  36086. * Defines the actions happening during the per camera render target step.
  36087. */
  36088. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36089. /**
  36090. * @hidden
  36091. * Defines the actions happening just before the active camera is drawing.
  36092. */
  36093. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36094. /**
  36095. * @hidden
  36096. * Defines the actions happening just before a render target is drawing.
  36097. */
  36098. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36099. /**
  36100. * @hidden
  36101. * Defines the actions happening just before a rendering group is drawing.
  36102. */
  36103. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36104. /**
  36105. * @hidden
  36106. * Defines the actions happening just before a mesh is drawing.
  36107. */
  36108. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36109. /**
  36110. * @hidden
  36111. * Defines the actions happening just after a mesh has been drawn.
  36112. */
  36113. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36114. /**
  36115. * @hidden
  36116. * Defines the actions happening just after a rendering group has been drawn.
  36117. */
  36118. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36119. /**
  36120. * @hidden
  36121. * Defines the actions happening just after the active camera has been drawn.
  36122. */
  36123. _afterCameraDrawStage: Stage<CameraStageAction>;
  36124. /**
  36125. * @hidden
  36126. * Defines the actions happening just after a render target has been drawn.
  36127. */
  36128. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36129. /**
  36130. * @hidden
  36131. * Defines the actions happening just after rendering all cameras and computing intersections.
  36132. */
  36133. _afterRenderStage: Stage<SimpleStageAction>;
  36134. /**
  36135. * @hidden
  36136. * Defines the actions happening when a pointer move event happens.
  36137. */
  36138. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36139. /**
  36140. * @hidden
  36141. * Defines the actions happening when a pointer down event happens.
  36142. */
  36143. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36144. /**
  36145. * @hidden
  36146. * Defines the actions happening when a pointer up event happens.
  36147. */
  36148. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36149. /**
  36150. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36151. */
  36152. private geometriesByUniqueId;
  36153. /**
  36154. * Creates a new Scene
  36155. * @param engine defines the engine to use to render this scene
  36156. * @param options defines the scene options
  36157. */
  36158. constructor(engine: Engine, options?: SceneOptions);
  36159. /**
  36160. * Gets a string idenfifying the name of the class
  36161. * @returns "Scene" string
  36162. */
  36163. getClassName(): string;
  36164. private _defaultMeshCandidates;
  36165. /**
  36166. * @hidden
  36167. */
  36168. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36169. private _defaultSubMeshCandidates;
  36170. /**
  36171. * @hidden
  36172. */
  36173. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36174. /**
  36175. * Sets the default candidate providers for the scene.
  36176. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36177. * and getCollidingSubMeshCandidates to their default function
  36178. */
  36179. setDefaultCandidateProviders(): void;
  36180. /**
  36181. * Gets the mesh that is currently under the pointer
  36182. */
  36183. get meshUnderPointer(): Nullable<AbstractMesh>;
  36184. /**
  36185. * Gets or sets the current on-screen X position of the pointer
  36186. */
  36187. get pointerX(): number;
  36188. set pointerX(value: number);
  36189. /**
  36190. * Gets or sets the current on-screen Y position of the pointer
  36191. */
  36192. get pointerY(): number;
  36193. set pointerY(value: number);
  36194. /**
  36195. * Gets the cached material (ie. the latest rendered one)
  36196. * @returns the cached material
  36197. */
  36198. getCachedMaterial(): Nullable<Material>;
  36199. /**
  36200. * Gets the cached effect (ie. the latest rendered one)
  36201. * @returns the cached effect
  36202. */
  36203. getCachedEffect(): Nullable<Effect>;
  36204. /**
  36205. * Gets the cached visibility state (ie. the latest rendered one)
  36206. * @returns the cached visibility state
  36207. */
  36208. getCachedVisibility(): Nullable<number>;
  36209. /**
  36210. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36211. * @param material defines the current material
  36212. * @param effect defines the current effect
  36213. * @param visibility defines the current visibility state
  36214. * @returns true if one parameter is not cached
  36215. */
  36216. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36217. /**
  36218. * Gets the engine associated with the scene
  36219. * @returns an Engine
  36220. */
  36221. getEngine(): Engine;
  36222. /**
  36223. * Gets the total number of vertices rendered per frame
  36224. * @returns the total number of vertices rendered per frame
  36225. */
  36226. getTotalVertices(): number;
  36227. /**
  36228. * Gets the performance counter for total vertices
  36229. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36230. */
  36231. get totalVerticesPerfCounter(): PerfCounter;
  36232. /**
  36233. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36234. * @returns the total number of active indices rendered per frame
  36235. */
  36236. getActiveIndices(): number;
  36237. /**
  36238. * Gets the performance counter for active indices
  36239. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36240. */
  36241. get totalActiveIndicesPerfCounter(): PerfCounter;
  36242. /**
  36243. * Gets the total number of active particles rendered per frame
  36244. * @returns the total number of active particles rendered per frame
  36245. */
  36246. getActiveParticles(): number;
  36247. /**
  36248. * Gets the performance counter for active particles
  36249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36250. */
  36251. get activeParticlesPerfCounter(): PerfCounter;
  36252. /**
  36253. * Gets the total number of active bones rendered per frame
  36254. * @returns the total number of active bones rendered per frame
  36255. */
  36256. getActiveBones(): number;
  36257. /**
  36258. * Gets the performance counter for active bones
  36259. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36260. */
  36261. get activeBonesPerfCounter(): PerfCounter;
  36262. /**
  36263. * Gets the array of active meshes
  36264. * @returns an array of AbstractMesh
  36265. */
  36266. getActiveMeshes(): SmartArray<AbstractMesh>;
  36267. /**
  36268. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36269. * @returns a number
  36270. */
  36271. getAnimationRatio(): number;
  36272. /**
  36273. * Gets an unique Id for the current render phase
  36274. * @returns a number
  36275. */
  36276. getRenderId(): number;
  36277. /**
  36278. * Gets an unique Id for the current frame
  36279. * @returns a number
  36280. */
  36281. getFrameId(): number;
  36282. /** Call this function if you want to manually increment the render Id*/
  36283. incrementRenderId(): void;
  36284. private _createUbo;
  36285. /**
  36286. * Use this method to simulate a pointer move on a mesh
  36287. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36288. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36289. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36290. * @returns the current scene
  36291. */
  36292. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36293. /**
  36294. * Use this method to simulate a pointer down on a mesh
  36295. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36296. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36297. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36298. * @returns the current scene
  36299. */
  36300. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36301. /**
  36302. * Use this method to simulate a pointer up on a mesh
  36303. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36304. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36305. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36306. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36307. * @returns the current scene
  36308. */
  36309. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36310. /**
  36311. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36312. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36313. * @returns true if the pointer was captured
  36314. */
  36315. isPointerCaptured(pointerId?: number): boolean;
  36316. /**
  36317. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36318. * @param attachUp defines if you want to attach events to pointerup
  36319. * @param attachDown defines if you want to attach events to pointerdown
  36320. * @param attachMove defines if you want to attach events to pointermove
  36321. */
  36322. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36323. /** Detaches all event handlers*/
  36324. detachControl(): void;
  36325. /**
  36326. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36327. * Delay loaded resources are not taking in account
  36328. * @return true if all required resources are ready
  36329. */
  36330. isReady(): boolean;
  36331. /** Resets all cached information relative to material (including effect and visibility) */
  36332. resetCachedMaterial(): void;
  36333. /**
  36334. * Registers a function to be called before every frame render
  36335. * @param func defines the function to register
  36336. */
  36337. registerBeforeRender(func: () => void): void;
  36338. /**
  36339. * Unregisters a function called before every frame render
  36340. * @param func defines the function to unregister
  36341. */
  36342. unregisterBeforeRender(func: () => void): void;
  36343. /**
  36344. * Registers a function to be called after every frame render
  36345. * @param func defines the function to register
  36346. */
  36347. registerAfterRender(func: () => void): void;
  36348. /**
  36349. * Unregisters a function called after every frame render
  36350. * @param func defines the function to unregister
  36351. */
  36352. unregisterAfterRender(func: () => void): void;
  36353. private _executeOnceBeforeRender;
  36354. /**
  36355. * The provided function will run before render once and will be disposed afterwards.
  36356. * A timeout delay can be provided so that the function will be executed in N ms.
  36357. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36358. * @param func The function to be executed.
  36359. * @param timeout optional delay in ms
  36360. */
  36361. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36362. /** @hidden */
  36363. _addPendingData(data: any): void;
  36364. /** @hidden */
  36365. _removePendingData(data: any): void;
  36366. /**
  36367. * Returns the number of items waiting to be loaded
  36368. * @returns the number of items waiting to be loaded
  36369. */
  36370. getWaitingItemsCount(): number;
  36371. /**
  36372. * Returns a boolean indicating if the scene is still loading data
  36373. */
  36374. get isLoading(): boolean;
  36375. /**
  36376. * Registers a function to be executed when the scene is ready
  36377. * @param {Function} func - the function to be executed
  36378. */
  36379. executeWhenReady(func: () => void): void;
  36380. /**
  36381. * Returns a promise that resolves when the scene is ready
  36382. * @returns A promise that resolves when the scene is ready
  36383. */
  36384. whenReadyAsync(): Promise<void>;
  36385. /** @hidden */
  36386. _checkIsReady(): void;
  36387. /**
  36388. * Gets all animatable attached to the scene
  36389. */
  36390. get animatables(): Animatable[];
  36391. /**
  36392. * Resets the last animation time frame.
  36393. * Useful to override when animations start running when loading a scene for the first time.
  36394. */
  36395. resetLastAnimationTimeFrame(): void;
  36396. /**
  36397. * Gets the current view matrix
  36398. * @returns a Matrix
  36399. */
  36400. getViewMatrix(): Matrix;
  36401. /**
  36402. * Gets the current projection matrix
  36403. * @returns a Matrix
  36404. */
  36405. getProjectionMatrix(): Matrix;
  36406. /**
  36407. * Gets the current transform matrix
  36408. * @returns a Matrix made of View * Projection
  36409. */
  36410. getTransformMatrix(): Matrix;
  36411. /**
  36412. * Sets the current transform matrix
  36413. * @param viewL defines the View matrix to use
  36414. * @param projectionL defines the Projection matrix to use
  36415. * @param viewR defines the right View matrix to use (if provided)
  36416. * @param projectionR defines the right Projection matrix to use (if provided)
  36417. */
  36418. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36419. /**
  36420. * Gets the uniform buffer used to store scene data
  36421. * @returns a UniformBuffer
  36422. */
  36423. getSceneUniformBuffer(): UniformBuffer;
  36424. /**
  36425. * Gets an unique (relatively to the current scene) Id
  36426. * @returns an unique number for the scene
  36427. */
  36428. getUniqueId(): number;
  36429. /**
  36430. * Add a mesh to the list of scene's meshes
  36431. * @param newMesh defines the mesh to add
  36432. * @param recursive if all child meshes should also be added to the scene
  36433. */
  36434. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36435. /**
  36436. * Remove a mesh for the list of scene's meshes
  36437. * @param toRemove defines the mesh to remove
  36438. * @param recursive if all child meshes should also be removed from the scene
  36439. * @returns the index where the mesh was in the mesh list
  36440. */
  36441. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36442. /**
  36443. * Add a transform node to the list of scene's transform nodes
  36444. * @param newTransformNode defines the transform node to add
  36445. */
  36446. addTransformNode(newTransformNode: TransformNode): void;
  36447. /**
  36448. * Remove a transform node for the list of scene's transform nodes
  36449. * @param toRemove defines the transform node to remove
  36450. * @returns the index where the transform node was in the transform node list
  36451. */
  36452. removeTransformNode(toRemove: TransformNode): number;
  36453. /**
  36454. * Remove a skeleton for the list of scene's skeletons
  36455. * @param toRemove defines the skeleton to remove
  36456. * @returns the index where the skeleton was in the skeleton list
  36457. */
  36458. removeSkeleton(toRemove: Skeleton): number;
  36459. /**
  36460. * Remove a morph target for the list of scene's morph targets
  36461. * @param toRemove defines the morph target to remove
  36462. * @returns the index where the morph target was in the morph target list
  36463. */
  36464. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36465. /**
  36466. * Remove a light for the list of scene's lights
  36467. * @param toRemove defines the light to remove
  36468. * @returns the index where the light was in the light list
  36469. */
  36470. removeLight(toRemove: Light): number;
  36471. /**
  36472. * Remove a camera for the list of scene's cameras
  36473. * @param toRemove defines the camera to remove
  36474. * @returns the index where the camera was in the camera list
  36475. */
  36476. removeCamera(toRemove: Camera): number;
  36477. /**
  36478. * Remove a particle system for the list of scene's particle systems
  36479. * @param toRemove defines the particle system to remove
  36480. * @returns the index where the particle system was in the particle system list
  36481. */
  36482. removeParticleSystem(toRemove: IParticleSystem): number;
  36483. /**
  36484. * Remove a animation for the list of scene's animations
  36485. * @param toRemove defines the animation to remove
  36486. * @returns the index where the animation was in the animation list
  36487. */
  36488. removeAnimation(toRemove: Animation): number;
  36489. /**
  36490. * Will stop the animation of the given target
  36491. * @param target - the target
  36492. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36493. * @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)
  36494. */
  36495. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36496. /**
  36497. * Removes the given animation group from this scene.
  36498. * @param toRemove The animation group to remove
  36499. * @returns The index of the removed animation group
  36500. */
  36501. removeAnimationGroup(toRemove: AnimationGroup): number;
  36502. /**
  36503. * Removes the given multi-material from this scene.
  36504. * @param toRemove The multi-material to remove
  36505. * @returns The index of the removed multi-material
  36506. */
  36507. removeMultiMaterial(toRemove: MultiMaterial): number;
  36508. /**
  36509. * Removes the given material from this scene.
  36510. * @param toRemove The material to remove
  36511. * @returns The index of the removed material
  36512. */
  36513. removeMaterial(toRemove: Material): number;
  36514. /**
  36515. * Removes the given action manager from this scene.
  36516. * @param toRemove The action manager to remove
  36517. * @returns The index of the removed action manager
  36518. */
  36519. removeActionManager(toRemove: AbstractActionManager): number;
  36520. /**
  36521. * Removes the given texture from this scene.
  36522. * @param toRemove The texture to remove
  36523. * @returns The index of the removed texture
  36524. */
  36525. removeTexture(toRemove: BaseTexture): number;
  36526. /**
  36527. * Adds the given light to this scene
  36528. * @param newLight The light to add
  36529. */
  36530. addLight(newLight: Light): void;
  36531. /**
  36532. * Sorts the list list based on light priorities
  36533. */
  36534. sortLightsByPriority(): void;
  36535. /**
  36536. * Adds the given camera to this scene
  36537. * @param newCamera The camera to add
  36538. */
  36539. addCamera(newCamera: Camera): void;
  36540. /**
  36541. * Adds the given skeleton to this scene
  36542. * @param newSkeleton The skeleton to add
  36543. */
  36544. addSkeleton(newSkeleton: Skeleton): void;
  36545. /**
  36546. * Adds the given particle system to this scene
  36547. * @param newParticleSystem The particle system to add
  36548. */
  36549. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36550. /**
  36551. * Adds the given animation to this scene
  36552. * @param newAnimation The animation to add
  36553. */
  36554. addAnimation(newAnimation: Animation): void;
  36555. /**
  36556. * Adds the given animation group to this scene.
  36557. * @param newAnimationGroup The animation group to add
  36558. */
  36559. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36560. /**
  36561. * Adds the given multi-material to this scene
  36562. * @param newMultiMaterial The multi-material to add
  36563. */
  36564. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36565. /**
  36566. * Adds the given material to this scene
  36567. * @param newMaterial The material to add
  36568. */
  36569. addMaterial(newMaterial: Material): void;
  36570. /**
  36571. * Adds the given morph target to this scene
  36572. * @param newMorphTargetManager The morph target to add
  36573. */
  36574. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36575. /**
  36576. * Adds the given geometry to this scene
  36577. * @param newGeometry The geometry to add
  36578. */
  36579. addGeometry(newGeometry: Geometry): void;
  36580. /**
  36581. * Adds the given action manager to this scene
  36582. * @param newActionManager The action manager to add
  36583. */
  36584. addActionManager(newActionManager: AbstractActionManager): void;
  36585. /**
  36586. * Adds the given texture to this scene.
  36587. * @param newTexture The texture to add
  36588. */
  36589. addTexture(newTexture: BaseTexture): void;
  36590. /**
  36591. * Switch active camera
  36592. * @param newCamera defines the new active camera
  36593. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36594. */
  36595. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36596. /**
  36597. * sets the active camera of the scene using its ID
  36598. * @param id defines the camera's ID
  36599. * @return the new active camera or null if none found.
  36600. */
  36601. setActiveCameraByID(id: string): Nullable<Camera>;
  36602. /**
  36603. * sets the active camera of the scene using its name
  36604. * @param name defines the camera's name
  36605. * @returns the new active camera or null if none found.
  36606. */
  36607. setActiveCameraByName(name: string): Nullable<Camera>;
  36608. /**
  36609. * get an animation group using its name
  36610. * @param name defines the material's name
  36611. * @return the animation group or null if none found.
  36612. */
  36613. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36614. /**
  36615. * Get a material using its unique id
  36616. * @param uniqueId defines the material's unique id
  36617. * @return the material or null if none found.
  36618. */
  36619. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36620. /**
  36621. * get a material using its id
  36622. * @param id defines the material's ID
  36623. * @return the material or null if none found.
  36624. */
  36625. getMaterialByID(id: string): Nullable<Material>;
  36626. /**
  36627. * Gets a the last added material using a given id
  36628. * @param id defines the material's ID
  36629. * @return the last material with the given id or null if none found.
  36630. */
  36631. getLastMaterialByID(id: string): Nullable<Material>;
  36632. /**
  36633. * Gets a material using its name
  36634. * @param name defines the material's name
  36635. * @return the material or null if none found.
  36636. */
  36637. getMaterialByName(name: string): Nullable<Material>;
  36638. /**
  36639. * Get a texture using its unique id
  36640. * @param uniqueId defines the texture's unique id
  36641. * @return the texture or null if none found.
  36642. */
  36643. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36644. /**
  36645. * Gets a camera using its id
  36646. * @param id defines the id to look for
  36647. * @returns the camera or null if not found
  36648. */
  36649. getCameraByID(id: string): Nullable<Camera>;
  36650. /**
  36651. * Gets a camera using its unique id
  36652. * @param uniqueId defines the unique id to look for
  36653. * @returns the camera or null if not found
  36654. */
  36655. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36656. /**
  36657. * Gets a camera using its name
  36658. * @param name defines the camera's name
  36659. * @return the camera or null if none found.
  36660. */
  36661. getCameraByName(name: string): Nullable<Camera>;
  36662. /**
  36663. * Gets a bone using its id
  36664. * @param id defines the bone's id
  36665. * @return the bone or null if not found
  36666. */
  36667. getBoneByID(id: string): Nullable<Bone>;
  36668. /**
  36669. * Gets a bone using its id
  36670. * @param name defines the bone's name
  36671. * @return the bone or null if not found
  36672. */
  36673. getBoneByName(name: string): Nullable<Bone>;
  36674. /**
  36675. * Gets a light node using its name
  36676. * @param name defines the the light's name
  36677. * @return the light or null if none found.
  36678. */
  36679. getLightByName(name: string): Nullable<Light>;
  36680. /**
  36681. * Gets a light node using its id
  36682. * @param id defines the light's id
  36683. * @return the light or null if none found.
  36684. */
  36685. getLightByID(id: string): Nullable<Light>;
  36686. /**
  36687. * Gets a light node using its scene-generated unique ID
  36688. * @param uniqueId defines the light's unique id
  36689. * @return the light or null if none found.
  36690. */
  36691. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36692. /**
  36693. * Gets a particle system by id
  36694. * @param id defines the particle system id
  36695. * @return the corresponding system or null if none found
  36696. */
  36697. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36698. /**
  36699. * Gets a geometry using its ID
  36700. * @param id defines the geometry's id
  36701. * @return the geometry or null if none found.
  36702. */
  36703. getGeometryByID(id: string): Nullable<Geometry>;
  36704. private _getGeometryByUniqueID;
  36705. /**
  36706. * Add a new geometry to this scene
  36707. * @param geometry defines the geometry to be added to the scene.
  36708. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36709. * @return a boolean defining if the geometry was added or not
  36710. */
  36711. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36712. /**
  36713. * Removes an existing geometry
  36714. * @param geometry defines the geometry to be removed from the scene
  36715. * @return a boolean defining if the geometry was removed or not
  36716. */
  36717. removeGeometry(geometry: Geometry): boolean;
  36718. /**
  36719. * Gets the list of geometries attached to the scene
  36720. * @returns an array of Geometry
  36721. */
  36722. getGeometries(): Geometry[];
  36723. /**
  36724. * Gets the first added mesh found of a given ID
  36725. * @param id defines the id to search for
  36726. * @return the mesh found or null if not found at all
  36727. */
  36728. getMeshByID(id: string): Nullable<AbstractMesh>;
  36729. /**
  36730. * Gets a list of meshes using their id
  36731. * @param id defines the id to search for
  36732. * @returns a list of meshes
  36733. */
  36734. getMeshesByID(id: string): Array<AbstractMesh>;
  36735. /**
  36736. * Gets the first added transform node found of a given ID
  36737. * @param id defines the id to search for
  36738. * @return the found transform node or null if not found at all.
  36739. */
  36740. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36741. /**
  36742. * Gets a transform node with its auto-generated unique id
  36743. * @param uniqueId efines the unique id to search for
  36744. * @return the found transform node or null if not found at all.
  36745. */
  36746. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36747. /**
  36748. * Gets a list of transform nodes using their id
  36749. * @param id defines the id to search for
  36750. * @returns a list of transform nodes
  36751. */
  36752. getTransformNodesByID(id: string): Array<TransformNode>;
  36753. /**
  36754. * Gets a mesh with its auto-generated unique id
  36755. * @param uniqueId defines the unique id to search for
  36756. * @return the found mesh or null if not found at all.
  36757. */
  36758. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36759. /**
  36760. * Gets a the last added mesh using a given id
  36761. * @param id defines the id to search for
  36762. * @return the found mesh or null if not found at all.
  36763. */
  36764. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36765. /**
  36766. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36767. * @param id defines the id to search for
  36768. * @return the found node or null if not found at all
  36769. */
  36770. getLastEntryByID(id: string): Nullable<Node>;
  36771. /**
  36772. * Gets a node (Mesh, Camera, Light) using a given id
  36773. * @param id defines the id to search for
  36774. * @return the found node or null if not found at all
  36775. */
  36776. getNodeByID(id: string): Nullable<Node>;
  36777. /**
  36778. * Gets a node (Mesh, Camera, Light) using a given name
  36779. * @param name defines the name to search for
  36780. * @return the found node or null if not found at all.
  36781. */
  36782. getNodeByName(name: string): Nullable<Node>;
  36783. /**
  36784. * Gets a mesh using a given name
  36785. * @param name defines the name to search for
  36786. * @return the found mesh or null if not found at all.
  36787. */
  36788. getMeshByName(name: string): Nullable<AbstractMesh>;
  36789. /**
  36790. * Gets a transform node using a given name
  36791. * @param name defines the name to search for
  36792. * @return the found transform node or null if not found at all.
  36793. */
  36794. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36795. /**
  36796. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36797. * @param id defines the id to search for
  36798. * @return the found skeleton or null if not found at all.
  36799. */
  36800. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36801. /**
  36802. * Gets a skeleton using a given auto generated unique id
  36803. * @param uniqueId defines the unique id to search for
  36804. * @return the found skeleton or null if not found at all.
  36805. */
  36806. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36807. /**
  36808. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36809. * @param id defines the id to search for
  36810. * @return the found skeleton or null if not found at all.
  36811. */
  36812. getSkeletonById(id: string): Nullable<Skeleton>;
  36813. /**
  36814. * Gets a skeleton using a given name
  36815. * @param name defines the name to search for
  36816. * @return the found skeleton or null if not found at all.
  36817. */
  36818. getSkeletonByName(name: string): Nullable<Skeleton>;
  36819. /**
  36820. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36821. * @param id defines the id to search for
  36822. * @return the found morph target manager or null if not found at all.
  36823. */
  36824. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36825. /**
  36826. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36827. * @param id defines the id to search for
  36828. * @return the found morph target or null if not found at all.
  36829. */
  36830. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36831. /**
  36832. * Gets a boolean indicating if the given mesh is active
  36833. * @param mesh defines the mesh to look for
  36834. * @returns true if the mesh is in the active list
  36835. */
  36836. isActiveMesh(mesh: AbstractMesh): boolean;
  36837. /**
  36838. * Return a unique id as a string which can serve as an identifier for the scene
  36839. */
  36840. get uid(): string;
  36841. /**
  36842. * Add an externaly attached data from its key.
  36843. * This method call will fail and return false, if such key already exists.
  36844. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36845. * @param key the unique key that identifies the data
  36846. * @param data the data object to associate to the key for this Engine instance
  36847. * @return true if no such key were already present and the data was added successfully, false otherwise
  36848. */
  36849. addExternalData<T>(key: string, data: T): boolean;
  36850. /**
  36851. * Get an externaly attached data from its key
  36852. * @param key the unique key that identifies the data
  36853. * @return the associated data, if present (can be null), or undefined if not present
  36854. */
  36855. getExternalData<T>(key: string): Nullable<T>;
  36856. /**
  36857. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36858. * @param key the unique key that identifies the data
  36859. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36860. * @return the associated data, can be null if the factory returned null.
  36861. */
  36862. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36863. /**
  36864. * Remove an externaly attached data from the Engine instance
  36865. * @param key the unique key that identifies the data
  36866. * @return true if the data was successfully removed, false if it doesn't exist
  36867. */
  36868. removeExternalData(key: string): boolean;
  36869. private _evaluateSubMesh;
  36870. /**
  36871. * Clear the processed materials smart array preventing retention point in material dispose.
  36872. */
  36873. freeProcessedMaterials(): void;
  36874. private _preventFreeActiveMeshesAndRenderingGroups;
  36875. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36876. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36877. * when disposing several meshes in a row or a hierarchy of meshes.
  36878. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36879. */
  36880. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36881. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36882. /**
  36883. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36884. */
  36885. freeActiveMeshes(): void;
  36886. /**
  36887. * Clear the info related to rendering groups preventing retention points during dispose.
  36888. */
  36889. freeRenderingGroups(): void;
  36890. /** @hidden */
  36891. _isInIntermediateRendering(): boolean;
  36892. /**
  36893. * Lambda returning the list of potentially active meshes.
  36894. */
  36895. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36896. /**
  36897. * Lambda returning the list of potentially active sub meshes.
  36898. */
  36899. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36900. /**
  36901. * Lambda returning the list of potentially intersecting sub meshes.
  36902. */
  36903. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36904. /**
  36905. * Lambda returning the list of potentially colliding sub meshes.
  36906. */
  36907. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36908. private _activeMeshesFrozen;
  36909. private _skipEvaluateActiveMeshesCompletely;
  36910. /**
  36911. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36912. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36913. * @returns the current scene
  36914. */
  36915. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36916. /**
  36917. * Use this function to restart evaluating active meshes on every frame
  36918. * @returns the current scene
  36919. */
  36920. unfreezeActiveMeshes(): Scene;
  36921. private _evaluateActiveMeshes;
  36922. private _activeMesh;
  36923. /**
  36924. * Update the transform matrix to update from the current active camera
  36925. * @param force defines a boolean used to force the update even if cache is up to date
  36926. */
  36927. updateTransformMatrix(force?: boolean): void;
  36928. private _bindFrameBuffer;
  36929. /** @hidden */
  36930. _allowPostProcessClearColor: boolean;
  36931. /** @hidden */
  36932. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36933. private _processSubCameras;
  36934. private _checkIntersections;
  36935. /** @hidden */
  36936. _advancePhysicsEngineStep(step: number): void;
  36937. /**
  36938. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36939. */
  36940. getDeterministicFrameTime: () => number;
  36941. /** @hidden */
  36942. _animate(): void;
  36943. /** Execute all animations (for a frame) */
  36944. animate(): void;
  36945. /**
  36946. * Render the scene
  36947. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36948. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36949. */
  36950. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36951. /**
  36952. * Freeze all materials
  36953. * A frozen material will not be updatable but should be faster to render
  36954. */
  36955. freezeMaterials(): void;
  36956. /**
  36957. * Unfreeze all materials
  36958. * A frozen material will not be updatable but should be faster to render
  36959. */
  36960. unfreezeMaterials(): void;
  36961. /**
  36962. * Releases all held ressources
  36963. */
  36964. dispose(): void;
  36965. /**
  36966. * Gets if the scene is already disposed
  36967. */
  36968. get isDisposed(): boolean;
  36969. /**
  36970. * Call this function to reduce memory footprint of the scene.
  36971. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36972. */
  36973. clearCachedVertexData(): void;
  36974. /**
  36975. * This function will remove the local cached buffer data from texture.
  36976. * It will save memory but will prevent the texture from being rebuilt
  36977. */
  36978. cleanCachedTextureBuffer(): void;
  36979. /**
  36980. * Get the world extend vectors with an optional filter
  36981. *
  36982. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36983. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36984. */
  36985. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36986. min: Vector3;
  36987. max: Vector3;
  36988. };
  36989. /**
  36990. * Creates a ray that can be used to pick in the scene
  36991. * @param x defines the x coordinate of the origin (on-screen)
  36992. * @param y defines the y coordinate of the origin (on-screen)
  36993. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36994. * @param camera defines the camera to use for the picking
  36995. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36996. * @returns a Ray
  36997. */
  36998. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36999. /**
  37000. * Creates a ray that can be used to pick in the scene
  37001. * @param x defines the x coordinate of the origin (on-screen)
  37002. * @param y defines the y coordinate of the origin (on-screen)
  37003. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37004. * @param result defines the ray where to store the picking ray
  37005. * @param camera defines the camera to use for the picking
  37006. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37007. * @returns the current scene
  37008. */
  37009. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37010. /**
  37011. * Creates a ray that can be used to pick in the scene
  37012. * @param x defines the x coordinate of the origin (on-screen)
  37013. * @param y defines the y coordinate of the origin (on-screen)
  37014. * @param camera defines the camera to use for the picking
  37015. * @returns a Ray
  37016. */
  37017. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37018. /**
  37019. * Creates a ray that can be used to pick in the scene
  37020. * @param x defines the x coordinate of the origin (on-screen)
  37021. * @param y defines the y coordinate of the origin (on-screen)
  37022. * @param result defines the ray where to store the picking ray
  37023. * @param camera defines the camera to use for the picking
  37024. * @returns the current scene
  37025. */
  37026. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37027. /** Launch a ray to try to pick a mesh in the scene
  37028. * @param x position on screen
  37029. * @param y position on screen
  37030. * @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
  37031. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37032. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37033. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37034. * @returns a PickingInfo
  37035. */
  37036. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37037. /** Use the given ray to pick a mesh in the scene
  37038. * @param ray The ray to use to pick meshes
  37039. * @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
  37040. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37041. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37042. * @returns a PickingInfo
  37043. */
  37044. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37045. /**
  37046. * Launch a ray to try to pick a mesh in the scene
  37047. * @param x X position on screen
  37048. * @param y Y position on screen
  37049. * @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
  37050. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37051. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37052. * @returns an array of PickingInfo
  37053. */
  37054. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37055. /**
  37056. * Launch a ray to try to pick a mesh in the scene
  37057. * @param ray Ray to use
  37058. * @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
  37059. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37060. * @returns an array of PickingInfo
  37061. */
  37062. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37063. /**
  37064. * Force the value of meshUnderPointer
  37065. * @param mesh defines the mesh to use
  37066. */
  37067. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37068. /**
  37069. * Gets the mesh under the pointer
  37070. * @returns a Mesh or null if no mesh is under the pointer
  37071. */
  37072. getPointerOverMesh(): Nullable<AbstractMesh>;
  37073. /** @hidden */
  37074. _rebuildGeometries(): void;
  37075. /** @hidden */
  37076. _rebuildTextures(): void;
  37077. private _getByTags;
  37078. /**
  37079. * Get a list of meshes by tags
  37080. * @param tagsQuery defines the tags query to use
  37081. * @param forEach defines a predicate used to filter results
  37082. * @returns an array of Mesh
  37083. */
  37084. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37085. /**
  37086. * Get a list of cameras by tags
  37087. * @param tagsQuery defines the tags query to use
  37088. * @param forEach defines a predicate used to filter results
  37089. * @returns an array of Camera
  37090. */
  37091. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37092. /**
  37093. * Get a list of lights by tags
  37094. * @param tagsQuery defines the tags query to use
  37095. * @param forEach defines a predicate used to filter results
  37096. * @returns an array of Light
  37097. */
  37098. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37099. /**
  37100. * Get a list of materials by tags
  37101. * @param tagsQuery defines the tags query to use
  37102. * @param forEach defines a predicate used to filter results
  37103. * @returns an array of Material
  37104. */
  37105. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37106. /**
  37107. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37108. * This allowed control for front to back rendering or reversly depending of the special needs.
  37109. *
  37110. * @param renderingGroupId The rendering group id corresponding to its index
  37111. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37112. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37113. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37114. */
  37115. 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;
  37116. /**
  37117. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37118. *
  37119. * @param renderingGroupId The rendering group id corresponding to its index
  37120. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37121. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37122. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37123. */
  37124. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37125. /**
  37126. * Gets the current auto clear configuration for one rendering group of the rendering
  37127. * manager.
  37128. * @param index the rendering group index to get the information for
  37129. * @returns The auto clear setup for the requested rendering group
  37130. */
  37131. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37132. private _blockMaterialDirtyMechanism;
  37133. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37134. get blockMaterialDirtyMechanism(): boolean;
  37135. set blockMaterialDirtyMechanism(value: boolean);
  37136. /**
  37137. * Will flag all materials as dirty to trigger new shader compilation
  37138. * @param flag defines the flag used to specify which material part must be marked as dirty
  37139. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37140. */
  37141. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37142. /** @hidden */
  37143. _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;
  37144. /** @hidden */
  37145. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37146. /** @hidden */
  37147. _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;
  37148. /** @hidden */
  37149. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37150. /** @hidden */
  37151. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37152. /** @hidden */
  37153. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37154. }
  37155. }
  37156. declare module BABYLON {
  37157. /**
  37158. * Set of assets to keep when moving a scene into an asset container.
  37159. */
  37160. export class KeepAssets extends AbstractScene {
  37161. }
  37162. /**
  37163. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37164. */
  37165. export class InstantiatedEntries {
  37166. /**
  37167. * List of new root nodes (eg. nodes with no parent)
  37168. */
  37169. rootNodes: TransformNode[];
  37170. /**
  37171. * List of new skeletons
  37172. */
  37173. skeletons: Skeleton[];
  37174. /**
  37175. * List of new animation groups
  37176. */
  37177. animationGroups: AnimationGroup[];
  37178. }
  37179. /**
  37180. * Container with a set of assets that can be added or removed from a scene.
  37181. */
  37182. export class AssetContainer extends AbstractScene {
  37183. private _wasAddedToScene;
  37184. /**
  37185. * The scene the AssetContainer belongs to.
  37186. */
  37187. scene: Scene;
  37188. /**
  37189. * Instantiates an AssetContainer.
  37190. * @param scene The scene the AssetContainer belongs to.
  37191. */
  37192. constructor(scene: Scene);
  37193. /**
  37194. * Instantiate or clone all meshes and add the new ones to the scene.
  37195. * Skeletons and animation groups will all be cloned
  37196. * @param nameFunction defines an optional function used to get new names for clones
  37197. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37198. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37199. */
  37200. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37201. /**
  37202. * Adds all the assets from the container to the scene.
  37203. */
  37204. addAllToScene(): void;
  37205. /**
  37206. * Removes all the assets in the container from the scene
  37207. */
  37208. removeAllFromScene(): void;
  37209. /**
  37210. * Disposes all the assets in the container
  37211. */
  37212. dispose(): void;
  37213. private _moveAssets;
  37214. /**
  37215. * Removes all the assets contained in the scene and adds them to the container.
  37216. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37217. */
  37218. moveAllFromScene(keepAssets?: KeepAssets): void;
  37219. /**
  37220. * 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.
  37221. * @returns the root mesh
  37222. */
  37223. createRootMesh(): Mesh;
  37224. /**
  37225. * Merge animations from this asset container into a scene
  37226. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37227. * @param animatables set of animatables to retarget to a node from the scene
  37228. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37229. */
  37230. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37231. }
  37232. }
  37233. declare module BABYLON {
  37234. /**
  37235. * Defines how the parser contract is defined.
  37236. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37237. */
  37238. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37239. /**
  37240. * Defines how the individual parser contract is defined.
  37241. * These parser can parse an individual asset
  37242. */
  37243. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37244. /**
  37245. * Base class of the scene acting as a container for the different elements composing a scene.
  37246. * This class is dynamically extended by the different components of the scene increasing
  37247. * flexibility and reducing coupling
  37248. */
  37249. export abstract class AbstractScene {
  37250. /**
  37251. * Stores the list of available parsers in the application.
  37252. */
  37253. private static _BabylonFileParsers;
  37254. /**
  37255. * Stores the list of available individual parsers in the application.
  37256. */
  37257. private static _IndividualBabylonFileParsers;
  37258. /**
  37259. * Adds a parser in the list of available ones
  37260. * @param name Defines the name of the parser
  37261. * @param parser Defines the parser to add
  37262. */
  37263. static AddParser(name: string, parser: BabylonFileParser): void;
  37264. /**
  37265. * Gets a general parser from the list of avaialble ones
  37266. * @param name Defines the name of the parser
  37267. * @returns the requested parser or null
  37268. */
  37269. static GetParser(name: string): Nullable<BabylonFileParser>;
  37270. /**
  37271. * Adds n individual parser in the list of available ones
  37272. * @param name Defines the name of the parser
  37273. * @param parser Defines the parser to add
  37274. */
  37275. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37276. /**
  37277. * Gets an individual parser from the list of avaialble ones
  37278. * @param name Defines the name of the parser
  37279. * @returns the requested parser or null
  37280. */
  37281. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37282. /**
  37283. * Parser json data and populate both a scene and its associated container object
  37284. * @param jsonData Defines the data to parse
  37285. * @param scene Defines the scene to parse the data for
  37286. * @param container Defines the container attached to the parsing sequence
  37287. * @param rootUrl Defines the root url of the data
  37288. */
  37289. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37290. /**
  37291. * Gets the list of root nodes (ie. nodes with no parent)
  37292. */
  37293. rootNodes: Node[];
  37294. /** All of the cameras added to this scene
  37295. * @see http://doc.babylonjs.com/babylon101/cameras
  37296. */
  37297. cameras: Camera[];
  37298. /**
  37299. * All of the lights added to this scene
  37300. * @see http://doc.babylonjs.com/babylon101/lights
  37301. */
  37302. lights: Light[];
  37303. /**
  37304. * All of the (abstract) meshes added to this scene
  37305. */
  37306. meshes: AbstractMesh[];
  37307. /**
  37308. * The list of skeletons added to the scene
  37309. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37310. */
  37311. skeletons: Skeleton[];
  37312. /**
  37313. * All of the particle systems added to this scene
  37314. * @see http://doc.babylonjs.com/babylon101/particles
  37315. */
  37316. particleSystems: IParticleSystem[];
  37317. /**
  37318. * Gets a list of Animations associated with the scene
  37319. */
  37320. animations: Animation[];
  37321. /**
  37322. * All of the animation groups added to this scene
  37323. * @see http://doc.babylonjs.com/how_to/group
  37324. */
  37325. animationGroups: AnimationGroup[];
  37326. /**
  37327. * All of the multi-materials added to this scene
  37328. * @see http://doc.babylonjs.com/how_to/multi_materials
  37329. */
  37330. multiMaterials: MultiMaterial[];
  37331. /**
  37332. * All of the materials added to this scene
  37333. * In the context of a Scene, it is not supposed to be modified manually.
  37334. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37335. * Note also that the order of the Material within the array is not significant and might change.
  37336. * @see http://doc.babylonjs.com/babylon101/materials
  37337. */
  37338. materials: Material[];
  37339. /**
  37340. * The list of morph target managers added to the scene
  37341. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37342. */
  37343. morphTargetManagers: MorphTargetManager[];
  37344. /**
  37345. * The list of geometries used in the scene.
  37346. */
  37347. geometries: Geometry[];
  37348. /**
  37349. * All of the tranform nodes added to this scene
  37350. * In the context of a Scene, it is not supposed to be modified manually.
  37351. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37352. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37353. * @see http://doc.babylonjs.com/how_to/transformnode
  37354. */
  37355. transformNodes: TransformNode[];
  37356. /**
  37357. * ActionManagers available on the scene.
  37358. */
  37359. actionManagers: AbstractActionManager[];
  37360. /**
  37361. * Textures to keep.
  37362. */
  37363. textures: BaseTexture[];
  37364. /**
  37365. * Environment texture for the scene
  37366. */
  37367. environmentTexture: Nullable<BaseTexture>;
  37368. /**
  37369. * @returns all meshes, lights, cameras, transformNodes and bones
  37370. */
  37371. getNodes(): Array<Node>;
  37372. }
  37373. }
  37374. declare module BABYLON {
  37375. /**
  37376. * Interface used to define options for Sound class
  37377. */
  37378. export interface ISoundOptions {
  37379. /**
  37380. * Does the sound autoplay once loaded.
  37381. */
  37382. autoplay?: boolean;
  37383. /**
  37384. * Does the sound loop after it finishes playing once.
  37385. */
  37386. loop?: boolean;
  37387. /**
  37388. * Sound's volume
  37389. */
  37390. volume?: number;
  37391. /**
  37392. * Is it a spatial sound?
  37393. */
  37394. spatialSound?: boolean;
  37395. /**
  37396. * Maximum distance to hear that sound
  37397. */
  37398. maxDistance?: number;
  37399. /**
  37400. * Uses user defined attenuation function
  37401. */
  37402. useCustomAttenuation?: boolean;
  37403. /**
  37404. * Define the roll off factor of spatial sounds.
  37405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37406. */
  37407. rolloffFactor?: number;
  37408. /**
  37409. * Define the reference distance the sound should be heard perfectly.
  37410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37411. */
  37412. refDistance?: number;
  37413. /**
  37414. * Define the distance attenuation model the sound will follow.
  37415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37416. */
  37417. distanceModel?: string;
  37418. /**
  37419. * Defines the playback speed (1 by default)
  37420. */
  37421. playbackRate?: number;
  37422. /**
  37423. * Defines if the sound is from a streaming source
  37424. */
  37425. streaming?: boolean;
  37426. /**
  37427. * Defines an optional length (in seconds) inside the sound file
  37428. */
  37429. length?: number;
  37430. /**
  37431. * Defines an optional offset (in seconds) inside the sound file
  37432. */
  37433. offset?: number;
  37434. /**
  37435. * If true, URLs will not be required to state the audio file codec to use.
  37436. */
  37437. skipCodecCheck?: boolean;
  37438. }
  37439. /**
  37440. * Defines a sound that can be played in the application.
  37441. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37443. */
  37444. export class Sound {
  37445. /**
  37446. * The name of the sound in the scene.
  37447. */
  37448. name: string;
  37449. /**
  37450. * Does the sound autoplay once loaded.
  37451. */
  37452. autoplay: boolean;
  37453. /**
  37454. * Does the sound loop after it finishes playing once.
  37455. */
  37456. loop: boolean;
  37457. /**
  37458. * Does the sound use a custom attenuation curve to simulate the falloff
  37459. * happening when the source gets further away from the camera.
  37460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37461. */
  37462. useCustomAttenuation: boolean;
  37463. /**
  37464. * The sound track id this sound belongs to.
  37465. */
  37466. soundTrackId: number;
  37467. /**
  37468. * Is this sound currently played.
  37469. */
  37470. isPlaying: boolean;
  37471. /**
  37472. * Is this sound currently paused.
  37473. */
  37474. isPaused: boolean;
  37475. /**
  37476. * Does this sound enables spatial sound.
  37477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37478. */
  37479. spatialSound: boolean;
  37480. /**
  37481. * Define the reference distance the sound should be heard perfectly.
  37482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37483. */
  37484. refDistance: number;
  37485. /**
  37486. * Define the roll off factor of spatial sounds.
  37487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37488. */
  37489. rolloffFactor: number;
  37490. /**
  37491. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37493. */
  37494. maxDistance: number;
  37495. /**
  37496. * Define the distance attenuation model the sound will follow.
  37497. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37498. */
  37499. distanceModel: string;
  37500. /**
  37501. * @hidden
  37502. * Back Compat
  37503. **/
  37504. onended: () => any;
  37505. /**
  37506. * Observable event when the current playing sound finishes.
  37507. */
  37508. onEndedObservable: Observable<Sound>;
  37509. private _panningModel;
  37510. private _playbackRate;
  37511. private _streaming;
  37512. private _startTime;
  37513. private _startOffset;
  37514. private _position;
  37515. /** @hidden */
  37516. _positionInEmitterSpace: boolean;
  37517. private _localDirection;
  37518. private _volume;
  37519. private _isReadyToPlay;
  37520. private _isDirectional;
  37521. private _readyToPlayCallback;
  37522. private _audioBuffer;
  37523. private _soundSource;
  37524. private _streamingSource;
  37525. private _soundPanner;
  37526. private _soundGain;
  37527. private _inputAudioNode;
  37528. private _outputAudioNode;
  37529. private _coneInnerAngle;
  37530. private _coneOuterAngle;
  37531. private _coneOuterGain;
  37532. private _scene;
  37533. private _connectedTransformNode;
  37534. private _customAttenuationFunction;
  37535. private _registerFunc;
  37536. private _isOutputConnected;
  37537. private _htmlAudioElement;
  37538. private _urlType;
  37539. private _length?;
  37540. private _offset?;
  37541. /** @hidden */
  37542. static _SceneComponentInitialization: (scene: Scene) => void;
  37543. /**
  37544. * Create a sound and attach it to a scene
  37545. * @param name Name of your sound
  37546. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37547. * @param scene defines the scene the sound belongs to
  37548. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37549. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37550. */
  37551. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37552. /**
  37553. * Release the sound and its associated resources
  37554. */
  37555. dispose(): void;
  37556. /**
  37557. * Gets if the sounds is ready to be played or not.
  37558. * @returns true if ready, otherwise false
  37559. */
  37560. isReady(): boolean;
  37561. private _soundLoaded;
  37562. /**
  37563. * Sets the data of the sound from an audiobuffer
  37564. * @param audioBuffer The audioBuffer containing the data
  37565. */
  37566. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37567. /**
  37568. * Updates the current sounds options such as maxdistance, loop...
  37569. * @param options A JSON object containing values named as the object properties
  37570. */
  37571. updateOptions(options: ISoundOptions): void;
  37572. private _createSpatialParameters;
  37573. private _updateSpatialParameters;
  37574. /**
  37575. * Switch the panning model to HRTF:
  37576. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37578. */
  37579. switchPanningModelToHRTF(): void;
  37580. /**
  37581. * Switch the panning model to Equal Power:
  37582. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37584. */
  37585. switchPanningModelToEqualPower(): void;
  37586. private _switchPanningModel;
  37587. /**
  37588. * Connect this sound to a sound track audio node like gain...
  37589. * @param soundTrackAudioNode the sound track audio node to connect to
  37590. */
  37591. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37592. /**
  37593. * Transform this sound into a directional source
  37594. * @param coneInnerAngle Size of the inner cone in degree
  37595. * @param coneOuterAngle Size of the outer cone in degree
  37596. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37597. */
  37598. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37599. /**
  37600. * Gets or sets the inner angle for the directional cone.
  37601. */
  37602. get directionalConeInnerAngle(): number;
  37603. /**
  37604. * Gets or sets the inner angle for the directional cone.
  37605. */
  37606. set directionalConeInnerAngle(value: number);
  37607. /**
  37608. * Gets or sets the outer angle for the directional cone.
  37609. */
  37610. get directionalConeOuterAngle(): number;
  37611. /**
  37612. * Gets or sets the outer angle for the directional cone.
  37613. */
  37614. set directionalConeOuterAngle(value: number);
  37615. /**
  37616. * Sets the position of the emitter if spatial sound is enabled
  37617. * @param newPosition Defines the new posisiton
  37618. */
  37619. setPosition(newPosition: Vector3): void;
  37620. /**
  37621. * Sets the local direction of the emitter if spatial sound is enabled
  37622. * @param newLocalDirection Defines the new local direction
  37623. */
  37624. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37625. private _updateDirection;
  37626. /** @hidden */
  37627. updateDistanceFromListener(): void;
  37628. /**
  37629. * Sets a new custom attenuation function for the sound.
  37630. * @param callback Defines the function used for the attenuation
  37631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37632. */
  37633. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37634. /**
  37635. * Play the sound
  37636. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37637. * @param offset (optional) Start the sound at a specific time in seconds
  37638. * @param length (optional) Sound duration (in seconds)
  37639. */
  37640. play(time?: number, offset?: number, length?: number): void;
  37641. private _onended;
  37642. /**
  37643. * Stop the sound
  37644. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37645. */
  37646. stop(time?: number): void;
  37647. /**
  37648. * Put the sound in pause
  37649. */
  37650. pause(): void;
  37651. /**
  37652. * Sets a dedicated volume for this sounds
  37653. * @param newVolume Define the new volume of the sound
  37654. * @param time Define time for gradual change to new volume
  37655. */
  37656. setVolume(newVolume: number, time?: number): void;
  37657. /**
  37658. * Set the sound play back rate
  37659. * @param newPlaybackRate Define the playback rate the sound should be played at
  37660. */
  37661. setPlaybackRate(newPlaybackRate: number): void;
  37662. /**
  37663. * Gets the volume of the sound.
  37664. * @returns the volume of the sound
  37665. */
  37666. getVolume(): number;
  37667. /**
  37668. * Attach the sound to a dedicated mesh
  37669. * @param transformNode The transform node to connect the sound with
  37670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37671. */
  37672. attachToMesh(transformNode: TransformNode): void;
  37673. /**
  37674. * Detach the sound from the previously attached mesh
  37675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37676. */
  37677. detachFromMesh(): void;
  37678. private _onRegisterAfterWorldMatrixUpdate;
  37679. /**
  37680. * Clone the current sound in the scene.
  37681. * @returns the new sound clone
  37682. */
  37683. clone(): Nullable<Sound>;
  37684. /**
  37685. * Gets the current underlying audio buffer containing the data
  37686. * @returns the audio buffer
  37687. */
  37688. getAudioBuffer(): Nullable<AudioBuffer>;
  37689. /**
  37690. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37691. * @returns the source node
  37692. */
  37693. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37694. /**
  37695. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37696. * @returns the gain node
  37697. */
  37698. getSoundGain(): Nullable<GainNode>;
  37699. /**
  37700. * Serializes the Sound in a JSON representation
  37701. * @returns the JSON representation of the sound
  37702. */
  37703. serialize(): any;
  37704. /**
  37705. * Parse a JSON representation of a sound to innstantiate in a given scene
  37706. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37707. * @param scene Define the scene the new parsed sound should be created in
  37708. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37709. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37710. * @returns the newly parsed sound
  37711. */
  37712. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37713. }
  37714. }
  37715. declare module BABYLON {
  37716. /**
  37717. * This defines an action helpful to play a defined sound on a triggered action.
  37718. */
  37719. export class PlaySoundAction extends Action {
  37720. private _sound;
  37721. /**
  37722. * Instantiate the action
  37723. * @param triggerOptions defines the trigger options
  37724. * @param sound defines the sound to play
  37725. * @param condition defines the trigger related conditions
  37726. */
  37727. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37728. /** @hidden */
  37729. _prepare(): void;
  37730. /**
  37731. * Execute the action and play the sound.
  37732. */
  37733. execute(): void;
  37734. /**
  37735. * Serializes the actions and its related information.
  37736. * @param parent defines the object to serialize in
  37737. * @returns the serialized object
  37738. */
  37739. serialize(parent: any): any;
  37740. }
  37741. /**
  37742. * This defines an action helpful to stop a defined sound on a triggered action.
  37743. */
  37744. export class StopSoundAction extends Action {
  37745. private _sound;
  37746. /**
  37747. * Instantiate the action
  37748. * @param triggerOptions defines the trigger options
  37749. * @param sound defines the sound to stop
  37750. * @param condition defines the trigger related conditions
  37751. */
  37752. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37753. /** @hidden */
  37754. _prepare(): void;
  37755. /**
  37756. * Execute the action and stop the sound.
  37757. */
  37758. execute(): void;
  37759. /**
  37760. * Serializes the actions and its related information.
  37761. * @param parent defines the object to serialize in
  37762. * @returns the serialized object
  37763. */
  37764. serialize(parent: any): any;
  37765. }
  37766. }
  37767. declare module BABYLON {
  37768. /**
  37769. * This defines an action responsible to change the value of a property
  37770. * by interpolating between its current value and the newly set one once triggered.
  37771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37772. */
  37773. export class InterpolateValueAction extends Action {
  37774. /**
  37775. * Defines the path of the property where the value should be interpolated
  37776. */
  37777. propertyPath: string;
  37778. /**
  37779. * Defines the target value at the end of the interpolation.
  37780. */
  37781. value: any;
  37782. /**
  37783. * Defines the time it will take for the property to interpolate to the value.
  37784. */
  37785. duration: number;
  37786. /**
  37787. * Defines if the other scene animations should be stopped when the action has been triggered
  37788. */
  37789. stopOtherAnimations?: boolean;
  37790. /**
  37791. * Defines a callback raised once the interpolation animation has been done.
  37792. */
  37793. onInterpolationDone?: () => void;
  37794. /**
  37795. * Observable triggered once the interpolation animation has been done.
  37796. */
  37797. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37798. private _target;
  37799. private _effectiveTarget;
  37800. private _property;
  37801. /**
  37802. * Instantiate the action
  37803. * @param triggerOptions defines the trigger options
  37804. * @param target defines the object containing the value to interpolate
  37805. * @param propertyPath defines the path to the property in the target object
  37806. * @param value defines the target value at the end of the interpolation
  37807. * @param duration deines the time it will take for the property to interpolate to the value.
  37808. * @param condition defines the trigger related conditions
  37809. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37810. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37811. */
  37812. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37813. /** @hidden */
  37814. _prepare(): void;
  37815. /**
  37816. * Execute the action starts the value interpolation.
  37817. */
  37818. execute(): void;
  37819. /**
  37820. * Serializes the actions and its related information.
  37821. * @param parent defines the object to serialize in
  37822. * @returns the serialized object
  37823. */
  37824. serialize(parent: any): any;
  37825. }
  37826. }
  37827. declare module BABYLON {
  37828. /**
  37829. * Options allowed during the creation of a sound track.
  37830. */
  37831. export interface ISoundTrackOptions {
  37832. /**
  37833. * The volume the sound track should take during creation
  37834. */
  37835. volume?: number;
  37836. /**
  37837. * Define if the sound track is the main sound track of the scene
  37838. */
  37839. mainTrack?: boolean;
  37840. }
  37841. /**
  37842. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37843. * It will be also used in a future release to apply effects on a specific track.
  37844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37845. */
  37846. export class SoundTrack {
  37847. /**
  37848. * The unique identifier of the sound track in the scene.
  37849. */
  37850. id: number;
  37851. /**
  37852. * The list of sounds included in the sound track.
  37853. */
  37854. soundCollection: Array<Sound>;
  37855. private _outputAudioNode;
  37856. private _scene;
  37857. private _connectedAnalyser;
  37858. private _options;
  37859. private _isInitialized;
  37860. /**
  37861. * Creates a new sound track.
  37862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37863. * @param scene Define the scene the sound track belongs to
  37864. * @param options
  37865. */
  37866. constructor(scene: Scene, options?: ISoundTrackOptions);
  37867. private _initializeSoundTrackAudioGraph;
  37868. /**
  37869. * Release the sound track and its associated resources
  37870. */
  37871. dispose(): void;
  37872. /**
  37873. * Adds a sound to this sound track
  37874. * @param sound define the cound to add
  37875. * @ignoreNaming
  37876. */
  37877. AddSound(sound: Sound): void;
  37878. /**
  37879. * Removes a sound to this sound track
  37880. * @param sound define the cound to remove
  37881. * @ignoreNaming
  37882. */
  37883. RemoveSound(sound: Sound): void;
  37884. /**
  37885. * Set a global volume for the full sound track.
  37886. * @param newVolume Define the new volume of the sound track
  37887. */
  37888. setVolume(newVolume: number): void;
  37889. /**
  37890. * Switch the panning model to HRTF:
  37891. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37893. */
  37894. switchPanningModelToHRTF(): void;
  37895. /**
  37896. * Switch the panning model to Equal Power:
  37897. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37899. */
  37900. switchPanningModelToEqualPower(): void;
  37901. /**
  37902. * Connect the sound track to an audio analyser allowing some amazing
  37903. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37905. * @param analyser The analyser to connect to the engine
  37906. */
  37907. connectToAnalyser(analyser: Analyser): void;
  37908. }
  37909. }
  37910. declare module BABYLON {
  37911. interface AbstractScene {
  37912. /**
  37913. * The list of sounds used in the scene.
  37914. */
  37915. sounds: Nullable<Array<Sound>>;
  37916. }
  37917. interface Scene {
  37918. /**
  37919. * @hidden
  37920. * Backing field
  37921. */
  37922. _mainSoundTrack: SoundTrack;
  37923. /**
  37924. * The main sound track played by the scene.
  37925. * It cotains your primary collection of sounds.
  37926. */
  37927. mainSoundTrack: SoundTrack;
  37928. /**
  37929. * The list of sound tracks added to the scene
  37930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37931. */
  37932. soundTracks: Nullable<Array<SoundTrack>>;
  37933. /**
  37934. * Gets a sound using a given name
  37935. * @param name defines the name to search for
  37936. * @return the found sound or null if not found at all.
  37937. */
  37938. getSoundByName(name: string): Nullable<Sound>;
  37939. /**
  37940. * Gets or sets if audio support is enabled
  37941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37942. */
  37943. audioEnabled: boolean;
  37944. /**
  37945. * Gets or sets if audio will be output to headphones
  37946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37947. */
  37948. headphone: boolean;
  37949. /**
  37950. * Gets or sets custom audio listener position provider
  37951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37952. */
  37953. audioListenerPositionProvider: Nullable<() => Vector3>;
  37954. /**
  37955. * Gets or sets a refresh rate when using 3D audio positioning
  37956. */
  37957. audioPositioningRefreshRate: number;
  37958. }
  37959. /**
  37960. * Defines the sound scene component responsible to manage any sounds
  37961. * in a given scene.
  37962. */
  37963. export class AudioSceneComponent implements ISceneSerializableComponent {
  37964. /**
  37965. * The component name helpfull to identify the component in the list of scene components.
  37966. */
  37967. readonly name: string;
  37968. /**
  37969. * The scene the component belongs to.
  37970. */
  37971. scene: Scene;
  37972. private _audioEnabled;
  37973. /**
  37974. * Gets whether audio is enabled or not.
  37975. * Please use related enable/disable method to switch state.
  37976. */
  37977. get audioEnabled(): boolean;
  37978. private _headphone;
  37979. /**
  37980. * Gets whether audio is outputing to headphone or not.
  37981. * Please use the according Switch methods to change output.
  37982. */
  37983. get headphone(): boolean;
  37984. /**
  37985. * Gets or sets a refresh rate when using 3D audio positioning
  37986. */
  37987. audioPositioningRefreshRate: number;
  37988. private _audioListenerPositionProvider;
  37989. /**
  37990. * Gets the current audio listener position provider
  37991. */
  37992. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37993. /**
  37994. * Sets a custom listener position for all sounds in the scene
  37995. * By default, this is the position of the first active camera
  37996. */
  37997. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37998. /**
  37999. * Creates a new instance of the component for the given scene
  38000. * @param scene Defines the scene to register the component in
  38001. */
  38002. constructor(scene: Scene);
  38003. /**
  38004. * Registers the component in a given scene
  38005. */
  38006. register(): void;
  38007. /**
  38008. * Rebuilds the elements related to this component in case of
  38009. * context lost for instance.
  38010. */
  38011. rebuild(): void;
  38012. /**
  38013. * Serializes the component data to the specified json object
  38014. * @param serializationObject The object to serialize to
  38015. */
  38016. serialize(serializationObject: any): void;
  38017. /**
  38018. * Adds all the elements from the container to the scene
  38019. * @param container the container holding the elements
  38020. */
  38021. addFromContainer(container: AbstractScene): void;
  38022. /**
  38023. * Removes all the elements in the container from the scene
  38024. * @param container contains the elements to remove
  38025. * @param dispose if the removed element should be disposed (default: false)
  38026. */
  38027. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38028. /**
  38029. * Disposes the component and the associated ressources.
  38030. */
  38031. dispose(): void;
  38032. /**
  38033. * Disables audio in the associated scene.
  38034. */
  38035. disableAudio(): void;
  38036. /**
  38037. * Enables audio in the associated scene.
  38038. */
  38039. enableAudio(): void;
  38040. /**
  38041. * Switch audio to headphone output.
  38042. */
  38043. switchAudioModeForHeadphones(): void;
  38044. /**
  38045. * Switch audio to normal speakers.
  38046. */
  38047. switchAudioModeForNormalSpeakers(): void;
  38048. private _cachedCameraDirection;
  38049. private _cachedCameraPosition;
  38050. private _lastCheck;
  38051. private _afterRender;
  38052. }
  38053. }
  38054. declare module BABYLON {
  38055. /**
  38056. * Wraps one or more Sound objects and selects one with random weight for playback.
  38057. */
  38058. export class WeightedSound {
  38059. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38060. loop: boolean;
  38061. private _coneInnerAngle;
  38062. private _coneOuterAngle;
  38063. private _volume;
  38064. /** A Sound is currently playing. */
  38065. isPlaying: boolean;
  38066. /** A Sound is currently paused. */
  38067. isPaused: boolean;
  38068. private _sounds;
  38069. private _weights;
  38070. private _currentIndex?;
  38071. /**
  38072. * Creates a new WeightedSound from the list of sounds given.
  38073. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38074. * @param sounds Array of Sounds that will be selected from.
  38075. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38076. */
  38077. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38078. /**
  38079. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38080. */
  38081. get directionalConeInnerAngle(): number;
  38082. /**
  38083. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38084. */
  38085. set directionalConeInnerAngle(value: number);
  38086. /**
  38087. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38088. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38089. */
  38090. get directionalConeOuterAngle(): number;
  38091. /**
  38092. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38093. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38094. */
  38095. set directionalConeOuterAngle(value: number);
  38096. /**
  38097. * Playback volume.
  38098. */
  38099. get volume(): number;
  38100. /**
  38101. * Playback volume.
  38102. */
  38103. set volume(value: number);
  38104. private _onended;
  38105. /**
  38106. * Suspend playback
  38107. */
  38108. pause(): void;
  38109. /**
  38110. * Stop playback
  38111. */
  38112. stop(): void;
  38113. /**
  38114. * Start playback.
  38115. * @param startOffset Position the clip head at a specific time in seconds.
  38116. */
  38117. play(startOffset?: number): void;
  38118. }
  38119. }
  38120. declare module BABYLON {
  38121. /**
  38122. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38123. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38124. */
  38125. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38126. /**
  38127. * Gets the name of the behavior.
  38128. */
  38129. get name(): string;
  38130. /**
  38131. * The easing function used by animations
  38132. */
  38133. static EasingFunction: BackEase;
  38134. /**
  38135. * The easing mode used by animations
  38136. */
  38137. static EasingMode: number;
  38138. /**
  38139. * The duration of the animation, in milliseconds
  38140. */
  38141. transitionDuration: number;
  38142. /**
  38143. * Length of the distance animated by the transition when lower radius is reached
  38144. */
  38145. lowerRadiusTransitionRange: number;
  38146. /**
  38147. * Length of the distance animated by the transition when upper radius is reached
  38148. */
  38149. upperRadiusTransitionRange: number;
  38150. private _autoTransitionRange;
  38151. /**
  38152. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38153. */
  38154. get autoTransitionRange(): boolean;
  38155. /**
  38156. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38157. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38158. */
  38159. set autoTransitionRange(value: boolean);
  38160. private _attachedCamera;
  38161. private _onAfterCheckInputsObserver;
  38162. private _onMeshTargetChangedObserver;
  38163. /**
  38164. * Initializes the behavior.
  38165. */
  38166. init(): void;
  38167. /**
  38168. * Attaches the behavior to its arc rotate camera.
  38169. * @param camera Defines the camera to attach the behavior to
  38170. */
  38171. attach(camera: ArcRotateCamera): void;
  38172. /**
  38173. * Detaches the behavior from its current arc rotate camera.
  38174. */
  38175. detach(): void;
  38176. private _radiusIsAnimating;
  38177. private _radiusBounceTransition;
  38178. private _animatables;
  38179. private _cachedWheelPrecision;
  38180. /**
  38181. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38182. * @param radiusLimit The limit to check against.
  38183. * @return Bool to indicate if at limit.
  38184. */
  38185. private _isRadiusAtLimit;
  38186. /**
  38187. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38188. * @param radiusDelta The delta by which to animate to. Can be negative.
  38189. */
  38190. private _applyBoundRadiusAnimation;
  38191. /**
  38192. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38193. */
  38194. protected _clearAnimationLocks(): void;
  38195. /**
  38196. * Stops and removes all animations that have been applied to the camera
  38197. */
  38198. stopAllAnimations(): void;
  38199. }
  38200. }
  38201. declare module BABYLON {
  38202. /**
  38203. * 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.
  38204. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38205. */
  38206. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38207. /**
  38208. * Gets the name of the behavior.
  38209. */
  38210. get name(): string;
  38211. private _mode;
  38212. private _radiusScale;
  38213. private _positionScale;
  38214. private _defaultElevation;
  38215. private _elevationReturnTime;
  38216. private _elevationReturnWaitTime;
  38217. private _zoomStopsAnimation;
  38218. private _framingTime;
  38219. /**
  38220. * The easing function used by animations
  38221. */
  38222. static EasingFunction: ExponentialEase;
  38223. /**
  38224. * The easing mode used by animations
  38225. */
  38226. static EasingMode: number;
  38227. /**
  38228. * Sets the current mode used by the behavior
  38229. */
  38230. set mode(mode: number);
  38231. /**
  38232. * Gets current mode used by the behavior.
  38233. */
  38234. get mode(): number;
  38235. /**
  38236. * Sets the scale applied to the radius (1 by default)
  38237. */
  38238. set radiusScale(radius: number);
  38239. /**
  38240. * Gets the scale applied to the radius
  38241. */
  38242. get radiusScale(): number;
  38243. /**
  38244. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38245. */
  38246. set positionScale(scale: number);
  38247. /**
  38248. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38249. */
  38250. get positionScale(): number;
  38251. /**
  38252. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38253. * behaviour is triggered, in radians.
  38254. */
  38255. set defaultElevation(elevation: number);
  38256. /**
  38257. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38258. * behaviour is triggered, in radians.
  38259. */
  38260. get defaultElevation(): number;
  38261. /**
  38262. * Sets the time (in milliseconds) taken to return to the default beta position.
  38263. * Negative value indicates camera should not return to default.
  38264. */
  38265. set elevationReturnTime(speed: number);
  38266. /**
  38267. * Gets the time (in milliseconds) taken to return to the default beta position.
  38268. * Negative value indicates camera should not return to default.
  38269. */
  38270. get elevationReturnTime(): number;
  38271. /**
  38272. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38273. */
  38274. set elevationReturnWaitTime(time: number);
  38275. /**
  38276. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38277. */
  38278. get elevationReturnWaitTime(): number;
  38279. /**
  38280. * Sets the flag that indicates if user zooming should stop animation.
  38281. */
  38282. set zoomStopsAnimation(flag: boolean);
  38283. /**
  38284. * Gets the flag that indicates if user zooming should stop animation.
  38285. */
  38286. get zoomStopsAnimation(): boolean;
  38287. /**
  38288. * Sets the transition time when framing the mesh, in milliseconds
  38289. */
  38290. set framingTime(time: number);
  38291. /**
  38292. * Gets the transition time when framing the mesh, in milliseconds
  38293. */
  38294. get framingTime(): number;
  38295. /**
  38296. * Define if the behavior should automatically change the configured
  38297. * camera limits and sensibilities.
  38298. */
  38299. autoCorrectCameraLimitsAndSensibility: boolean;
  38300. private _onPrePointerObservableObserver;
  38301. private _onAfterCheckInputsObserver;
  38302. private _onMeshTargetChangedObserver;
  38303. private _attachedCamera;
  38304. private _isPointerDown;
  38305. private _lastInteractionTime;
  38306. /**
  38307. * Initializes the behavior.
  38308. */
  38309. init(): void;
  38310. /**
  38311. * Attaches the behavior to its arc rotate camera.
  38312. * @param camera Defines the camera to attach the behavior to
  38313. */
  38314. attach(camera: ArcRotateCamera): void;
  38315. /**
  38316. * Detaches the behavior from its current arc rotate camera.
  38317. */
  38318. detach(): void;
  38319. private _animatables;
  38320. private _betaIsAnimating;
  38321. private _betaTransition;
  38322. private _radiusTransition;
  38323. private _vectorTransition;
  38324. /**
  38325. * Targets the given mesh and updates zoom level accordingly.
  38326. * @param mesh The mesh to target.
  38327. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38328. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38329. */
  38330. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38331. /**
  38332. * Targets the given mesh with its children and updates zoom level accordingly.
  38333. * @param mesh The mesh to target.
  38334. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38335. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38336. */
  38337. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38338. /**
  38339. * Targets the given meshes with their children and updates zoom level accordingly.
  38340. * @param meshes The mesh to target.
  38341. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38342. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38343. */
  38344. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38345. /**
  38346. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38347. * @param minimumWorld Determines the smaller position of the bounding box extend
  38348. * @param maximumWorld Determines the bigger position of the bounding box extend
  38349. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38350. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38351. */
  38352. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38353. /**
  38354. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38355. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38356. * frustum width.
  38357. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38358. * to fully enclose the mesh in the viewing frustum.
  38359. */
  38360. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38361. /**
  38362. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38363. * is automatically returned to its default position (expected to be above ground plane).
  38364. */
  38365. private _maintainCameraAboveGround;
  38366. /**
  38367. * Returns the frustum slope based on the canvas ratio and camera FOV
  38368. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38369. */
  38370. private _getFrustumSlope;
  38371. /**
  38372. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38373. */
  38374. private _clearAnimationLocks;
  38375. /**
  38376. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38377. */
  38378. private _applyUserInteraction;
  38379. /**
  38380. * Stops and removes all animations that have been applied to the camera
  38381. */
  38382. stopAllAnimations(): void;
  38383. /**
  38384. * Gets a value indicating if the user is moving the camera
  38385. */
  38386. get isUserIsMoving(): boolean;
  38387. /**
  38388. * The camera can move all the way towards the mesh.
  38389. */
  38390. static IgnoreBoundsSizeMode: number;
  38391. /**
  38392. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38393. */
  38394. static FitFrustumSidesMode: number;
  38395. }
  38396. }
  38397. declare module BABYLON {
  38398. /**
  38399. * Base class for Camera Pointer Inputs.
  38400. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38401. * for example usage.
  38402. */
  38403. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38404. /**
  38405. * Defines the camera the input is attached to.
  38406. */
  38407. abstract camera: Camera;
  38408. /**
  38409. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38410. */
  38411. protected _altKey: boolean;
  38412. protected _ctrlKey: boolean;
  38413. protected _metaKey: boolean;
  38414. protected _shiftKey: boolean;
  38415. /**
  38416. * Which mouse buttons were pressed at time of last mouse event.
  38417. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38418. */
  38419. protected _buttonsPressed: number;
  38420. /**
  38421. * Defines the buttons associated with the input to handle camera move.
  38422. */
  38423. buttons: number[];
  38424. /**
  38425. * Attach the input controls to a specific dom element to get the input from.
  38426. * @param element Defines the element the controls should be listened from
  38427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38428. */
  38429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38430. /**
  38431. * Detach the current controls from the specified dom element.
  38432. * @param element Defines the element to stop listening the inputs from
  38433. */
  38434. detachControl(element: Nullable<HTMLElement>): void;
  38435. /**
  38436. * Gets the class name of the current input.
  38437. * @returns the class name
  38438. */
  38439. getClassName(): string;
  38440. /**
  38441. * Get the friendly name associated with the input class.
  38442. * @returns the input friendly name
  38443. */
  38444. getSimpleName(): string;
  38445. /**
  38446. * Called on pointer POINTERDOUBLETAP event.
  38447. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38448. */
  38449. protected onDoubleTap(type: string): void;
  38450. /**
  38451. * Called on pointer POINTERMOVE event if only a single touch is active.
  38452. * Override this method to provide functionality.
  38453. */
  38454. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38455. /**
  38456. * Called on pointer POINTERMOVE event if multiple touches are active.
  38457. * Override this method to provide functionality.
  38458. */
  38459. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38460. /**
  38461. * Called on JS contextmenu event.
  38462. * Override this method to provide functionality.
  38463. */
  38464. protected onContextMenu(evt: PointerEvent): void;
  38465. /**
  38466. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38467. * press.
  38468. * Override this method to provide functionality.
  38469. */
  38470. protected onButtonDown(evt: PointerEvent): void;
  38471. /**
  38472. * Called each time a new POINTERUP event occurs. Ie, for each button
  38473. * release.
  38474. * Override this method to provide functionality.
  38475. */
  38476. protected onButtonUp(evt: PointerEvent): void;
  38477. /**
  38478. * Called when window becomes inactive.
  38479. * Override this method to provide functionality.
  38480. */
  38481. protected onLostFocus(): void;
  38482. private _pointerInput;
  38483. private _observer;
  38484. private _onLostFocus;
  38485. private pointA;
  38486. private pointB;
  38487. }
  38488. }
  38489. declare module BABYLON {
  38490. /**
  38491. * Manage the pointers inputs to control an arc rotate camera.
  38492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38493. */
  38494. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38495. /**
  38496. * Defines the camera the input is attached to.
  38497. */
  38498. camera: ArcRotateCamera;
  38499. /**
  38500. * Gets the class name of the current input.
  38501. * @returns the class name
  38502. */
  38503. getClassName(): string;
  38504. /**
  38505. * Defines the buttons associated with the input to handle camera move.
  38506. */
  38507. buttons: number[];
  38508. /**
  38509. * Defines the pointer angular sensibility along the X axis or how fast is
  38510. * the camera rotating.
  38511. */
  38512. angularSensibilityX: number;
  38513. /**
  38514. * Defines the pointer angular sensibility along the Y axis or how fast is
  38515. * the camera rotating.
  38516. */
  38517. angularSensibilityY: number;
  38518. /**
  38519. * Defines the pointer pinch precision or how fast is the camera zooming.
  38520. */
  38521. pinchPrecision: number;
  38522. /**
  38523. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38524. * from 0.
  38525. * It defines the percentage of current camera.radius to use as delta when
  38526. * pinch zoom is used.
  38527. */
  38528. pinchDeltaPercentage: number;
  38529. /**
  38530. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38531. * that any object in the plane at the camera's target point will scale
  38532. * perfectly with finger motion.
  38533. * Overrides pinchDeltaPercentage and pinchPrecision.
  38534. */
  38535. useNaturalPinchZoom: boolean;
  38536. /**
  38537. * Defines the pointer panning sensibility or how fast is the camera moving.
  38538. */
  38539. panningSensibility: number;
  38540. /**
  38541. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38542. */
  38543. multiTouchPanning: boolean;
  38544. /**
  38545. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38546. * zoom (pinch) through multitouch.
  38547. */
  38548. multiTouchPanAndZoom: boolean;
  38549. /**
  38550. * Revers pinch action direction.
  38551. */
  38552. pinchInwards: boolean;
  38553. private _isPanClick;
  38554. private _twoFingerActivityCount;
  38555. private _isPinching;
  38556. /**
  38557. * Called on pointer POINTERMOVE event if only a single touch is active.
  38558. */
  38559. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38560. /**
  38561. * Called on pointer POINTERDOUBLETAP event.
  38562. */
  38563. protected onDoubleTap(type: string): void;
  38564. /**
  38565. * Called on pointer POINTERMOVE event if multiple touches are active.
  38566. */
  38567. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38568. /**
  38569. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38570. * press.
  38571. */
  38572. protected onButtonDown(evt: PointerEvent): void;
  38573. /**
  38574. * Called each time a new POINTERUP event occurs. Ie, for each button
  38575. * release.
  38576. */
  38577. protected onButtonUp(evt: PointerEvent): void;
  38578. /**
  38579. * Called when window becomes inactive.
  38580. */
  38581. protected onLostFocus(): void;
  38582. }
  38583. }
  38584. declare module BABYLON {
  38585. /**
  38586. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38587. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38588. */
  38589. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38590. /**
  38591. * Defines the camera the input is attached to.
  38592. */
  38593. camera: ArcRotateCamera;
  38594. /**
  38595. * Defines the list of key codes associated with the up action (increase alpha)
  38596. */
  38597. keysUp: number[];
  38598. /**
  38599. * Defines the list of key codes associated with the down action (decrease alpha)
  38600. */
  38601. keysDown: number[];
  38602. /**
  38603. * Defines the list of key codes associated with the left action (increase beta)
  38604. */
  38605. keysLeft: number[];
  38606. /**
  38607. * Defines the list of key codes associated with the right action (decrease beta)
  38608. */
  38609. keysRight: number[];
  38610. /**
  38611. * Defines the list of key codes associated with the reset action.
  38612. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38613. */
  38614. keysReset: number[];
  38615. /**
  38616. * Defines the panning sensibility of the inputs.
  38617. * (How fast is the camera panning)
  38618. */
  38619. panningSensibility: number;
  38620. /**
  38621. * Defines the zooming sensibility of the inputs.
  38622. * (How fast is the camera zooming)
  38623. */
  38624. zoomingSensibility: number;
  38625. /**
  38626. * Defines whether maintaining the alt key down switch the movement mode from
  38627. * orientation to zoom.
  38628. */
  38629. useAltToZoom: boolean;
  38630. /**
  38631. * Rotation speed of the camera
  38632. */
  38633. angularSpeed: number;
  38634. private _keys;
  38635. private _ctrlPressed;
  38636. private _altPressed;
  38637. private _onCanvasBlurObserver;
  38638. private _onKeyboardObserver;
  38639. private _engine;
  38640. private _scene;
  38641. /**
  38642. * Attach the input controls to a specific dom element to get the input from.
  38643. * @param element Defines the element the controls should be listened from
  38644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38645. */
  38646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38647. /**
  38648. * Detach the current controls from the specified dom element.
  38649. * @param element Defines the element to stop listening the inputs from
  38650. */
  38651. detachControl(element: Nullable<HTMLElement>): void;
  38652. /**
  38653. * Update the current camera state depending on the inputs that have been used this frame.
  38654. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38655. */
  38656. checkInputs(): void;
  38657. /**
  38658. * Gets the class name of the current intput.
  38659. * @returns the class name
  38660. */
  38661. getClassName(): string;
  38662. /**
  38663. * Get the friendly name associated with the input class.
  38664. * @returns the input friendly name
  38665. */
  38666. getSimpleName(): string;
  38667. }
  38668. }
  38669. declare module BABYLON {
  38670. /**
  38671. * Manage the mouse wheel inputs to control an arc rotate camera.
  38672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38673. */
  38674. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38675. /**
  38676. * Defines the camera the input is attached to.
  38677. */
  38678. camera: ArcRotateCamera;
  38679. /**
  38680. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38681. */
  38682. wheelPrecision: number;
  38683. /**
  38684. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38685. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38686. */
  38687. wheelDeltaPercentage: number;
  38688. private _wheel;
  38689. private _observer;
  38690. private computeDeltaFromMouseWheelLegacyEvent;
  38691. /**
  38692. * Attach the input controls to a specific dom element to get the input from.
  38693. * @param element Defines the element the controls should be listened from
  38694. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38695. */
  38696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38697. /**
  38698. * Detach the current controls from the specified dom element.
  38699. * @param element Defines the element to stop listening the inputs from
  38700. */
  38701. detachControl(element: Nullable<HTMLElement>): void;
  38702. /**
  38703. * Gets the class name of the current intput.
  38704. * @returns the class name
  38705. */
  38706. getClassName(): string;
  38707. /**
  38708. * Get the friendly name associated with the input class.
  38709. * @returns the input friendly name
  38710. */
  38711. getSimpleName(): string;
  38712. }
  38713. }
  38714. declare module BABYLON {
  38715. /**
  38716. * Default Inputs manager for the ArcRotateCamera.
  38717. * It groups all the default supported inputs for ease of use.
  38718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38719. */
  38720. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38721. /**
  38722. * Instantiates a new ArcRotateCameraInputsManager.
  38723. * @param camera Defines the camera the inputs belong to
  38724. */
  38725. constructor(camera: ArcRotateCamera);
  38726. /**
  38727. * Add mouse wheel input support to the input manager.
  38728. * @returns the current input manager
  38729. */
  38730. addMouseWheel(): ArcRotateCameraInputsManager;
  38731. /**
  38732. * Add pointers input support to the input manager.
  38733. * @returns the current input manager
  38734. */
  38735. addPointers(): ArcRotateCameraInputsManager;
  38736. /**
  38737. * Add keyboard input support to the input manager.
  38738. * @returns the current input manager
  38739. */
  38740. addKeyboard(): ArcRotateCameraInputsManager;
  38741. }
  38742. }
  38743. declare module BABYLON {
  38744. /**
  38745. * This represents an orbital type of camera.
  38746. *
  38747. * 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.
  38748. * 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.
  38749. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38750. */
  38751. export class ArcRotateCamera extends TargetCamera {
  38752. /**
  38753. * Defines the rotation angle of the camera along the longitudinal axis.
  38754. */
  38755. alpha: number;
  38756. /**
  38757. * Defines the rotation angle of the camera along the latitudinal axis.
  38758. */
  38759. beta: number;
  38760. /**
  38761. * Defines the radius of the camera from it s target point.
  38762. */
  38763. radius: number;
  38764. protected _target: Vector3;
  38765. protected _targetHost: Nullable<AbstractMesh>;
  38766. /**
  38767. * Defines the target point of the camera.
  38768. * The camera looks towards it form the radius distance.
  38769. */
  38770. get target(): Vector3;
  38771. set target(value: Vector3);
  38772. /**
  38773. * Define the current local position of the camera in the scene
  38774. */
  38775. get position(): Vector3;
  38776. set position(newPosition: Vector3);
  38777. protected _upVector: Vector3;
  38778. protected _upToYMatrix: Matrix;
  38779. protected _YToUpMatrix: Matrix;
  38780. /**
  38781. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38782. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38783. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38784. */
  38785. set upVector(vec: Vector3);
  38786. get upVector(): Vector3;
  38787. /**
  38788. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38789. */
  38790. setMatUp(): void;
  38791. /**
  38792. * Current inertia value on the longitudinal axis.
  38793. * The bigger this number the longer it will take for the camera to stop.
  38794. */
  38795. inertialAlphaOffset: number;
  38796. /**
  38797. * Current inertia value on the latitudinal axis.
  38798. * The bigger this number the longer it will take for the camera to stop.
  38799. */
  38800. inertialBetaOffset: number;
  38801. /**
  38802. * Current inertia value on the radius axis.
  38803. * The bigger this number the longer it will take for the camera to stop.
  38804. */
  38805. inertialRadiusOffset: number;
  38806. /**
  38807. * Minimum allowed angle on the longitudinal axis.
  38808. * This can help limiting how the Camera is able to move in the scene.
  38809. */
  38810. lowerAlphaLimit: Nullable<number>;
  38811. /**
  38812. * Maximum allowed angle on the longitudinal axis.
  38813. * This can help limiting how the Camera is able to move in the scene.
  38814. */
  38815. upperAlphaLimit: Nullable<number>;
  38816. /**
  38817. * Minimum allowed angle on the latitudinal axis.
  38818. * This can help limiting how the Camera is able to move in the scene.
  38819. */
  38820. lowerBetaLimit: number;
  38821. /**
  38822. * Maximum allowed angle on the latitudinal axis.
  38823. * This can help limiting how the Camera is able to move in the scene.
  38824. */
  38825. upperBetaLimit: number;
  38826. /**
  38827. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38828. * This can help limiting how the Camera is able to move in the scene.
  38829. */
  38830. lowerRadiusLimit: Nullable<number>;
  38831. /**
  38832. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38833. * This can help limiting how the Camera is able to move in the scene.
  38834. */
  38835. upperRadiusLimit: Nullable<number>;
  38836. /**
  38837. * Defines the current inertia value used during panning of the camera along the X axis.
  38838. */
  38839. inertialPanningX: number;
  38840. /**
  38841. * Defines the current inertia value used during panning of the camera along the Y axis.
  38842. */
  38843. inertialPanningY: number;
  38844. /**
  38845. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38846. * Basically if your fingers moves away from more than this distance you will be considered
  38847. * in pinch mode.
  38848. */
  38849. pinchToPanMaxDistance: number;
  38850. /**
  38851. * Defines the maximum distance the camera can pan.
  38852. * This could help keeping the cammera always in your scene.
  38853. */
  38854. panningDistanceLimit: Nullable<number>;
  38855. /**
  38856. * Defines the target of the camera before paning.
  38857. */
  38858. panningOriginTarget: Vector3;
  38859. /**
  38860. * Defines the value of the inertia used during panning.
  38861. * 0 would mean stop inertia and one would mean no decelleration at all.
  38862. */
  38863. panningInertia: number;
  38864. /**
  38865. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38866. */
  38867. get angularSensibilityX(): number;
  38868. set angularSensibilityX(value: number);
  38869. /**
  38870. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38871. */
  38872. get angularSensibilityY(): number;
  38873. set angularSensibilityY(value: number);
  38874. /**
  38875. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38876. */
  38877. get pinchPrecision(): number;
  38878. set pinchPrecision(value: number);
  38879. /**
  38880. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38881. * It will be used instead of pinchDeltaPrecision if different from 0.
  38882. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38883. */
  38884. get pinchDeltaPercentage(): number;
  38885. set pinchDeltaPercentage(value: number);
  38886. /**
  38887. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38888. * and pinch delta percentage.
  38889. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38890. * that any object in the plane at the camera's target point will scale
  38891. * perfectly with finger motion.
  38892. */
  38893. get useNaturalPinchZoom(): boolean;
  38894. set useNaturalPinchZoom(value: boolean);
  38895. /**
  38896. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38897. */
  38898. get panningSensibility(): number;
  38899. set panningSensibility(value: number);
  38900. /**
  38901. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38902. */
  38903. get keysUp(): number[];
  38904. set keysUp(value: number[]);
  38905. /**
  38906. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38907. */
  38908. get keysDown(): number[];
  38909. set keysDown(value: number[]);
  38910. /**
  38911. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38912. */
  38913. get keysLeft(): number[];
  38914. set keysLeft(value: number[]);
  38915. /**
  38916. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38917. */
  38918. get keysRight(): number[];
  38919. set keysRight(value: number[]);
  38920. /**
  38921. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38922. */
  38923. get wheelPrecision(): number;
  38924. set wheelPrecision(value: number);
  38925. /**
  38926. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38927. * It will be used instead of pinchDeltaPrecision if different from 0.
  38928. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38929. */
  38930. get wheelDeltaPercentage(): number;
  38931. set wheelDeltaPercentage(value: number);
  38932. /**
  38933. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38934. */
  38935. zoomOnFactor: number;
  38936. /**
  38937. * Defines a screen offset for the camera position.
  38938. */
  38939. targetScreenOffset: Vector2;
  38940. /**
  38941. * Allows the camera to be completely reversed.
  38942. * If false the camera can not arrive upside down.
  38943. */
  38944. allowUpsideDown: boolean;
  38945. /**
  38946. * Define if double tap/click is used to restore the previously saved state of the camera.
  38947. */
  38948. useInputToRestoreState: boolean;
  38949. /** @hidden */
  38950. _viewMatrix: Matrix;
  38951. /** @hidden */
  38952. _useCtrlForPanning: boolean;
  38953. /** @hidden */
  38954. _panningMouseButton: number;
  38955. /**
  38956. * Defines the input associated to the camera.
  38957. */
  38958. inputs: ArcRotateCameraInputsManager;
  38959. /** @hidden */
  38960. _reset: () => void;
  38961. /**
  38962. * Defines the allowed panning axis.
  38963. */
  38964. panningAxis: Vector3;
  38965. protected _localDirection: Vector3;
  38966. protected _transformedDirection: Vector3;
  38967. private _bouncingBehavior;
  38968. /**
  38969. * Gets the bouncing behavior of the camera if it has been enabled.
  38970. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38971. */
  38972. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38973. /**
  38974. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38975. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38976. */
  38977. get useBouncingBehavior(): boolean;
  38978. set useBouncingBehavior(value: boolean);
  38979. private _framingBehavior;
  38980. /**
  38981. * Gets the framing behavior of the camera if it has been enabled.
  38982. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38983. */
  38984. get framingBehavior(): Nullable<FramingBehavior>;
  38985. /**
  38986. * Defines if the framing behavior of the camera is enabled on the camera.
  38987. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38988. */
  38989. get useFramingBehavior(): boolean;
  38990. set useFramingBehavior(value: boolean);
  38991. private _autoRotationBehavior;
  38992. /**
  38993. * Gets the auto rotation behavior of the camera if it has been enabled.
  38994. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38995. */
  38996. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38997. /**
  38998. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38999. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39000. */
  39001. get useAutoRotationBehavior(): boolean;
  39002. set useAutoRotationBehavior(value: boolean);
  39003. /**
  39004. * Observable triggered when the mesh target has been changed on the camera.
  39005. */
  39006. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39007. /**
  39008. * Event raised when the camera is colliding with a mesh.
  39009. */
  39010. onCollide: (collidedMesh: AbstractMesh) => void;
  39011. /**
  39012. * Defines whether the camera should check collision with the objects oh the scene.
  39013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39014. */
  39015. checkCollisions: boolean;
  39016. /**
  39017. * Defines the collision radius of the camera.
  39018. * This simulates a sphere around the camera.
  39019. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39020. */
  39021. collisionRadius: Vector3;
  39022. protected _collider: Collider;
  39023. protected _previousPosition: Vector3;
  39024. protected _collisionVelocity: Vector3;
  39025. protected _newPosition: Vector3;
  39026. protected _previousAlpha: number;
  39027. protected _previousBeta: number;
  39028. protected _previousRadius: number;
  39029. protected _collisionTriggered: boolean;
  39030. protected _targetBoundingCenter: Nullable<Vector3>;
  39031. private _computationVector;
  39032. /**
  39033. * Instantiates a new ArcRotateCamera in a given scene
  39034. * @param name Defines the name of the camera
  39035. * @param alpha Defines the camera rotation along the logitudinal axis
  39036. * @param beta Defines the camera rotation along the latitudinal axis
  39037. * @param radius Defines the camera distance from its target
  39038. * @param target Defines the camera target
  39039. * @param scene Defines the scene the camera belongs to
  39040. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39041. */
  39042. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39043. /** @hidden */
  39044. _initCache(): void;
  39045. /** @hidden */
  39046. _updateCache(ignoreParentClass?: boolean): void;
  39047. protected _getTargetPosition(): Vector3;
  39048. private _storedAlpha;
  39049. private _storedBeta;
  39050. private _storedRadius;
  39051. private _storedTarget;
  39052. private _storedTargetScreenOffset;
  39053. /**
  39054. * Stores the current state of the camera (alpha, beta, radius and target)
  39055. * @returns the camera itself
  39056. */
  39057. storeState(): Camera;
  39058. /**
  39059. * @hidden
  39060. * Restored camera state. You must call storeState() first
  39061. */
  39062. _restoreStateValues(): boolean;
  39063. /** @hidden */
  39064. _isSynchronizedViewMatrix(): boolean;
  39065. /**
  39066. * Attached controls to the current camera.
  39067. * @param element Defines the element the controls should be listened from
  39068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39069. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39070. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39071. */
  39072. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39073. /**
  39074. * Detach the current controls from the camera.
  39075. * The camera will stop reacting to inputs.
  39076. * @param element Defines the element to stop listening the inputs from
  39077. */
  39078. detachControl(element: HTMLElement): void;
  39079. /** @hidden */
  39080. _checkInputs(): void;
  39081. protected _checkLimits(): void;
  39082. /**
  39083. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39084. */
  39085. rebuildAnglesAndRadius(): void;
  39086. /**
  39087. * Use a position to define the current camera related information like alpha, beta and radius
  39088. * @param position Defines the position to set the camera at
  39089. */
  39090. setPosition(position: Vector3): void;
  39091. /**
  39092. * Defines the target the camera should look at.
  39093. * This will automatically adapt alpha beta and radius to fit within the new target.
  39094. * @param target Defines the new target as a Vector or a mesh
  39095. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39096. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39097. */
  39098. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39099. /** @hidden */
  39100. _getViewMatrix(): Matrix;
  39101. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39102. /**
  39103. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39104. * @param meshes Defines the mesh to zoom on
  39105. * @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)
  39106. */
  39107. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39108. /**
  39109. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39110. * The target will be changed but the radius
  39111. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39112. * @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)
  39113. */
  39114. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39115. min: Vector3;
  39116. max: Vector3;
  39117. distance: number;
  39118. }, doNotUpdateMaxZ?: boolean): void;
  39119. /**
  39120. * @override
  39121. * Override Camera.createRigCamera
  39122. */
  39123. createRigCamera(name: string, cameraIndex: number): Camera;
  39124. /**
  39125. * @hidden
  39126. * @override
  39127. * Override Camera._updateRigCameras
  39128. */
  39129. _updateRigCameras(): void;
  39130. /**
  39131. * Destroy the camera and release the current resources hold by it.
  39132. */
  39133. dispose(): void;
  39134. /**
  39135. * Gets the current object class name.
  39136. * @return the class name
  39137. */
  39138. getClassName(): string;
  39139. }
  39140. }
  39141. declare module BABYLON {
  39142. /**
  39143. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39144. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39145. */
  39146. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39147. /**
  39148. * Gets the name of the behavior.
  39149. */
  39150. get name(): string;
  39151. private _zoomStopsAnimation;
  39152. private _idleRotationSpeed;
  39153. private _idleRotationWaitTime;
  39154. private _idleRotationSpinupTime;
  39155. /**
  39156. * Sets the flag that indicates if user zooming should stop animation.
  39157. */
  39158. set zoomStopsAnimation(flag: boolean);
  39159. /**
  39160. * Gets the flag that indicates if user zooming should stop animation.
  39161. */
  39162. get zoomStopsAnimation(): boolean;
  39163. /**
  39164. * Sets the default speed at which the camera rotates around the model.
  39165. */
  39166. set idleRotationSpeed(speed: number);
  39167. /**
  39168. * Gets the default speed at which the camera rotates around the model.
  39169. */
  39170. get idleRotationSpeed(): number;
  39171. /**
  39172. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39173. */
  39174. set idleRotationWaitTime(time: number);
  39175. /**
  39176. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39177. */
  39178. get idleRotationWaitTime(): number;
  39179. /**
  39180. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39181. */
  39182. set idleRotationSpinupTime(time: number);
  39183. /**
  39184. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39185. */
  39186. get idleRotationSpinupTime(): number;
  39187. /**
  39188. * Gets a value indicating if the camera is currently rotating because of this behavior
  39189. */
  39190. get rotationInProgress(): boolean;
  39191. private _onPrePointerObservableObserver;
  39192. private _onAfterCheckInputsObserver;
  39193. private _attachedCamera;
  39194. private _isPointerDown;
  39195. private _lastFrameTime;
  39196. private _lastInteractionTime;
  39197. private _cameraRotationSpeed;
  39198. /**
  39199. * Initializes the behavior.
  39200. */
  39201. init(): void;
  39202. /**
  39203. * Attaches the behavior to its arc rotate camera.
  39204. * @param camera Defines the camera to attach the behavior to
  39205. */
  39206. attach(camera: ArcRotateCamera): void;
  39207. /**
  39208. * Detaches the behavior from its current arc rotate camera.
  39209. */
  39210. detach(): void;
  39211. /**
  39212. * Returns true if user is scrolling.
  39213. * @return true if user is scrolling.
  39214. */
  39215. private _userIsZooming;
  39216. private _lastFrameRadius;
  39217. private _shouldAnimationStopForInteraction;
  39218. /**
  39219. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39220. */
  39221. private _applyUserInteraction;
  39222. private _userIsMoving;
  39223. }
  39224. }
  39225. declare module BABYLON {
  39226. /**
  39227. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39228. */
  39229. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39230. private ui;
  39231. /**
  39232. * The name of the behavior
  39233. */
  39234. name: string;
  39235. /**
  39236. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39237. */
  39238. distanceAwayFromFace: number;
  39239. /**
  39240. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39241. */
  39242. distanceAwayFromBottomOfFace: number;
  39243. private _faceVectors;
  39244. private _target;
  39245. private _scene;
  39246. private _onRenderObserver;
  39247. private _tmpMatrix;
  39248. private _tmpVector;
  39249. /**
  39250. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39251. * @param ui The transform node that should be attched to the mesh
  39252. */
  39253. constructor(ui: TransformNode);
  39254. /**
  39255. * Initializes the behavior
  39256. */
  39257. init(): void;
  39258. private _closestFace;
  39259. private _zeroVector;
  39260. private _lookAtTmpMatrix;
  39261. private _lookAtToRef;
  39262. /**
  39263. * Attaches the AttachToBoxBehavior to the passed in mesh
  39264. * @param target The mesh that the specified node will be attached to
  39265. */
  39266. attach(target: Mesh): void;
  39267. /**
  39268. * Detaches the behavior from the mesh
  39269. */
  39270. detach(): void;
  39271. }
  39272. }
  39273. declare module BABYLON {
  39274. /**
  39275. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39276. */
  39277. export class FadeInOutBehavior implements Behavior<Mesh> {
  39278. /**
  39279. * Time in milliseconds to delay before fading in (Default: 0)
  39280. */
  39281. delay: number;
  39282. /**
  39283. * Time in milliseconds for the mesh to fade in (Default: 300)
  39284. */
  39285. fadeInTime: number;
  39286. private _millisecondsPerFrame;
  39287. private _hovered;
  39288. private _hoverValue;
  39289. private _ownerNode;
  39290. /**
  39291. * Instatiates the FadeInOutBehavior
  39292. */
  39293. constructor();
  39294. /**
  39295. * The name of the behavior
  39296. */
  39297. get name(): string;
  39298. /**
  39299. * Initializes the behavior
  39300. */
  39301. init(): void;
  39302. /**
  39303. * Attaches the fade behavior on the passed in mesh
  39304. * @param ownerNode The mesh that will be faded in/out once attached
  39305. */
  39306. attach(ownerNode: Mesh): void;
  39307. /**
  39308. * Detaches the behavior from the mesh
  39309. */
  39310. detach(): void;
  39311. /**
  39312. * Triggers the mesh to begin fading in or out
  39313. * @param value if the object should fade in or out (true to fade in)
  39314. */
  39315. fadeIn(value: boolean): void;
  39316. private _update;
  39317. private _setAllVisibility;
  39318. }
  39319. }
  39320. declare module BABYLON {
  39321. /**
  39322. * Class containing a set of static utilities functions for managing Pivots
  39323. * @hidden
  39324. */
  39325. export class PivotTools {
  39326. private static _PivotCached;
  39327. private static _OldPivotPoint;
  39328. private static _PivotTranslation;
  39329. private static _PivotTmpVector;
  39330. /** @hidden */
  39331. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39332. /** @hidden */
  39333. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39334. }
  39335. }
  39336. declare module BABYLON {
  39337. /**
  39338. * Class containing static functions to help procedurally build meshes
  39339. */
  39340. export class PlaneBuilder {
  39341. /**
  39342. * Creates a plane mesh
  39343. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39344. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39345. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39347. * * 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
  39348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39349. * @param name defines the name of the mesh
  39350. * @param options defines the options used to create the mesh
  39351. * @param scene defines the hosting scene
  39352. * @returns the plane mesh
  39353. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39354. */
  39355. static CreatePlane(name: string, options: {
  39356. size?: number;
  39357. width?: number;
  39358. height?: number;
  39359. sideOrientation?: number;
  39360. frontUVs?: Vector4;
  39361. backUVs?: Vector4;
  39362. updatable?: boolean;
  39363. sourcePlane?: Plane;
  39364. }, scene?: Nullable<Scene>): Mesh;
  39365. }
  39366. }
  39367. declare module BABYLON {
  39368. /**
  39369. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39370. */
  39371. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39372. private static _AnyMouseID;
  39373. /**
  39374. * Abstract mesh the behavior is set on
  39375. */
  39376. attachedNode: AbstractMesh;
  39377. private _dragPlane;
  39378. private _scene;
  39379. private _pointerObserver;
  39380. private _beforeRenderObserver;
  39381. private static _planeScene;
  39382. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39383. /**
  39384. * 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)
  39385. */
  39386. maxDragAngle: number;
  39387. /**
  39388. * @hidden
  39389. */
  39390. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39391. /**
  39392. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39393. */
  39394. currentDraggingPointerID: number;
  39395. /**
  39396. * The last position where the pointer hit the drag plane in world space
  39397. */
  39398. lastDragPosition: Vector3;
  39399. /**
  39400. * If the behavior is currently in a dragging state
  39401. */
  39402. dragging: boolean;
  39403. /**
  39404. * 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)
  39405. */
  39406. dragDeltaRatio: number;
  39407. /**
  39408. * If the drag plane orientation should be updated during the dragging (Default: true)
  39409. */
  39410. updateDragPlane: boolean;
  39411. private _debugMode;
  39412. private _moving;
  39413. /**
  39414. * Fires each time the attached mesh is dragged with the pointer
  39415. * * delta between last drag position and current drag position in world space
  39416. * * dragDistance along the drag axis
  39417. * * dragPlaneNormal normal of the current drag plane used during the drag
  39418. * * dragPlanePoint in world space where the drag intersects the drag plane
  39419. */
  39420. onDragObservable: Observable<{
  39421. delta: Vector3;
  39422. dragPlanePoint: Vector3;
  39423. dragPlaneNormal: Vector3;
  39424. dragDistance: number;
  39425. pointerId: number;
  39426. }>;
  39427. /**
  39428. * Fires each time a drag begins (eg. mouse down on mesh)
  39429. */
  39430. onDragStartObservable: Observable<{
  39431. dragPlanePoint: Vector3;
  39432. pointerId: number;
  39433. }>;
  39434. /**
  39435. * Fires each time a drag ends (eg. mouse release after drag)
  39436. */
  39437. onDragEndObservable: Observable<{
  39438. dragPlanePoint: Vector3;
  39439. pointerId: number;
  39440. }>;
  39441. /**
  39442. * If the attached mesh should be moved when dragged
  39443. */
  39444. moveAttached: boolean;
  39445. /**
  39446. * If the drag behavior will react to drag events (Default: true)
  39447. */
  39448. enabled: boolean;
  39449. /**
  39450. * If pointer events should start and release the drag (Default: true)
  39451. */
  39452. startAndReleaseDragOnPointerEvents: boolean;
  39453. /**
  39454. * If camera controls should be detached during the drag
  39455. */
  39456. detachCameraControls: boolean;
  39457. /**
  39458. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39459. */
  39460. useObjectOrientationForDragging: boolean;
  39461. private _options;
  39462. /**
  39463. * Gets the options used by the behavior
  39464. */
  39465. get options(): {
  39466. dragAxis?: Vector3;
  39467. dragPlaneNormal?: Vector3;
  39468. };
  39469. /**
  39470. * Sets the options used by the behavior
  39471. */
  39472. set options(options: {
  39473. dragAxis?: Vector3;
  39474. dragPlaneNormal?: Vector3;
  39475. });
  39476. /**
  39477. * Creates a pointer drag behavior that can be attached to a mesh
  39478. * @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)
  39479. */
  39480. constructor(options?: {
  39481. dragAxis?: Vector3;
  39482. dragPlaneNormal?: Vector3;
  39483. });
  39484. /**
  39485. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39486. */
  39487. validateDrag: (targetPosition: Vector3) => boolean;
  39488. /**
  39489. * The name of the behavior
  39490. */
  39491. get name(): string;
  39492. /**
  39493. * Initializes the behavior
  39494. */
  39495. init(): void;
  39496. private _tmpVector;
  39497. private _alternatePickedPoint;
  39498. private _worldDragAxis;
  39499. private _targetPosition;
  39500. private _attachedElement;
  39501. /**
  39502. * Attaches the drag behavior the passed in mesh
  39503. * @param ownerNode The mesh that will be dragged around once attached
  39504. * @param predicate Predicate to use for pick filtering
  39505. */
  39506. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39507. /**
  39508. * Force relase the drag action by code.
  39509. */
  39510. releaseDrag(): void;
  39511. private _startDragRay;
  39512. private _lastPointerRay;
  39513. /**
  39514. * Simulates the start of a pointer drag event on the behavior
  39515. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39516. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39517. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39518. */
  39519. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39520. private _startDrag;
  39521. private _dragDelta;
  39522. private _moveDrag;
  39523. private _pickWithRayOnDragPlane;
  39524. private _pointA;
  39525. private _pointB;
  39526. private _pointC;
  39527. private _lineA;
  39528. private _lineB;
  39529. private _localAxis;
  39530. private _lookAt;
  39531. private _updateDragPlanePosition;
  39532. /**
  39533. * Detaches the behavior from the mesh
  39534. */
  39535. detach(): void;
  39536. }
  39537. }
  39538. declare module BABYLON {
  39539. /**
  39540. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39541. */
  39542. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39543. private _dragBehaviorA;
  39544. private _dragBehaviorB;
  39545. private _startDistance;
  39546. private _initialScale;
  39547. private _targetScale;
  39548. private _ownerNode;
  39549. private _sceneRenderObserver;
  39550. /**
  39551. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39552. */
  39553. constructor();
  39554. /**
  39555. * The name of the behavior
  39556. */
  39557. get name(): string;
  39558. /**
  39559. * Initializes the behavior
  39560. */
  39561. init(): void;
  39562. private _getCurrentDistance;
  39563. /**
  39564. * Attaches the scale behavior the passed in mesh
  39565. * @param ownerNode The mesh that will be scaled around once attached
  39566. */
  39567. attach(ownerNode: Mesh): void;
  39568. /**
  39569. * Detaches the behavior from the mesh
  39570. */
  39571. detach(): void;
  39572. }
  39573. }
  39574. declare module BABYLON {
  39575. /**
  39576. * 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
  39577. */
  39578. export class SixDofDragBehavior implements Behavior<Mesh> {
  39579. private static _virtualScene;
  39580. private _ownerNode;
  39581. private _sceneRenderObserver;
  39582. private _scene;
  39583. private _targetPosition;
  39584. private _virtualOriginMesh;
  39585. private _virtualDragMesh;
  39586. private _pointerObserver;
  39587. private _moving;
  39588. private _startingOrientation;
  39589. private _attachedElement;
  39590. /**
  39591. * 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)
  39592. */
  39593. private zDragFactor;
  39594. /**
  39595. * If the object should rotate to face the drag origin
  39596. */
  39597. rotateDraggedObject: boolean;
  39598. /**
  39599. * If the behavior is currently in a dragging state
  39600. */
  39601. dragging: boolean;
  39602. /**
  39603. * 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)
  39604. */
  39605. dragDeltaRatio: number;
  39606. /**
  39607. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39608. */
  39609. currentDraggingPointerID: number;
  39610. /**
  39611. * If camera controls should be detached during the drag
  39612. */
  39613. detachCameraControls: boolean;
  39614. /**
  39615. * Fires each time a drag starts
  39616. */
  39617. onDragStartObservable: Observable<{}>;
  39618. /**
  39619. * Fires each time a drag ends (eg. mouse release after drag)
  39620. */
  39621. onDragEndObservable: Observable<{}>;
  39622. /**
  39623. * 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
  39624. */
  39625. constructor();
  39626. /**
  39627. * The name of the behavior
  39628. */
  39629. get name(): string;
  39630. /**
  39631. * Initializes the behavior
  39632. */
  39633. init(): void;
  39634. /**
  39635. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39636. */
  39637. private get _pointerCamera();
  39638. /**
  39639. * Attaches the scale behavior the passed in mesh
  39640. * @param ownerNode The mesh that will be scaled around once attached
  39641. */
  39642. attach(ownerNode: Mesh): void;
  39643. /**
  39644. * Detaches the behavior from the mesh
  39645. */
  39646. detach(): void;
  39647. }
  39648. }
  39649. declare module BABYLON {
  39650. /**
  39651. * Class used to apply inverse kinematics to bones
  39652. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39653. */
  39654. export class BoneIKController {
  39655. private static _tmpVecs;
  39656. private static _tmpQuat;
  39657. private static _tmpMats;
  39658. /**
  39659. * Gets or sets the target mesh
  39660. */
  39661. targetMesh: AbstractMesh;
  39662. /** Gets or sets the mesh used as pole */
  39663. poleTargetMesh: AbstractMesh;
  39664. /**
  39665. * Gets or sets the bone used as pole
  39666. */
  39667. poleTargetBone: Nullable<Bone>;
  39668. /**
  39669. * Gets or sets the target position
  39670. */
  39671. targetPosition: Vector3;
  39672. /**
  39673. * Gets or sets the pole target position
  39674. */
  39675. poleTargetPosition: Vector3;
  39676. /**
  39677. * Gets or sets the pole target local offset
  39678. */
  39679. poleTargetLocalOffset: Vector3;
  39680. /**
  39681. * Gets or sets the pole angle
  39682. */
  39683. poleAngle: number;
  39684. /**
  39685. * Gets or sets the mesh associated with the controller
  39686. */
  39687. mesh: AbstractMesh;
  39688. /**
  39689. * 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)
  39690. */
  39691. slerpAmount: number;
  39692. private _bone1Quat;
  39693. private _bone1Mat;
  39694. private _bone2Ang;
  39695. private _bone1;
  39696. private _bone2;
  39697. private _bone1Length;
  39698. private _bone2Length;
  39699. private _maxAngle;
  39700. private _maxReach;
  39701. private _rightHandedSystem;
  39702. private _bendAxis;
  39703. private _slerping;
  39704. private _adjustRoll;
  39705. /**
  39706. * Gets or sets maximum allowed angle
  39707. */
  39708. get maxAngle(): number;
  39709. set maxAngle(value: number);
  39710. /**
  39711. * Creates a new BoneIKController
  39712. * @param mesh defines the mesh to control
  39713. * @param bone defines the bone to control
  39714. * @param options defines options to set up the controller
  39715. */
  39716. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39717. targetMesh?: AbstractMesh;
  39718. poleTargetMesh?: AbstractMesh;
  39719. poleTargetBone?: Bone;
  39720. poleTargetLocalOffset?: Vector3;
  39721. poleAngle?: number;
  39722. bendAxis?: Vector3;
  39723. maxAngle?: number;
  39724. slerpAmount?: number;
  39725. });
  39726. private _setMaxAngle;
  39727. /**
  39728. * Force the controller to update the bones
  39729. */
  39730. update(): void;
  39731. }
  39732. }
  39733. declare module BABYLON {
  39734. /**
  39735. * Class used to make a bone look toward a point in space
  39736. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39737. */
  39738. export class BoneLookController {
  39739. private static _tmpVecs;
  39740. private static _tmpQuat;
  39741. private static _tmpMats;
  39742. /**
  39743. * The target Vector3 that the bone will look at
  39744. */
  39745. target: Vector3;
  39746. /**
  39747. * The mesh that the bone is attached to
  39748. */
  39749. mesh: AbstractMesh;
  39750. /**
  39751. * The bone that will be looking to the target
  39752. */
  39753. bone: Bone;
  39754. /**
  39755. * The up axis of the coordinate system that is used when the bone is rotated
  39756. */
  39757. upAxis: Vector3;
  39758. /**
  39759. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39760. */
  39761. upAxisSpace: Space;
  39762. /**
  39763. * Used to make an adjustment to the yaw of the bone
  39764. */
  39765. adjustYaw: number;
  39766. /**
  39767. * Used to make an adjustment to the pitch of the bone
  39768. */
  39769. adjustPitch: number;
  39770. /**
  39771. * Used to make an adjustment to the roll of the bone
  39772. */
  39773. adjustRoll: number;
  39774. /**
  39775. * 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)
  39776. */
  39777. slerpAmount: number;
  39778. private _minYaw;
  39779. private _maxYaw;
  39780. private _minPitch;
  39781. private _maxPitch;
  39782. private _minYawSin;
  39783. private _minYawCos;
  39784. private _maxYawSin;
  39785. private _maxYawCos;
  39786. private _midYawConstraint;
  39787. private _minPitchTan;
  39788. private _maxPitchTan;
  39789. private _boneQuat;
  39790. private _slerping;
  39791. private _transformYawPitch;
  39792. private _transformYawPitchInv;
  39793. private _firstFrameSkipped;
  39794. private _yawRange;
  39795. private _fowardAxis;
  39796. /**
  39797. * Gets or sets the minimum yaw angle that the bone can look to
  39798. */
  39799. get minYaw(): number;
  39800. set minYaw(value: number);
  39801. /**
  39802. * Gets or sets the maximum yaw angle that the bone can look to
  39803. */
  39804. get maxYaw(): number;
  39805. set maxYaw(value: number);
  39806. /**
  39807. * Gets or sets the minimum pitch angle that the bone can look to
  39808. */
  39809. get minPitch(): number;
  39810. set minPitch(value: number);
  39811. /**
  39812. * Gets or sets the maximum pitch angle that the bone can look to
  39813. */
  39814. get maxPitch(): number;
  39815. set maxPitch(value: number);
  39816. /**
  39817. * Create a BoneLookController
  39818. * @param mesh the mesh that the bone belongs to
  39819. * @param bone the bone that will be looking to the target
  39820. * @param target the target Vector3 to look at
  39821. * @param options optional settings:
  39822. * * maxYaw: the maximum angle the bone will yaw to
  39823. * * minYaw: the minimum angle the bone will yaw to
  39824. * * maxPitch: the maximum angle the bone will pitch to
  39825. * * minPitch: the minimum angle the bone will yaw to
  39826. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39827. * * upAxis: the up axis of the coordinate system
  39828. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39829. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39830. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39831. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39832. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39833. * * adjustRoll: used to make an adjustment to the roll of the bone
  39834. **/
  39835. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39836. maxYaw?: number;
  39837. minYaw?: number;
  39838. maxPitch?: number;
  39839. minPitch?: number;
  39840. slerpAmount?: number;
  39841. upAxis?: Vector3;
  39842. upAxisSpace?: Space;
  39843. yawAxis?: Vector3;
  39844. pitchAxis?: Vector3;
  39845. adjustYaw?: number;
  39846. adjustPitch?: number;
  39847. adjustRoll?: number;
  39848. });
  39849. /**
  39850. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39851. */
  39852. update(): void;
  39853. private _getAngleDiff;
  39854. private _getAngleBetween;
  39855. private _isAngleBetween;
  39856. }
  39857. }
  39858. declare module BABYLON {
  39859. /**
  39860. * Manage the gamepad inputs to control an arc rotate camera.
  39861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39862. */
  39863. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39864. /**
  39865. * Defines the camera the input is attached to.
  39866. */
  39867. camera: ArcRotateCamera;
  39868. /**
  39869. * Defines the gamepad the input is gathering event from.
  39870. */
  39871. gamepad: Nullable<Gamepad>;
  39872. /**
  39873. * Defines the gamepad rotation sensiblity.
  39874. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39875. */
  39876. gamepadRotationSensibility: number;
  39877. /**
  39878. * Defines the gamepad move sensiblity.
  39879. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39880. */
  39881. gamepadMoveSensibility: number;
  39882. private _yAxisScale;
  39883. /**
  39884. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39885. */
  39886. get invertYAxis(): boolean;
  39887. set invertYAxis(value: boolean);
  39888. private _onGamepadConnectedObserver;
  39889. private _onGamepadDisconnectedObserver;
  39890. /**
  39891. * Attach the input controls to a specific dom element to get the input from.
  39892. * @param element Defines the element the controls should be listened from
  39893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39894. */
  39895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39896. /**
  39897. * Detach the current controls from the specified dom element.
  39898. * @param element Defines the element to stop listening the inputs from
  39899. */
  39900. detachControl(element: Nullable<HTMLElement>): void;
  39901. /**
  39902. * Update the current camera state depending on the inputs that have been used this frame.
  39903. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39904. */
  39905. checkInputs(): void;
  39906. /**
  39907. * Gets the class name of the current intput.
  39908. * @returns the class name
  39909. */
  39910. getClassName(): string;
  39911. /**
  39912. * Get the friendly name associated with the input class.
  39913. * @returns the input friendly name
  39914. */
  39915. getSimpleName(): string;
  39916. }
  39917. }
  39918. declare module BABYLON {
  39919. interface ArcRotateCameraInputsManager {
  39920. /**
  39921. * Add orientation input support to the input manager.
  39922. * @returns the current input manager
  39923. */
  39924. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39925. }
  39926. /**
  39927. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39928. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39929. */
  39930. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39931. /**
  39932. * Defines the camera the input is attached to.
  39933. */
  39934. camera: ArcRotateCamera;
  39935. /**
  39936. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39937. */
  39938. alphaCorrection: number;
  39939. /**
  39940. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39941. */
  39942. gammaCorrection: number;
  39943. private _alpha;
  39944. private _gamma;
  39945. private _dirty;
  39946. private _deviceOrientationHandler;
  39947. /**
  39948. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39949. */
  39950. constructor();
  39951. /**
  39952. * Attach the input controls to a specific dom element to get the input from.
  39953. * @param element Defines the element the controls should be listened from
  39954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39955. */
  39956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39957. /** @hidden */
  39958. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39959. /**
  39960. * Update the current camera state depending on the inputs that have been used this frame.
  39961. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39962. */
  39963. checkInputs(): void;
  39964. /**
  39965. * Detach the current controls from the specified dom element.
  39966. * @param element Defines the element to stop listening the inputs from
  39967. */
  39968. detachControl(element: Nullable<HTMLElement>): void;
  39969. /**
  39970. * Gets the class name of the current intput.
  39971. * @returns the class name
  39972. */
  39973. getClassName(): string;
  39974. /**
  39975. * Get the friendly name associated with the input class.
  39976. * @returns the input friendly name
  39977. */
  39978. getSimpleName(): string;
  39979. }
  39980. }
  39981. declare module BABYLON {
  39982. /**
  39983. * Listen to mouse events to control the camera.
  39984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39985. */
  39986. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39987. /**
  39988. * Defines the camera the input is attached to.
  39989. */
  39990. camera: FlyCamera;
  39991. /**
  39992. * Defines if touch is enabled. (Default is true.)
  39993. */
  39994. touchEnabled: boolean;
  39995. /**
  39996. * Defines the buttons associated with the input to handle camera rotation.
  39997. */
  39998. buttons: number[];
  39999. /**
  40000. * Assign buttons for Yaw control.
  40001. */
  40002. buttonsYaw: number[];
  40003. /**
  40004. * Assign buttons for Pitch control.
  40005. */
  40006. buttonsPitch: number[];
  40007. /**
  40008. * Assign buttons for Roll control.
  40009. */
  40010. buttonsRoll: number[];
  40011. /**
  40012. * Detect if any button is being pressed while mouse is moved.
  40013. * -1 = Mouse locked.
  40014. * 0 = Left button.
  40015. * 1 = Middle Button.
  40016. * 2 = Right Button.
  40017. */
  40018. activeButton: number;
  40019. /**
  40020. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40021. * Higher values reduce its sensitivity.
  40022. */
  40023. angularSensibility: number;
  40024. private _mousemoveCallback;
  40025. private _observer;
  40026. private _rollObserver;
  40027. private previousPosition;
  40028. private noPreventDefault;
  40029. private element;
  40030. /**
  40031. * Listen to mouse events to control the camera.
  40032. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40034. */
  40035. constructor(touchEnabled?: boolean);
  40036. /**
  40037. * Attach the mouse control to the HTML DOM element.
  40038. * @param element Defines the element that listens to the input events.
  40039. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40040. */
  40041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40042. /**
  40043. * Detach the current controls from the specified dom element.
  40044. * @param element Defines the element to stop listening the inputs from
  40045. */
  40046. detachControl(element: Nullable<HTMLElement>): void;
  40047. /**
  40048. * Gets the class name of the current input.
  40049. * @returns the class name.
  40050. */
  40051. getClassName(): string;
  40052. /**
  40053. * Get the friendly name associated with the input class.
  40054. * @returns the input's friendly name.
  40055. */
  40056. getSimpleName(): string;
  40057. private _pointerInput;
  40058. private _onMouseMove;
  40059. /**
  40060. * Rotate camera by mouse offset.
  40061. */
  40062. private rotateCamera;
  40063. }
  40064. }
  40065. declare module BABYLON {
  40066. /**
  40067. * Default Inputs manager for the FlyCamera.
  40068. * It groups all the default supported inputs for ease of use.
  40069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40070. */
  40071. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40072. /**
  40073. * Instantiates a new FlyCameraInputsManager.
  40074. * @param camera Defines the camera the inputs belong to.
  40075. */
  40076. constructor(camera: FlyCamera);
  40077. /**
  40078. * Add keyboard input support to the input manager.
  40079. * @returns the new FlyCameraKeyboardMoveInput().
  40080. */
  40081. addKeyboard(): FlyCameraInputsManager;
  40082. /**
  40083. * Add mouse input support to the input manager.
  40084. * @param touchEnabled Enable touch screen support.
  40085. * @returns the new FlyCameraMouseInput().
  40086. */
  40087. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40088. }
  40089. }
  40090. declare module BABYLON {
  40091. /**
  40092. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40093. * such as in a 3D Space Shooter or a Flight Simulator.
  40094. */
  40095. export class FlyCamera extends TargetCamera {
  40096. /**
  40097. * Define the collision ellipsoid of the camera.
  40098. * This is helpful for simulating a camera body, like a player's body.
  40099. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40100. */
  40101. ellipsoid: Vector3;
  40102. /**
  40103. * Define an offset for the position of the ellipsoid around the camera.
  40104. * This can be helpful if the camera is attached away from the player's body center,
  40105. * such as at its head.
  40106. */
  40107. ellipsoidOffset: Vector3;
  40108. /**
  40109. * Enable or disable collisions of the camera with the rest of the scene objects.
  40110. */
  40111. checkCollisions: boolean;
  40112. /**
  40113. * Enable or disable gravity on the camera.
  40114. */
  40115. applyGravity: boolean;
  40116. /**
  40117. * Define the current direction the camera is moving to.
  40118. */
  40119. cameraDirection: Vector3;
  40120. /**
  40121. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40122. * This overrides and empties cameraRotation.
  40123. */
  40124. rotationQuaternion: Quaternion;
  40125. /**
  40126. * Track Roll to maintain the wanted Rolling when looking around.
  40127. */
  40128. _trackRoll: number;
  40129. /**
  40130. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40131. */
  40132. rollCorrect: number;
  40133. /**
  40134. * Mimic a banked turn, Rolling the camera when Yawing.
  40135. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40136. */
  40137. bankedTurn: boolean;
  40138. /**
  40139. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40140. */
  40141. bankedTurnLimit: number;
  40142. /**
  40143. * Value of 0 disables the banked Roll.
  40144. * Value of 1 is equal to the Yaw angle in radians.
  40145. */
  40146. bankedTurnMultiplier: number;
  40147. /**
  40148. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40149. */
  40150. inputs: FlyCameraInputsManager;
  40151. /**
  40152. * Gets the input sensibility for mouse input.
  40153. * Higher values reduce sensitivity.
  40154. */
  40155. get angularSensibility(): number;
  40156. /**
  40157. * Sets the input sensibility for a mouse input.
  40158. * Higher values reduce sensitivity.
  40159. */
  40160. set angularSensibility(value: number);
  40161. /**
  40162. * Get the keys for camera movement forward.
  40163. */
  40164. get keysForward(): number[];
  40165. /**
  40166. * Set the keys for camera movement forward.
  40167. */
  40168. set keysForward(value: number[]);
  40169. /**
  40170. * Get the keys for camera movement backward.
  40171. */
  40172. get keysBackward(): number[];
  40173. set keysBackward(value: number[]);
  40174. /**
  40175. * Get the keys for camera movement up.
  40176. */
  40177. get keysUp(): number[];
  40178. /**
  40179. * Set the keys for camera movement up.
  40180. */
  40181. set keysUp(value: number[]);
  40182. /**
  40183. * Get the keys for camera movement down.
  40184. */
  40185. get keysDown(): number[];
  40186. /**
  40187. * Set the keys for camera movement down.
  40188. */
  40189. set keysDown(value: number[]);
  40190. /**
  40191. * Get the keys for camera movement left.
  40192. */
  40193. get keysLeft(): number[];
  40194. /**
  40195. * Set the keys for camera movement left.
  40196. */
  40197. set keysLeft(value: number[]);
  40198. /**
  40199. * Set the keys for camera movement right.
  40200. */
  40201. get keysRight(): number[];
  40202. /**
  40203. * Set the keys for camera movement right.
  40204. */
  40205. set keysRight(value: number[]);
  40206. /**
  40207. * Event raised when the camera collides with a mesh in the scene.
  40208. */
  40209. onCollide: (collidedMesh: AbstractMesh) => void;
  40210. private _collider;
  40211. private _needMoveForGravity;
  40212. private _oldPosition;
  40213. private _diffPosition;
  40214. private _newPosition;
  40215. /** @hidden */
  40216. _localDirection: Vector3;
  40217. /** @hidden */
  40218. _transformedDirection: Vector3;
  40219. /**
  40220. * Instantiates a FlyCamera.
  40221. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40222. * such as in a 3D Space Shooter or a Flight Simulator.
  40223. * @param name Define the name of the camera in the scene.
  40224. * @param position Define the starting position of the camera in the scene.
  40225. * @param scene Define the scene the camera belongs to.
  40226. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40227. */
  40228. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40229. /**
  40230. * Attach a control to the HTML DOM element.
  40231. * @param element Defines the element that listens to the input events.
  40232. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40233. */
  40234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40235. /**
  40236. * Detach a control from the HTML DOM element.
  40237. * The camera will stop reacting to that input.
  40238. * @param element Defines the element that listens to the input events.
  40239. */
  40240. detachControl(element: HTMLElement): void;
  40241. private _collisionMask;
  40242. /**
  40243. * Get the mask that the camera ignores in collision events.
  40244. */
  40245. get collisionMask(): number;
  40246. /**
  40247. * Set the mask that the camera ignores in collision events.
  40248. */
  40249. set collisionMask(mask: number);
  40250. /** @hidden */
  40251. _collideWithWorld(displacement: Vector3): void;
  40252. /** @hidden */
  40253. private _onCollisionPositionChange;
  40254. /** @hidden */
  40255. _checkInputs(): void;
  40256. /** @hidden */
  40257. _decideIfNeedsToMove(): boolean;
  40258. /** @hidden */
  40259. _updatePosition(): void;
  40260. /**
  40261. * Restore the Roll to its target value at the rate specified.
  40262. * @param rate - Higher means slower restoring.
  40263. * @hidden
  40264. */
  40265. restoreRoll(rate: number): void;
  40266. /**
  40267. * Destroy the camera and release the current resources held by it.
  40268. */
  40269. dispose(): void;
  40270. /**
  40271. * Get the current object class name.
  40272. * @returns the class name.
  40273. */
  40274. getClassName(): string;
  40275. }
  40276. }
  40277. declare module BABYLON {
  40278. /**
  40279. * Listen to keyboard events to control the camera.
  40280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40281. */
  40282. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40283. /**
  40284. * Defines the camera the input is attached to.
  40285. */
  40286. camera: FlyCamera;
  40287. /**
  40288. * The list of keyboard keys used to control the forward move of the camera.
  40289. */
  40290. keysForward: number[];
  40291. /**
  40292. * The list of keyboard keys used to control the backward move of the camera.
  40293. */
  40294. keysBackward: number[];
  40295. /**
  40296. * The list of keyboard keys used to control the forward move of the camera.
  40297. */
  40298. keysUp: number[];
  40299. /**
  40300. * The list of keyboard keys used to control the backward move of the camera.
  40301. */
  40302. keysDown: number[];
  40303. /**
  40304. * The list of keyboard keys used to control the right strafe move of the camera.
  40305. */
  40306. keysRight: number[];
  40307. /**
  40308. * The list of keyboard keys used to control the left strafe move of the camera.
  40309. */
  40310. keysLeft: number[];
  40311. private _keys;
  40312. private _onCanvasBlurObserver;
  40313. private _onKeyboardObserver;
  40314. private _engine;
  40315. private _scene;
  40316. /**
  40317. * Attach the input controls to a specific dom element to get the input from.
  40318. * @param element Defines the element the controls should be listened from
  40319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40320. */
  40321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40322. /**
  40323. * Detach the current controls from the specified dom element.
  40324. * @param element Defines the element to stop listening the inputs from
  40325. */
  40326. detachControl(element: Nullable<HTMLElement>): void;
  40327. /**
  40328. * Gets the class name of the current intput.
  40329. * @returns the class name
  40330. */
  40331. getClassName(): string;
  40332. /** @hidden */
  40333. _onLostFocus(e: FocusEvent): void;
  40334. /**
  40335. * Get the friendly name associated with the input class.
  40336. * @returns the input friendly name
  40337. */
  40338. getSimpleName(): string;
  40339. /**
  40340. * Update the current camera state depending on the inputs that have been used this frame.
  40341. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40342. */
  40343. checkInputs(): void;
  40344. }
  40345. }
  40346. declare module BABYLON {
  40347. /**
  40348. * Manage the mouse wheel inputs to control a follow camera.
  40349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40350. */
  40351. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40352. /**
  40353. * Defines the camera the input is attached to.
  40354. */
  40355. camera: FollowCamera;
  40356. /**
  40357. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40358. */
  40359. axisControlRadius: boolean;
  40360. /**
  40361. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40362. */
  40363. axisControlHeight: boolean;
  40364. /**
  40365. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40366. */
  40367. axisControlRotation: boolean;
  40368. /**
  40369. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40370. * relation to mouseWheel events.
  40371. */
  40372. wheelPrecision: number;
  40373. /**
  40374. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40375. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40376. */
  40377. wheelDeltaPercentage: number;
  40378. private _wheel;
  40379. private _observer;
  40380. /**
  40381. * Attach the input controls to a specific dom element to get the input from.
  40382. * @param element Defines the element the controls should be listened from
  40383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40384. */
  40385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40386. /**
  40387. * Detach the current controls from the specified dom element.
  40388. * @param element Defines the element to stop listening the inputs from
  40389. */
  40390. detachControl(element: Nullable<HTMLElement>): void;
  40391. /**
  40392. * Gets the class name of the current intput.
  40393. * @returns the class name
  40394. */
  40395. getClassName(): string;
  40396. /**
  40397. * Get the friendly name associated with the input class.
  40398. * @returns the input friendly name
  40399. */
  40400. getSimpleName(): string;
  40401. }
  40402. }
  40403. declare module BABYLON {
  40404. /**
  40405. * Manage the pointers inputs to control an follow camera.
  40406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40407. */
  40408. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40409. /**
  40410. * Defines the camera the input is attached to.
  40411. */
  40412. camera: FollowCamera;
  40413. /**
  40414. * Gets the class name of the current input.
  40415. * @returns the class name
  40416. */
  40417. getClassName(): string;
  40418. /**
  40419. * Defines the pointer angular sensibility along the X axis or how fast is
  40420. * the camera rotating.
  40421. * A negative number will reverse the axis direction.
  40422. */
  40423. angularSensibilityX: number;
  40424. /**
  40425. * Defines the pointer angular sensibility along the Y axis or how fast is
  40426. * the camera rotating.
  40427. * A negative number will reverse the axis direction.
  40428. */
  40429. angularSensibilityY: number;
  40430. /**
  40431. * Defines the pointer pinch precision or how fast is the camera zooming.
  40432. * A negative number will reverse the axis direction.
  40433. */
  40434. pinchPrecision: number;
  40435. /**
  40436. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40437. * from 0.
  40438. * It defines the percentage of current camera.radius to use as delta when
  40439. * pinch zoom is used.
  40440. */
  40441. pinchDeltaPercentage: number;
  40442. /**
  40443. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40444. */
  40445. axisXControlRadius: boolean;
  40446. /**
  40447. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40448. */
  40449. axisXControlHeight: boolean;
  40450. /**
  40451. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40452. */
  40453. axisXControlRotation: boolean;
  40454. /**
  40455. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40456. */
  40457. axisYControlRadius: boolean;
  40458. /**
  40459. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40460. */
  40461. axisYControlHeight: boolean;
  40462. /**
  40463. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40464. */
  40465. axisYControlRotation: boolean;
  40466. /**
  40467. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40468. */
  40469. axisPinchControlRadius: boolean;
  40470. /**
  40471. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40472. */
  40473. axisPinchControlHeight: boolean;
  40474. /**
  40475. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40476. */
  40477. axisPinchControlRotation: boolean;
  40478. /**
  40479. * Log error messages if basic misconfiguration has occurred.
  40480. */
  40481. warningEnable: boolean;
  40482. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40483. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40484. private _warningCounter;
  40485. private _warning;
  40486. }
  40487. }
  40488. declare module BABYLON {
  40489. /**
  40490. * Default Inputs manager for the FollowCamera.
  40491. * It groups all the default supported inputs for ease of use.
  40492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40493. */
  40494. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40495. /**
  40496. * Instantiates a new FollowCameraInputsManager.
  40497. * @param camera Defines the camera the inputs belong to
  40498. */
  40499. constructor(camera: FollowCamera);
  40500. /**
  40501. * Add keyboard input support to the input manager.
  40502. * @returns the current input manager
  40503. */
  40504. addKeyboard(): FollowCameraInputsManager;
  40505. /**
  40506. * Add mouse wheel input support to the input manager.
  40507. * @returns the current input manager
  40508. */
  40509. addMouseWheel(): FollowCameraInputsManager;
  40510. /**
  40511. * Add pointers input support to the input manager.
  40512. * @returns the current input manager
  40513. */
  40514. addPointers(): FollowCameraInputsManager;
  40515. /**
  40516. * Add orientation input support to the input manager.
  40517. * @returns the current input manager
  40518. */
  40519. addVRDeviceOrientation(): FollowCameraInputsManager;
  40520. }
  40521. }
  40522. declare module BABYLON {
  40523. /**
  40524. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40525. * an arc rotate version arcFollowCamera are available.
  40526. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40527. */
  40528. export class FollowCamera extends TargetCamera {
  40529. /**
  40530. * Distance the follow camera should follow an object at
  40531. */
  40532. radius: number;
  40533. /**
  40534. * Minimum allowed distance of the camera to the axis of rotation
  40535. * (The camera can not get closer).
  40536. * This can help limiting how the Camera is able to move in the scene.
  40537. */
  40538. lowerRadiusLimit: Nullable<number>;
  40539. /**
  40540. * Maximum allowed distance of the camera to the axis of rotation
  40541. * (The camera can not get further).
  40542. * This can help limiting how the Camera is able to move in the scene.
  40543. */
  40544. upperRadiusLimit: Nullable<number>;
  40545. /**
  40546. * Define a rotation offset between the camera and the object it follows
  40547. */
  40548. rotationOffset: number;
  40549. /**
  40550. * Minimum allowed angle to camera position relative to target object.
  40551. * This can help limiting how the Camera is able to move in the scene.
  40552. */
  40553. lowerRotationOffsetLimit: Nullable<number>;
  40554. /**
  40555. * Maximum allowed angle to camera position relative to target object.
  40556. * This can help limiting how the Camera is able to move in the scene.
  40557. */
  40558. upperRotationOffsetLimit: Nullable<number>;
  40559. /**
  40560. * Define a height offset between the camera and the object it follows.
  40561. * It can help following an object from the top (like a car chaing a plane)
  40562. */
  40563. heightOffset: number;
  40564. /**
  40565. * Minimum allowed height of camera position relative to target object.
  40566. * This can help limiting how the Camera is able to move in the scene.
  40567. */
  40568. lowerHeightOffsetLimit: Nullable<number>;
  40569. /**
  40570. * Maximum allowed height of camera position relative to target object.
  40571. * This can help limiting how the Camera is able to move in the scene.
  40572. */
  40573. upperHeightOffsetLimit: Nullable<number>;
  40574. /**
  40575. * Define how fast the camera can accelerate to follow it s target.
  40576. */
  40577. cameraAcceleration: number;
  40578. /**
  40579. * Define the speed limit of the camera following an object.
  40580. */
  40581. maxCameraSpeed: number;
  40582. /**
  40583. * Define the target of the camera.
  40584. */
  40585. lockedTarget: Nullable<AbstractMesh>;
  40586. /**
  40587. * Defines the input associated with the camera.
  40588. */
  40589. inputs: FollowCameraInputsManager;
  40590. /**
  40591. * Instantiates the follow camera.
  40592. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40593. * @param name Define the name of the camera in the scene
  40594. * @param position Define the position of the camera
  40595. * @param scene Define the scene the camera belong to
  40596. * @param lockedTarget Define the target of the camera
  40597. */
  40598. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40599. private _follow;
  40600. /**
  40601. * Attached controls to the current camera.
  40602. * @param element Defines the element the controls should be listened from
  40603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40604. */
  40605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40606. /**
  40607. * Detach the current controls from the camera.
  40608. * The camera will stop reacting to inputs.
  40609. * @param element Defines the element to stop listening the inputs from
  40610. */
  40611. detachControl(element: HTMLElement): void;
  40612. /** @hidden */
  40613. _checkInputs(): void;
  40614. private _checkLimits;
  40615. /**
  40616. * Gets the camera class name.
  40617. * @returns the class name
  40618. */
  40619. getClassName(): string;
  40620. }
  40621. /**
  40622. * Arc Rotate version of the follow camera.
  40623. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40624. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40625. */
  40626. export class ArcFollowCamera extends TargetCamera {
  40627. /** The longitudinal angle of the camera */
  40628. alpha: number;
  40629. /** The latitudinal angle of the camera */
  40630. beta: number;
  40631. /** The radius of the camera from its target */
  40632. radius: number;
  40633. /** Define the camera target (the messh it should follow) */
  40634. target: Nullable<AbstractMesh>;
  40635. private _cartesianCoordinates;
  40636. /**
  40637. * Instantiates a new ArcFollowCamera
  40638. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40639. * @param name Define the name of the camera
  40640. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40641. * @param beta Define the rotation angle of the camera around the elevation axis
  40642. * @param radius Define the radius of the camera from its target point
  40643. * @param target Define the target of the camera
  40644. * @param scene Define the scene the camera belongs to
  40645. */
  40646. constructor(name: string,
  40647. /** The longitudinal angle of the camera */
  40648. alpha: number,
  40649. /** The latitudinal angle of the camera */
  40650. beta: number,
  40651. /** The radius of the camera from its target */
  40652. radius: number,
  40653. /** Define the camera target (the messh it should follow) */
  40654. target: Nullable<AbstractMesh>, scene: Scene);
  40655. private _follow;
  40656. /** @hidden */
  40657. _checkInputs(): void;
  40658. /**
  40659. * Returns the class name of the object.
  40660. * It is mostly used internally for serialization purposes.
  40661. */
  40662. getClassName(): string;
  40663. }
  40664. }
  40665. declare module BABYLON {
  40666. /**
  40667. * Manage the keyboard inputs to control the movement of a follow camera.
  40668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40669. */
  40670. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40671. /**
  40672. * Defines the camera the input is attached to.
  40673. */
  40674. camera: FollowCamera;
  40675. /**
  40676. * Defines the list of key codes associated with the up action (increase heightOffset)
  40677. */
  40678. keysHeightOffsetIncr: number[];
  40679. /**
  40680. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40681. */
  40682. keysHeightOffsetDecr: number[];
  40683. /**
  40684. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40685. */
  40686. keysHeightOffsetModifierAlt: boolean;
  40687. /**
  40688. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40689. */
  40690. keysHeightOffsetModifierCtrl: boolean;
  40691. /**
  40692. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40693. */
  40694. keysHeightOffsetModifierShift: boolean;
  40695. /**
  40696. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40697. */
  40698. keysRotationOffsetIncr: number[];
  40699. /**
  40700. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40701. */
  40702. keysRotationOffsetDecr: number[];
  40703. /**
  40704. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40705. */
  40706. keysRotationOffsetModifierAlt: boolean;
  40707. /**
  40708. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40709. */
  40710. keysRotationOffsetModifierCtrl: boolean;
  40711. /**
  40712. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40713. */
  40714. keysRotationOffsetModifierShift: boolean;
  40715. /**
  40716. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40717. */
  40718. keysRadiusIncr: number[];
  40719. /**
  40720. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40721. */
  40722. keysRadiusDecr: number[];
  40723. /**
  40724. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40725. */
  40726. keysRadiusModifierAlt: boolean;
  40727. /**
  40728. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40729. */
  40730. keysRadiusModifierCtrl: boolean;
  40731. /**
  40732. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40733. */
  40734. keysRadiusModifierShift: boolean;
  40735. /**
  40736. * Defines the rate of change of heightOffset.
  40737. */
  40738. heightSensibility: number;
  40739. /**
  40740. * Defines the rate of change of rotationOffset.
  40741. */
  40742. rotationSensibility: number;
  40743. /**
  40744. * Defines the rate of change of radius.
  40745. */
  40746. radiusSensibility: number;
  40747. private _keys;
  40748. private _ctrlPressed;
  40749. private _altPressed;
  40750. private _shiftPressed;
  40751. private _onCanvasBlurObserver;
  40752. private _onKeyboardObserver;
  40753. private _engine;
  40754. private _scene;
  40755. /**
  40756. * Attach the input controls to a specific dom element to get the input from.
  40757. * @param element Defines the element the controls should be listened from
  40758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40759. */
  40760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40761. /**
  40762. * Detach the current controls from the specified dom element.
  40763. * @param element Defines the element to stop listening the inputs from
  40764. */
  40765. detachControl(element: Nullable<HTMLElement>): void;
  40766. /**
  40767. * Update the current camera state depending on the inputs that have been used this frame.
  40768. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40769. */
  40770. checkInputs(): void;
  40771. /**
  40772. * Gets the class name of the current input.
  40773. * @returns the class name
  40774. */
  40775. getClassName(): string;
  40776. /**
  40777. * Get the friendly name associated with the input class.
  40778. * @returns the input friendly name
  40779. */
  40780. getSimpleName(): string;
  40781. /**
  40782. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40783. * allow modification of the heightOffset value.
  40784. */
  40785. private _modifierHeightOffset;
  40786. /**
  40787. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40788. * allow modification of the rotationOffset value.
  40789. */
  40790. private _modifierRotationOffset;
  40791. /**
  40792. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40793. * allow modification of the radius value.
  40794. */
  40795. private _modifierRadius;
  40796. }
  40797. }
  40798. declare module BABYLON {
  40799. interface FreeCameraInputsManager {
  40800. /**
  40801. * @hidden
  40802. */
  40803. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40804. /**
  40805. * Add orientation input support to the input manager.
  40806. * @returns the current input manager
  40807. */
  40808. addDeviceOrientation(): FreeCameraInputsManager;
  40809. }
  40810. /**
  40811. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40812. * Screen rotation is taken into account.
  40813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40814. */
  40815. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40816. private _camera;
  40817. private _screenOrientationAngle;
  40818. private _constantTranform;
  40819. private _screenQuaternion;
  40820. private _alpha;
  40821. private _beta;
  40822. private _gamma;
  40823. /**
  40824. * Can be used to detect if a device orientation sensor is available on a device
  40825. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40826. * @returns a promise that will resolve on orientation change
  40827. */
  40828. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40829. /**
  40830. * @hidden
  40831. */
  40832. _onDeviceOrientationChangedObservable: Observable<void>;
  40833. /**
  40834. * Instantiates a new input
  40835. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40836. */
  40837. constructor();
  40838. /**
  40839. * Define the camera controlled by the input.
  40840. */
  40841. get camera(): FreeCamera;
  40842. set camera(camera: FreeCamera);
  40843. /**
  40844. * Attach the input controls to a specific dom element to get the input from.
  40845. * @param element Defines the element the controls should be listened from
  40846. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40847. */
  40848. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40849. private _orientationChanged;
  40850. private _deviceOrientation;
  40851. /**
  40852. * Detach the current controls from the specified dom element.
  40853. * @param element Defines the element to stop listening the inputs from
  40854. */
  40855. detachControl(element: Nullable<HTMLElement>): void;
  40856. /**
  40857. * Update the current camera state depending on the inputs that have been used this frame.
  40858. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40859. */
  40860. checkInputs(): void;
  40861. /**
  40862. * Gets the class name of the current intput.
  40863. * @returns the class name
  40864. */
  40865. getClassName(): string;
  40866. /**
  40867. * Get the friendly name associated with the input class.
  40868. * @returns the input friendly name
  40869. */
  40870. getSimpleName(): string;
  40871. }
  40872. }
  40873. declare module BABYLON {
  40874. /**
  40875. * Manage the gamepad inputs to control a free camera.
  40876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40877. */
  40878. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40879. /**
  40880. * Define the camera the input is attached to.
  40881. */
  40882. camera: FreeCamera;
  40883. /**
  40884. * Define the Gamepad controlling the input
  40885. */
  40886. gamepad: Nullable<Gamepad>;
  40887. /**
  40888. * Defines the gamepad rotation sensiblity.
  40889. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40890. */
  40891. gamepadAngularSensibility: number;
  40892. /**
  40893. * Defines the gamepad move sensiblity.
  40894. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40895. */
  40896. gamepadMoveSensibility: number;
  40897. private _yAxisScale;
  40898. /**
  40899. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40900. */
  40901. get invertYAxis(): boolean;
  40902. set invertYAxis(value: boolean);
  40903. private _onGamepadConnectedObserver;
  40904. private _onGamepadDisconnectedObserver;
  40905. private _cameraTransform;
  40906. private _deltaTransform;
  40907. private _vector3;
  40908. private _vector2;
  40909. /**
  40910. * Attach the input controls to a specific dom element to get the input from.
  40911. * @param element Defines the element the controls should be listened from
  40912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40913. */
  40914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40915. /**
  40916. * Detach the current controls from the specified dom element.
  40917. * @param element Defines the element to stop listening the inputs from
  40918. */
  40919. detachControl(element: Nullable<HTMLElement>): void;
  40920. /**
  40921. * Update the current camera state depending on the inputs that have been used this frame.
  40922. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40923. */
  40924. checkInputs(): void;
  40925. /**
  40926. * Gets the class name of the current intput.
  40927. * @returns the class name
  40928. */
  40929. getClassName(): string;
  40930. /**
  40931. * Get the friendly name associated with the input class.
  40932. * @returns the input friendly name
  40933. */
  40934. getSimpleName(): string;
  40935. }
  40936. }
  40937. declare module BABYLON {
  40938. /**
  40939. * Defines the potential axis of a Joystick
  40940. */
  40941. export enum JoystickAxis {
  40942. /** X axis */
  40943. X = 0,
  40944. /** Y axis */
  40945. Y = 1,
  40946. /** Z axis */
  40947. Z = 2
  40948. }
  40949. /**
  40950. * Class used to define virtual joystick (used in touch mode)
  40951. */
  40952. export class VirtualJoystick {
  40953. /**
  40954. * Gets or sets a boolean indicating that left and right values must be inverted
  40955. */
  40956. reverseLeftRight: boolean;
  40957. /**
  40958. * Gets or sets a boolean indicating that up and down values must be inverted
  40959. */
  40960. reverseUpDown: boolean;
  40961. /**
  40962. * Gets the offset value for the position (ie. the change of the position value)
  40963. */
  40964. deltaPosition: Vector3;
  40965. /**
  40966. * Gets a boolean indicating if the virtual joystick was pressed
  40967. */
  40968. pressed: boolean;
  40969. /**
  40970. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40971. */
  40972. static Canvas: Nullable<HTMLCanvasElement>;
  40973. private static _globalJoystickIndex;
  40974. private static vjCanvasContext;
  40975. private static vjCanvasWidth;
  40976. private static vjCanvasHeight;
  40977. private static halfWidth;
  40978. private _action;
  40979. private _axisTargetedByLeftAndRight;
  40980. private _axisTargetedByUpAndDown;
  40981. private _joystickSensibility;
  40982. private _inversedSensibility;
  40983. private _joystickPointerID;
  40984. private _joystickColor;
  40985. private _joystickPointerPos;
  40986. private _joystickPreviousPointerPos;
  40987. private _joystickPointerStartPos;
  40988. private _deltaJoystickVector;
  40989. private _leftJoystick;
  40990. private _touches;
  40991. private _onPointerDownHandlerRef;
  40992. private _onPointerMoveHandlerRef;
  40993. private _onPointerUpHandlerRef;
  40994. private _onResize;
  40995. /**
  40996. * Creates a new virtual joystick
  40997. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40998. */
  40999. constructor(leftJoystick?: boolean);
  41000. /**
  41001. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41002. * @param newJoystickSensibility defines the new sensibility
  41003. */
  41004. setJoystickSensibility(newJoystickSensibility: number): void;
  41005. private _onPointerDown;
  41006. private _onPointerMove;
  41007. private _onPointerUp;
  41008. /**
  41009. * Change the color of the virtual joystick
  41010. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41011. */
  41012. setJoystickColor(newColor: string): void;
  41013. /**
  41014. * Defines a callback to call when the joystick is touched
  41015. * @param action defines the callback
  41016. */
  41017. setActionOnTouch(action: () => any): void;
  41018. /**
  41019. * Defines which axis you'd like to control for left & right
  41020. * @param axis defines the axis to use
  41021. */
  41022. setAxisForLeftRight(axis: JoystickAxis): void;
  41023. /**
  41024. * Defines which axis you'd like to control for up & down
  41025. * @param axis defines the axis to use
  41026. */
  41027. setAxisForUpDown(axis: JoystickAxis): void;
  41028. private _drawVirtualJoystick;
  41029. /**
  41030. * Release internal HTML canvas
  41031. */
  41032. releaseCanvas(): void;
  41033. }
  41034. }
  41035. declare module BABYLON {
  41036. interface FreeCameraInputsManager {
  41037. /**
  41038. * Add virtual joystick input support to the input manager.
  41039. * @returns the current input manager
  41040. */
  41041. addVirtualJoystick(): FreeCameraInputsManager;
  41042. }
  41043. /**
  41044. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41046. */
  41047. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41048. /**
  41049. * Defines the camera the input is attached to.
  41050. */
  41051. camera: FreeCamera;
  41052. private _leftjoystick;
  41053. private _rightjoystick;
  41054. /**
  41055. * Gets the left stick of the virtual joystick.
  41056. * @returns The virtual Joystick
  41057. */
  41058. getLeftJoystick(): VirtualJoystick;
  41059. /**
  41060. * Gets the right stick of the virtual joystick.
  41061. * @returns The virtual Joystick
  41062. */
  41063. getRightJoystick(): VirtualJoystick;
  41064. /**
  41065. * Update the current camera state depending on the inputs that have been used this frame.
  41066. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41067. */
  41068. checkInputs(): void;
  41069. /**
  41070. * Attach the input controls to a specific dom element to get the input from.
  41071. * @param element Defines the element the controls should be listened from
  41072. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41073. */
  41074. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41075. /**
  41076. * Detach the current controls from the specified dom element.
  41077. * @param element Defines the element to stop listening the inputs from
  41078. */
  41079. detachControl(element: Nullable<HTMLElement>): void;
  41080. /**
  41081. * Gets the class name of the current intput.
  41082. * @returns the class name
  41083. */
  41084. getClassName(): string;
  41085. /**
  41086. * Get the friendly name associated with the input class.
  41087. * @returns the input friendly name
  41088. */
  41089. getSimpleName(): string;
  41090. }
  41091. }
  41092. declare module BABYLON {
  41093. /**
  41094. * This represents a FPS type of camera controlled by touch.
  41095. * This is like a universal camera minus the Gamepad controls.
  41096. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41097. */
  41098. export class TouchCamera extends FreeCamera {
  41099. /**
  41100. * Defines the touch sensibility for rotation.
  41101. * The higher the faster.
  41102. */
  41103. get touchAngularSensibility(): number;
  41104. set touchAngularSensibility(value: number);
  41105. /**
  41106. * Defines the touch sensibility for move.
  41107. * The higher the faster.
  41108. */
  41109. get touchMoveSensibility(): number;
  41110. set touchMoveSensibility(value: number);
  41111. /**
  41112. * Instantiates a new touch camera.
  41113. * This represents a FPS type of camera controlled by touch.
  41114. * This is like a universal camera minus the Gamepad controls.
  41115. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41116. * @param name Define the name of the camera in the scene
  41117. * @param position Define the start position of the camera in the scene
  41118. * @param scene Define the scene the camera belongs to
  41119. */
  41120. constructor(name: string, position: Vector3, scene: Scene);
  41121. /**
  41122. * Gets the current object class name.
  41123. * @return the class name
  41124. */
  41125. getClassName(): string;
  41126. /** @hidden */
  41127. _setupInputs(): void;
  41128. }
  41129. }
  41130. declare module BABYLON {
  41131. /**
  41132. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41133. * being tilted forward or back and left or right.
  41134. */
  41135. export class DeviceOrientationCamera extends FreeCamera {
  41136. private _initialQuaternion;
  41137. private _quaternionCache;
  41138. private _tmpDragQuaternion;
  41139. private _disablePointerInputWhenUsingDeviceOrientation;
  41140. /**
  41141. * Creates a new device orientation camera
  41142. * @param name The name of the camera
  41143. * @param position The start position camera
  41144. * @param scene The scene the camera belongs to
  41145. */
  41146. constructor(name: string, position: Vector3, scene: Scene);
  41147. /**
  41148. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41149. */
  41150. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41151. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41152. private _dragFactor;
  41153. /**
  41154. * Enabled turning on the y axis when the orientation sensor is active
  41155. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41156. */
  41157. enableHorizontalDragging(dragFactor?: number): void;
  41158. /**
  41159. * Gets the current instance class name ("DeviceOrientationCamera").
  41160. * This helps avoiding instanceof at run time.
  41161. * @returns the class name
  41162. */
  41163. getClassName(): string;
  41164. /**
  41165. * @hidden
  41166. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41167. */
  41168. _checkInputs(): void;
  41169. /**
  41170. * Reset the camera to its default orientation on the specified axis only.
  41171. * @param axis The axis to reset
  41172. */
  41173. resetToCurrentRotation(axis?: Axis): void;
  41174. }
  41175. }
  41176. declare module BABYLON {
  41177. /**
  41178. * Defines supported buttons for XBox360 compatible gamepads
  41179. */
  41180. export enum Xbox360Button {
  41181. /** A */
  41182. A = 0,
  41183. /** B */
  41184. B = 1,
  41185. /** X */
  41186. X = 2,
  41187. /** Y */
  41188. Y = 3,
  41189. /** Left button */
  41190. LB = 4,
  41191. /** Right button */
  41192. RB = 5,
  41193. /** Back */
  41194. Back = 8,
  41195. /** Start */
  41196. Start = 9,
  41197. /** Left stick */
  41198. LeftStick = 10,
  41199. /** Right stick */
  41200. RightStick = 11
  41201. }
  41202. /** Defines values for XBox360 DPad */
  41203. export enum Xbox360Dpad {
  41204. /** Up */
  41205. Up = 12,
  41206. /** Down */
  41207. Down = 13,
  41208. /** Left */
  41209. Left = 14,
  41210. /** Right */
  41211. Right = 15
  41212. }
  41213. /**
  41214. * Defines a XBox360 gamepad
  41215. */
  41216. export class Xbox360Pad extends Gamepad {
  41217. private _leftTrigger;
  41218. private _rightTrigger;
  41219. private _onlefttriggerchanged;
  41220. private _onrighttriggerchanged;
  41221. private _onbuttondown;
  41222. private _onbuttonup;
  41223. private _ondpaddown;
  41224. private _ondpadup;
  41225. /** Observable raised when a button is pressed */
  41226. onButtonDownObservable: Observable<Xbox360Button>;
  41227. /** Observable raised when a button is released */
  41228. onButtonUpObservable: Observable<Xbox360Button>;
  41229. /** Observable raised when a pad is pressed */
  41230. onPadDownObservable: Observable<Xbox360Dpad>;
  41231. /** Observable raised when a pad is released */
  41232. onPadUpObservable: Observable<Xbox360Dpad>;
  41233. private _buttonA;
  41234. private _buttonB;
  41235. private _buttonX;
  41236. private _buttonY;
  41237. private _buttonBack;
  41238. private _buttonStart;
  41239. private _buttonLB;
  41240. private _buttonRB;
  41241. private _buttonLeftStick;
  41242. private _buttonRightStick;
  41243. private _dPadUp;
  41244. private _dPadDown;
  41245. private _dPadLeft;
  41246. private _dPadRight;
  41247. private _isXboxOnePad;
  41248. /**
  41249. * Creates a new XBox360 gamepad object
  41250. * @param id defines the id of this gamepad
  41251. * @param index defines its index
  41252. * @param gamepad defines the internal HTML gamepad object
  41253. * @param xboxOne defines if it is a XBox One gamepad
  41254. */
  41255. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41256. /**
  41257. * Defines the callback to call when left trigger is pressed
  41258. * @param callback defines the callback to use
  41259. */
  41260. onlefttriggerchanged(callback: (value: number) => void): void;
  41261. /**
  41262. * Defines the callback to call when right trigger is pressed
  41263. * @param callback defines the callback to use
  41264. */
  41265. onrighttriggerchanged(callback: (value: number) => void): void;
  41266. /**
  41267. * Gets the left trigger value
  41268. */
  41269. get leftTrigger(): number;
  41270. /**
  41271. * Sets the left trigger value
  41272. */
  41273. set leftTrigger(newValue: number);
  41274. /**
  41275. * Gets the right trigger value
  41276. */
  41277. get rightTrigger(): number;
  41278. /**
  41279. * Sets the right trigger value
  41280. */
  41281. set rightTrigger(newValue: number);
  41282. /**
  41283. * Defines the callback to call when a button is pressed
  41284. * @param callback defines the callback to use
  41285. */
  41286. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41287. /**
  41288. * Defines the callback to call when a button is released
  41289. * @param callback defines the callback to use
  41290. */
  41291. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41292. /**
  41293. * Defines the callback to call when a pad is pressed
  41294. * @param callback defines the callback to use
  41295. */
  41296. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41297. /**
  41298. * Defines the callback to call when a pad is released
  41299. * @param callback defines the callback to use
  41300. */
  41301. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41302. private _setButtonValue;
  41303. private _setDPadValue;
  41304. /**
  41305. * Gets the value of the `A` button
  41306. */
  41307. get buttonA(): number;
  41308. /**
  41309. * Sets the value of the `A` button
  41310. */
  41311. set buttonA(value: number);
  41312. /**
  41313. * Gets the value of the `B` button
  41314. */
  41315. get buttonB(): number;
  41316. /**
  41317. * Sets the value of the `B` button
  41318. */
  41319. set buttonB(value: number);
  41320. /**
  41321. * Gets the value of the `X` button
  41322. */
  41323. get buttonX(): number;
  41324. /**
  41325. * Sets the value of the `X` button
  41326. */
  41327. set buttonX(value: number);
  41328. /**
  41329. * Gets the value of the `Y` button
  41330. */
  41331. get buttonY(): number;
  41332. /**
  41333. * Sets the value of the `Y` button
  41334. */
  41335. set buttonY(value: number);
  41336. /**
  41337. * Gets the value of the `Start` button
  41338. */
  41339. get buttonStart(): number;
  41340. /**
  41341. * Sets the value of the `Start` button
  41342. */
  41343. set buttonStart(value: number);
  41344. /**
  41345. * Gets the value of the `Back` button
  41346. */
  41347. get buttonBack(): number;
  41348. /**
  41349. * Sets the value of the `Back` button
  41350. */
  41351. set buttonBack(value: number);
  41352. /**
  41353. * Gets the value of the `Left` button
  41354. */
  41355. get buttonLB(): number;
  41356. /**
  41357. * Sets the value of the `Left` button
  41358. */
  41359. set buttonLB(value: number);
  41360. /**
  41361. * Gets the value of the `Right` button
  41362. */
  41363. get buttonRB(): number;
  41364. /**
  41365. * Sets the value of the `Right` button
  41366. */
  41367. set buttonRB(value: number);
  41368. /**
  41369. * Gets the value of the Left joystick
  41370. */
  41371. get buttonLeftStick(): number;
  41372. /**
  41373. * Sets the value of the Left joystick
  41374. */
  41375. set buttonLeftStick(value: number);
  41376. /**
  41377. * Gets the value of the Right joystick
  41378. */
  41379. get buttonRightStick(): number;
  41380. /**
  41381. * Sets the value of the Right joystick
  41382. */
  41383. set buttonRightStick(value: number);
  41384. /**
  41385. * Gets the value of D-pad up
  41386. */
  41387. get dPadUp(): number;
  41388. /**
  41389. * Sets the value of D-pad up
  41390. */
  41391. set dPadUp(value: number);
  41392. /**
  41393. * Gets the value of D-pad down
  41394. */
  41395. get dPadDown(): number;
  41396. /**
  41397. * Sets the value of D-pad down
  41398. */
  41399. set dPadDown(value: number);
  41400. /**
  41401. * Gets the value of D-pad left
  41402. */
  41403. get dPadLeft(): number;
  41404. /**
  41405. * Sets the value of D-pad left
  41406. */
  41407. set dPadLeft(value: number);
  41408. /**
  41409. * Gets the value of D-pad right
  41410. */
  41411. get dPadRight(): number;
  41412. /**
  41413. * Sets the value of D-pad right
  41414. */
  41415. set dPadRight(value: number);
  41416. /**
  41417. * Force the gamepad to synchronize with device values
  41418. */
  41419. update(): void;
  41420. /**
  41421. * Disposes the gamepad
  41422. */
  41423. dispose(): void;
  41424. }
  41425. }
  41426. declare module BABYLON {
  41427. /**
  41428. * Defines supported buttons for DualShock compatible gamepads
  41429. */
  41430. export enum DualShockButton {
  41431. /** Cross */
  41432. Cross = 0,
  41433. /** Circle */
  41434. Circle = 1,
  41435. /** Square */
  41436. Square = 2,
  41437. /** Triangle */
  41438. Triangle = 3,
  41439. /** L1 */
  41440. L1 = 4,
  41441. /** R1 */
  41442. R1 = 5,
  41443. /** Share */
  41444. Share = 8,
  41445. /** Options */
  41446. Options = 9,
  41447. /** Left stick */
  41448. LeftStick = 10,
  41449. /** Right stick */
  41450. RightStick = 11
  41451. }
  41452. /** Defines values for DualShock DPad */
  41453. export enum DualShockDpad {
  41454. /** Up */
  41455. Up = 12,
  41456. /** Down */
  41457. Down = 13,
  41458. /** Left */
  41459. Left = 14,
  41460. /** Right */
  41461. Right = 15
  41462. }
  41463. /**
  41464. * Defines a DualShock gamepad
  41465. */
  41466. export class DualShockPad extends Gamepad {
  41467. private _leftTrigger;
  41468. private _rightTrigger;
  41469. private _onlefttriggerchanged;
  41470. private _onrighttriggerchanged;
  41471. private _onbuttondown;
  41472. private _onbuttonup;
  41473. private _ondpaddown;
  41474. private _ondpadup;
  41475. /** Observable raised when a button is pressed */
  41476. onButtonDownObservable: Observable<DualShockButton>;
  41477. /** Observable raised when a button is released */
  41478. onButtonUpObservable: Observable<DualShockButton>;
  41479. /** Observable raised when a pad is pressed */
  41480. onPadDownObservable: Observable<DualShockDpad>;
  41481. /** Observable raised when a pad is released */
  41482. onPadUpObservable: Observable<DualShockDpad>;
  41483. private _buttonCross;
  41484. private _buttonCircle;
  41485. private _buttonSquare;
  41486. private _buttonTriangle;
  41487. private _buttonShare;
  41488. private _buttonOptions;
  41489. private _buttonL1;
  41490. private _buttonR1;
  41491. private _buttonLeftStick;
  41492. private _buttonRightStick;
  41493. private _dPadUp;
  41494. private _dPadDown;
  41495. private _dPadLeft;
  41496. private _dPadRight;
  41497. /**
  41498. * Creates a new DualShock gamepad object
  41499. * @param id defines the id of this gamepad
  41500. * @param index defines its index
  41501. * @param gamepad defines the internal HTML gamepad object
  41502. */
  41503. constructor(id: string, index: number, gamepad: any);
  41504. /**
  41505. * Defines the callback to call when left trigger is pressed
  41506. * @param callback defines the callback to use
  41507. */
  41508. onlefttriggerchanged(callback: (value: number) => void): void;
  41509. /**
  41510. * Defines the callback to call when right trigger is pressed
  41511. * @param callback defines the callback to use
  41512. */
  41513. onrighttriggerchanged(callback: (value: number) => void): void;
  41514. /**
  41515. * Gets the left trigger value
  41516. */
  41517. get leftTrigger(): number;
  41518. /**
  41519. * Sets the left trigger value
  41520. */
  41521. set leftTrigger(newValue: number);
  41522. /**
  41523. * Gets the right trigger value
  41524. */
  41525. get rightTrigger(): number;
  41526. /**
  41527. * Sets the right trigger value
  41528. */
  41529. set rightTrigger(newValue: number);
  41530. /**
  41531. * Defines the callback to call when a button is pressed
  41532. * @param callback defines the callback to use
  41533. */
  41534. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41535. /**
  41536. * Defines the callback to call when a button is released
  41537. * @param callback defines the callback to use
  41538. */
  41539. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41540. /**
  41541. * Defines the callback to call when a pad is pressed
  41542. * @param callback defines the callback to use
  41543. */
  41544. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41545. /**
  41546. * Defines the callback to call when a pad is released
  41547. * @param callback defines the callback to use
  41548. */
  41549. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41550. private _setButtonValue;
  41551. private _setDPadValue;
  41552. /**
  41553. * Gets the value of the `Cross` button
  41554. */
  41555. get buttonCross(): number;
  41556. /**
  41557. * Sets the value of the `Cross` button
  41558. */
  41559. set buttonCross(value: number);
  41560. /**
  41561. * Gets the value of the `Circle` button
  41562. */
  41563. get buttonCircle(): number;
  41564. /**
  41565. * Sets the value of the `Circle` button
  41566. */
  41567. set buttonCircle(value: number);
  41568. /**
  41569. * Gets the value of the `Square` button
  41570. */
  41571. get buttonSquare(): number;
  41572. /**
  41573. * Sets the value of the `Square` button
  41574. */
  41575. set buttonSquare(value: number);
  41576. /**
  41577. * Gets the value of the `Triangle` button
  41578. */
  41579. get buttonTriangle(): number;
  41580. /**
  41581. * Sets the value of the `Triangle` button
  41582. */
  41583. set buttonTriangle(value: number);
  41584. /**
  41585. * Gets the value of the `Options` button
  41586. */
  41587. get buttonOptions(): number;
  41588. /**
  41589. * Sets the value of the `Options` button
  41590. */
  41591. set buttonOptions(value: number);
  41592. /**
  41593. * Gets the value of the `Share` button
  41594. */
  41595. get buttonShare(): number;
  41596. /**
  41597. * Sets the value of the `Share` button
  41598. */
  41599. set buttonShare(value: number);
  41600. /**
  41601. * Gets the value of the `L1` button
  41602. */
  41603. get buttonL1(): number;
  41604. /**
  41605. * Sets the value of the `L1` button
  41606. */
  41607. set buttonL1(value: number);
  41608. /**
  41609. * Gets the value of the `R1` button
  41610. */
  41611. get buttonR1(): number;
  41612. /**
  41613. * Sets the value of the `R1` button
  41614. */
  41615. set buttonR1(value: number);
  41616. /**
  41617. * Gets the value of the Left joystick
  41618. */
  41619. get buttonLeftStick(): number;
  41620. /**
  41621. * Sets the value of the Left joystick
  41622. */
  41623. set buttonLeftStick(value: number);
  41624. /**
  41625. * Gets the value of the Right joystick
  41626. */
  41627. get buttonRightStick(): number;
  41628. /**
  41629. * Sets the value of the Right joystick
  41630. */
  41631. set buttonRightStick(value: number);
  41632. /**
  41633. * Gets the value of D-pad up
  41634. */
  41635. get dPadUp(): number;
  41636. /**
  41637. * Sets the value of D-pad up
  41638. */
  41639. set dPadUp(value: number);
  41640. /**
  41641. * Gets the value of D-pad down
  41642. */
  41643. get dPadDown(): number;
  41644. /**
  41645. * Sets the value of D-pad down
  41646. */
  41647. set dPadDown(value: number);
  41648. /**
  41649. * Gets the value of D-pad left
  41650. */
  41651. get dPadLeft(): number;
  41652. /**
  41653. * Sets the value of D-pad left
  41654. */
  41655. set dPadLeft(value: number);
  41656. /**
  41657. * Gets the value of D-pad right
  41658. */
  41659. get dPadRight(): number;
  41660. /**
  41661. * Sets the value of D-pad right
  41662. */
  41663. set dPadRight(value: number);
  41664. /**
  41665. * Force the gamepad to synchronize with device values
  41666. */
  41667. update(): void;
  41668. /**
  41669. * Disposes the gamepad
  41670. */
  41671. dispose(): void;
  41672. }
  41673. }
  41674. declare module BABYLON {
  41675. /**
  41676. * Manager for handling gamepads
  41677. */
  41678. export class GamepadManager {
  41679. private _scene?;
  41680. private _babylonGamepads;
  41681. private _oneGamepadConnected;
  41682. /** @hidden */
  41683. _isMonitoring: boolean;
  41684. private _gamepadEventSupported;
  41685. private _gamepadSupport?;
  41686. /**
  41687. * observable to be triggered when the gamepad controller has been connected
  41688. */
  41689. onGamepadConnectedObservable: Observable<Gamepad>;
  41690. /**
  41691. * observable to be triggered when the gamepad controller has been disconnected
  41692. */
  41693. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41694. private _onGamepadConnectedEvent;
  41695. private _onGamepadDisconnectedEvent;
  41696. /**
  41697. * Initializes the gamepad manager
  41698. * @param _scene BabylonJS scene
  41699. */
  41700. constructor(_scene?: Scene | undefined);
  41701. /**
  41702. * The gamepads in the game pad manager
  41703. */
  41704. get gamepads(): Gamepad[];
  41705. /**
  41706. * Get the gamepad controllers based on type
  41707. * @param type The type of gamepad controller
  41708. * @returns Nullable gamepad
  41709. */
  41710. getGamepadByType(type?: number): Nullable<Gamepad>;
  41711. /**
  41712. * Disposes the gamepad manager
  41713. */
  41714. dispose(): void;
  41715. private _addNewGamepad;
  41716. private _startMonitoringGamepads;
  41717. private _stopMonitoringGamepads;
  41718. /** @hidden */
  41719. _checkGamepadsStatus(): void;
  41720. private _updateGamepadObjects;
  41721. }
  41722. }
  41723. declare module BABYLON {
  41724. interface Scene {
  41725. /** @hidden */
  41726. _gamepadManager: Nullable<GamepadManager>;
  41727. /**
  41728. * Gets the gamepad manager associated with the scene
  41729. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41730. */
  41731. gamepadManager: GamepadManager;
  41732. }
  41733. /**
  41734. * Interface representing a free camera inputs manager
  41735. */
  41736. interface FreeCameraInputsManager {
  41737. /**
  41738. * Adds gamepad input support to the FreeCameraInputsManager.
  41739. * @returns the FreeCameraInputsManager
  41740. */
  41741. addGamepad(): FreeCameraInputsManager;
  41742. }
  41743. /**
  41744. * Interface representing an arc rotate camera inputs manager
  41745. */
  41746. interface ArcRotateCameraInputsManager {
  41747. /**
  41748. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41749. * @returns the camera inputs manager
  41750. */
  41751. addGamepad(): ArcRotateCameraInputsManager;
  41752. }
  41753. /**
  41754. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41755. */
  41756. export class GamepadSystemSceneComponent implements ISceneComponent {
  41757. /**
  41758. * The component name helpfull to identify the component in the list of scene components.
  41759. */
  41760. readonly name: string;
  41761. /**
  41762. * The scene the component belongs to.
  41763. */
  41764. scene: Scene;
  41765. /**
  41766. * Creates a new instance of the component for the given scene
  41767. * @param scene Defines the scene to register the component in
  41768. */
  41769. constructor(scene: Scene);
  41770. /**
  41771. * Registers the component in a given scene
  41772. */
  41773. register(): void;
  41774. /**
  41775. * Rebuilds the elements related to this component in case of
  41776. * context lost for instance.
  41777. */
  41778. rebuild(): void;
  41779. /**
  41780. * Disposes the component and the associated ressources
  41781. */
  41782. dispose(): void;
  41783. private _beforeCameraUpdate;
  41784. }
  41785. }
  41786. declare module BABYLON {
  41787. /**
  41788. * 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,
  41789. * which still works and will still be found in many Playgrounds.
  41790. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41791. */
  41792. export class UniversalCamera extends TouchCamera {
  41793. /**
  41794. * Defines the gamepad rotation sensiblity.
  41795. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41796. */
  41797. get gamepadAngularSensibility(): number;
  41798. set gamepadAngularSensibility(value: number);
  41799. /**
  41800. * Defines the gamepad move sensiblity.
  41801. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41802. */
  41803. get gamepadMoveSensibility(): number;
  41804. set gamepadMoveSensibility(value: number);
  41805. /**
  41806. * 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,
  41807. * which still works and will still be found in many Playgrounds.
  41808. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41809. * @param name Define the name of the camera in the scene
  41810. * @param position Define the start position of the camera in the scene
  41811. * @param scene Define the scene the camera belongs to
  41812. */
  41813. constructor(name: string, position: Vector3, scene: Scene);
  41814. /**
  41815. * Gets the current object class name.
  41816. * @return the class name
  41817. */
  41818. getClassName(): string;
  41819. }
  41820. }
  41821. declare module BABYLON {
  41822. /**
  41823. * This represents a FPS type of camera. This is only here for back compat purpose.
  41824. * Please use the UniversalCamera instead as both are identical.
  41825. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41826. */
  41827. export class GamepadCamera extends UniversalCamera {
  41828. /**
  41829. * Instantiates a new Gamepad Camera
  41830. * This represents a FPS type of camera. This is only here for back compat purpose.
  41831. * Please use the UniversalCamera instead as both are identical.
  41832. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41833. * @param name Define the name of the camera in the scene
  41834. * @param position Define the start position of the camera in the scene
  41835. * @param scene Define the scene the camera belongs to
  41836. */
  41837. constructor(name: string, position: Vector3, scene: Scene);
  41838. /**
  41839. * Gets the current object class name.
  41840. * @return the class name
  41841. */
  41842. getClassName(): string;
  41843. }
  41844. }
  41845. declare module BABYLON {
  41846. /** @hidden */
  41847. export var passPixelShader: {
  41848. name: string;
  41849. shader: string;
  41850. };
  41851. }
  41852. declare module BABYLON {
  41853. /** @hidden */
  41854. export var passCubePixelShader: {
  41855. name: string;
  41856. shader: string;
  41857. };
  41858. }
  41859. declare module BABYLON {
  41860. /**
  41861. * PassPostProcess which produces an output the same as it's input
  41862. */
  41863. export class PassPostProcess extends PostProcess {
  41864. /**
  41865. * Creates the PassPostProcess
  41866. * @param name The name of the effect.
  41867. * @param options The required width/height ratio to downsize to before computing the render pass.
  41868. * @param camera The camera to apply the render pass to.
  41869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41870. * @param engine The engine which the post process will be applied. (default: current engine)
  41871. * @param reusable If the post process can be reused on the same frame. (default: false)
  41872. * @param textureType The type of texture to be used when performing the post processing.
  41873. * @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)
  41874. */
  41875. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41876. }
  41877. /**
  41878. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41879. */
  41880. export class PassCubePostProcess extends PostProcess {
  41881. private _face;
  41882. /**
  41883. * Gets or sets the cube face to display.
  41884. * * 0 is +X
  41885. * * 1 is -X
  41886. * * 2 is +Y
  41887. * * 3 is -Y
  41888. * * 4 is +Z
  41889. * * 5 is -Z
  41890. */
  41891. get face(): number;
  41892. set face(value: number);
  41893. /**
  41894. * Creates the PassCubePostProcess
  41895. * @param name The name of the effect.
  41896. * @param options The required width/height ratio to downsize to before computing the render pass.
  41897. * @param camera The camera to apply the render pass to.
  41898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41899. * @param engine The engine which the post process will be applied. (default: current engine)
  41900. * @param reusable If the post process can be reused on the same frame. (default: false)
  41901. * @param textureType The type of texture to be used when performing the post processing.
  41902. * @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)
  41903. */
  41904. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41905. }
  41906. }
  41907. declare module BABYLON {
  41908. /** @hidden */
  41909. export var anaglyphPixelShader: {
  41910. name: string;
  41911. shader: string;
  41912. };
  41913. }
  41914. declare module BABYLON {
  41915. /**
  41916. * Postprocess used to generate anaglyphic rendering
  41917. */
  41918. export class AnaglyphPostProcess extends PostProcess {
  41919. private _passedProcess;
  41920. /**
  41921. * Creates a new AnaglyphPostProcess
  41922. * @param name defines postprocess name
  41923. * @param options defines creation options or target ratio scale
  41924. * @param rigCameras defines cameras using this postprocess
  41925. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41926. * @param engine defines hosting engine
  41927. * @param reusable defines if the postprocess will be reused multiple times per frame
  41928. */
  41929. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41930. }
  41931. }
  41932. declare module BABYLON {
  41933. /**
  41934. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41935. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41936. */
  41937. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41938. /**
  41939. * Creates a new AnaglyphArcRotateCamera
  41940. * @param name defines camera name
  41941. * @param alpha defines alpha angle (in radians)
  41942. * @param beta defines beta angle (in radians)
  41943. * @param radius defines radius
  41944. * @param target defines camera target
  41945. * @param interaxialDistance defines distance between each color axis
  41946. * @param scene defines the hosting scene
  41947. */
  41948. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41949. /**
  41950. * Gets camera class name
  41951. * @returns AnaglyphArcRotateCamera
  41952. */
  41953. getClassName(): string;
  41954. }
  41955. }
  41956. declare module BABYLON {
  41957. /**
  41958. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41959. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41960. */
  41961. export class AnaglyphFreeCamera extends FreeCamera {
  41962. /**
  41963. * Creates a new AnaglyphFreeCamera
  41964. * @param name defines camera name
  41965. * @param position defines initial position
  41966. * @param interaxialDistance defines distance between each color axis
  41967. * @param scene defines the hosting scene
  41968. */
  41969. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41970. /**
  41971. * Gets camera class name
  41972. * @returns AnaglyphFreeCamera
  41973. */
  41974. getClassName(): string;
  41975. }
  41976. }
  41977. declare module BABYLON {
  41978. /**
  41979. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41980. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41981. */
  41982. export class AnaglyphGamepadCamera extends GamepadCamera {
  41983. /**
  41984. * Creates a new AnaglyphGamepadCamera
  41985. * @param name defines camera name
  41986. * @param position defines initial position
  41987. * @param interaxialDistance defines distance between each color axis
  41988. * @param scene defines the hosting scene
  41989. */
  41990. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41991. /**
  41992. * Gets camera class name
  41993. * @returns AnaglyphGamepadCamera
  41994. */
  41995. getClassName(): string;
  41996. }
  41997. }
  41998. declare module BABYLON {
  41999. /**
  42000. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42001. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42002. */
  42003. export class AnaglyphUniversalCamera extends UniversalCamera {
  42004. /**
  42005. * Creates a new AnaglyphUniversalCamera
  42006. * @param name defines camera name
  42007. * @param position defines initial position
  42008. * @param interaxialDistance defines distance between each color axis
  42009. * @param scene defines the hosting scene
  42010. */
  42011. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42012. /**
  42013. * Gets camera class name
  42014. * @returns AnaglyphUniversalCamera
  42015. */
  42016. getClassName(): string;
  42017. }
  42018. }
  42019. declare module BABYLON {
  42020. /** @hidden */
  42021. export var stereoscopicInterlacePixelShader: {
  42022. name: string;
  42023. shader: string;
  42024. };
  42025. }
  42026. declare module BABYLON {
  42027. /**
  42028. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42029. */
  42030. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42031. private _stepSize;
  42032. private _passedProcess;
  42033. /**
  42034. * Initializes a StereoscopicInterlacePostProcessI
  42035. * @param name The name of the effect.
  42036. * @param rigCameras The rig cameras to be appled to the post process
  42037. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42038. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42040. * @param engine The engine which the post process will be applied. (default: current engine)
  42041. * @param reusable If the post process can be reused on the same frame. (default: false)
  42042. */
  42043. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42044. }
  42045. /**
  42046. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42047. */
  42048. export class StereoscopicInterlacePostProcess extends PostProcess {
  42049. private _stepSize;
  42050. private _passedProcess;
  42051. /**
  42052. * Initializes a StereoscopicInterlacePostProcess
  42053. * @param name The name of the effect.
  42054. * @param rigCameras The rig cameras to be appled to the post process
  42055. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42057. * @param engine The engine which the post process will be applied. (default: current engine)
  42058. * @param reusable If the post process can be reused on the same frame. (default: false)
  42059. */
  42060. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42061. }
  42062. }
  42063. declare module BABYLON {
  42064. /**
  42065. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42066. * @see http://doc.babylonjs.com/features/cameras
  42067. */
  42068. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42069. /**
  42070. * Creates a new StereoscopicArcRotateCamera
  42071. * @param name defines camera name
  42072. * @param alpha defines alpha angle (in radians)
  42073. * @param beta defines beta angle (in radians)
  42074. * @param radius defines radius
  42075. * @param target defines camera target
  42076. * @param interaxialDistance defines distance between each color axis
  42077. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42078. * @param scene defines the hosting scene
  42079. */
  42080. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42081. /**
  42082. * Gets camera class name
  42083. * @returns StereoscopicArcRotateCamera
  42084. */
  42085. getClassName(): string;
  42086. }
  42087. }
  42088. declare module BABYLON {
  42089. /**
  42090. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42091. * @see http://doc.babylonjs.com/features/cameras
  42092. */
  42093. export class StereoscopicFreeCamera extends FreeCamera {
  42094. /**
  42095. * Creates a new StereoscopicFreeCamera
  42096. * @param name defines camera name
  42097. * @param position defines initial position
  42098. * @param interaxialDistance defines distance between each color axis
  42099. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42100. * @param scene defines the hosting scene
  42101. */
  42102. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42103. /**
  42104. * Gets camera class name
  42105. * @returns StereoscopicFreeCamera
  42106. */
  42107. getClassName(): string;
  42108. }
  42109. }
  42110. declare module BABYLON {
  42111. /**
  42112. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42113. * @see http://doc.babylonjs.com/features/cameras
  42114. */
  42115. export class StereoscopicGamepadCamera extends GamepadCamera {
  42116. /**
  42117. * Creates a new StereoscopicGamepadCamera
  42118. * @param name defines camera name
  42119. * @param position defines initial position
  42120. * @param interaxialDistance defines distance between each color axis
  42121. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42122. * @param scene defines the hosting scene
  42123. */
  42124. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42125. /**
  42126. * Gets camera class name
  42127. * @returns StereoscopicGamepadCamera
  42128. */
  42129. getClassName(): string;
  42130. }
  42131. }
  42132. declare module BABYLON {
  42133. /**
  42134. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42135. * @see http://doc.babylonjs.com/features/cameras
  42136. */
  42137. export class StereoscopicUniversalCamera extends UniversalCamera {
  42138. /**
  42139. * Creates a new StereoscopicUniversalCamera
  42140. * @param name defines camera name
  42141. * @param position defines initial position
  42142. * @param interaxialDistance defines distance between each color axis
  42143. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42144. * @param scene defines the hosting scene
  42145. */
  42146. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42147. /**
  42148. * Gets camera class name
  42149. * @returns StereoscopicUniversalCamera
  42150. */
  42151. getClassName(): string;
  42152. }
  42153. }
  42154. declare module BABYLON {
  42155. /**
  42156. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42157. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42158. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42159. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42160. */
  42161. export class VirtualJoysticksCamera extends FreeCamera {
  42162. /**
  42163. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42164. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42165. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42166. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42167. * @param name Define the name of the camera in the scene
  42168. * @param position Define the start position of the camera in the scene
  42169. * @param scene Define the scene the camera belongs to
  42170. */
  42171. constructor(name: string, position: Vector3, scene: Scene);
  42172. /**
  42173. * Gets the current object class name.
  42174. * @return the class name
  42175. */
  42176. getClassName(): string;
  42177. }
  42178. }
  42179. declare module BABYLON {
  42180. /**
  42181. * This represents all the required metrics to create a VR camera.
  42182. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42183. */
  42184. export class VRCameraMetrics {
  42185. /**
  42186. * Define the horizontal resolution off the screen.
  42187. */
  42188. hResolution: number;
  42189. /**
  42190. * Define the vertical resolution off the screen.
  42191. */
  42192. vResolution: number;
  42193. /**
  42194. * Define the horizontal screen size.
  42195. */
  42196. hScreenSize: number;
  42197. /**
  42198. * Define the vertical screen size.
  42199. */
  42200. vScreenSize: number;
  42201. /**
  42202. * Define the vertical screen center position.
  42203. */
  42204. vScreenCenter: number;
  42205. /**
  42206. * Define the distance of the eyes to the screen.
  42207. */
  42208. eyeToScreenDistance: number;
  42209. /**
  42210. * Define the distance between both lenses
  42211. */
  42212. lensSeparationDistance: number;
  42213. /**
  42214. * Define the distance between both viewer's eyes.
  42215. */
  42216. interpupillaryDistance: number;
  42217. /**
  42218. * Define the distortion factor of the VR postprocess.
  42219. * Please, touch with care.
  42220. */
  42221. distortionK: number[];
  42222. /**
  42223. * Define the chromatic aberration correction factors for the VR post process.
  42224. */
  42225. chromaAbCorrection: number[];
  42226. /**
  42227. * Define the scale factor of the post process.
  42228. * The smaller the better but the slower.
  42229. */
  42230. postProcessScaleFactor: number;
  42231. /**
  42232. * Define an offset for the lens center.
  42233. */
  42234. lensCenterOffset: number;
  42235. /**
  42236. * Define if the current vr camera should compensate the distortion of the lense or not.
  42237. */
  42238. compensateDistortion: boolean;
  42239. /**
  42240. * Defines if multiview should be enabled when rendering (Default: false)
  42241. */
  42242. multiviewEnabled: boolean;
  42243. /**
  42244. * Gets the rendering aspect ratio based on the provided resolutions.
  42245. */
  42246. get aspectRatio(): number;
  42247. /**
  42248. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42249. */
  42250. get aspectRatioFov(): number;
  42251. /**
  42252. * @hidden
  42253. */
  42254. get leftHMatrix(): Matrix;
  42255. /**
  42256. * @hidden
  42257. */
  42258. get rightHMatrix(): Matrix;
  42259. /**
  42260. * @hidden
  42261. */
  42262. get leftPreViewMatrix(): Matrix;
  42263. /**
  42264. * @hidden
  42265. */
  42266. get rightPreViewMatrix(): Matrix;
  42267. /**
  42268. * Get the default VRMetrics based on the most generic setup.
  42269. * @returns the default vr metrics
  42270. */
  42271. static GetDefault(): VRCameraMetrics;
  42272. }
  42273. }
  42274. declare module BABYLON {
  42275. /** @hidden */
  42276. export var vrDistortionCorrectionPixelShader: {
  42277. name: string;
  42278. shader: string;
  42279. };
  42280. }
  42281. declare module BABYLON {
  42282. /**
  42283. * VRDistortionCorrectionPostProcess used for mobile VR
  42284. */
  42285. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42286. private _isRightEye;
  42287. private _distortionFactors;
  42288. private _postProcessScaleFactor;
  42289. private _lensCenterOffset;
  42290. private _scaleIn;
  42291. private _scaleFactor;
  42292. private _lensCenter;
  42293. /**
  42294. * Initializes the VRDistortionCorrectionPostProcess
  42295. * @param name The name of the effect.
  42296. * @param camera The camera to apply the render pass to.
  42297. * @param isRightEye If this is for the right eye distortion
  42298. * @param vrMetrics All the required metrics for the VR camera
  42299. */
  42300. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42301. }
  42302. }
  42303. declare module BABYLON {
  42304. /**
  42305. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42306. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42307. */
  42308. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42309. /**
  42310. * Creates a new VRDeviceOrientationArcRotateCamera
  42311. * @param name defines camera name
  42312. * @param alpha defines the camera rotation along the logitudinal axis
  42313. * @param beta defines the camera rotation along the latitudinal axis
  42314. * @param radius defines the camera distance from its target
  42315. * @param target defines the camera target
  42316. * @param scene defines the scene the camera belongs to
  42317. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42318. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42319. */
  42320. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42321. /**
  42322. * Gets camera class name
  42323. * @returns VRDeviceOrientationArcRotateCamera
  42324. */
  42325. getClassName(): string;
  42326. }
  42327. }
  42328. declare module BABYLON {
  42329. /**
  42330. * Camera used to simulate VR rendering (based on FreeCamera)
  42331. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42332. */
  42333. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42334. /**
  42335. * Creates a new VRDeviceOrientationFreeCamera
  42336. * @param name defines camera name
  42337. * @param position defines the start position of the camera
  42338. * @param scene defines the scene the camera belongs to
  42339. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42340. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42341. */
  42342. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42343. /**
  42344. * Gets camera class name
  42345. * @returns VRDeviceOrientationFreeCamera
  42346. */
  42347. getClassName(): string;
  42348. }
  42349. }
  42350. declare module BABYLON {
  42351. /**
  42352. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42353. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42354. */
  42355. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42356. /**
  42357. * Creates a new VRDeviceOrientationGamepadCamera
  42358. * @param name defines camera name
  42359. * @param position defines the start position of the camera
  42360. * @param scene defines the scene the camera belongs to
  42361. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42362. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42363. */
  42364. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42365. /**
  42366. * Gets camera class name
  42367. * @returns VRDeviceOrientationGamepadCamera
  42368. */
  42369. getClassName(): string;
  42370. }
  42371. }
  42372. declare module BABYLON {
  42373. /** @hidden */
  42374. export var imageProcessingPixelShader: {
  42375. name: string;
  42376. shader: string;
  42377. };
  42378. }
  42379. declare module BABYLON {
  42380. /**
  42381. * ImageProcessingPostProcess
  42382. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42383. */
  42384. export class ImageProcessingPostProcess extends PostProcess {
  42385. /**
  42386. * Default configuration related to image processing available in the PBR Material.
  42387. */
  42388. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42389. /**
  42390. * Gets the image processing configuration used either in this material.
  42391. */
  42392. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42393. /**
  42394. * Sets the Default image processing configuration used either in the this material.
  42395. *
  42396. * If sets to null, the scene one is in use.
  42397. */
  42398. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42399. /**
  42400. * Keep track of the image processing observer to allow dispose and replace.
  42401. */
  42402. private _imageProcessingObserver;
  42403. /**
  42404. * Attaches a new image processing configuration to the PBR Material.
  42405. * @param configuration
  42406. */
  42407. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42408. /**
  42409. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42410. */
  42411. get colorCurves(): Nullable<ColorCurves>;
  42412. /**
  42413. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42414. */
  42415. set colorCurves(value: Nullable<ColorCurves>);
  42416. /**
  42417. * Gets wether the color curves effect is enabled.
  42418. */
  42419. get colorCurvesEnabled(): boolean;
  42420. /**
  42421. * Sets wether the color curves effect is enabled.
  42422. */
  42423. set colorCurvesEnabled(value: boolean);
  42424. /**
  42425. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42426. */
  42427. get colorGradingTexture(): Nullable<BaseTexture>;
  42428. /**
  42429. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42430. */
  42431. set colorGradingTexture(value: Nullable<BaseTexture>);
  42432. /**
  42433. * Gets wether the color grading effect is enabled.
  42434. */
  42435. get colorGradingEnabled(): boolean;
  42436. /**
  42437. * Gets wether the color grading effect is enabled.
  42438. */
  42439. set colorGradingEnabled(value: boolean);
  42440. /**
  42441. * Gets exposure used in the effect.
  42442. */
  42443. get exposure(): number;
  42444. /**
  42445. * Sets exposure used in the effect.
  42446. */
  42447. set exposure(value: number);
  42448. /**
  42449. * Gets wether tonemapping is enabled or not.
  42450. */
  42451. get toneMappingEnabled(): boolean;
  42452. /**
  42453. * Sets wether tonemapping is enabled or not
  42454. */
  42455. set toneMappingEnabled(value: boolean);
  42456. /**
  42457. * Gets the type of tone mapping effect.
  42458. */
  42459. get toneMappingType(): number;
  42460. /**
  42461. * Sets the type of tone mapping effect.
  42462. */
  42463. set toneMappingType(value: number);
  42464. /**
  42465. * Gets contrast used in the effect.
  42466. */
  42467. get contrast(): number;
  42468. /**
  42469. * Sets contrast used in the effect.
  42470. */
  42471. set contrast(value: number);
  42472. /**
  42473. * Gets Vignette stretch size.
  42474. */
  42475. get vignetteStretch(): number;
  42476. /**
  42477. * Sets Vignette stretch size.
  42478. */
  42479. set vignetteStretch(value: number);
  42480. /**
  42481. * Gets Vignette centre X Offset.
  42482. */
  42483. get vignetteCentreX(): number;
  42484. /**
  42485. * Sets Vignette centre X Offset.
  42486. */
  42487. set vignetteCentreX(value: number);
  42488. /**
  42489. * Gets Vignette centre Y Offset.
  42490. */
  42491. get vignetteCentreY(): number;
  42492. /**
  42493. * Sets Vignette centre Y Offset.
  42494. */
  42495. set vignetteCentreY(value: number);
  42496. /**
  42497. * Gets Vignette weight or intensity of the vignette effect.
  42498. */
  42499. get vignetteWeight(): number;
  42500. /**
  42501. * Sets Vignette weight or intensity of the vignette effect.
  42502. */
  42503. set vignetteWeight(value: number);
  42504. /**
  42505. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42506. * if vignetteEnabled is set to true.
  42507. */
  42508. get vignetteColor(): Color4;
  42509. /**
  42510. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42511. * if vignetteEnabled is set to true.
  42512. */
  42513. set vignetteColor(value: Color4);
  42514. /**
  42515. * Gets Camera field of view used by the Vignette effect.
  42516. */
  42517. get vignetteCameraFov(): number;
  42518. /**
  42519. * Sets Camera field of view used by the Vignette effect.
  42520. */
  42521. set vignetteCameraFov(value: number);
  42522. /**
  42523. * Gets the vignette blend mode allowing different kind of effect.
  42524. */
  42525. get vignetteBlendMode(): number;
  42526. /**
  42527. * Sets the vignette blend mode allowing different kind of effect.
  42528. */
  42529. set vignetteBlendMode(value: number);
  42530. /**
  42531. * Gets wether the vignette effect is enabled.
  42532. */
  42533. get vignetteEnabled(): boolean;
  42534. /**
  42535. * Sets wether the vignette effect is enabled.
  42536. */
  42537. set vignetteEnabled(value: boolean);
  42538. private _fromLinearSpace;
  42539. /**
  42540. * Gets wether the input of the processing is in Gamma or Linear Space.
  42541. */
  42542. get fromLinearSpace(): boolean;
  42543. /**
  42544. * Sets wether the input of the processing is in Gamma or Linear Space.
  42545. */
  42546. set fromLinearSpace(value: boolean);
  42547. /**
  42548. * Defines cache preventing GC.
  42549. */
  42550. private _defines;
  42551. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42552. /**
  42553. * "ImageProcessingPostProcess"
  42554. * @returns "ImageProcessingPostProcess"
  42555. */
  42556. getClassName(): string;
  42557. protected _updateParameters(): void;
  42558. dispose(camera?: Camera): void;
  42559. }
  42560. }
  42561. declare module BABYLON {
  42562. /**
  42563. * Class containing static functions to help procedurally build meshes
  42564. */
  42565. export class GroundBuilder {
  42566. /**
  42567. * Creates a ground mesh
  42568. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42569. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42571. * @param name defines the name of the mesh
  42572. * @param options defines the options used to create the mesh
  42573. * @param scene defines the hosting scene
  42574. * @returns the ground mesh
  42575. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42576. */
  42577. static CreateGround(name: string, options: {
  42578. width?: number;
  42579. height?: number;
  42580. subdivisions?: number;
  42581. subdivisionsX?: number;
  42582. subdivisionsY?: number;
  42583. updatable?: boolean;
  42584. }, scene: any): Mesh;
  42585. /**
  42586. * Creates a tiled ground mesh
  42587. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42588. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42589. * * 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
  42590. * * 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
  42591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42592. * @param name defines the name of the mesh
  42593. * @param options defines the options used to create the mesh
  42594. * @param scene defines the hosting scene
  42595. * @returns the tiled ground mesh
  42596. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42597. */
  42598. static CreateTiledGround(name: string, options: {
  42599. xmin: number;
  42600. zmin: number;
  42601. xmax: number;
  42602. zmax: number;
  42603. subdivisions?: {
  42604. w: number;
  42605. h: number;
  42606. };
  42607. precision?: {
  42608. w: number;
  42609. h: number;
  42610. };
  42611. updatable?: boolean;
  42612. }, scene?: Nullable<Scene>): Mesh;
  42613. /**
  42614. * Creates a ground mesh from a height map
  42615. * * The parameter `url` sets the URL of the height map image resource.
  42616. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42617. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42618. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42619. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42620. * * 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.
  42621. * * 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).
  42622. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42624. * @param name defines the name of the mesh
  42625. * @param url defines the url to the height map
  42626. * @param options defines the options used to create the mesh
  42627. * @param scene defines the hosting scene
  42628. * @returns the ground mesh
  42629. * @see https://doc.babylonjs.com/babylon101/height_map
  42630. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42631. */
  42632. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42633. width?: number;
  42634. height?: number;
  42635. subdivisions?: number;
  42636. minHeight?: number;
  42637. maxHeight?: number;
  42638. colorFilter?: Color3;
  42639. alphaFilter?: number;
  42640. updatable?: boolean;
  42641. onReady?: (mesh: GroundMesh) => void;
  42642. }, scene?: Nullable<Scene>): GroundMesh;
  42643. }
  42644. }
  42645. declare module BABYLON {
  42646. /**
  42647. * Class containing static functions to help procedurally build meshes
  42648. */
  42649. export class TorusBuilder {
  42650. /**
  42651. * Creates a torus mesh
  42652. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42653. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42654. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42656. * * 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
  42657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42658. * @param name defines the name of the mesh
  42659. * @param options defines the options used to create the mesh
  42660. * @param scene defines the hosting scene
  42661. * @returns the torus mesh
  42662. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42663. */
  42664. static CreateTorus(name: string, options: {
  42665. diameter?: number;
  42666. thickness?: number;
  42667. tessellation?: number;
  42668. updatable?: boolean;
  42669. sideOrientation?: number;
  42670. frontUVs?: Vector4;
  42671. backUVs?: Vector4;
  42672. }, scene: any): Mesh;
  42673. }
  42674. }
  42675. declare module BABYLON {
  42676. /**
  42677. * Class containing static functions to help procedurally build meshes
  42678. */
  42679. export class CylinderBuilder {
  42680. /**
  42681. * Creates a cylinder or a cone mesh
  42682. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42683. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42684. * * 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.
  42685. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42686. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42687. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42688. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42689. * * 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).
  42690. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42691. * * 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).
  42692. * * 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
  42693. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42694. * * 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
  42695. * * 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.
  42696. * * If `enclose` is false, a ring surface is one element.
  42697. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42698. * * 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
  42699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42700. * * 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
  42701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42702. * @param name defines the name of the mesh
  42703. * @param options defines the options used to create the mesh
  42704. * @param scene defines the hosting scene
  42705. * @returns the cylinder mesh
  42706. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42707. */
  42708. static CreateCylinder(name: string, options: {
  42709. height?: number;
  42710. diameterTop?: number;
  42711. diameterBottom?: number;
  42712. diameter?: number;
  42713. tessellation?: number;
  42714. subdivisions?: number;
  42715. arc?: number;
  42716. faceColors?: Color4[];
  42717. faceUV?: Vector4[];
  42718. updatable?: boolean;
  42719. hasRings?: boolean;
  42720. enclose?: boolean;
  42721. cap?: number;
  42722. sideOrientation?: number;
  42723. frontUVs?: Vector4;
  42724. backUVs?: Vector4;
  42725. }, scene: any): Mesh;
  42726. }
  42727. }
  42728. declare module BABYLON {
  42729. /**
  42730. * States of the webXR experience
  42731. */
  42732. export enum WebXRState {
  42733. /**
  42734. * Transitioning to being in XR mode
  42735. */
  42736. ENTERING_XR = 0,
  42737. /**
  42738. * Transitioning to non XR mode
  42739. */
  42740. EXITING_XR = 1,
  42741. /**
  42742. * In XR mode and presenting
  42743. */
  42744. IN_XR = 2,
  42745. /**
  42746. * Not entered XR mode
  42747. */
  42748. NOT_IN_XR = 3
  42749. }
  42750. /**
  42751. * Abstraction of the XR render target
  42752. */
  42753. export interface WebXRRenderTarget extends IDisposable {
  42754. /**
  42755. * xrpresent context of the canvas which can be used to display/mirror xr content
  42756. */
  42757. canvasContext: WebGLRenderingContext;
  42758. /**
  42759. * xr layer for the canvas
  42760. */
  42761. xrLayer: Nullable<XRWebGLLayer>;
  42762. /**
  42763. * Initializes the xr layer for the session
  42764. * @param xrSession xr session
  42765. * @returns a promise that will resolve once the XR Layer has been created
  42766. */
  42767. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42768. }
  42769. }
  42770. declare module BABYLON {
  42771. /**
  42772. * COnfiguration object for WebXR output canvas
  42773. */
  42774. export class WebXRManagedOutputCanvasOptions {
  42775. /**
  42776. * An optional canvas in case you wish to create it yourself and provide it here.
  42777. * If not provided, a new canvas will be created
  42778. */
  42779. canvasElement?: HTMLCanvasElement;
  42780. /**
  42781. * Options for this XR Layer output
  42782. */
  42783. canvasOptions?: XRWebGLLayerOptions;
  42784. /**
  42785. * CSS styling for a newly created canvas (if not provided)
  42786. */
  42787. newCanvasCssStyle?: string;
  42788. /**
  42789. * Get the default values of the configuration object
  42790. * @returns default values of this configuration object
  42791. */
  42792. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42793. }
  42794. /**
  42795. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42796. */
  42797. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42798. private _options;
  42799. private _canvas;
  42800. private _engine;
  42801. /**
  42802. * Rendering context of the canvas which can be used to display/mirror xr content
  42803. */
  42804. canvasContext: WebGLRenderingContext;
  42805. /**
  42806. * xr layer for the canvas
  42807. */
  42808. xrLayer: Nullable<XRWebGLLayer>;
  42809. /**
  42810. * Initializes the canvas to be added/removed upon entering/exiting xr
  42811. * @param _xrSessionManager The XR Session manager
  42812. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42813. */
  42814. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42815. /**
  42816. * Disposes of the object
  42817. */
  42818. dispose(): void;
  42819. /**
  42820. * Initializes the xr layer for the session
  42821. * @param xrSession xr session
  42822. * @returns a promise that will resolve once the XR Layer has been created
  42823. */
  42824. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42825. private _addCanvas;
  42826. private _removeCanvas;
  42827. private _setManagedOutputCanvas;
  42828. }
  42829. }
  42830. declare module BABYLON {
  42831. /**
  42832. * Manages an XRSession to work with Babylon's engine
  42833. * @see https://doc.babylonjs.com/how_to/webxr
  42834. */
  42835. export class WebXRSessionManager implements IDisposable {
  42836. /** The scene which the session should be created for */
  42837. scene: Scene;
  42838. private _referenceSpace;
  42839. private _rttProvider;
  42840. private _sessionEnded;
  42841. private _xrNavigator;
  42842. private baseLayer;
  42843. /**
  42844. * The base reference space from which the session started. good if you want to reset your
  42845. * reference space
  42846. */
  42847. baseReferenceSpace: XRReferenceSpace;
  42848. /**
  42849. * Current XR frame
  42850. */
  42851. currentFrame: Nullable<XRFrame>;
  42852. /** WebXR timestamp updated every frame */
  42853. currentTimestamp: number;
  42854. /**
  42855. * Used just in case of a failure to initialize an immersive session.
  42856. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42857. */
  42858. defaultHeightCompensation: number;
  42859. /**
  42860. * Fires every time a new xrFrame arrives which can be used to update the camera
  42861. */
  42862. onXRFrameObservable: Observable<XRFrame>;
  42863. /**
  42864. * Fires when the reference space changed
  42865. */
  42866. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42867. /**
  42868. * Fires when the xr session is ended either by the device or manually done
  42869. */
  42870. onXRSessionEnded: Observable<any>;
  42871. /**
  42872. * Fires when the xr session is ended either by the device or manually done
  42873. */
  42874. onXRSessionInit: Observable<XRSession>;
  42875. /**
  42876. * Underlying xr session
  42877. */
  42878. session: XRSession;
  42879. /**
  42880. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42881. * or get the offset the player is currently at.
  42882. */
  42883. viewerReferenceSpace: XRReferenceSpace;
  42884. /**
  42885. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42886. * @param scene The scene which the session should be created for
  42887. */
  42888. constructor(
  42889. /** The scene which the session should be created for */
  42890. scene: Scene);
  42891. /**
  42892. * The current reference space used in this session. This reference space can constantly change!
  42893. * It is mainly used to offset the camera's position.
  42894. */
  42895. get referenceSpace(): XRReferenceSpace;
  42896. /**
  42897. * Set a new reference space and triggers the observable
  42898. */
  42899. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42900. /**
  42901. * Disposes of the session manager
  42902. */
  42903. dispose(): void;
  42904. /**
  42905. * Stops the xrSession and restores the render loop
  42906. * @returns Promise which resolves after it exits XR
  42907. */
  42908. exitXRAsync(): Promise<void>;
  42909. /**
  42910. * Gets the correct render target texture to be rendered this frame for this eye
  42911. * @param eye the eye for which to get the render target
  42912. * @returns the render target for the specified eye
  42913. */
  42914. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42915. /**
  42916. * Creates a WebXRRenderTarget object for the XR session
  42917. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42918. * @param options optional options to provide when creating a new render target
  42919. * @returns a WebXR render target to which the session can render
  42920. */
  42921. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42922. /**
  42923. * Initializes the manager
  42924. * After initialization enterXR can be called to start an XR session
  42925. * @returns Promise which resolves after it is initialized
  42926. */
  42927. initializeAsync(): Promise<void>;
  42928. /**
  42929. * Initializes an xr session
  42930. * @param xrSessionMode mode to initialize
  42931. * @param xrSessionInit defines optional and required values to pass to the session builder
  42932. * @returns a promise which will resolve once the session has been initialized
  42933. */
  42934. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42935. /**
  42936. * Checks if a session would be supported for the creation options specified
  42937. * @param sessionMode session mode to check if supported eg. immersive-vr
  42938. * @returns A Promise that resolves to true if supported and false if not
  42939. */
  42940. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42941. /**
  42942. * Resets the reference space to the one started the session
  42943. */
  42944. resetReferenceSpace(): void;
  42945. /**
  42946. * Starts rendering to the xr layer
  42947. */
  42948. runXRRenderLoop(): void;
  42949. /**
  42950. * Sets the reference space on the xr session
  42951. * @param referenceSpaceType space to set
  42952. * @returns a promise that will resolve once the reference space has been set
  42953. */
  42954. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42955. /**
  42956. * Updates the render state of the session
  42957. * @param state state to set
  42958. * @returns a promise that resolves once the render state has been updated
  42959. */
  42960. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42961. /**
  42962. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42963. * @param sessionMode defines the session to test
  42964. * @returns a promise with boolean as final value
  42965. */
  42966. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42967. private _createRenderTargetTexture;
  42968. }
  42969. }
  42970. declare module BABYLON {
  42971. /**
  42972. * WebXR Camera which holds the views for the xrSession
  42973. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42974. */
  42975. export class WebXRCamera extends FreeCamera {
  42976. private _xrSessionManager;
  42977. private _firstFrame;
  42978. private _referenceQuaternion;
  42979. private _referencedPosition;
  42980. private _xrInvPositionCache;
  42981. private _xrInvQuaternionCache;
  42982. /**
  42983. * Should position compensation execute on first frame.
  42984. * This is used when copying the position from a native (non XR) camera
  42985. */
  42986. compensateOnFirstFrame: boolean;
  42987. /**
  42988. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42989. * @param name the name of the camera
  42990. * @param scene the scene to add the camera to
  42991. * @param _xrSessionManager a constructed xr session manager
  42992. */
  42993. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42994. /**
  42995. * Return the user's height, unrelated to the current ground.
  42996. * This will be the y position of this camera, when ground level is 0.
  42997. */
  42998. get realWorldHeight(): number;
  42999. /** @hidden */
  43000. _updateForDualEyeDebugging(): void;
  43001. /**
  43002. * Sets this camera's transformation based on a non-vr camera
  43003. * @param otherCamera the non-vr camera to copy the transformation from
  43004. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43005. */
  43006. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43007. /**
  43008. * Gets the current instance class name ("WebXRCamera").
  43009. * @returns the class name
  43010. */
  43011. getClassName(): string;
  43012. private _updateFromXRSession;
  43013. private _updateNumberOfRigCameras;
  43014. private _updateReferenceSpace;
  43015. private _updateReferenceSpaceOffset;
  43016. }
  43017. }
  43018. declare module BABYLON {
  43019. /**
  43020. * Defining the interface required for a (webxr) feature
  43021. */
  43022. export interface IWebXRFeature extends IDisposable {
  43023. /**
  43024. * Is this feature attached
  43025. */
  43026. attached: boolean;
  43027. /**
  43028. * Should auto-attach be disabled?
  43029. */
  43030. disableAutoAttach: boolean;
  43031. /**
  43032. * Attach the feature to the session
  43033. * Will usually be called by the features manager
  43034. *
  43035. * @param force should attachment be forced (even when already attached)
  43036. * @returns true if successful.
  43037. */
  43038. attach(force?: boolean): boolean;
  43039. /**
  43040. * Detach the feature from the session
  43041. * Will usually be called by the features manager
  43042. *
  43043. * @returns true if successful.
  43044. */
  43045. detach(): boolean;
  43046. }
  43047. /**
  43048. * A list of the currently available features without referencing them
  43049. */
  43050. export class WebXRFeatureName {
  43051. /**
  43052. * The name of the anchor system feature
  43053. */
  43054. static ANCHOR_SYSTEM: string;
  43055. /**
  43056. * The name of the background remover feature
  43057. */
  43058. static BACKGROUND_REMOVER: string;
  43059. /**
  43060. * The name of the hit test feature
  43061. */
  43062. static HIT_TEST: string;
  43063. /**
  43064. * physics impostors for xr controllers feature
  43065. */
  43066. static PHYSICS_CONTROLLERS: string;
  43067. /**
  43068. * The name of the plane detection feature
  43069. */
  43070. static PLANE_DETECTION: string;
  43071. /**
  43072. * The name of the pointer selection feature
  43073. */
  43074. static POINTER_SELECTION: string;
  43075. /**
  43076. * The name of the teleportation feature
  43077. */
  43078. static TELEPORTATION: string;
  43079. }
  43080. /**
  43081. * Defining the constructor of a feature. Used to register the modules.
  43082. */
  43083. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43084. /**
  43085. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43086. * It is mainly used in AR sessions.
  43087. *
  43088. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43089. */
  43090. export class WebXRFeaturesManager implements IDisposable {
  43091. private _xrSessionManager;
  43092. private static readonly _AvailableFeatures;
  43093. private _features;
  43094. /**
  43095. * constructs a new features manages.
  43096. *
  43097. * @param _xrSessionManager an instance of WebXRSessionManager
  43098. */
  43099. constructor(_xrSessionManager: WebXRSessionManager);
  43100. /**
  43101. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43102. * Mainly used internally.
  43103. *
  43104. * @param featureName the name of the feature to register
  43105. * @param constructorFunction the function used to construct the module
  43106. * @param version the (babylon) version of the module
  43107. * @param stable is that a stable version of this module
  43108. */
  43109. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43110. /**
  43111. * Returns a constructor of a specific feature.
  43112. *
  43113. * @param featureName the name of the feature to construct
  43114. * @param version the version of the feature to load
  43115. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43116. * @param options optional options provided to the module.
  43117. * @returns a function that, when called, will return a new instance of this feature
  43118. */
  43119. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43120. /**
  43121. * Can be used to return the list of features currently registered
  43122. *
  43123. * @returns an Array of available features
  43124. */
  43125. static GetAvailableFeatures(): string[];
  43126. /**
  43127. * Gets the versions available for a specific feature
  43128. * @param featureName the name of the feature
  43129. * @returns an array with the available versions
  43130. */
  43131. static GetAvailableVersions(featureName: string): string[];
  43132. /**
  43133. * Return the latest unstable version of this feature
  43134. * @param featureName the name of the feature to search
  43135. * @returns the version number. if not found will return -1
  43136. */
  43137. static GetLatestVersionOfFeature(featureName: string): number;
  43138. /**
  43139. * Return the latest stable version of this feature
  43140. * @param featureName the name of the feature to search
  43141. * @returns the version number. if not found will return -1
  43142. */
  43143. static GetStableVersionOfFeature(featureName: string): number;
  43144. /**
  43145. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43146. * Can be used during a session to start a feature
  43147. * @param featureName the name of feature to attach
  43148. */
  43149. attachFeature(featureName: string): void;
  43150. /**
  43151. * Can be used inside a session or when the session ends to detach a specific feature
  43152. * @param featureName the name of the feature to detach
  43153. */
  43154. detachFeature(featureName: string): void;
  43155. /**
  43156. * Used to disable an already-enabled feature
  43157. * The feature will be disposed and will be recreated once enabled.
  43158. * @param featureName the feature to disable
  43159. * @returns true if disable was successful
  43160. */
  43161. disableFeature(featureName: string | {
  43162. Name: string;
  43163. }): boolean;
  43164. /**
  43165. * dispose this features manager
  43166. */
  43167. dispose(): void;
  43168. /**
  43169. * 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.
  43170. * 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.
  43171. *
  43172. * @param featureName the name of the feature to load or the class of the feature
  43173. * @param version optional version to load. if not provided the latest version will be enabled
  43174. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43175. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43176. * @returns a new constructed feature or throws an error if feature not found.
  43177. */
  43178. enableFeature(featureName: string | {
  43179. Name: string;
  43180. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43181. /**
  43182. * get the implementation of an enabled feature.
  43183. * @param featureName the name of the feature to load
  43184. * @returns the feature class, if found
  43185. */
  43186. getEnabledFeature(featureName: string): IWebXRFeature;
  43187. /**
  43188. * Get the list of enabled features
  43189. * @returns an array of enabled features
  43190. */
  43191. getEnabledFeatures(): string[];
  43192. }
  43193. }
  43194. declare module BABYLON {
  43195. /**
  43196. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43197. * @see https://doc.babylonjs.com/how_to/webxr
  43198. */
  43199. export class WebXRExperienceHelper implements IDisposable {
  43200. private scene;
  43201. private _nonVRCamera;
  43202. private _originalSceneAutoClear;
  43203. private _supported;
  43204. /**
  43205. * Camera used to render xr content
  43206. */
  43207. camera: WebXRCamera;
  43208. /** A features manager for this xr session */
  43209. featuresManager: WebXRFeaturesManager;
  43210. /**
  43211. * Observers registered here will be triggered after the camera's initial transformation is set
  43212. * This can be used to set a different ground level or an extra rotation.
  43213. *
  43214. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43215. * to the position set after this observable is done executing.
  43216. */
  43217. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43218. /**
  43219. * Fires when the state of the experience helper has changed
  43220. */
  43221. onStateChangedObservable: Observable<WebXRState>;
  43222. /** Session manager used to keep track of xr session */
  43223. sessionManager: WebXRSessionManager;
  43224. /**
  43225. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43226. */
  43227. state: WebXRState;
  43228. /**
  43229. * Creates a WebXRExperienceHelper
  43230. * @param scene The scene the helper should be created in
  43231. */
  43232. private constructor();
  43233. /**
  43234. * Creates the experience helper
  43235. * @param scene the scene to attach the experience helper to
  43236. * @returns a promise for the experience helper
  43237. */
  43238. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43239. /**
  43240. * Disposes of the experience helper
  43241. */
  43242. dispose(): void;
  43243. /**
  43244. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43245. * @param sessionMode options for the XR session
  43246. * @param referenceSpaceType frame of reference of the XR session
  43247. * @param renderTarget the output canvas that will be used to enter XR mode
  43248. * @returns promise that resolves after xr mode has entered
  43249. */
  43250. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43251. /**
  43252. * Exits XR mode and returns the scene to its original state
  43253. * @returns promise that resolves after xr mode has exited
  43254. */
  43255. exitXRAsync(): Promise<void>;
  43256. private _nonXRToXRCamera;
  43257. private _setState;
  43258. }
  43259. }
  43260. declare module BABYLON {
  43261. /**
  43262. * X-Y values for axes in WebXR
  43263. */
  43264. export interface IWebXRMotionControllerAxesValue {
  43265. /**
  43266. * The value of the x axis
  43267. */
  43268. x: number;
  43269. /**
  43270. * The value of the y-axis
  43271. */
  43272. y: number;
  43273. }
  43274. /**
  43275. * changed / previous values for the values of this component
  43276. */
  43277. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43278. /**
  43279. * current (this frame) value
  43280. */
  43281. current: T;
  43282. /**
  43283. * previous (last change) value
  43284. */
  43285. previous: T;
  43286. }
  43287. /**
  43288. * Represents changes in the component between current frame and last values recorded
  43289. */
  43290. export interface IWebXRMotionControllerComponentChanges {
  43291. /**
  43292. * will be populated with previous and current values if axes changed
  43293. */
  43294. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43295. /**
  43296. * will be populated with previous and current values if pressed changed
  43297. */
  43298. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43299. /**
  43300. * will be populated with previous and current values if touched changed
  43301. */
  43302. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43303. /**
  43304. * will be populated with previous and current values if value changed
  43305. */
  43306. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43307. }
  43308. /**
  43309. * This class represents a single component (for example button or thumbstick) of a motion controller
  43310. */
  43311. export class WebXRControllerComponent implements IDisposable {
  43312. /**
  43313. * the id of this component
  43314. */
  43315. id: string;
  43316. /**
  43317. * the type of the component
  43318. */
  43319. type: MotionControllerComponentType;
  43320. private _buttonIndex;
  43321. private _axesIndices;
  43322. private _axes;
  43323. private _changes;
  43324. private _currentValue;
  43325. private _hasChanges;
  43326. private _pressed;
  43327. private _touched;
  43328. /**
  43329. * button component type
  43330. */
  43331. static BUTTON_TYPE: MotionControllerComponentType;
  43332. /**
  43333. * squeeze component type
  43334. */
  43335. static SQUEEZE_TYPE: MotionControllerComponentType;
  43336. /**
  43337. * Thumbstick component type
  43338. */
  43339. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43340. /**
  43341. * Touchpad component type
  43342. */
  43343. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43344. /**
  43345. * trigger component type
  43346. */
  43347. static TRIGGER_TYPE: MotionControllerComponentType;
  43348. /**
  43349. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43350. * the axes data changes
  43351. */
  43352. onAxisValueChangedObservable: Observable<{
  43353. x: number;
  43354. y: number;
  43355. }>;
  43356. /**
  43357. * Observers registered here will be triggered when the state of a button changes
  43358. * State change is either pressed / touched / value
  43359. */
  43360. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43361. /**
  43362. * Creates a new component for a motion controller.
  43363. * It is created by the motion controller itself
  43364. *
  43365. * @param id the id of this component
  43366. * @param type the type of the component
  43367. * @param _buttonIndex index in the buttons array of the gamepad
  43368. * @param _axesIndices indices of the values in the axes array of the gamepad
  43369. */
  43370. constructor(
  43371. /**
  43372. * the id of this component
  43373. */
  43374. id: string,
  43375. /**
  43376. * the type of the component
  43377. */
  43378. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43379. /**
  43380. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43381. */
  43382. get axes(): IWebXRMotionControllerAxesValue;
  43383. /**
  43384. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43385. */
  43386. get changes(): IWebXRMotionControllerComponentChanges;
  43387. /**
  43388. * Return whether or not the component changed the last frame
  43389. */
  43390. get hasChanges(): boolean;
  43391. /**
  43392. * is the button currently pressed
  43393. */
  43394. get pressed(): boolean;
  43395. /**
  43396. * is the button currently touched
  43397. */
  43398. get touched(): boolean;
  43399. /**
  43400. * Get the current value of this component
  43401. */
  43402. get value(): number;
  43403. /**
  43404. * Dispose this component
  43405. */
  43406. dispose(): void;
  43407. /**
  43408. * Are there axes correlating to this component
  43409. * @return true is axes data is available
  43410. */
  43411. isAxes(): boolean;
  43412. /**
  43413. * Is this component a button (hence - pressable)
  43414. * @returns true if can be pressed
  43415. */
  43416. isButton(): boolean;
  43417. /**
  43418. * update this component using the gamepad object it is in. Called on every frame
  43419. * @param nativeController the native gamepad controller object
  43420. */
  43421. update(nativeController: IMinimalMotionControllerObject): void;
  43422. }
  43423. }
  43424. declare module BABYLON {
  43425. /**
  43426. * Class used to represent data loading progression
  43427. */
  43428. export class SceneLoaderProgressEvent {
  43429. /** defines if data length to load can be evaluated */
  43430. readonly lengthComputable: boolean;
  43431. /** defines the loaded data length */
  43432. readonly loaded: number;
  43433. /** defines the data length to load */
  43434. readonly total: number;
  43435. /**
  43436. * Create a new progress event
  43437. * @param lengthComputable defines if data length to load can be evaluated
  43438. * @param loaded defines the loaded data length
  43439. * @param total defines the data length to load
  43440. */
  43441. constructor(
  43442. /** defines if data length to load can be evaluated */
  43443. lengthComputable: boolean,
  43444. /** defines the loaded data length */
  43445. loaded: number,
  43446. /** defines the data length to load */
  43447. total: number);
  43448. /**
  43449. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43450. * @param event defines the source event
  43451. * @returns a new SceneLoaderProgressEvent
  43452. */
  43453. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43454. }
  43455. /**
  43456. * Interface used by SceneLoader plugins to define supported file extensions
  43457. */
  43458. export interface ISceneLoaderPluginExtensions {
  43459. /**
  43460. * Defines the list of supported extensions
  43461. */
  43462. [extension: string]: {
  43463. isBinary: boolean;
  43464. };
  43465. }
  43466. /**
  43467. * Interface used by SceneLoader plugin factory
  43468. */
  43469. export interface ISceneLoaderPluginFactory {
  43470. /**
  43471. * Defines the name of the factory
  43472. */
  43473. name: string;
  43474. /**
  43475. * Function called to create a new plugin
  43476. * @return the new plugin
  43477. */
  43478. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43479. /**
  43480. * The callback that returns true if the data can be directly loaded.
  43481. * @param data string containing the file data
  43482. * @returns if the data can be loaded directly
  43483. */
  43484. canDirectLoad?(data: string): boolean;
  43485. }
  43486. /**
  43487. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43488. */
  43489. export interface ISceneLoaderPluginBase {
  43490. /**
  43491. * The friendly name of this plugin.
  43492. */
  43493. name: string;
  43494. /**
  43495. * The file extensions supported by this plugin.
  43496. */
  43497. extensions: string | ISceneLoaderPluginExtensions;
  43498. /**
  43499. * The callback called when loading from a url.
  43500. * @param scene scene loading this url
  43501. * @param url url to load
  43502. * @param onSuccess callback called when the file successfully loads
  43503. * @param onProgress callback called while file is loading (if the server supports this mode)
  43504. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43505. * @param onError callback called when the file fails to load
  43506. * @returns a file request object
  43507. */
  43508. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43509. /**
  43510. * The callback called when loading from a file object.
  43511. * @param scene scene loading this file
  43512. * @param file defines the file to load
  43513. * @param onSuccess defines the callback to call when data is loaded
  43514. * @param onProgress defines the callback to call during loading process
  43515. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43516. * @param onError defines the callback to call when an error occurs
  43517. * @returns a file request object
  43518. */
  43519. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43520. /**
  43521. * The callback that returns true if the data can be directly loaded.
  43522. * @param data string containing the file data
  43523. * @returns if the data can be loaded directly
  43524. */
  43525. canDirectLoad?(data: string): boolean;
  43526. /**
  43527. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43528. * @param scene scene loading this data
  43529. * @param data string containing the data
  43530. * @returns data to pass to the plugin
  43531. */
  43532. directLoad?(scene: Scene, data: string): any;
  43533. /**
  43534. * The callback that allows custom handling of the root url based on the response url.
  43535. * @param rootUrl the original root url
  43536. * @param responseURL the response url if available
  43537. * @returns the new root url
  43538. */
  43539. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43540. }
  43541. /**
  43542. * Interface used to define a SceneLoader plugin
  43543. */
  43544. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43545. /**
  43546. * Import meshes into a scene.
  43547. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43548. * @param scene The scene to import into
  43549. * @param data The data to import
  43550. * @param rootUrl The root url for scene and resources
  43551. * @param meshes The meshes array to import into
  43552. * @param particleSystems The particle systems array to import into
  43553. * @param skeletons The skeletons array to import into
  43554. * @param onError The callback when import fails
  43555. * @returns True if successful or false otherwise
  43556. */
  43557. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43558. /**
  43559. * Load into a scene.
  43560. * @param scene The scene to load into
  43561. * @param data The data to import
  43562. * @param rootUrl The root url for scene and resources
  43563. * @param onError The callback when import fails
  43564. * @returns True if successful or false otherwise
  43565. */
  43566. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43567. /**
  43568. * Load into an asset container.
  43569. * @param scene The scene to load into
  43570. * @param data The data to import
  43571. * @param rootUrl The root url for scene and resources
  43572. * @param onError The callback when import fails
  43573. * @returns The loaded asset container
  43574. */
  43575. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43576. }
  43577. /**
  43578. * Interface used to define an async SceneLoader plugin
  43579. */
  43580. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43581. /**
  43582. * Import meshes into a scene.
  43583. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43584. * @param scene The scene to import into
  43585. * @param data The data to import
  43586. * @param rootUrl The root url for scene and resources
  43587. * @param onProgress The callback when the load progresses
  43588. * @param fileName Defines the name of the file to load
  43589. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43590. */
  43591. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43592. meshes: AbstractMesh[];
  43593. particleSystems: IParticleSystem[];
  43594. skeletons: Skeleton[];
  43595. animationGroups: AnimationGroup[];
  43596. }>;
  43597. /**
  43598. * Load into a scene.
  43599. * @param scene The scene to load into
  43600. * @param data The data to import
  43601. * @param rootUrl The root url for scene and resources
  43602. * @param onProgress The callback when the load progresses
  43603. * @param fileName Defines the name of the file to load
  43604. * @returns Nothing
  43605. */
  43606. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43607. /**
  43608. * Load into an asset container.
  43609. * @param scene The scene to load into
  43610. * @param data The data to import
  43611. * @param rootUrl The root url for scene and resources
  43612. * @param onProgress The callback when the load progresses
  43613. * @param fileName Defines the name of the file to load
  43614. * @returns The loaded asset container
  43615. */
  43616. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43617. }
  43618. /**
  43619. * Mode that determines how to handle old animation groups before loading new ones.
  43620. */
  43621. export enum SceneLoaderAnimationGroupLoadingMode {
  43622. /**
  43623. * Reset all old animations to initial state then dispose them.
  43624. */
  43625. Clean = 0,
  43626. /**
  43627. * Stop all old animations.
  43628. */
  43629. Stop = 1,
  43630. /**
  43631. * Restart old animations from first frame.
  43632. */
  43633. Sync = 2,
  43634. /**
  43635. * Old animations remains untouched.
  43636. */
  43637. NoSync = 3
  43638. }
  43639. /**
  43640. * Class used to load scene from various file formats using registered plugins
  43641. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43642. */
  43643. export class SceneLoader {
  43644. /**
  43645. * No logging while loading
  43646. */
  43647. static readonly NO_LOGGING: number;
  43648. /**
  43649. * Minimal logging while loading
  43650. */
  43651. static readonly MINIMAL_LOGGING: number;
  43652. /**
  43653. * Summary logging while loading
  43654. */
  43655. static readonly SUMMARY_LOGGING: number;
  43656. /**
  43657. * Detailled logging while loading
  43658. */
  43659. static readonly DETAILED_LOGGING: number;
  43660. /**
  43661. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43662. */
  43663. static get ForceFullSceneLoadingForIncremental(): boolean;
  43664. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43665. /**
  43666. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43667. */
  43668. static get ShowLoadingScreen(): boolean;
  43669. static set ShowLoadingScreen(value: boolean);
  43670. /**
  43671. * Defines the current logging level (while loading the scene)
  43672. * @ignorenaming
  43673. */
  43674. static get loggingLevel(): number;
  43675. static set loggingLevel(value: number);
  43676. /**
  43677. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43678. */
  43679. static get CleanBoneMatrixWeights(): boolean;
  43680. static set CleanBoneMatrixWeights(value: boolean);
  43681. /**
  43682. * Event raised when a plugin is used to load a scene
  43683. */
  43684. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43685. private static _registeredPlugins;
  43686. private static _getDefaultPlugin;
  43687. private static _getPluginForExtension;
  43688. private static _getPluginForDirectLoad;
  43689. private static _getPluginForFilename;
  43690. private static _getDirectLoad;
  43691. private static _loadData;
  43692. private static _getFileInfo;
  43693. /**
  43694. * Gets a plugin that can load the given extension
  43695. * @param extension defines the extension to load
  43696. * @returns a plugin or null if none works
  43697. */
  43698. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43699. /**
  43700. * Gets a boolean indicating that the given extension can be loaded
  43701. * @param extension defines the extension to load
  43702. * @returns true if the extension is supported
  43703. */
  43704. static IsPluginForExtensionAvailable(extension: string): boolean;
  43705. /**
  43706. * Adds a new plugin to the list of registered plugins
  43707. * @param plugin defines the plugin to add
  43708. */
  43709. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43710. /**
  43711. * Import meshes into a scene
  43712. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43713. * @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)
  43714. * @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)
  43715. * @param scene the instance of BABYLON.Scene to append to
  43716. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43717. * @param onProgress a callback with a progress event for each file being loaded
  43718. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43719. * @param pluginExtension the extension used to determine the plugin
  43720. * @returns The loaded plugin
  43721. */
  43722. 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>;
  43723. /**
  43724. * Import meshes into a scene
  43725. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43726. * @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)
  43727. * @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)
  43728. * @param scene the instance of BABYLON.Scene to append to
  43729. * @param onProgress a callback with a progress event for each file being loaded
  43730. * @param pluginExtension the extension used to determine the plugin
  43731. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43732. */
  43733. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43734. meshes: AbstractMesh[];
  43735. particleSystems: IParticleSystem[];
  43736. skeletons: Skeleton[];
  43737. animationGroups: AnimationGroup[];
  43738. }>;
  43739. /**
  43740. * Load a scene
  43741. * @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)
  43742. * @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)
  43743. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43744. * @param onSuccess a callback with the scene when import succeeds
  43745. * @param onProgress a callback with a progress event for each file being loaded
  43746. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43747. * @param pluginExtension the extension used to determine the plugin
  43748. * @returns The loaded plugin
  43749. */
  43750. 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>;
  43751. /**
  43752. * Load a scene
  43753. * @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)
  43754. * @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)
  43755. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43756. * @param onProgress a callback with a progress event for each file being loaded
  43757. * @param pluginExtension the extension used to determine the plugin
  43758. * @returns The loaded scene
  43759. */
  43760. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43761. /**
  43762. * Append a scene
  43763. * @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)
  43764. * @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)
  43765. * @param scene is the instance of BABYLON.Scene to append to
  43766. * @param onSuccess a callback with the scene when import succeeds
  43767. * @param onProgress a callback with a progress event for each file being loaded
  43768. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43769. * @param pluginExtension the extension used to determine the plugin
  43770. * @returns The loaded plugin
  43771. */
  43772. 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>;
  43773. /**
  43774. * Append a scene
  43775. * @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)
  43776. * @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)
  43777. * @param scene is the instance of BABYLON.Scene to append to
  43778. * @param onProgress a callback with a progress event for each file being loaded
  43779. * @param pluginExtension the extension used to determine the plugin
  43780. * @returns The given scene
  43781. */
  43782. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43783. /**
  43784. * Load a scene into an asset container
  43785. * @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)
  43786. * @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)
  43787. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43788. * @param onSuccess a callback with the scene when import succeeds
  43789. * @param onProgress a callback with a progress event for each file being loaded
  43790. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43791. * @param pluginExtension the extension used to determine the plugin
  43792. * @returns The loaded plugin
  43793. */
  43794. 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>;
  43795. /**
  43796. * Load a scene into an asset container
  43797. * @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)
  43798. * @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)
  43799. * @param scene is the instance of Scene to append to
  43800. * @param onProgress a callback with a progress event for each file being loaded
  43801. * @param pluginExtension the extension used to determine the plugin
  43802. * @returns The loaded asset container
  43803. */
  43804. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43805. /**
  43806. * Import animations from a file into a scene
  43807. * @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)
  43808. * @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)
  43809. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43810. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43811. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43812. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43813. * @param onSuccess a callback with the scene when import succeeds
  43814. * @param onProgress a callback with a progress event for each file being loaded
  43815. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43816. */
  43817. 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;
  43818. /**
  43819. * Import animations from a file into a scene
  43820. * @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)
  43821. * @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)
  43822. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43823. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43824. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43825. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43826. * @param onSuccess a callback with the scene when import succeeds
  43827. * @param onProgress a callback with a progress event for each file being loaded
  43828. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43829. * @returns the updated scene with imported animations
  43830. */
  43831. 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>;
  43832. }
  43833. }
  43834. declare module BABYLON {
  43835. /**
  43836. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43837. */
  43838. export type MotionControllerHandness = "none" | "left" | "right";
  43839. /**
  43840. * The type of components available in motion controllers.
  43841. * This is not the name of the component.
  43842. */
  43843. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43844. /**
  43845. * The state of a controller component
  43846. */
  43847. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43848. /**
  43849. * The schema of motion controller layout.
  43850. * No object will be initialized using this interface
  43851. * This is used just to define the profile.
  43852. */
  43853. export interface IMotionControllerLayout {
  43854. /**
  43855. * Path to load the assets. Usually relative to the base path
  43856. */
  43857. assetPath: string;
  43858. /**
  43859. * Available components (unsorted)
  43860. */
  43861. components: {
  43862. /**
  43863. * A map of component Ids
  43864. */
  43865. [componentId: string]: {
  43866. /**
  43867. * The type of input the component outputs
  43868. */
  43869. type: MotionControllerComponentType;
  43870. /**
  43871. * The indices of this component in the gamepad object
  43872. */
  43873. gamepadIndices: {
  43874. /**
  43875. * Index of button
  43876. */
  43877. button?: number;
  43878. /**
  43879. * If available, index of x-axis
  43880. */
  43881. xAxis?: number;
  43882. /**
  43883. * If available, index of y-axis
  43884. */
  43885. yAxis?: number;
  43886. };
  43887. /**
  43888. * The mesh's root node name
  43889. */
  43890. rootNodeName: string;
  43891. /**
  43892. * Animation definitions for this model
  43893. */
  43894. visualResponses: {
  43895. [stateKey: string]: {
  43896. /**
  43897. * What property will be animated
  43898. */
  43899. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43900. /**
  43901. * What states influence this visual response
  43902. */
  43903. states: MotionControllerComponentStateType[];
  43904. /**
  43905. * Type of animation - movement or visibility
  43906. */
  43907. valueNodeProperty: "transform" | "visibility";
  43908. /**
  43909. * Base node name to move. Its position will be calculated according to the min and max nodes
  43910. */
  43911. valueNodeName?: string;
  43912. /**
  43913. * Minimum movement node
  43914. */
  43915. minNodeName?: string;
  43916. /**
  43917. * Max movement node
  43918. */
  43919. maxNodeName?: string;
  43920. };
  43921. };
  43922. /**
  43923. * If touch enabled, what is the name of node to display user feedback
  43924. */
  43925. touchPointNodeName?: string;
  43926. };
  43927. };
  43928. /**
  43929. * Is it xr standard mapping or not
  43930. */
  43931. gamepadMapping: "" | "xr-standard";
  43932. /**
  43933. * Base root node of this entire model
  43934. */
  43935. rootNodeName: string;
  43936. /**
  43937. * Defines the main button component id
  43938. */
  43939. selectComponentId: string;
  43940. }
  43941. /**
  43942. * A definition for the layout map in the input profile
  43943. */
  43944. export interface IMotionControllerLayoutMap {
  43945. /**
  43946. * Layouts with handness type as a key
  43947. */
  43948. [handness: string]: IMotionControllerLayout;
  43949. }
  43950. /**
  43951. * The XR Input profile schema
  43952. * Profiles can be found here:
  43953. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43954. */
  43955. export interface IMotionControllerProfile {
  43956. /**
  43957. * fallback profiles for this profileId
  43958. */
  43959. fallbackProfileIds: string[];
  43960. /**
  43961. * The layout map, with handness as key
  43962. */
  43963. layouts: IMotionControllerLayoutMap;
  43964. /**
  43965. * The id of this profile
  43966. * correlates to the profile(s) in the xrInput.profiles array
  43967. */
  43968. profileId: string;
  43969. }
  43970. /**
  43971. * A helper-interface for the 3 meshes needed for controller button animation
  43972. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43973. */
  43974. export interface IMotionControllerButtonMeshMap {
  43975. /**
  43976. * the mesh that defines the pressed value mesh position.
  43977. * This is used to find the max-position of this button
  43978. */
  43979. pressedMesh: AbstractMesh;
  43980. /**
  43981. * the mesh that defines the unpressed value mesh position.
  43982. * This is used to find the min (or initial) position of this button
  43983. */
  43984. unpressedMesh: AbstractMesh;
  43985. /**
  43986. * The mesh that will be changed when value changes
  43987. */
  43988. valueMesh: AbstractMesh;
  43989. }
  43990. /**
  43991. * A helper-interface for the 3 meshes needed for controller axis animation.
  43992. * This will be expanded when touchpad animations are fully supported
  43993. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43994. */
  43995. export interface IMotionControllerMeshMap {
  43996. /**
  43997. * the mesh that defines the maximum value mesh position.
  43998. */
  43999. maxMesh?: AbstractMesh;
  44000. /**
  44001. * the mesh that defines the minimum value mesh position.
  44002. */
  44003. minMesh?: AbstractMesh;
  44004. /**
  44005. * The mesh that will be changed when axis value changes
  44006. */
  44007. valueMesh: AbstractMesh;
  44008. }
  44009. /**
  44010. * The elements needed for change-detection of the gamepad objects in motion controllers
  44011. */
  44012. export interface IMinimalMotionControllerObject {
  44013. /**
  44014. * Available axes of this controller
  44015. */
  44016. axes: number[];
  44017. /**
  44018. * An array of available buttons
  44019. */
  44020. buttons: Array<{
  44021. /**
  44022. * Value of the button/trigger
  44023. */
  44024. value: number;
  44025. /**
  44026. * If the button/trigger is currently touched
  44027. */
  44028. touched: boolean;
  44029. /**
  44030. * If the button/trigger is currently pressed
  44031. */
  44032. pressed: boolean;
  44033. }>;
  44034. }
  44035. /**
  44036. * An Abstract Motion controller
  44037. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44038. * Each component has an observable to check for changes in value and state
  44039. */
  44040. export abstract class WebXRAbstractMotionController implements IDisposable {
  44041. protected scene: Scene;
  44042. protected layout: IMotionControllerLayout;
  44043. /**
  44044. * The gamepad object correlating to this controller
  44045. */
  44046. gamepadObject: IMinimalMotionControllerObject;
  44047. /**
  44048. * handness (left/right/none) of this controller
  44049. */
  44050. handness: MotionControllerHandness;
  44051. private _initComponent;
  44052. private _modelReady;
  44053. /**
  44054. * A map of components (WebXRControllerComponent) in this motion controller
  44055. * Components have a ComponentType and can also have both button and axis definitions
  44056. */
  44057. readonly components: {
  44058. [id: string]: WebXRControllerComponent;
  44059. };
  44060. /**
  44061. * Disable the model's animation. Can be set at any time.
  44062. */
  44063. disableAnimation: boolean;
  44064. /**
  44065. * Observers registered here will be triggered when the model of this controller is done loading
  44066. */
  44067. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44068. /**
  44069. * The profile id of this motion controller
  44070. */
  44071. abstract profileId: string;
  44072. /**
  44073. * The root mesh of the model. It is null if the model was not yet initialized
  44074. */
  44075. rootMesh: Nullable<AbstractMesh>;
  44076. /**
  44077. * constructs a new abstract motion controller
  44078. * @param scene the scene to which the model of the controller will be added
  44079. * @param layout The profile layout to load
  44080. * @param gamepadObject The gamepad object correlating to this controller
  44081. * @param handness handness (left/right/none) of this controller
  44082. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44083. */
  44084. constructor(scene: Scene, layout: IMotionControllerLayout,
  44085. /**
  44086. * The gamepad object correlating to this controller
  44087. */
  44088. gamepadObject: IMinimalMotionControllerObject,
  44089. /**
  44090. * handness (left/right/none) of this controller
  44091. */
  44092. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44093. /**
  44094. * Dispose this controller, the model mesh and all its components
  44095. */
  44096. dispose(): void;
  44097. /**
  44098. * Returns all components of specific type
  44099. * @param type the type to search for
  44100. * @return an array of components with this type
  44101. */
  44102. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44103. /**
  44104. * get a component based an its component id as defined in layout.components
  44105. * @param id the id of the component
  44106. * @returns the component correlates to the id or undefined if not found
  44107. */
  44108. getComponent(id: string): WebXRControllerComponent;
  44109. /**
  44110. * Get the list of components available in this motion controller
  44111. * @returns an array of strings correlating to available components
  44112. */
  44113. getComponentIds(): string[];
  44114. /**
  44115. * Get the first component of specific type
  44116. * @param type type of component to find
  44117. * @return a controller component or null if not found
  44118. */
  44119. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44120. /**
  44121. * Get the main (Select) component of this controller as defined in the layout
  44122. * @returns the main component of this controller
  44123. */
  44124. getMainComponent(): WebXRControllerComponent;
  44125. /**
  44126. * Loads the model correlating to this controller
  44127. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44128. * @returns A promise fulfilled with the result of the model loading
  44129. */
  44130. loadModel(): Promise<boolean>;
  44131. /**
  44132. * Update this model using the current XRFrame
  44133. * @param xrFrame the current xr frame to use and update the model
  44134. */
  44135. updateFromXRFrame(xrFrame: XRFrame): void;
  44136. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44137. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44138. /**
  44139. * Moves the axis on the controller mesh based on its current state
  44140. * @param axis the index of the axis
  44141. * @param axisValue the value of the axis which determines the meshes new position
  44142. * @hidden
  44143. */
  44144. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44145. /**
  44146. * Update the model itself with the current frame data
  44147. * @param xrFrame the frame to use for updating the model mesh
  44148. */
  44149. protected updateModel(xrFrame: XRFrame): void;
  44150. /**
  44151. * Get the filename and path for this controller's model
  44152. * @returns a map of filename and path
  44153. */
  44154. protected abstract _getFilenameAndPath(): {
  44155. filename: string;
  44156. path: string;
  44157. };
  44158. /**
  44159. * This function is called before the mesh is loaded. It checks for loading constraints.
  44160. * For example, this function can check if the GLB loader is available
  44161. * If this function returns false, the generic controller will be loaded instead
  44162. * @returns Is the client ready to load the mesh
  44163. */
  44164. protected abstract _getModelLoadingConstraints(): boolean;
  44165. /**
  44166. * This function will be called after the model was successfully loaded and can be used
  44167. * for mesh transformations before it is available for the user
  44168. * @param meshes the loaded meshes
  44169. */
  44170. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44171. /**
  44172. * Set the root mesh for this controller. Important for the WebXR controller class
  44173. * @param meshes the loaded meshes
  44174. */
  44175. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44176. /**
  44177. * A function executed each frame that updates the mesh (if needed)
  44178. * @param xrFrame the current xrFrame
  44179. */
  44180. protected abstract _updateModel(xrFrame: XRFrame): void;
  44181. private _getGenericFilenameAndPath;
  44182. private _getGenericParentMesh;
  44183. }
  44184. }
  44185. declare module BABYLON {
  44186. /**
  44187. * A generic trigger-only motion controller for WebXR
  44188. */
  44189. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44190. /**
  44191. * Static version of the profile id of this controller
  44192. */
  44193. static ProfileId: string;
  44194. profileId: string;
  44195. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44196. protected _getFilenameAndPath(): {
  44197. filename: string;
  44198. path: string;
  44199. };
  44200. protected _getModelLoadingConstraints(): boolean;
  44201. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44202. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44203. protected _updateModel(): void;
  44204. }
  44205. }
  44206. declare module BABYLON {
  44207. /**
  44208. * Class containing static functions to help procedurally build meshes
  44209. */
  44210. export class SphereBuilder {
  44211. /**
  44212. * Creates a sphere mesh
  44213. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44214. * * 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`)
  44215. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44216. * * 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
  44217. * * 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)
  44218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44219. * * 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
  44220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44221. * @param name defines the name of the mesh
  44222. * @param options defines the options used to create the mesh
  44223. * @param scene defines the hosting scene
  44224. * @returns the sphere mesh
  44225. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44226. */
  44227. static CreateSphere(name: string, options: {
  44228. segments?: number;
  44229. diameter?: number;
  44230. diameterX?: number;
  44231. diameterY?: number;
  44232. diameterZ?: number;
  44233. arc?: number;
  44234. slice?: number;
  44235. sideOrientation?: number;
  44236. frontUVs?: Vector4;
  44237. backUVs?: Vector4;
  44238. updatable?: boolean;
  44239. }, scene?: Nullable<Scene>): Mesh;
  44240. }
  44241. }
  44242. declare module BABYLON {
  44243. /**
  44244. * A profiled motion controller has its profile loaded from an online repository.
  44245. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44246. */
  44247. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44248. private _repositoryUrl;
  44249. private _buttonMeshMapping;
  44250. private _touchDots;
  44251. /**
  44252. * The profile ID of this controller. Will be populated when the controller initializes.
  44253. */
  44254. profileId: string;
  44255. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44256. dispose(): void;
  44257. protected _getFilenameAndPath(): {
  44258. filename: string;
  44259. path: string;
  44260. };
  44261. protected _getModelLoadingConstraints(): boolean;
  44262. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44263. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44264. protected _updateModel(_xrFrame: XRFrame): void;
  44265. }
  44266. }
  44267. declare module BABYLON {
  44268. /**
  44269. * A construction function type to create a new controller based on an xrInput object
  44270. */
  44271. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44272. /**
  44273. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44274. *
  44275. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44276. * it should be replaced with auto-loaded controllers.
  44277. *
  44278. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44279. */
  44280. export class WebXRMotionControllerManager {
  44281. private static _AvailableControllers;
  44282. private static _Fallbacks;
  44283. private static _ProfileLoadingPromises;
  44284. private static _ProfilesList;
  44285. /**
  44286. * The base URL of the online controller repository. Can be changed at any time.
  44287. */
  44288. static BaseRepositoryUrl: string;
  44289. /**
  44290. * Which repository gets priority - local or online
  44291. */
  44292. static PrioritizeOnlineRepository: boolean;
  44293. /**
  44294. * Use the online repository, or use only locally-defined controllers
  44295. */
  44296. static UseOnlineRepository: boolean;
  44297. /**
  44298. * Clear the cache used for profile loading and reload when requested again
  44299. */
  44300. static ClearProfilesCache(): void;
  44301. /**
  44302. * Register the default fallbacks.
  44303. * This function is called automatically when this file is imported.
  44304. */
  44305. static DefaultFallbacks(): void;
  44306. /**
  44307. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44308. * @param profileId the profile to which a fallback needs to be found
  44309. * @return an array with corresponding fallback profiles
  44310. */
  44311. static FindFallbackWithProfileId(profileId: string): string[];
  44312. /**
  44313. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44314. * The order of search:
  44315. *
  44316. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44317. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44318. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44319. * 4) return the generic trigger controller if none were found
  44320. *
  44321. * @param xrInput the xrInput to which a new controller is initialized
  44322. * @param scene the scene to which the model will be added
  44323. * @param forceProfile force a certain profile for this controller
  44324. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44325. */
  44326. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44327. /**
  44328. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44329. *
  44330. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44331. *
  44332. * @param type the profile type to register
  44333. * @param constructFunction the function to be called when loading this profile
  44334. */
  44335. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44336. /**
  44337. * Register a fallback to a specific profile.
  44338. * @param profileId the profileId that will receive the fallbacks
  44339. * @param fallbacks A list of fallback profiles
  44340. */
  44341. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44342. /**
  44343. * Will update the list of profiles available in the repository
  44344. * @return a promise that resolves to a map of profiles available online
  44345. */
  44346. static UpdateProfilesList(): Promise<{
  44347. [profile: string]: string;
  44348. }>;
  44349. private static _LoadProfileFromRepository;
  44350. private static _LoadProfilesFromAvailableControllers;
  44351. }
  44352. }
  44353. declare module BABYLON {
  44354. /**
  44355. * Configuration options for the WebXR controller creation
  44356. */
  44357. export interface IWebXRControllerOptions {
  44358. /**
  44359. * Should the controller mesh be animated when a user interacts with it
  44360. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44361. */
  44362. disableMotionControllerAnimation?: boolean;
  44363. /**
  44364. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44365. */
  44366. doNotLoadControllerMesh?: boolean;
  44367. /**
  44368. * Force a specific controller type for this controller.
  44369. * This can be used when creating your own profile or when testing different controllers
  44370. */
  44371. forceControllerProfile?: string;
  44372. }
  44373. /**
  44374. * Represents an XR controller
  44375. */
  44376. export class WebXRInputSource {
  44377. private _scene;
  44378. /** The underlying input source for the controller */
  44379. inputSource: XRInputSource;
  44380. private _options;
  44381. private _tmpQuaternion;
  44382. private _tmpVector;
  44383. private _uniqueId;
  44384. /**
  44385. * 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
  44386. */
  44387. grip?: AbstractMesh;
  44388. /**
  44389. * If available, this is the gamepad object related to this controller.
  44390. * Using this object it is possible to get click events and trackpad changes of the
  44391. * webxr controller that is currently being used.
  44392. */
  44393. motionController?: WebXRAbstractMotionController;
  44394. /**
  44395. * Event that fires when the controller is removed/disposed.
  44396. * The object provided as event data is this controller, after associated assets were disposed.
  44397. * uniqueId is still available.
  44398. */
  44399. onDisposeObservable: Observable<WebXRInputSource>;
  44400. /**
  44401. * Will be triggered when the mesh associated with the motion controller is done loading.
  44402. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44403. * A shortened version of controller -> motion controller -> on mesh loaded.
  44404. */
  44405. onMeshLoadedObservable: Observable<AbstractMesh>;
  44406. /**
  44407. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44408. */
  44409. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44410. /**
  44411. * Pointer which can be used to select objects or attach a visible laser to
  44412. */
  44413. pointer: AbstractMesh;
  44414. /**
  44415. * Creates the controller
  44416. * @see https://doc.babylonjs.com/how_to/webxr
  44417. * @param _scene the scene which the controller should be associated to
  44418. * @param inputSource the underlying input source for the controller
  44419. * @param _options options for this controller creation
  44420. */
  44421. constructor(_scene: Scene,
  44422. /** The underlying input source for the controller */
  44423. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44424. /**
  44425. * Get this controllers unique id
  44426. */
  44427. get uniqueId(): string;
  44428. /**
  44429. * Disposes of the object
  44430. */
  44431. dispose(): void;
  44432. /**
  44433. * Gets a world space ray coming from the pointer or grip
  44434. * @param result the resulting ray
  44435. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44436. */
  44437. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44438. /**
  44439. * Updates the controller pose based on the given XRFrame
  44440. * @param xrFrame xr frame to update the pose with
  44441. * @param referenceSpace reference space to use
  44442. */
  44443. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44444. }
  44445. }
  44446. declare module BABYLON {
  44447. /**
  44448. * The schema for initialization options of the XR Input class
  44449. */
  44450. export interface IWebXRInputOptions {
  44451. /**
  44452. * If set to true no model will be automatically loaded
  44453. */
  44454. doNotLoadControllerMeshes?: boolean;
  44455. /**
  44456. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44457. * If not found, the xr input profile data will be used.
  44458. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44459. */
  44460. forceInputProfile?: string;
  44461. /**
  44462. * Do not send a request to the controller repository to load the profile.
  44463. *
  44464. * Instead, use the controllers available in babylon itself.
  44465. */
  44466. disableOnlineControllerRepository?: boolean;
  44467. /**
  44468. * A custom URL for the controllers repository
  44469. */
  44470. customControllersRepositoryURL?: string;
  44471. /**
  44472. * Should the controller model's components not move according to the user input
  44473. */
  44474. disableControllerAnimation?: boolean;
  44475. }
  44476. /**
  44477. * XR input used to track XR inputs such as controllers/rays
  44478. */
  44479. export class WebXRInput implements IDisposable {
  44480. /**
  44481. * the xr session manager for this session
  44482. */
  44483. xrSessionManager: WebXRSessionManager;
  44484. /**
  44485. * the WebXR camera for this session. Mainly used for teleportation
  44486. */
  44487. xrCamera: WebXRCamera;
  44488. private readonly options;
  44489. /**
  44490. * XR controllers being tracked
  44491. */
  44492. controllers: Array<WebXRInputSource>;
  44493. private _frameObserver;
  44494. private _sessionEndedObserver;
  44495. private _sessionInitObserver;
  44496. /**
  44497. * Event when a controller has been connected/added
  44498. */
  44499. onControllerAddedObservable: Observable<WebXRInputSource>;
  44500. /**
  44501. * Event when a controller has been removed/disconnected
  44502. */
  44503. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44504. /**
  44505. * Initializes the WebXRInput
  44506. * @param xrSessionManager the xr session manager for this session
  44507. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44508. * @param options = initialization options for this xr input
  44509. */
  44510. constructor(
  44511. /**
  44512. * the xr session manager for this session
  44513. */
  44514. xrSessionManager: WebXRSessionManager,
  44515. /**
  44516. * the WebXR camera for this session. Mainly used for teleportation
  44517. */
  44518. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44519. private _onInputSourcesChange;
  44520. private _addAndRemoveControllers;
  44521. /**
  44522. * Disposes of the object
  44523. */
  44524. dispose(): void;
  44525. }
  44526. }
  44527. declare module BABYLON {
  44528. /**
  44529. * This is the base class for all WebXR features.
  44530. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44531. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44532. */
  44533. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44534. protected _xrSessionManager: WebXRSessionManager;
  44535. private _attached;
  44536. private _removeOnDetach;
  44537. /**
  44538. * Should auto-attach be disabled?
  44539. */
  44540. disableAutoAttach: boolean;
  44541. /**
  44542. * Construct a new (abstract) WebXR feature
  44543. * @param _xrSessionManager the xr session manager for this feature
  44544. */
  44545. constructor(_xrSessionManager: WebXRSessionManager);
  44546. /**
  44547. * Is this feature attached
  44548. */
  44549. get attached(): boolean;
  44550. /**
  44551. * attach this feature
  44552. *
  44553. * @param force should attachment be forced (even when already attached)
  44554. * @returns true if successful, false is failed or already attached
  44555. */
  44556. attach(force?: boolean): boolean;
  44557. /**
  44558. * detach this feature.
  44559. *
  44560. * @returns true if successful, false if failed or already detached
  44561. */
  44562. detach(): boolean;
  44563. /**
  44564. * Dispose this feature and all of the resources attached
  44565. */
  44566. dispose(): void;
  44567. /**
  44568. * This is used to register callbacks that will automatically be removed when detach is called.
  44569. * @param observable the observable to which the observer will be attached
  44570. * @param callback the callback to register
  44571. */
  44572. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44573. /**
  44574. * Code in this function will be executed on each xrFrame received from the browser.
  44575. * This function will not execute after the feature is detached.
  44576. * @param _xrFrame the current frame
  44577. */
  44578. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44579. }
  44580. }
  44581. declare module BABYLON {
  44582. /**
  44583. * Renders a layer on top of an existing scene
  44584. */
  44585. export class UtilityLayerRenderer implements IDisposable {
  44586. /** the original scene that will be rendered on top of */
  44587. originalScene: Scene;
  44588. private _pointerCaptures;
  44589. private _lastPointerEvents;
  44590. private static _DefaultUtilityLayer;
  44591. private static _DefaultKeepDepthUtilityLayer;
  44592. private _sharedGizmoLight;
  44593. private _renderCamera;
  44594. /**
  44595. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44596. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44597. * @returns the camera that is used when rendering the utility layer
  44598. */
  44599. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44600. /**
  44601. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44602. * @param cam the camera that should be used when rendering the utility layer
  44603. */
  44604. setRenderCamera(cam: Nullable<Camera>): void;
  44605. /**
  44606. * @hidden
  44607. * Light which used by gizmos to get light shading
  44608. */
  44609. _getSharedGizmoLight(): HemisphericLight;
  44610. /**
  44611. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44612. */
  44613. pickUtilitySceneFirst: boolean;
  44614. /**
  44615. * 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)
  44616. */
  44617. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44618. /**
  44619. * 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)
  44620. */
  44621. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44622. /**
  44623. * The scene that is rendered on top of the original scene
  44624. */
  44625. utilityLayerScene: Scene;
  44626. /**
  44627. * If the utility layer should automatically be rendered on top of existing scene
  44628. */
  44629. shouldRender: boolean;
  44630. /**
  44631. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44632. */
  44633. onlyCheckPointerDownEvents: boolean;
  44634. /**
  44635. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44636. */
  44637. processAllEvents: boolean;
  44638. /**
  44639. * Observable raised when the pointer move from the utility layer scene to the main scene
  44640. */
  44641. onPointerOutObservable: Observable<number>;
  44642. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44643. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44644. private _afterRenderObserver;
  44645. private _sceneDisposeObserver;
  44646. private _originalPointerObserver;
  44647. /**
  44648. * Instantiates a UtilityLayerRenderer
  44649. * @param originalScene the original scene that will be rendered on top of
  44650. * @param handleEvents boolean indicating if the utility layer should handle events
  44651. */
  44652. constructor(
  44653. /** the original scene that will be rendered on top of */
  44654. originalScene: Scene, handleEvents?: boolean);
  44655. private _notifyObservers;
  44656. /**
  44657. * Renders the utility layers scene on top of the original scene
  44658. */
  44659. render(): void;
  44660. /**
  44661. * Disposes of the renderer
  44662. */
  44663. dispose(): void;
  44664. private _updateCamera;
  44665. }
  44666. }
  44667. declare module BABYLON {
  44668. /**
  44669. * Options interface for the pointer selection module
  44670. */
  44671. export interface IWebXRControllerPointerSelectionOptions {
  44672. /**
  44673. * if provided, this scene will be used to render meshes.
  44674. */
  44675. customUtilityLayerScene?: Scene;
  44676. /**
  44677. * 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)
  44678. * If not disabled, the last picked point will be used to execute a pointer up event
  44679. * If disabled, pointer up event will be triggered right after the pointer down event.
  44680. * Used in screen and gaze target ray mode only
  44681. */
  44682. disablePointerUpOnTouchOut: boolean;
  44683. /**
  44684. * For gaze mode (time to select instead of press)
  44685. */
  44686. forceGazeMode: boolean;
  44687. /**
  44688. * 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
  44689. * to start a new countdown to the pointer down event.
  44690. * Defaults to 1.
  44691. */
  44692. gazeModePointerMovedFactor?: number;
  44693. /**
  44694. * Different button type to use instead of the main component
  44695. */
  44696. overrideButtonId?: string;
  44697. /**
  44698. * use this rendering group id for the meshes (optional)
  44699. */
  44700. renderingGroupId?: number;
  44701. /**
  44702. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44703. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44704. * 3000 means 3 seconds between pointing at something and selecting it
  44705. */
  44706. timeToSelect?: number;
  44707. /**
  44708. * Should meshes created here be added to a utility layer or the main scene
  44709. */
  44710. useUtilityLayer?: boolean;
  44711. /**
  44712. * the xr input to use with this pointer selection
  44713. */
  44714. xrInput: WebXRInput;
  44715. }
  44716. /**
  44717. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44718. */
  44719. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44720. private readonly _options;
  44721. private static _idCounter;
  44722. private _attachController;
  44723. private _controllers;
  44724. private _scene;
  44725. private _tmpVectorForPickCompare;
  44726. /**
  44727. * The module's name
  44728. */
  44729. static readonly Name: string;
  44730. /**
  44731. * The (Babylon) version of this module.
  44732. * This is an integer representing the implementation version.
  44733. * This number does not correspond to the WebXR specs version
  44734. */
  44735. static readonly Version: number;
  44736. /**
  44737. * Disable lighting on the laser pointer (so it will always be visible)
  44738. */
  44739. disablePointerLighting: boolean;
  44740. /**
  44741. * Disable lighting on the selection mesh (so it will always be visible)
  44742. */
  44743. disableSelectionMeshLighting: boolean;
  44744. /**
  44745. * Should the laser pointer be displayed
  44746. */
  44747. displayLaserPointer: boolean;
  44748. /**
  44749. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44750. */
  44751. displaySelectionMesh: boolean;
  44752. /**
  44753. * This color will be set to the laser pointer when selection is triggered
  44754. */
  44755. laserPointerPickedColor: Color3;
  44756. /**
  44757. * Default color of the laser pointer
  44758. */
  44759. lasterPointerDefaultColor: Color3;
  44760. /**
  44761. * default color of the selection ring
  44762. */
  44763. selectionMeshDefaultColor: Color3;
  44764. /**
  44765. * This color will be applied to the selection ring when selection is triggered
  44766. */
  44767. selectionMeshPickedColor: Color3;
  44768. /**
  44769. * Optional filter to be used for ray selection. This predicate shares behavior with
  44770. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44771. */
  44772. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44773. /**
  44774. * constructs a new background remover module
  44775. * @param _xrSessionManager the session manager for this module
  44776. * @param _options read-only options to be used in this module
  44777. */
  44778. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44779. /**
  44780. * attach this feature
  44781. * Will usually be called by the features manager
  44782. *
  44783. * @returns true if successful.
  44784. */
  44785. attach(): boolean;
  44786. /**
  44787. * detach this feature.
  44788. * Will usually be called by the features manager
  44789. *
  44790. * @returns true if successful.
  44791. */
  44792. detach(): boolean;
  44793. /**
  44794. * Will get the mesh under a specific pointer.
  44795. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44796. * @param controllerId the controllerId to check
  44797. * @returns The mesh under pointer or null if no mesh is under the pointer
  44798. */
  44799. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44800. /**
  44801. * Get the xr controller that correlates to the pointer id in the pointer event
  44802. *
  44803. * @param id the pointer id to search for
  44804. * @returns the controller that correlates to this id or null if not found
  44805. */
  44806. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44807. protected _onXRFrame(_xrFrame: XRFrame): void;
  44808. private _attachGazeMode;
  44809. private _attachScreenRayMode;
  44810. private _attachTrackedPointerRayMode;
  44811. private _convertNormalToDirectionOfRay;
  44812. private _detachController;
  44813. private _generateNewMeshPair;
  44814. private _pickingMoved;
  44815. private _updatePointerDistance;
  44816. }
  44817. }
  44818. declare module BABYLON {
  44819. /**
  44820. * Button which can be used to enter a different mode of XR
  44821. */
  44822. export class WebXREnterExitUIButton {
  44823. /** button element */
  44824. element: HTMLElement;
  44825. /** XR initialization options for the button */
  44826. sessionMode: XRSessionMode;
  44827. /** Reference space type */
  44828. referenceSpaceType: XRReferenceSpaceType;
  44829. /**
  44830. * Creates a WebXREnterExitUIButton
  44831. * @param element button element
  44832. * @param sessionMode XR initialization session mode
  44833. * @param referenceSpaceType the type of reference space to be used
  44834. */
  44835. constructor(
  44836. /** button element */
  44837. element: HTMLElement,
  44838. /** XR initialization options for the button */
  44839. sessionMode: XRSessionMode,
  44840. /** Reference space type */
  44841. referenceSpaceType: XRReferenceSpaceType);
  44842. /**
  44843. * Extendable function which can be used to update the button's visuals when the state changes
  44844. * @param activeButton the current active button in the UI
  44845. */
  44846. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44847. }
  44848. /**
  44849. * Options to create the webXR UI
  44850. */
  44851. export class WebXREnterExitUIOptions {
  44852. /**
  44853. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44854. */
  44855. customButtons?: Array<WebXREnterExitUIButton>;
  44856. /**
  44857. * A reference space type to use when creating the default button.
  44858. * Default is local-floor
  44859. */
  44860. referenceSpaceType?: XRReferenceSpaceType;
  44861. /**
  44862. * Context to enter xr with
  44863. */
  44864. renderTarget?: Nullable<WebXRRenderTarget>;
  44865. /**
  44866. * A session mode to use when creating the default button.
  44867. * Default is immersive-vr
  44868. */
  44869. sessionMode?: XRSessionMode;
  44870. }
  44871. /**
  44872. * UI to allow the user to enter/exit XR mode
  44873. */
  44874. export class WebXREnterExitUI implements IDisposable {
  44875. private scene;
  44876. /** version of the options passed to this UI */
  44877. options: WebXREnterExitUIOptions;
  44878. private _activeButton;
  44879. private _buttons;
  44880. private _overlay;
  44881. /**
  44882. * Fired every time the active button is changed.
  44883. *
  44884. * When xr is entered via a button that launches xr that button will be the callback parameter
  44885. *
  44886. * When exiting xr the callback parameter will be null)
  44887. */
  44888. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44889. /**
  44890. *
  44891. * @param scene babylon scene object to use
  44892. * @param options (read-only) version of the options passed to this UI
  44893. */
  44894. private constructor();
  44895. /**
  44896. * Creates UI to allow the user to enter/exit XR mode
  44897. * @param scene the scene to add the ui to
  44898. * @param helper the xr experience helper to enter/exit xr with
  44899. * @param options options to configure the UI
  44900. * @returns the created ui
  44901. */
  44902. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44903. /**
  44904. * Disposes of the XR UI component
  44905. */
  44906. dispose(): void;
  44907. private _updateButtons;
  44908. }
  44909. }
  44910. declare module BABYLON {
  44911. /**
  44912. * Class containing static functions to help procedurally build meshes
  44913. */
  44914. export class LinesBuilder {
  44915. /**
  44916. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44917. * * 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
  44918. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44919. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44920. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44921. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44922. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44923. * * 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
  44924. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44927. * @param name defines the name of the new line system
  44928. * @param options defines the options used to create the line system
  44929. * @param scene defines the hosting scene
  44930. * @returns a new line system mesh
  44931. */
  44932. static CreateLineSystem(name: string, options: {
  44933. lines: Vector3[][];
  44934. updatable?: boolean;
  44935. instance?: Nullable<LinesMesh>;
  44936. colors?: Nullable<Color4[][]>;
  44937. useVertexAlpha?: boolean;
  44938. }, scene: Nullable<Scene>): LinesMesh;
  44939. /**
  44940. * Creates a line mesh
  44941. * 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
  44942. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44943. * * The parameter `points` is an array successive Vector3
  44944. * * 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
  44945. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44946. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44947. * * When updating an instance, remember that only point positions can change, not the number of points
  44948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44950. * @param name defines the name of the new line system
  44951. * @param options defines the options used to create the line system
  44952. * @param scene defines the hosting scene
  44953. * @returns a new line mesh
  44954. */
  44955. static CreateLines(name: string, options: {
  44956. points: Vector3[];
  44957. updatable?: boolean;
  44958. instance?: Nullable<LinesMesh>;
  44959. colors?: Color4[];
  44960. useVertexAlpha?: boolean;
  44961. }, scene?: Nullable<Scene>): LinesMesh;
  44962. /**
  44963. * Creates a dashed line mesh
  44964. * * 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
  44965. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44966. * * The parameter `points` is an array successive Vector3
  44967. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44968. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44969. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44970. * * 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
  44971. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44972. * * When updating an instance, remember that only point positions can change, not the number of points
  44973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44974. * @param name defines the name of the mesh
  44975. * @param options defines the options used to create the mesh
  44976. * @param scene defines the hosting scene
  44977. * @returns the dashed line mesh
  44978. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44979. */
  44980. static CreateDashedLines(name: string, options: {
  44981. points: Vector3[];
  44982. dashSize?: number;
  44983. gapSize?: number;
  44984. dashNb?: number;
  44985. updatable?: boolean;
  44986. instance?: LinesMesh;
  44987. useVertexAlpha?: boolean;
  44988. }, scene?: Nullable<Scene>): LinesMesh;
  44989. }
  44990. }
  44991. declare module BABYLON {
  44992. /**
  44993. * The options container for the teleportation module
  44994. */
  44995. export interface IWebXRTeleportationOptions {
  44996. /**
  44997. * if provided, this scene will be used to render meshes.
  44998. */
  44999. customUtilityLayerScene?: Scene;
  45000. /**
  45001. * Values to configure the default target mesh
  45002. */
  45003. defaultTargetMeshOptions?: {
  45004. /**
  45005. * Fill color of the teleportation area
  45006. */
  45007. teleportationFillColor?: string;
  45008. /**
  45009. * Border color for the teleportation area
  45010. */
  45011. teleportationBorderColor?: string;
  45012. /**
  45013. * Disable the mesh's animation sequence
  45014. */
  45015. disableAnimation?: boolean;
  45016. /**
  45017. * Disable lighting on the material or the ring and arrow
  45018. */
  45019. disableLighting?: boolean;
  45020. /**
  45021. * Override the default material of the torus and arrow
  45022. */
  45023. torusArrowMaterial?: Material;
  45024. };
  45025. /**
  45026. * A list of meshes to use as floor meshes.
  45027. * Meshes can be added and removed after initializing the feature using the
  45028. * addFloorMesh and removeFloorMesh functions
  45029. * If empty, rotation will still work
  45030. */
  45031. floorMeshes?: AbstractMesh[];
  45032. /**
  45033. * use this rendering group id for the meshes (optional)
  45034. */
  45035. renderingGroupId?: number;
  45036. /**
  45037. * Should teleportation move only to snap points
  45038. */
  45039. snapPointsOnly?: boolean;
  45040. /**
  45041. * An array of points to which the teleportation will snap to.
  45042. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45043. */
  45044. snapPositions?: Vector3[];
  45045. /**
  45046. * How close should the teleportation ray be in order to snap to position.
  45047. * Default to 0.8 units (meters)
  45048. */
  45049. snapToPositionRadius?: number;
  45050. /**
  45051. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45052. * If you want to support rotation, make sure your mesh has a direction indicator.
  45053. *
  45054. * When left untouched, the default mesh will be initialized.
  45055. */
  45056. teleportationTargetMesh?: AbstractMesh;
  45057. /**
  45058. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45059. */
  45060. timeToTeleport?: number;
  45061. /**
  45062. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45063. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45064. */
  45065. useMainComponentOnly?: boolean;
  45066. /**
  45067. * Should meshes created here be added to a utility layer or the main scene
  45068. */
  45069. useUtilityLayer?: boolean;
  45070. /**
  45071. * Babylon XR Input class for controller
  45072. */
  45073. xrInput: WebXRInput;
  45074. }
  45075. /**
  45076. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45077. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45078. * the input of the attached controllers.
  45079. */
  45080. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45081. private _options;
  45082. private _controllers;
  45083. private _currentTeleportationControllerId;
  45084. private _floorMeshes;
  45085. private _quadraticBezierCurve;
  45086. private _selectionFeature;
  45087. private _snapToPositions;
  45088. private _snappedToPoint;
  45089. private _teleportationRingMaterial?;
  45090. private _tmpRay;
  45091. private _tmpVector;
  45092. /**
  45093. * The module's name
  45094. */
  45095. static readonly Name: string;
  45096. /**
  45097. * The (Babylon) version of this module.
  45098. * This is an integer representing the implementation version.
  45099. * This number does not correspond to the webxr specs version
  45100. */
  45101. static readonly Version: number;
  45102. /**
  45103. * Is movement backwards enabled
  45104. */
  45105. backwardsMovementEnabled: boolean;
  45106. /**
  45107. * Distance to travel when moving backwards
  45108. */
  45109. backwardsTeleportationDistance: number;
  45110. /**
  45111. * The distance from the user to the inspection point in the direction of the controller
  45112. * A higher number will allow the user to move further
  45113. * defaults to 5 (meters, in xr units)
  45114. */
  45115. parabolicCheckRadius: number;
  45116. /**
  45117. * Should the module support parabolic ray on top of direct ray
  45118. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45119. * Very helpful when moving between floors / different heights
  45120. */
  45121. parabolicRayEnabled: boolean;
  45122. /**
  45123. * How much rotation should be applied when rotating right and left
  45124. */
  45125. rotationAngle: number;
  45126. /**
  45127. * Is rotation enabled when moving forward?
  45128. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45129. */
  45130. rotationEnabled: boolean;
  45131. /**
  45132. * constructs a new anchor system
  45133. * @param _xrSessionManager an instance of WebXRSessionManager
  45134. * @param _options configuration object for this feature
  45135. */
  45136. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45137. /**
  45138. * Get the snapPointsOnly flag
  45139. */
  45140. get snapPointsOnly(): boolean;
  45141. /**
  45142. * Sets the snapPointsOnly flag
  45143. * @param snapToPoints should teleportation be exclusively to snap points
  45144. */
  45145. set snapPointsOnly(snapToPoints: boolean);
  45146. /**
  45147. * Add a new mesh to the floor meshes array
  45148. * @param mesh the mesh to use as floor mesh
  45149. */
  45150. addFloorMesh(mesh: AbstractMesh): void;
  45151. /**
  45152. * Add a new snap-to point to fix teleportation to this position
  45153. * @param newSnapPoint The new Snap-To point
  45154. */
  45155. addSnapPoint(newSnapPoint: Vector3): void;
  45156. attach(): boolean;
  45157. detach(): boolean;
  45158. dispose(): void;
  45159. /**
  45160. * Remove a mesh from the floor meshes array
  45161. * @param mesh the mesh to remove
  45162. */
  45163. removeFloorMesh(mesh: AbstractMesh): void;
  45164. /**
  45165. * Remove a mesh from the floor meshes array using its name
  45166. * @param name the mesh name to remove
  45167. */
  45168. removeFloorMeshByName(name: string): void;
  45169. /**
  45170. * 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
  45171. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45172. * @returns was the point found and removed or not
  45173. */
  45174. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45175. /**
  45176. * This function sets a selection feature that will be disabled when
  45177. * the forward ray is shown and will be reattached when hidden.
  45178. * This is used to remove the selection rays when moving.
  45179. * @param selectionFeature the feature to disable when forward movement is enabled
  45180. */
  45181. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45182. protected _onXRFrame(_xrFrame: XRFrame): void;
  45183. private _attachController;
  45184. private _createDefaultTargetMesh;
  45185. private _detachController;
  45186. private _findClosestSnapPointWithRadius;
  45187. private _setTargetMeshPosition;
  45188. private _setTargetMeshVisibility;
  45189. private _showParabolicPath;
  45190. private _teleportForward;
  45191. }
  45192. }
  45193. declare module BABYLON {
  45194. /**
  45195. * Options for the default xr helper
  45196. */
  45197. export class WebXRDefaultExperienceOptions {
  45198. /**
  45199. * Enable or disable default UI to enter XR
  45200. */
  45201. disableDefaultUI?: boolean;
  45202. /**
  45203. * Should teleportation not initialize. defaults to false.
  45204. */
  45205. disableTeleportation?: boolean;
  45206. /**
  45207. * Floor meshes that will be used for teleport
  45208. */
  45209. floorMeshes?: Array<AbstractMesh>;
  45210. /**
  45211. * If set to true, the first frame will not be used to reset position
  45212. * The first frame is mainly used when copying transformation from the old camera
  45213. * Mainly used in AR
  45214. */
  45215. ignoreNativeCameraTransformation?: boolean;
  45216. /**
  45217. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45218. */
  45219. inputOptions?: IWebXRInputOptions;
  45220. /**
  45221. * optional configuration for the output canvas
  45222. */
  45223. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45224. /**
  45225. * optional UI options. This can be used among other to change session mode and reference space type
  45226. */
  45227. uiOptions?: WebXREnterExitUIOptions;
  45228. /**
  45229. * When loading teleportation and pointer select, use stable versions instead of latest.
  45230. */
  45231. useStablePlugins?: boolean;
  45232. }
  45233. /**
  45234. * Default experience which provides a similar setup to the previous webVRExperience
  45235. */
  45236. export class WebXRDefaultExperience {
  45237. /**
  45238. * Base experience
  45239. */
  45240. baseExperience: WebXRExperienceHelper;
  45241. /**
  45242. * Enables ui for entering/exiting xr
  45243. */
  45244. enterExitUI: WebXREnterExitUI;
  45245. /**
  45246. * Input experience extension
  45247. */
  45248. input: WebXRInput;
  45249. /**
  45250. * Enables laser pointer and selection
  45251. */
  45252. pointerSelection: WebXRControllerPointerSelection;
  45253. /**
  45254. * Default target xr should render to
  45255. */
  45256. renderTarget: WebXRRenderTarget;
  45257. /**
  45258. * Enables teleportation
  45259. */
  45260. teleportation: WebXRMotionControllerTeleportation;
  45261. private constructor();
  45262. /**
  45263. * Creates the default xr experience
  45264. * @param scene scene
  45265. * @param options options for basic configuration
  45266. * @returns resulting WebXRDefaultExperience
  45267. */
  45268. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45269. /**
  45270. * DIsposes of the experience helper
  45271. */
  45272. dispose(): void;
  45273. }
  45274. }
  45275. declare module BABYLON {
  45276. /**
  45277. * Options to modify the vr teleportation behavior.
  45278. */
  45279. export interface VRTeleportationOptions {
  45280. /**
  45281. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45282. */
  45283. floorMeshName?: string;
  45284. /**
  45285. * A list of meshes to be used as the teleportation floor. (default: empty)
  45286. */
  45287. floorMeshes?: Mesh[];
  45288. /**
  45289. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45290. */
  45291. teleportationMode?: number;
  45292. /**
  45293. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45294. */
  45295. teleportationTime?: number;
  45296. /**
  45297. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45298. */
  45299. teleportationSpeed?: number;
  45300. /**
  45301. * The easing function used in the animation or null for Linear. (default CircleEase)
  45302. */
  45303. easingFunction?: EasingFunction;
  45304. }
  45305. /**
  45306. * Options to modify the vr experience helper's behavior.
  45307. */
  45308. export interface VRExperienceHelperOptions extends WebVROptions {
  45309. /**
  45310. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45311. */
  45312. createDeviceOrientationCamera?: boolean;
  45313. /**
  45314. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45315. */
  45316. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45317. /**
  45318. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45319. */
  45320. laserToggle?: boolean;
  45321. /**
  45322. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45323. */
  45324. floorMeshes?: Mesh[];
  45325. /**
  45326. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45327. */
  45328. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45329. /**
  45330. * Defines if WebXR should be used instead of WebVR (if available)
  45331. */
  45332. useXR?: boolean;
  45333. }
  45334. /**
  45335. * Event containing information after VR has been entered
  45336. */
  45337. export class OnAfterEnteringVRObservableEvent {
  45338. /**
  45339. * If entering vr was successful
  45340. */
  45341. success: boolean;
  45342. }
  45343. /**
  45344. * Helps to quickly add VR support to an existing scene.
  45345. * See http://doc.babylonjs.com/how_to/webvr_helper
  45346. */
  45347. export class VRExperienceHelper {
  45348. /** Options to modify the vr experience helper's behavior. */
  45349. webVROptions: VRExperienceHelperOptions;
  45350. private _scene;
  45351. private _position;
  45352. private _btnVR;
  45353. private _btnVRDisplayed;
  45354. private _webVRsupported;
  45355. private _webVRready;
  45356. private _webVRrequesting;
  45357. private _webVRpresenting;
  45358. private _hasEnteredVR;
  45359. private _fullscreenVRpresenting;
  45360. private _inputElement;
  45361. private _webVRCamera;
  45362. private _vrDeviceOrientationCamera;
  45363. private _deviceOrientationCamera;
  45364. private _existingCamera;
  45365. private _onKeyDown;
  45366. private _onVrDisplayPresentChange;
  45367. private _onVRDisplayChanged;
  45368. private _onVRRequestPresentStart;
  45369. private _onVRRequestPresentComplete;
  45370. /**
  45371. * 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)
  45372. */
  45373. enableGazeEvenWhenNoPointerLock: boolean;
  45374. /**
  45375. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45376. */
  45377. exitVROnDoubleTap: boolean;
  45378. /**
  45379. * Observable raised right before entering VR.
  45380. */
  45381. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45382. /**
  45383. * Observable raised when entering VR has completed.
  45384. */
  45385. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45386. /**
  45387. * Observable raised when exiting VR.
  45388. */
  45389. onExitingVRObservable: Observable<VRExperienceHelper>;
  45390. /**
  45391. * Observable raised when controller mesh is loaded.
  45392. */
  45393. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45394. /** Return this.onEnteringVRObservable
  45395. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45396. */
  45397. get onEnteringVR(): Observable<VRExperienceHelper>;
  45398. /** Return this.onExitingVRObservable
  45399. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45400. */
  45401. get onExitingVR(): Observable<VRExperienceHelper>;
  45402. /** Return this.onControllerMeshLoadedObservable
  45403. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45404. */
  45405. get onControllerMeshLoaded(): Observable<WebVRController>;
  45406. private _rayLength;
  45407. private _useCustomVRButton;
  45408. private _teleportationRequested;
  45409. private _teleportActive;
  45410. private _floorMeshName;
  45411. private _floorMeshesCollection;
  45412. private _teleportationMode;
  45413. private _teleportationTime;
  45414. private _teleportationSpeed;
  45415. private _teleportationEasing;
  45416. private _rotationAllowed;
  45417. private _teleportBackwardsVector;
  45418. private _teleportationTarget;
  45419. private _isDefaultTeleportationTarget;
  45420. private _postProcessMove;
  45421. private _teleportationFillColor;
  45422. private _teleportationBorderColor;
  45423. private _rotationAngle;
  45424. private _haloCenter;
  45425. private _cameraGazer;
  45426. private _padSensibilityUp;
  45427. private _padSensibilityDown;
  45428. private _leftController;
  45429. private _rightController;
  45430. private _gazeColor;
  45431. private _laserColor;
  45432. private _pickedLaserColor;
  45433. private _pickedGazeColor;
  45434. /**
  45435. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45436. */
  45437. onNewMeshSelected: Observable<AbstractMesh>;
  45438. /**
  45439. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45440. * This observable will provide the mesh and the controller used to select the mesh
  45441. */
  45442. onMeshSelectedWithController: Observable<{
  45443. mesh: AbstractMesh;
  45444. controller: WebVRController;
  45445. }>;
  45446. /**
  45447. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45448. */
  45449. onNewMeshPicked: Observable<PickingInfo>;
  45450. private _circleEase;
  45451. /**
  45452. * Observable raised before camera teleportation
  45453. */
  45454. onBeforeCameraTeleport: Observable<Vector3>;
  45455. /**
  45456. * Observable raised after camera teleportation
  45457. */
  45458. onAfterCameraTeleport: Observable<Vector3>;
  45459. /**
  45460. * Observable raised when current selected mesh gets unselected
  45461. */
  45462. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45463. private _raySelectionPredicate;
  45464. /**
  45465. * To be optionaly changed by user to define custom ray selection
  45466. */
  45467. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45468. /**
  45469. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45470. */
  45471. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45472. /**
  45473. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45474. */
  45475. teleportationEnabled: boolean;
  45476. private _defaultHeight;
  45477. private _teleportationInitialized;
  45478. private _interactionsEnabled;
  45479. private _interactionsRequested;
  45480. private _displayGaze;
  45481. private _displayLaserPointer;
  45482. /**
  45483. * The mesh used to display where the user is going to teleport.
  45484. */
  45485. get teleportationTarget(): Mesh;
  45486. /**
  45487. * Sets the mesh to be used to display where the user is going to teleport.
  45488. */
  45489. set teleportationTarget(value: Mesh);
  45490. /**
  45491. * 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
  45492. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45493. * See http://doc.babylonjs.com/resources/baking_transformations
  45494. */
  45495. get gazeTrackerMesh(): Mesh;
  45496. set gazeTrackerMesh(value: Mesh);
  45497. /**
  45498. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45499. */
  45500. updateGazeTrackerScale: boolean;
  45501. /**
  45502. * If the gaze trackers color should be updated when selecting meshes
  45503. */
  45504. updateGazeTrackerColor: boolean;
  45505. /**
  45506. * If the controller laser color should be updated when selecting meshes
  45507. */
  45508. updateControllerLaserColor: boolean;
  45509. /**
  45510. * The gaze tracking mesh corresponding to the left controller
  45511. */
  45512. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45513. /**
  45514. * The gaze tracking mesh corresponding to the right controller
  45515. */
  45516. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45517. /**
  45518. * If the ray of the gaze should be displayed.
  45519. */
  45520. get displayGaze(): boolean;
  45521. /**
  45522. * Sets if the ray of the gaze should be displayed.
  45523. */
  45524. set displayGaze(value: boolean);
  45525. /**
  45526. * If the ray of the LaserPointer should be displayed.
  45527. */
  45528. get displayLaserPointer(): boolean;
  45529. /**
  45530. * Sets if the ray of the LaserPointer should be displayed.
  45531. */
  45532. set displayLaserPointer(value: boolean);
  45533. /**
  45534. * The deviceOrientationCamera used as the camera when not in VR.
  45535. */
  45536. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45537. /**
  45538. * Based on the current WebVR support, returns the current VR camera used.
  45539. */
  45540. get currentVRCamera(): Nullable<Camera>;
  45541. /**
  45542. * The webVRCamera which is used when in VR.
  45543. */
  45544. get webVRCamera(): WebVRFreeCamera;
  45545. /**
  45546. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45547. */
  45548. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45549. /**
  45550. * The html button that is used to trigger entering into VR.
  45551. */
  45552. get vrButton(): Nullable<HTMLButtonElement>;
  45553. private get _teleportationRequestInitiated();
  45554. /**
  45555. * Defines whether or not Pointer lock should be requested when switching to
  45556. * full screen.
  45557. */
  45558. requestPointerLockOnFullScreen: boolean;
  45559. /**
  45560. * If asking to force XR, this will be populated with the default xr experience
  45561. */
  45562. xr: WebXRDefaultExperience;
  45563. /**
  45564. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45565. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45566. */
  45567. xrTestDone: boolean;
  45568. /**
  45569. * Instantiates a VRExperienceHelper.
  45570. * Helps to quickly add VR support to an existing scene.
  45571. * @param scene The scene the VRExperienceHelper belongs to.
  45572. * @param webVROptions Options to modify the vr experience helper's behavior.
  45573. */
  45574. constructor(scene: Scene,
  45575. /** Options to modify the vr experience helper's behavior. */
  45576. webVROptions?: VRExperienceHelperOptions);
  45577. private completeVRInit;
  45578. private _onDefaultMeshLoaded;
  45579. private _onResize;
  45580. private _onFullscreenChange;
  45581. /**
  45582. * Gets a value indicating if we are currently in VR mode.
  45583. */
  45584. get isInVRMode(): boolean;
  45585. private onVrDisplayPresentChange;
  45586. private onVRDisplayChanged;
  45587. private moveButtonToBottomRight;
  45588. private displayVRButton;
  45589. private updateButtonVisibility;
  45590. private _cachedAngularSensibility;
  45591. /**
  45592. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45593. * Otherwise, will use the fullscreen API.
  45594. */
  45595. enterVR(): void;
  45596. /**
  45597. * Attempt to exit VR, or fullscreen.
  45598. */
  45599. exitVR(): void;
  45600. /**
  45601. * The position of the vr experience helper.
  45602. */
  45603. get position(): Vector3;
  45604. /**
  45605. * Sets the position of the vr experience helper.
  45606. */
  45607. set position(value: Vector3);
  45608. /**
  45609. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45610. */
  45611. enableInteractions(): void;
  45612. private get _noControllerIsActive();
  45613. private beforeRender;
  45614. private _isTeleportationFloor;
  45615. /**
  45616. * Adds a floor mesh to be used for teleportation.
  45617. * @param floorMesh the mesh to be used for teleportation.
  45618. */
  45619. addFloorMesh(floorMesh: Mesh): void;
  45620. /**
  45621. * Removes a floor mesh from being used for teleportation.
  45622. * @param floorMesh the mesh to be removed.
  45623. */
  45624. removeFloorMesh(floorMesh: Mesh): void;
  45625. /**
  45626. * Enables interactions and teleportation using the VR controllers and gaze.
  45627. * @param vrTeleportationOptions options to modify teleportation behavior.
  45628. */
  45629. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45630. private _onNewGamepadConnected;
  45631. private _tryEnableInteractionOnController;
  45632. private _onNewGamepadDisconnected;
  45633. private _enableInteractionOnController;
  45634. private _checkTeleportWithRay;
  45635. private _checkRotate;
  45636. private _checkTeleportBackwards;
  45637. private _enableTeleportationOnController;
  45638. private _createTeleportationCircles;
  45639. private _displayTeleportationTarget;
  45640. private _hideTeleportationTarget;
  45641. private _rotateCamera;
  45642. private _moveTeleportationSelectorTo;
  45643. private _workingVector;
  45644. private _workingQuaternion;
  45645. private _workingMatrix;
  45646. /**
  45647. * Time Constant Teleportation Mode
  45648. */
  45649. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45650. /**
  45651. * Speed Constant Teleportation Mode
  45652. */
  45653. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45654. /**
  45655. * Teleports the users feet to the desired location
  45656. * @param location The location where the user's feet should be placed
  45657. */
  45658. teleportCamera(location: Vector3): void;
  45659. private _convertNormalToDirectionOfRay;
  45660. private _castRayAndSelectObject;
  45661. private _notifySelectedMeshUnselected;
  45662. /**
  45663. * Permanently set new colors for the laser pointer
  45664. * @param color the new laser color
  45665. * @param pickedColor the new laser color when picked mesh detected
  45666. */
  45667. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45668. /**
  45669. * Set lighting enabled / disabled on the laser pointer of both controllers
  45670. * @param enabled should the lighting be enabled on the laser pointer
  45671. */
  45672. setLaserLightingState(enabled?: boolean): void;
  45673. /**
  45674. * Permanently set new colors for the gaze pointer
  45675. * @param color the new gaze color
  45676. * @param pickedColor the new gaze color when picked mesh detected
  45677. */
  45678. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45679. /**
  45680. * Sets the color of the laser ray from the vr controllers.
  45681. * @param color new color for the ray.
  45682. */
  45683. changeLaserColor(color: Color3): void;
  45684. /**
  45685. * Sets the color of the ray from the vr headsets gaze.
  45686. * @param color new color for the ray.
  45687. */
  45688. changeGazeColor(color: Color3): void;
  45689. /**
  45690. * Exits VR and disposes of the vr experience helper
  45691. */
  45692. dispose(): void;
  45693. /**
  45694. * Gets the name of the VRExperienceHelper class
  45695. * @returns "VRExperienceHelper"
  45696. */
  45697. getClassName(): string;
  45698. }
  45699. }
  45700. declare module BABYLON {
  45701. /**
  45702. * Contains an array of blocks representing the octree
  45703. */
  45704. export interface IOctreeContainer<T> {
  45705. /**
  45706. * Blocks within the octree
  45707. */
  45708. blocks: Array<OctreeBlock<T>>;
  45709. }
  45710. /**
  45711. * Class used to store a cell in an octree
  45712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45713. */
  45714. export class OctreeBlock<T> {
  45715. /**
  45716. * Gets the content of the current block
  45717. */
  45718. entries: T[];
  45719. /**
  45720. * Gets the list of block children
  45721. */
  45722. blocks: Array<OctreeBlock<T>>;
  45723. private _depth;
  45724. private _maxDepth;
  45725. private _capacity;
  45726. private _minPoint;
  45727. private _maxPoint;
  45728. private _boundingVectors;
  45729. private _creationFunc;
  45730. /**
  45731. * Creates a new block
  45732. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45733. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45734. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45735. * @param depth defines the current depth of this block in the octree
  45736. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45737. * @param creationFunc defines a callback to call when an element is added to the block
  45738. */
  45739. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45740. /**
  45741. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45742. */
  45743. get capacity(): number;
  45744. /**
  45745. * Gets the minimum vector (in world space) of the block's bounding box
  45746. */
  45747. get minPoint(): Vector3;
  45748. /**
  45749. * Gets the maximum vector (in world space) of the block's bounding box
  45750. */
  45751. get maxPoint(): Vector3;
  45752. /**
  45753. * Add a new element to this block
  45754. * @param entry defines the element to add
  45755. */
  45756. addEntry(entry: T): void;
  45757. /**
  45758. * Remove an element from this block
  45759. * @param entry defines the element to remove
  45760. */
  45761. removeEntry(entry: T): void;
  45762. /**
  45763. * Add an array of elements to this block
  45764. * @param entries defines the array of elements to add
  45765. */
  45766. addEntries(entries: T[]): void;
  45767. /**
  45768. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45769. * @param frustumPlanes defines the frustum planes to test
  45770. * @param selection defines the array to store current content if selection is positive
  45771. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45772. */
  45773. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45774. /**
  45775. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45776. * @param sphereCenter defines the bounding sphere center
  45777. * @param sphereRadius defines the bounding sphere radius
  45778. * @param selection defines the array to store current content if selection is positive
  45779. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45780. */
  45781. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45782. /**
  45783. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45784. * @param ray defines the ray to test with
  45785. * @param selection defines the array to store current content if selection is positive
  45786. */
  45787. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45788. /**
  45789. * Subdivide the content into child blocks (this block will then be empty)
  45790. */
  45791. createInnerBlocks(): void;
  45792. /**
  45793. * @hidden
  45794. */
  45795. 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;
  45796. }
  45797. }
  45798. declare module BABYLON {
  45799. /**
  45800. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45801. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45802. */
  45803. export class Octree<T> {
  45804. /** 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.) */
  45805. maxDepth: number;
  45806. /**
  45807. * Blocks within the octree containing objects
  45808. */
  45809. blocks: Array<OctreeBlock<T>>;
  45810. /**
  45811. * Content stored in the octree
  45812. */
  45813. dynamicContent: T[];
  45814. private _maxBlockCapacity;
  45815. private _selectionContent;
  45816. private _creationFunc;
  45817. /**
  45818. * Creates a octree
  45819. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45820. * @param creationFunc function to be used to instatiate the octree
  45821. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45822. * @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.)
  45823. */
  45824. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45825. /** 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.) */
  45826. maxDepth?: number);
  45827. /**
  45828. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45829. * @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);
  45830. * @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);
  45831. * @param entries meshes to be added to the octree blocks
  45832. */
  45833. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45834. /**
  45835. * Adds a mesh to the octree
  45836. * @param entry Mesh to add to the octree
  45837. */
  45838. addMesh(entry: T): void;
  45839. /**
  45840. * Remove an element from the octree
  45841. * @param entry defines the element to remove
  45842. */
  45843. removeMesh(entry: T): void;
  45844. /**
  45845. * Selects an array of meshes within the frustum
  45846. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45847. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45848. * @returns array of meshes within the frustum
  45849. */
  45850. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45851. /**
  45852. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45853. * @param sphereCenter defines the bounding sphere center
  45854. * @param sphereRadius defines the bounding sphere radius
  45855. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45856. * @returns an array of objects that intersect the sphere
  45857. */
  45858. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45859. /**
  45860. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45861. * @param ray defines the ray to test with
  45862. * @returns array of intersected objects
  45863. */
  45864. intersectsRay(ray: Ray): SmartArray<T>;
  45865. /**
  45866. * Adds a mesh into the octree block if it intersects the block
  45867. */
  45868. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45869. /**
  45870. * Adds a submesh into the octree block if it intersects the block
  45871. */
  45872. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45873. }
  45874. }
  45875. declare module BABYLON {
  45876. interface Scene {
  45877. /**
  45878. * @hidden
  45879. * Backing Filed
  45880. */
  45881. _selectionOctree: Octree<AbstractMesh>;
  45882. /**
  45883. * Gets the octree used to boost mesh selection (picking)
  45884. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45885. */
  45886. selectionOctree: Octree<AbstractMesh>;
  45887. /**
  45888. * Creates or updates the octree used to boost selection (picking)
  45889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45890. * @param maxCapacity defines the maximum capacity per leaf
  45891. * @param maxDepth defines the maximum depth of the octree
  45892. * @returns an octree of AbstractMesh
  45893. */
  45894. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45895. }
  45896. interface AbstractMesh {
  45897. /**
  45898. * @hidden
  45899. * Backing Field
  45900. */
  45901. _submeshesOctree: Octree<SubMesh>;
  45902. /**
  45903. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45904. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45905. * @param maxCapacity defines the maximum size of each block (64 by default)
  45906. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45907. * @returns the new octree
  45908. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45909. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45910. */
  45911. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45912. }
  45913. /**
  45914. * Defines the octree scene component responsible to manage any octrees
  45915. * in a given scene.
  45916. */
  45917. export class OctreeSceneComponent {
  45918. /**
  45919. * The component name help to identify the component in the list of scene components.
  45920. */
  45921. readonly name: string;
  45922. /**
  45923. * The scene the component belongs to.
  45924. */
  45925. scene: Scene;
  45926. /**
  45927. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45928. */
  45929. readonly checksIsEnabled: boolean;
  45930. /**
  45931. * Creates a new instance of the component for the given scene
  45932. * @param scene Defines the scene to register the component in
  45933. */
  45934. constructor(scene: Scene);
  45935. /**
  45936. * Registers the component in a given scene
  45937. */
  45938. register(): void;
  45939. /**
  45940. * Return the list of active meshes
  45941. * @returns the list of active meshes
  45942. */
  45943. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45944. /**
  45945. * Return the list of active sub meshes
  45946. * @param mesh The mesh to get the candidates sub meshes from
  45947. * @returns the list of active sub meshes
  45948. */
  45949. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45950. private _tempRay;
  45951. /**
  45952. * Return the list of sub meshes intersecting with a given local ray
  45953. * @param mesh defines the mesh to find the submesh for
  45954. * @param localRay defines the ray in local space
  45955. * @returns the list of intersecting sub meshes
  45956. */
  45957. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45958. /**
  45959. * Return the list of sub meshes colliding with a collider
  45960. * @param mesh defines the mesh to find the submesh for
  45961. * @param collider defines the collider to evaluate the collision against
  45962. * @returns the list of colliding sub meshes
  45963. */
  45964. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45965. /**
  45966. * Rebuilds the elements related to this component in case of
  45967. * context lost for instance.
  45968. */
  45969. rebuild(): void;
  45970. /**
  45971. * Disposes the component and the associated ressources.
  45972. */
  45973. dispose(): void;
  45974. }
  45975. }
  45976. declare module BABYLON {
  45977. /**
  45978. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45979. */
  45980. export class Gizmo implements IDisposable {
  45981. /** The utility layer the gizmo will be added to */
  45982. gizmoLayer: UtilityLayerRenderer;
  45983. /**
  45984. * The root mesh of the gizmo
  45985. */
  45986. _rootMesh: Mesh;
  45987. private _attachedMesh;
  45988. /**
  45989. * Ratio for the scale of the gizmo (Default: 1)
  45990. */
  45991. scaleRatio: number;
  45992. /**
  45993. * If a custom mesh has been set (Default: false)
  45994. */
  45995. protected _customMeshSet: boolean;
  45996. /**
  45997. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45998. * * When set, interactions will be enabled
  45999. */
  46000. get attachedMesh(): Nullable<AbstractMesh>;
  46001. set attachedMesh(value: Nullable<AbstractMesh>);
  46002. /**
  46003. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46004. * @param mesh The mesh to replace the default mesh of the gizmo
  46005. */
  46006. setCustomMesh(mesh: Mesh): void;
  46007. /**
  46008. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46009. */
  46010. updateGizmoRotationToMatchAttachedMesh: boolean;
  46011. /**
  46012. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46013. */
  46014. updateGizmoPositionToMatchAttachedMesh: boolean;
  46015. /**
  46016. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46017. */
  46018. updateScale: boolean;
  46019. protected _interactionsEnabled: boolean;
  46020. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46021. private _beforeRenderObserver;
  46022. private _tempVector;
  46023. /**
  46024. * Creates a gizmo
  46025. * @param gizmoLayer The utility layer the gizmo will be added to
  46026. */
  46027. constructor(
  46028. /** The utility layer the gizmo will be added to */
  46029. gizmoLayer?: UtilityLayerRenderer);
  46030. /**
  46031. * Updates the gizmo to match the attached mesh's position/rotation
  46032. */
  46033. protected _update(): void;
  46034. /**
  46035. * Disposes of the gizmo
  46036. */
  46037. dispose(): void;
  46038. }
  46039. }
  46040. declare module BABYLON {
  46041. /**
  46042. * Single plane drag gizmo
  46043. */
  46044. export class PlaneDragGizmo extends Gizmo {
  46045. /**
  46046. * Drag behavior responsible for the gizmos dragging interactions
  46047. */
  46048. dragBehavior: PointerDragBehavior;
  46049. private _pointerObserver;
  46050. /**
  46051. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46052. */
  46053. snapDistance: number;
  46054. /**
  46055. * Event that fires each time the gizmo snaps to a new location.
  46056. * * snapDistance is the the change in distance
  46057. */
  46058. onSnapObservable: Observable<{
  46059. snapDistance: number;
  46060. }>;
  46061. private _plane;
  46062. private _coloredMaterial;
  46063. private _hoverMaterial;
  46064. private _isEnabled;
  46065. private _parent;
  46066. /** @hidden */
  46067. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46068. /** @hidden */
  46069. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46070. /**
  46071. * Creates a PlaneDragGizmo
  46072. * @param gizmoLayer The utility layer the gizmo will be added to
  46073. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46074. * @param color The color of the gizmo
  46075. */
  46076. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46077. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46078. /**
  46079. * If the gizmo is enabled
  46080. */
  46081. set isEnabled(value: boolean);
  46082. get isEnabled(): boolean;
  46083. /**
  46084. * Disposes of the gizmo
  46085. */
  46086. dispose(): void;
  46087. }
  46088. }
  46089. declare module BABYLON {
  46090. /**
  46091. * Gizmo that enables dragging a mesh along 3 axis
  46092. */
  46093. export class PositionGizmo extends Gizmo {
  46094. /**
  46095. * Internal gizmo used for interactions on the x axis
  46096. */
  46097. xGizmo: AxisDragGizmo;
  46098. /**
  46099. * Internal gizmo used for interactions on the y axis
  46100. */
  46101. yGizmo: AxisDragGizmo;
  46102. /**
  46103. * Internal gizmo used for interactions on the z axis
  46104. */
  46105. zGizmo: AxisDragGizmo;
  46106. /**
  46107. * Internal gizmo used for interactions on the yz plane
  46108. */
  46109. xPlaneGizmo: PlaneDragGizmo;
  46110. /**
  46111. * Internal gizmo used for interactions on the xz plane
  46112. */
  46113. yPlaneGizmo: PlaneDragGizmo;
  46114. /**
  46115. * Internal gizmo used for interactions on the xy plane
  46116. */
  46117. zPlaneGizmo: PlaneDragGizmo;
  46118. /**
  46119. * private variables
  46120. */
  46121. private _meshAttached;
  46122. private _updateGizmoRotationToMatchAttachedMesh;
  46123. private _snapDistance;
  46124. private _scaleRatio;
  46125. /** Fires an event when any of it's sub gizmos are dragged */
  46126. onDragStartObservable: Observable<unknown>;
  46127. /** Fires an event when any of it's sub gizmos are released from dragging */
  46128. onDragEndObservable: Observable<unknown>;
  46129. /**
  46130. * If set to true, planar drag is enabled
  46131. */
  46132. private _planarGizmoEnabled;
  46133. get attachedMesh(): Nullable<AbstractMesh>;
  46134. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46135. /**
  46136. * Creates a PositionGizmo
  46137. * @param gizmoLayer The utility layer the gizmo will be added to
  46138. */
  46139. constructor(gizmoLayer?: UtilityLayerRenderer);
  46140. /**
  46141. * If the planar drag gizmo is enabled
  46142. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46143. */
  46144. set planarGizmoEnabled(value: boolean);
  46145. get planarGizmoEnabled(): boolean;
  46146. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46147. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46148. /**
  46149. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46150. */
  46151. set snapDistance(value: number);
  46152. get snapDistance(): number;
  46153. /**
  46154. * Ratio for the scale of the gizmo (Default: 1)
  46155. */
  46156. set scaleRatio(value: number);
  46157. get scaleRatio(): number;
  46158. /**
  46159. * Disposes of the gizmo
  46160. */
  46161. dispose(): void;
  46162. /**
  46163. * CustomMeshes are not supported by this gizmo
  46164. * @param mesh The mesh to replace the default mesh of the gizmo
  46165. */
  46166. setCustomMesh(mesh: Mesh): void;
  46167. }
  46168. }
  46169. declare module BABYLON {
  46170. /**
  46171. * Single axis drag gizmo
  46172. */
  46173. export class AxisDragGizmo extends Gizmo {
  46174. /**
  46175. * Drag behavior responsible for the gizmos dragging interactions
  46176. */
  46177. dragBehavior: PointerDragBehavior;
  46178. private _pointerObserver;
  46179. /**
  46180. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46181. */
  46182. snapDistance: number;
  46183. /**
  46184. * Event that fires each time the gizmo snaps to a new location.
  46185. * * snapDistance is the the change in distance
  46186. */
  46187. onSnapObservable: Observable<{
  46188. snapDistance: number;
  46189. }>;
  46190. private _isEnabled;
  46191. private _parent;
  46192. private _arrow;
  46193. private _coloredMaterial;
  46194. private _hoverMaterial;
  46195. /** @hidden */
  46196. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46197. /** @hidden */
  46198. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46199. /**
  46200. * Creates an AxisDragGizmo
  46201. * @param gizmoLayer The utility layer the gizmo will be added to
  46202. * @param dragAxis The axis which the gizmo will be able to drag on
  46203. * @param color The color of the gizmo
  46204. */
  46205. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46206. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46207. /**
  46208. * If the gizmo is enabled
  46209. */
  46210. set isEnabled(value: boolean);
  46211. get isEnabled(): boolean;
  46212. /**
  46213. * Disposes of the gizmo
  46214. */
  46215. dispose(): void;
  46216. }
  46217. }
  46218. declare module BABYLON.Debug {
  46219. /**
  46220. * The Axes viewer will show 3 axes in a specific point in space
  46221. */
  46222. export class AxesViewer {
  46223. private _xAxis;
  46224. private _yAxis;
  46225. private _zAxis;
  46226. private _scaleLinesFactor;
  46227. private _instanced;
  46228. /**
  46229. * Gets the hosting scene
  46230. */
  46231. scene: Scene;
  46232. /**
  46233. * Gets or sets a number used to scale line length
  46234. */
  46235. scaleLines: number;
  46236. /** Gets the node hierarchy used to render x-axis */
  46237. get xAxis(): TransformNode;
  46238. /** Gets the node hierarchy used to render y-axis */
  46239. get yAxis(): TransformNode;
  46240. /** Gets the node hierarchy used to render z-axis */
  46241. get zAxis(): TransformNode;
  46242. /**
  46243. * Creates a new AxesViewer
  46244. * @param scene defines the hosting scene
  46245. * @param scaleLines defines a number used to scale line length (1 by default)
  46246. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46247. * @param xAxis defines the node hierarchy used to render the x-axis
  46248. * @param yAxis defines the node hierarchy used to render the y-axis
  46249. * @param zAxis defines the node hierarchy used to render the z-axis
  46250. */
  46251. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46252. /**
  46253. * Force the viewer to update
  46254. * @param position defines the position of the viewer
  46255. * @param xaxis defines the x axis of the viewer
  46256. * @param yaxis defines the y axis of the viewer
  46257. * @param zaxis defines the z axis of the viewer
  46258. */
  46259. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46260. /**
  46261. * Creates an instance of this axes viewer.
  46262. * @returns a new axes viewer with instanced meshes
  46263. */
  46264. createInstance(): AxesViewer;
  46265. /** Releases resources */
  46266. dispose(): void;
  46267. private static _SetRenderingGroupId;
  46268. }
  46269. }
  46270. declare module BABYLON.Debug {
  46271. /**
  46272. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46273. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46274. */
  46275. export class BoneAxesViewer extends AxesViewer {
  46276. /**
  46277. * Gets or sets the target mesh where to display the axes viewer
  46278. */
  46279. mesh: Nullable<Mesh>;
  46280. /**
  46281. * Gets or sets the target bone where to display the axes viewer
  46282. */
  46283. bone: Nullable<Bone>;
  46284. /** Gets current position */
  46285. pos: Vector3;
  46286. /** Gets direction of X axis */
  46287. xaxis: Vector3;
  46288. /** Gets direction of Y axis */
  46289. yaxis: Vector3;
  46290. /** Gets direction of Z axis */
  46291. zaxis: Vector3;
  46292. /**
  46293. * Creates a new BoneAxesViewer
  46294. * @param scene defines the hosting scene
  46295. * @param bone defines the target bone
  46296. * @param mesh defines the target mesh
  46297. * @param scaleLines defines a scaling factor for line length (1 by default)
  46298. */
  46299. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46300. /**
  46301. * Force the viewer to update
  46302. */
  46303. update(): void;
  46304. /** Releases resources */
  46305. dispose(): void;
  46306. }
  46307. }
  46308. declare module BABYLON {
  46309. /**
  46310. * Interface used to define scene explorer extensibility option
  46311. */
  46312. export interface IExplorerExtensibilityOption {
  46313. /**
  46314. * Define the option label
  46315. */
  46316. label: string;
  46317. /**
  46318. * Defines the action to execute on click
  46319. */
  46320. action: (entity: any) => void;
  46321. }
  46322. /**
  46323. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46324. */
  46325. export interface IExplorerExtensibilityGroup {
  46326. /**
  46327. * Defines a predicate to test if a given type mut be extended
  46328. */
  46329. predicate: (entity: any) => boolean;
  46330. /**
  46331. * Gets the list of options added to a type
  46332. */
  46333. entries: IExplorerExtensibilityOption[];
  46334. }
  46335. /**
  46336. * Interface used to define the options to use to create the Inspector
  46337. */
  46338. export interface IInspectorOptions {
  46339. /**
  46340. * Display in overlay mode (default: false)
  46341. */
  46342. overlay?: boolean;
  46343. /**
  46344. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46345. */
  46346. globalRoot?: HTMLElement;
  46347. /**
  46348. * Display the Scene explorer
  46349. */
  46350. showExplorer?: boolean;
  46351. /**
  46352. * Display the property inspector
  46353. */
  46354. showInspector?: boolean;
  46355. /**
  46356. * Display in embed mode (both panes on the right)
  46357. */
  46358. embedMode?: boolean;
  46359. /**
  46360. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46361. */
  46362. handleResize?: boolean;
  46363. /**
  46364. * Allow the panes to popup (default: true)
  46365. */
  46366. enablePopup?: boolean;
  46367. /**
  46368. * Allow the panes to be closed by users (default: true)
  46369. */
  46370. enableClose?: boolean;
  46371. /**
  46372. * Optional list of extensibility entries
  46373. */
  46374. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46375. /**
  46376. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46377. */
  46378. inspectorURL?: string;
  46379. /**
  46380. * Optional initial tab (default to DebugLayerTab.Properties)
  46381. */
  46382. initialTab?: DebugLayerTab;
  46383. }
  46384. interface Scene {
  46385. /**
  46386. * @hidden
  46387. * Backing field
  46388. */
  46389. _debugLayer: DebugLayer;
  46390. /**
  46391. * Gets the debug layer (aka Inspector) associated with the scene
  46392. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46393. */
  46394. debugLayer: DebugLayer;
  46395. }
  46396. /**
  46397. * Enum of inspector action tab
  46398. */
  46399. export enum DebugLayerTab {
  46400. /**
  46401. * Properties tag (default)
  46402. */
  46403. Properties = 0,
  46404. /**
  46405. * Debug tab
  46406. */
  46407. Debug = 1,
  46408. /**
  46409. * Statistics tab
  46410. */
  46411. Statistics = 2,
  46412. /**
  46413. * Tools tab
  46414. */
  46415. Tools = 3,
  46416. /**
  46417. * Settings tab
  46418. */
  46419. Settings = 4
  46420. }
  46421. /**
  46422. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46423. * what is happening in your scene
  46424. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46425. */
  46426. export class DebugLayer {
  46427. /**
  46428. * Define the url to get the inspector script from.
  46429. * By default it uses the babylonjs CDN.
  46430. * @ignoreNaming
  46431. */
  46432. static InspectorURL: string;
  46433. private _scene;
  46434. private BJSINSPECTOR;
  46435. private _onPropertyChangedObservable?;
  46436. /**
  46437. * Observable triggered when a property is changed through the inspector.
  46438. */
  46439. get onPropertyChangedObservable(): any;
  46440. /**
  46441. * Instantiates a new debug layer.
  46442. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46443. * what is happening in your scene
  46444. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46445. * @param scene Defines the scene to inspect
  46446. */
  46447. constructor(scene: Scene);
  46448. /** Creates the inspector window. */
  46449. private _createInspector;
  46450. /**
  46451. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46452. * @param entity defines the entity to select
  46453. * @param lineContainerTitle defines the specific block to highlight
  46454. */
  46455. select(entity: any, lineContainerTitle?: string): void;
  46456. /** Get the inspector from bundle or global */
  46457. private _getGlobalInspector;
  46458. /**
  46459. * Get if the inspector is visible or not.
  46460. * @returns true if visible otherwise, false
  46461. */
  46462. isVisible(): boolean;
  46463. /**
  46464. * Hide the inspector and close its window.
  46465. */
  46466. hide(): void;
  46467. /**
  46468. * Launch the debugLayer.
  46469. * @param config Define the configuration of the inspector
  46470. * @return a promise fulfilled when the debug layer is visible
  46471. */
  46472. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46473. }
  46474. }
  46475. declare module BABYLON {
  46476. /**
  46477. * Class containing static functions to help procedurally build meshes
  46478. */
  46479. export class BoxBuilder {
  46480. /**
  46481. * Creates a box mesh
  46482. * * The parameter `size` sets the size (float) of each box side (default 1)
  46483. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46484. * * 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)
  46485. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46487. * * 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
  46488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46489. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46490. * @param name defines the name of the mesh
  46491. * @param options defines the options used to create the mesh
  46492. * @param scene defines the hosting scene
  46493. * @returns the box mesh
  46494. */
  46495. static CreateBox(name: string, options: {
  46496. size?: number;
  46497. width?: number;
  46498. height?: number;
  46499. depth?: number;
  46500. faceUV?: Vector4[];
  46501. faceColors?: Color4[];
  46502. sideOrientation?: number;
  46503. frontUVs?: Vector4;
  46504. backUVs?: Vector4;
  46505. wrap?: boolean;
  46506. topBaseAt?: number;
  46507. bottomBaseAt?: number;
  46508. updatable?: boolean;
  46509. }, scene?: Nullable<Scene>): Mesh;
  46510. }
  46511. }
  46512. declare module BABYLON.Debug {
  46513. /**
  46514. * Used to show the physics impostor around the specific mesh
  46515. */
  46516. export class PhysicsViewer {
  46517. /** @hidden */
  46518. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46519. /** @hidden */
  46520. protected _meshes: Array<Nullable<AbstractMesh>>;
  46521. /** @hidden */
  46522. protected _scene: Nullable<Scene>;
  46523. /** @hidden */
  46524. protected _numMeshes: number;
  46525. /** @hidden */
  46526. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46527. private _renderFunction;
  46528. private _utilityLayer;
  46529. private _debugBoxMesh;
  46530. private _debugSphereMesh;
  46531. private _debugCylinderMesh;
  46532. private _debugMaterial;
  46533. private _debugMeshMeshes;
  46534. /**
  46535. * Creates a new PhysicsViewer
  46536. * @param scene defines the hosting scene
  46537. */
  46538. constructor(scene: Scene);
  46539. /** @hidden */
  46540. protected _updateDebugMeshes(): void;
  46541. /**
  46542. * Renders a specified physic impostor
  46543. * @param impostor defines the impostor to render
  46544. * @param targetMesh defines the mesh represented by the impostor
  46545. * @returns the new debug mesh used to render the impostor
  46546. */
  46547. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46548. /**
  46549. * Hides a specified physic impostor
  46550. * @param impostor defines the impostor to hide
  46551. */
  46552. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46553. private _getDebugMaterial;
  46554. private _getDebugBoxMesh;
  46555. private _getDebugSphereMesh;
  46556. private _getDebugCylinderMesh;
  46557. private _getDebugMeshMesh;
  46558. private _getDebugMesh;
  46559. /** Releases all resources */
  46560. dispose(): void;
  46561. }
  46562. }
  46563. declare module BABYLON {
  46564. /**
  46565. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46566. * in order to better appreciate the issue one might have.
  46567. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46568. */
  46569. export class RayHelper {
  46570. /**
  46571. * Defines the ray we are currently tryin to visualize.
  46572. */
  46573. ray: Nullable<Ray>;
  46574. private _renderPoints;
  46575. private _renderLine;
  46576. private _renderFunction;
  46577. private _scene;
  46578. private _updateToMeshFunction;
  46579. private _attachedToMesh;
  46580. private _meshSpaceDirection;
  46581. private _meshSpaceOrigin;
  46582. /**
  46583. * Helper function to create a colored helper in a scene in one line.
  46584. * @param ray Defines the ray we are currently tryin to visualize
  46585. * @param scene Defines the scene the ray is used in
  46586. * @param color Defines the color we want to see the ray in
  46587. * @returns The newly created ray helper.
  46588. */
  46589. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46590. /**
  46591. * Instantiate a new ray helper.
  46592. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46593. * in order to better appreciate the issue one might have.
  46594. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46595. * @param ray Defines the ray we are currently tryin to visualize
  46596. */
  46597. constructor(ray: Ray);
  46598. /**
  46599. * Shows the ray we are willing to debug.
  46600. * @param scene Defines the scene the ray needs to be rendered in
  46601. * @param color Defines the color the ray needs to be rendered in
  46602. */
  46603. show(scene: Scene, color?: Color3): void;
  46604. /**
  46605. * Hides the ray we are debugging.
  46606. */
  46607. hide(): void;
  46608. private _render;
  46609. /**
  46610. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46611. * @param mesh Defines the mesh we want the helper attached to
  46612. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46613. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46614. * @param length Defines the length of the ray
  46615. */
  46616. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46617. /**
  46618. * Detach the ray helper from the mesh it has previously been attached to.
  46619. */
  46620. detachFromMesh(): void;
  46621. private _updateToMesh;
  46622. /**
  46623. * Dispose the helper and release its associated resources.
  46624. */
  46625. dispose(): void;
  46626. }
  46627. }
  46628. declare module BABYLON.Debug {
  46629. /**
  46630. * Class used to render a debug view of a given skeleton
  46631. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46632. */
  46633. export class SkeletonViewer {
  46634. /** defines the skeleton to render */
  46635. skeleton: Skeleton;
  46636. /** defines the mesh attached to the skeleton */
  46637. mesh: AbstractMesh;
  46638. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46639. autoUpdateBonesMatrices: boolean;
  46640. /** defines the rendering group id to use with the viewer */
  46641. renderingGroupId: number;
  46642. /** Gets or sets the color used to render the skeleton */
  46643. color: Color3;
  46644. private _scene;
  46645. private _debugLines;
  46646. private _debugMesh;
  46647. private _isEnabled;
  46648. private _renderFunction;
  46649. private _utilityLayer;
  46650. /**
  46651. * Returns the mesh used to render the bones
  46652. */
  46653. get debugMesh(): Nullable<LinesMesh>;
  46654. /**
  46655. * Creates a new SkeletonViewer
  46656. * @param skeleton defines the skeleton to render
  46657. * @param mesh defines the mesh attached to the skeleton
  46658. * @param scene defines the hosting scene
  46659. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46660. * @param renderingGroupId defines the rendering group id to use with the viewer
  46661. */
  46662. constructor(
  46663. /** defines the skeleton to render */
  46664. skeleton: Skeleton,
  46665. /** defines the mesh attached to the skeleton */
  46666. mesh: AbstractMesh, scene: Scene,
  46667. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46668. autoUpdateBonesMatrices?: boolean,
  46669. /** defines the rendering group id to use with the viewer */
  46670. renderingGroupId?: number);
  46671. /** Gets or sets a boolean indicating if the viewer is enabled */
  46672. set isEnabled(value: boolean);
  46673. get isEnabled(): boolean;
  46674. private _getBonePosition;
  46675. private _getLinesForBonesWithLength;
  46676. private _getLinesForBonesNoLength;
  46677. /** Update the viewer to sync with current skeleton state */
  46678. update(): void;
  46679. /** Release associated resources */
  46680. dispose(): void;
  46681. }
  46682. }
  46683. declare module BABYLON {
  46684. /**
  46685. * Options to create the null engine
  46686. */
  46687. export class NullEngineOptions {
  46688. /**
  46689. * Render width (Default: 512)
  46690. */
  46691. renderWidth: number;
  46692. /**
  46693. * Render height (Default: 256)
  46694. */
  46695. renderHeight: number;
  46696. /**
  46697. * Texture size (Default: 512)
  46698. */
  46699. textureSize: number;
  46700. /**
  46701. * If delta time between frames should be constant
  46702. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46703. */
  46704. deterministicLockstep: boolean;
  46705. /**
  46706. * Maximum about of steps between frames (Default: 4)
  46707. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46708. */
  46709. lockstepMaxSteps: number;
  46710. }
  46711. /**
  46712. * The null engine class provides support for headless version of babylon.js.
  46713. * This can be used in server side scenario or for testing purposes
  46714. */
  46715. export class NullEngine extends Engine {
  46716. private _options;
  46717. /**
  46718. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46719. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46720. * @returns true if engine is in deterministic lock step mode
  46721. */
  46722. isDeterministicLockStep(): boolean;
  46723. /**
  46724. * Gets the max steps when engine is running in deterministic lock step
  46725. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46726. * @returns the max steps
  46727. */
  46728. getLockstepMaxSteps(): number;
  46729. /**
  46730. * Gets the current hardware scaling level.
  46731. * By default the hardware scaling level is computed from the window device ratio.
  46732. * 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.
  46733. * @returns a number indicating the current hardware scaling level
  46734. */
  46735. getHardwareScalingLevel(): number;
  46736. constructor(options?: NullEngineOptions);
  46737. /**
  46738. * Creates a vertex buffer
  46739. * @param vertices the data for the vertex buffer
  46740. * @returns the new WebGL static buffer
  46741. */
  46742. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46743. /**
  46744. * Creates a new index buffer
  46745. * @param indices defines the content of the index buffer
  46746. * @param updatable defines if the index buffer must be updatable
  46747. * @returns a new webGL buffer
  46748. */
  46749. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46750. /**
  46751. * Clear the current render buffer or the current render target (if any is set up)
  46752. * @param color defines the color to use
  46753. * @param backBuffer defines if the back buffer must be cleared
  46754. * @param depth defines if the depth buffer must be cleared
  46755. * @param stencil defines if the stencil buffer must be cleared
  46756. */
  46757. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46758. /**
  46759. * Gets the current render width
  46760. * @param useScreen defines if screen size must be used (or the current render target if any)
  46761. * @returns a number defining the current render width
  46762. */
  46763. getRenderWidth(useScreen?: boolean): number;
  46764. /**
  46765. * Gets the current render height
  46766. * @param useScreen defines if screen size must be used (or the current render target if any)
  46767. * @returns a number defining the current render height
  46768. */
  46769. getRenderHeight(useScreen?: boolean): number;
  46770. /**
  46771. * Set the WebGL's viewport
  46772. * @param viewport defines the viewport element to be used
  46773. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46774. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46775. */
  46776. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46777. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46778. /**
  46779. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46780. * @param pipelineContext defines the pipeline context to use
  46781. * @param uniformsNames defines the list of uniform names
  46782. * @returns an array of webGL uniform locations
  46783. */
  46784. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46785. /**
  46786. * Gets the lsit of active attributes for a given webGL program
  46787. * @param pipelineContext defines the pipeline context to use
  46788. * @param attributesNames defines the list of attribute names to get
  46789. * @returns an array of indices indicating the offset of each attribute
  46790. */
  46791. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46792. /**
  46793. * Binds an effect to the webGL context
  46794. * @param effect defines the effect to bind
  46795. */
  46796. bindSamplers(effect: Effect): void;
  46797. /**
  46798. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46799. * @param effect defines the effect to activate
  46800. */
  46801. enableEffect(effect: Effect): void;
  46802. /**
  46803. * Set various states to the webGL context
  46804. * @param culling defines backface culling state
  46805. * @param zOffset defines the value to apply to zOffset (0 by default)
  46806. * @param force defines if states must be applied even if cache is up to date
  46807. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46808. */
  46809. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46810. /**
  46811. * Set the value of an uniform to an array of int32
  46812. * @param uniform defines the webGL uniform location where to store the value
  46813. * @param array defines the array of int32 to store
  46814. */
  46815. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46816. /**
  46817. * Set the value of an uniform to an array of int32 (stored as vec2)
  46818. * @param uniform defines the webGL uniform location where to store the value
  46819. * @param array defines the array of int32 to store
  46820. */
  46821. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46822. /**
  46823. * Set the value of an uniform to an array of int32 (stored as vec3)
  46824. * @param uniform defines the webGL uniform location where to store the value
  46825. * @param array defines the array of int32 to store
  46826. */
  46827. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46828. /**
  46829. * Set the value of an uniform to an array of int32 (stored as vec4)
  46830. * @param uniform defines the webGL uniform location where to store the value
  46831. * @param array defines the array of int32 to store
  46832. */
  46833. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46834. /**
  46835. * Set the value of an uniform to an array of float32
  46836. * @param uniform defines the webGL uniform location where to store the value
  46837. * @param array defines the array of float32 to store
  46838. */
  46839. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46840. /**
  46841. * Set the value of an uniform to an array of float32 (stored as vec2)
  46842. * @param uniform defines the webGL uniform location where to store the value
  46843. * @param array defines the array of float32 to store
  46844. */
  46845. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46846. /**
  46847. * Set the value of an uniform to an array of float32 (stored as vec3)
  46848. * @param uniform defines the webGL uniform location where to store the value
  46849. * @param array defines the array of float32 to store
  46850. */
  46851. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46852. /**
  46853. * Set the value of an uniform to an array of float32 (stored as vec4)
  46854. * @param uniform defines the webGL uniform location where to store the value
  46855. * @param array defines the array of float32 to store
  46856. */
  46857. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46858. /**
  46859. * Set the value of an uniform to an array of number
  46860. * @param uniform defines the webGL uniform location where to store the value
  46861. * @param array defines the array of number to store
  46862. */
  46863. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46864. /**
  46865. * Set the value of an uniform to an array of number (stored as vec2)
  46866. * @param uniform defines the webGL uniform location where to store the value
  46867. * @param array defines the array of number to store
  46868. */
  46869. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46870. /**
  46871. * Set the value of an uniform to an array of number (stored as vec3)
  46872. * @param uniform defines the webGL uniform location where to store the value
  46873. * @param array defines the array of number to store
  46874. */
  46875. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46876. /**
  46877. * Set the value of an uniform to an array of number (stored as vec4)
  46878. * @param uniform defines the webGL uniform location where to store the value
  46879. * @param array defines the array of number to store
  46880. */
  46881. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46882. /**
  46883. * Set the value of an uniform to an array of float32 (stored as matrices)
  46884. * @param uniform defines the webGL uniform location where to store the value
  46885. * @param matrices defines the array of float32 to store
  46886. */
  46887. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46888. /**
  46889. * Set the value of an uniform to a matrix (3x3)
  46890. * @param uniform defines the webGL uniform location where to store the value
  46891. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46892. */
  46893. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46894. /**
  46895. * Set the value of an uniform to a matrix (2x2)
  46896. * @param uniform defines the webGL uniform location where to store the value
  46897. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46898. */
  46899. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46900. /**
  46901. * Set the value of an uniform to a number (float)
  46902. * @param uniform defines the webGL uniform location where to store the value
  46903. * @param value defines the float number to store
  46904. */
  46905. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46906. /**
  46907. * Set the value of an uniform to a vec2
  46908. * @param uniform defines the webGL uniform location where to store the value
  46909. * @param x defines the 1st component of the value
  46910. * @param y defines the 2nd component of the value
  46911. */
  46912. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46913. /**
  46914. * Set the value of an uniform to a vec3
  46915. * @param uniform defines the webGL uniform location where to store the value
  46916. * @param x defines the 1st component of the value
  46917. * @param y defines the 2nd component of the value
  46918. * @param z defines the 3rd component of the value
  46919. */
  46920. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46921. /**
  46922. * Set the value of an uniform to a boolean
  46923. * @param uniform defines the webGL uniform location where to store the value
  46924. * @param bool defines the boolean to store
  46925. */
  46926. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46927. /**
  46928. * Set the value of an uniform to a vec4
  46929. * @param uniform defines the webGL uniform location where to store the value
  46930. * @param x defines the 1st component of the value
  46931. * @param y defines the 2nd component of the value
  46932. * @param z defines the 3rd component of the value
  46933. * @param w defines the 4th component of the value
  46934. */
  46935. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46936. /**
  46937. * Sets the current alpha mode
  46938. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46939. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46940. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46941. */
  46942. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46943. /**
  46944. * Bind webGl buffers directly to the webGL context
  46945. * @param vertexBuffers defines the vertex buffer to bind
  46946. * @param indexBuffer defines the index buffer to bind
  46947. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46948. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46949. * @param effect defines the effect associated with the vertex buffer
  46950. */
  46951. bindBuffers(vertexBuffers: {
  46952. [key: string]: VertexBuffer;
  46953. }, indexBuffer: DataBuffer, effect: Effect): void;
  46954. /**
  46955. * Force the entire cache to be cleared
  46956. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46957. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46958. */
  46959. wipeCaches(bruteForce?: boolean): void;
  46960. /**
  46961. * Send a draw order
  46962. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46963. * @param indexStart defines the starting index
  46964. * @param indexCount defines the number of index to draw
  46965. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46966. */
  46967. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46968. /**
  46969. * Draw a list of indexed primitives
  46970. * @param fillMode defines the primitive to use
  46971. * @param indexStart defines the starting index
  46972. * @param indexCount defines the number of index to draw
  46973. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46974. */
  46975. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46976. /**
  46977. * Draw a list of unindexed primitives
  46978. * @param fillMode defines the primitive to use
  46979. * @param verticesStart defines the index of first vertex to draw
  46980. * @param verticesCount defines the count of vertices to draw
  46981. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46982. */
  46983. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46984. /** @hidden */
  46985. _createTexture(): WebGLTexture;
  46986. /** @hidden */
  46987. _releaseTexture(texture: InternalTexture): void;
  46988. /**
  46989. * Usually called from Texture.ts.
  46990. * Passed information to create a WebGLTexture
  46991. * @param urlArg defines a value which contains one of the following:
  46992. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46993. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46994. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46995. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46996. * @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)
  46997. * @param scene needed for loading to the correct scene
  46998. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46999. * @param onLoad optional callback to be called upon successful completion
  47000. * @param onError optional callback to be called upon failure
  47001. * @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
  47002. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47003. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47004. * @param forcedExtension defines the extension to use to pick the right loader
  47005. * @param mimeType defines an optional mime type
  47006. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47007. */
  47008. 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;
  47009. /**
  47010. * Creates a new render target texture
  47011. * @param size defines the size of the texture
  47012. * @param options defines the options used to create the texture
  47013. * @returns a new render target texture stored in an InternalTexture
  47014. */
  47015. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47016. /**
  47017. * Update the sampling mode of a given texture
  47018. * @param samplingMode defines the required sampling mode
  47019. * @param texture defines the texture to update
  47020. */
  47021. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47022. /**
  47023. * Binds the frame buffer to the specified texture.
  47024. * @param texture The texture to render to or null for the default canvas
  47025. * @param faceIndex The face of the texture to render to in case of cube texture
  47026. * @param requiredWidth The width of the target to render to
  47027. * @param requiredHeight The height of the target to render to
  47028. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47029. * @param lodLevel defines le lod level to bind to the frame buffer
  47030. */
  47031. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47032. /**
  47033. * Unbind the current render target texture from the webGL context
  47034. * @param texture defines the render target texture to unbind
  47035. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47036. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47037. */
  47038. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47039. /**
  47040. * Creates a dynamic vertex buffer
  47041. * @param vertices the data for the dynamic vertex buffer
  47042. * @returns the new WebGL dynamic buffer
  47043. */
  47044. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47045. /**
  47046. * Update the content of a dynamic texture
  47047. * @param texture defines the texture to update
  47048. * @param canvas defines the canvas containing the source
  47049. * @param invertY defines if data must be stored with Y axis inverted
  47050. * @param premulAlpha defines if alpha is stored as premultiplied
  47051. * @param format defines the format of the data
  47052. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47053. */
  47054. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47055. /**
  47056. * Gets a boolean indicating if all created effects are ready
  47057. * @returns true if all effects are ready
  47058. */
  47059. areAllEffectsReady(): boolean;
  47060. /**
  47061. * @hidden
  47062. * Get the current error code of the webGL context
  47063. * @returns the error code
  47064. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47065. */
  47066. getError(): number;
  47067. /** @hidden */
  47068. _getUnpackAlignement(): number;
  47069. /** @hidden */
  47070. _unpackFlipY(value: boolean): void;
  47071. /**
  47072. * Update a dynamic index buffer
  47073. * @param indexBuffer defines the target index buffer
  47074. * @param indices defines the data to update
  47075. * @param offset defines the offset in the target index buffer where update should start
  47076. */
  47077. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47078. /**
  47079. * Updates a dynamic vertex buffer.
  47080. * @param vertexBuffer the vertex buffer to update
  47081. * @param vertices the data used to update the vertex buffer
  47082. * @param byteOffset the byte offset of the data (optional)
  47083. * @param byteLength the byte length of the data (optional)
  47084. */
  47085. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47086. /** @hidden */
  47087. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47088. /** @hidden */
  47089. _bindTexture(channel: number, texture: InternalTexture): void;
  47090. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47091. /**
  47092. * 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
  47093. */
  47094. releaseEffects(): void;
  47095. displayLoadingUI(): void;
  47096. hideLoadingUI(): void;
  47097. /** @hidden */
  47098. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47099. /** @hidden */
  47100. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47101. /** @hidden */
  47102. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47103. /** @hidden */
  47104. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47105. }
  47106. }
  47107. declare module BABYLON {
  47108. /**
  47109. * @hidden
  47110. **/
  47111. export class _TimeToken {
  47112. _startTimeQuery: Nullable<WebGLQuery>;
  47113. _endTimeQuery: Nullable<WebGLQuery>;
  47114. _timeElapsedQuery: Nullable<WebGLQuery>;
  47115. _timeElapsedQueryEnded: boolean;
  47116. }
  47117. }
  47118. declare module BABYLON {
  47119. /** @hidden */
  47120. export class _OcclusionDataStorage {
  47121. /** @hidden */
  47122. occlusionInternalRetryCounter: number;
  47123. /** @hidden */
  47124. isOcclusionQueryInProgress: boolean;
  47125. /** @hidden */
  47126. isOccluded: boolean;
  47127. /** @hidden */
  47128. occlusionRetryCount: number;
  47129. /** @hidden */
  47130. occlusionType: number;
  47131. /** @hidden */
  47132. occlusionQueryAlgorithmType: number;
  47133. }
  47134. interface Engine {
  47135. /**
  47136. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47137. * @return the new query
  47138. */
  47139. createQuery(): WebGLQuery;
  47140. /**
  47141. * Delete and release a webGL query
  47142. * @param query defines the query to delete
  47143. * @return the current engine
  47144. */
  47145. deleteQuery(query: WebGLQuery): Engine;
  47146. /**
  47147. * Check if a given query has resolved and got its value
  47148. * @param query defines the query to check
  47149. * @returns true if the query got its value
  47150. */
  47151. isQueryResultAvailable(query: WebGLQuery): boolean;
  47152. /**
  47153. * Gets the value of a given query
  47154. * @param query defines the query to check
  47155. * @returns the value of the query
  47156. */
  47157. getQueryResult(query: WebGLQuery): number;
  47158. /**
  47159. * Initiates an occlusion query
  47160. * @param algorithmType defines the algorithm to use
  47161. * @param query defines the query to use
  47162. * @returns the current engine
  47163. * @see http://doc.babylonjs.com/features/occlusionquery
  47164. */
  47165. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47166. /**
  47167. * Ends an occlusion query
  47168. * @see http://doc.babylonjs.com/features/occlusionquery
  47169. * @param algorithmType defines the algorithm to use
  47170. * @returns the current engine
  47171. */
  47172. endOcclusionQuery(algorithmType: number): Engine;
  47173. /**
  47174. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47175. * Please note that only one query can be issued at a time
  47176. * @returns a time token used to track the time span
  47177. */
  47178. startTimeQuery(): Nullable<_TimeToken>;
  47179. /**
  47180. * Ends a time query
  47181. * @param token defines the token used to measure the time span
  47182. * @returns the time spent (in ns)
  47183. */
  47184. endTimeQuery(token: _TimeToken): int;
  47185. /** @hidden */
  47186. _currentNonTimestampToken: Nullable<_TimeToken>;
  47187. /** @hidden */
  47188. _createTimeQuery(): WebGLQuery;
  47189. /** @hidden */
  47190. _deleteTimeQuery(query: WebGLQuery): void;
  47191. /** @hidden */
  47192. _getGlAlgorithmType(algorithmType: number): number;
  47193. /** @hidden */
  47194. _getTimeQueryResult(query: WebGLQuery): any;
  47195. /** @hidden */
  47196. _getTimeQueryAvailability(query: WebGLQuery): any;
  47197. }
  47198. interface AbstractMesh {
  47199. /**
  47200. * Backing filed
  47201. * @hidden
  47202. */
  47203. __occlusionDataStorage: _OcclusionDataStorage;
  47204. /**
  47205. * Access property
  47206. * @hidden
  47207. */
  47208. _occlusionDataStorage: _OcclusionDataStorage;
  47209. /**
  47210. * 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.
  47211. * The default value is -1 which means don't break the query and wait till the result
  47212. * @see http://doc.babylonjs.com/features/occlusionquery
  47213. */
  47214. occlusionRetryCount: number;
  47215. /**
  47216. * 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:
  47217. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47218. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47219. * * 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.
  47220. * @see http://doc.babylonjs.com/features/occlusionquery
  47221. */
  47222. occlusionType: number;
  47223. /**
  47224. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47225. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47226. * * 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.
  47227. * @see http://doc.babylonjs.com/features/occlusionquery
  47228. */
  47229. occlusionQueryAlgorithmType: number;
  47230. /**
  47231. * 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
  47232. * @see http://doc.babylonjs.com/features/occlusionquery
  47233. */
  47234. isOccluded: boolean;
  47235. /**
  47236. * Flag to check the progress status of the query
  47237. * @see http://doc.babylonjs.com/features/occlusionquery
  47238. */
  47239. isOcclusionQueryInProgress: boolean;
  47240. }
  47241. }
  47242. declare module BABYLON {
  47243. /** @hidden */
  47244. export var _forceTransformFeedbackToBundle: boolean;
  47245. interface Engine {
  47246. /**
  47247. * Creates a webGL transform feedback object
  47248. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47249. * @returns the webGL transform feedback object
  47250. */
  47251. createTransformFeedback(): WebGLTransformFeedback;
  47252. /**
  47253. * Delete a webGL transform feedback object
  47254. * @param value defines the webGL transform feedback object to delete
  47255. */
  47256. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47257. /**
  47258. * Bind a webGL transform feedback object to the webgl context
  47259. * @param value defines the webGL transform feedback object to bind
  47260. */
  47261. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47262. /**
  47263. * Begins a transform feedback operation
  47264. * @param usePoints defines if points or triangles must be used
  47265. */
  47266. beginTransformFeedback(usePoints: boolean): void;
  47267. /**
  47268. * Ends a transform feedback operation
  47269. */
  47270. endTransformFeedback(): void;
  47271. /**
  47272. * Specify the varyings to use with transform feedback
  47273. * @param program defines the associated webGL program
  47274. * @param value defines the list of strings representing the varying names
  47275. */
  47276. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47277. /**
  47278. * Bind a webGL buffer for a transform feedback operation
  47279. * @param value defines the webGL buffer to bind
  47280. */
  47281. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47282. }
  47283. }
  47284. declare module BABYLON {
  47285. /**
  47286. * Creation options of the multi render target texture.
  47287. */
  47288. export interface IMultiRenderTargetOptions {
  47289. /**
  47290. * Define if the texture needs to create mip maps after render.
  47291. */
  47292. generateMipMaps?: boolean;
  47293. /**
  47294. * Define the types of all the draw buffers we want to create
  47295. */
  47296. types?: number[];
  47297. /**
  47298. * Define the sampling modes of all the draw buffers we want to create
  47299. */
  47300. samplingModes?: number[];
  47301. /**
  47302. * Define if a depth buffer is required
  47303. */
  47304. generateDepthBuffer?: boolean;
  47305. /**
  47306. * Define if a stencil buffer is required
  47307. */
  47308. generateStencilBuffer?: boolean;
  47309. /**
  47310. * Define if a depth texture is required instead of a depth buffer
  47311. */
  47312. generateDepthTexture?: boolean;
  47313. /**
  47314. * Define the number of desired draw buffers
  47315. */
  47316. textureCount?: number;
  47317. /**
  47318. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47319. */
  47320. doNotChangeAspectRatio?: boolean;
  47321. /**
  47322. * Define the default type of the buffers we are creating
  47323. */
  47324. defaultType?: number;
  47325. }
  47326. /**
  47327. * A multi render target, like a render target provides the ability to render to a texture.
  47328. * Unlike the render target, it can render to several draw buffers in one draw.
  47329. * This is specially interesting in deferred rendering or for any effects requiring more than
  47330. * just one color from a single pass.
  47331. */
  47332. export class MultiRenderTarget extends RenderTargetTexture {
  47333. private _internalTextures;
  47334. private _textures;
  47335. private _multiRenderTargetOptions;
  47336. /**
  47337. * Get if draw buffers are currently supported by the used hardware and browser.
  47338. */
  47339. get isSupported(): boolean;
  47340. /**
  47341. * Get the list of textures generated by the multi render target.
  47342. */
  47343. get textures(): Texture[];
  47344. /**
  47345. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47346. */
  47347. get depthTexture(): Texture;
  47348. /**
  47349. * Set the wrapping mode on U of all the textures we are rendering to.
  47350. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47351. */
  47352. set wrapU(wrap: number);
  47353. /**
  47354. * Set the wrapping mode on V of all the textures we are rendering to.
  47355. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47356. */
  47357. set wrapV(wrap: number);
  47358. /**
  47359. * Instantiate a new multi render target texture.
  47360. * A multi render target, like a render target provides the ability to render to a texture.
  47361. * Unlike the render target, it can render to several draw buffers in one draw.
  47362. * This is specially interesting in deferred rendering or for any effects requiring more than
  47363. * just one color from a single pass.
  47364. * @param name Define the name of the texture
  47365. * @param size Define the size of the buffers to render to
  47366. * @param count Define the number of target we are rendering into
  47367. * @param scene Define the scene the texture belongs to
  47368. * @param options Define the options used to create the multi render target
  47369. */
  47370. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47371. /** @hidden */
  47372. _rebuild(): void;
  47373. private _createInternalTextures;
  47374. private _createTextures;
  47375. /**
  47376. * Define the number of samples used if MSAA is enabled.
  47377. */
  47378. get samples(): number;
  47379. set samples(value: number);
  47380. /**
  47381. * Resize all the textures in the multi render target.
  47382. * Be carrefull as it will recreate all the data in the new texture.
  47383. * @param size Define the new size
  47384. */
  47385. resize(size: any): void;
  47386. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47387. /**
  47388. * Dispose the render targets and their associated resources
  47389. */
  47390. dispose(): void;
  47391. /**
  47392. * Release all the underlying texture used as draw buffers.
  47393. */
  47394. releaseInternalTextures(): void;
  47395. }
  47396. }
  47397. declare module BABYLON {
  47398. interface ThinEngine {
  47399. /**
  47400. * Unbind a list of render target textures from the webGL context
  47401. * This is used only when drawBuffer extension or webGL2 are active
  47402. * @param textures defines the render target textures to unbind
  47403. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47404. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47405. */
  47406. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47407. /**
  47408. * Create a multi render target texture
  47409. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47410. * @param size defines the size of the texture
  47411. * @param options defines the creation options
  47412. * @returns the cube texture as an InternalTexture
  47413. */
  47414. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47415. /**
  47416. * Update the sample count for a given multiple render target texture
  47417. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47418. * @param textures defines the textures to update
  47419. * @param samples defines the sample count to set
  47420. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47421. */
  47422. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47423. }
  47424. }
  47425. declare module BABYLON {
  47426. /**
  47427. * Class used to define an additional view for the engine
  47428. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47429. */
  47430. export class EngineView {
  47431. /** Defines the canvas where to render the view */
  47432. target: HTMLCanvasElement;
  47433. /** Defines an optional camera used to render the view (will use active camera else) */
  47434. camera?: Camera;
  47435. }
  47436. interface Engine {
  47437. /**
  47438. * Gets or sets the HTML element to use for attaching events
  47439. */
  47440. inputElement: Nullable<HTMLElement>;
  47441. /**
  47442. * Gets the current engine view
  47443. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47444. */
  47445. activeView: Nullable<EngineView>;
  47446. /** Gets or sets the list of views */
  47447. views: EngineView[];
  47448. /**
  47449. * Register a new child canvas
  47450. * @param canvas defines the canvas to register
  47451. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47452. * @returns the associated view
  47453. */
  47454. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47455. /**
  47456. * Remove a registered child canvas
  47457. * @param canvas defines the canvas to remove
  47458. * @returns the current engine
  47459. */
  47460. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47461. }
  47462. }
  47463. declare module BABYLON {
  47464. interface Engine {
  47465. /** @hidden */
  47466. _excludedCompressedTextures: string[];
  47467. /** @hidden */
  47468. _textureFormatInUse: string;
  47469. /**
  47470. * Gets the list of texture formats supported
  47471. */
  47472. readonly texturesSupported: Array<string>;
  47473. /**
  47474. * Gets the texture format in use
  47475. */
  47476. readonly textureFormatInUse: Nullable<string>;
  47477. /**
  47478. * Set the compressed texture extensions or file names to skip.
  47479. *
  47480. * @param skippedFiles defines the list of those texture files you want to skip
  47481. * Example: [".dds", ".env", "myfile.png"]
  47482. */
  47483. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47484. /**
  47485. * Set the compressed texture format to use, based on the formats you have, and the formats
  47486. * supported by the hardware / browser.
  47487. *
  47488. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47489. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47490. * to API arguments needed to compressed textures. This puts the burden on the container
  47491. * generator to house the arcane code for determining these for current & future formats.
  47492. *
  47493. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47494. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47495. *
  47496. * Note: The result of this call is not taken into account when a texture is base64.
  47497. *
  47498. * @param formatsAvailable defines the list of those format families you have created
  47499. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47500. *
  47501. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47502. * @returns The extension selected.
  47503. */
  47504. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47505. }
  47506. }
  47507. declare module BABYLON {
  47508. /**
  47509. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47510. */
  47511. export interface CubeMapInfo {
  47512. /**
  47513. * The pixel array for the front face.
  47514. * This is stored in format, left to right, up to down format.
  47515. */
  47516. front: Nullable<ArrayBufferView>;
  47517. /**
  47518. * The pixel array for the back face.
  47519. * This is stored in format, left to right, up to down format.
  47520. */
  47521. back: Nullable<ArrayBufferView>;
  47522. /**
  47523. * The pixel array for the left face.
  47524. * This is stored in format, left to right, up to down format.
  47525. */
  47526. left: Nullable<ArrayBufferView>;
  47527. /**
  47528. * The pixel array for the right face.
  47529. * This is stored in format, left to right, up to down format.
  47530. */
  47531. right: Nullable<ArrayBufferView>;
  47532. /**
  47533. * The pixel array for the up face.
  47534. * This is stored in format, left to right, up to down format.
  47535. */
  47536. up: Nullable<ArrayBufferView>;
  47537. /**
  47538. * The pixel array for the down face.
  47539. * This is stored in format, left to right, up to down format.
  47540. */
  47541. down: Nullable<ArrayBufferView>;
  47542. /**
  47543. * The size of the cubemap stored.
  47544. *
  47545. * Each faces will be size * size pixels.
  47546. */
  47547. size: number;
  47548. /**
  47549. * The format of the texture.
  47550. *
  47551. * RGBA, RGB.
  47552. */
  47553. format: number;
  47554. /**
  47555. * The type of the texture data.
  47556. *
  47557. * UNSIGNED_INT, FLOAT.
  47558. */
  47559. type: number;
  47560. /**
  47561. * Specifies whether the texture is in gamma space.
  47562. */
  47563. gammaSpace: boolean;
  47564. }
  47565. /**
  47566. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47567. */
  47568. export class PanoramaToCubeMapTools {
  47569. private static FACE_FRONT;
  47570. private static FACE_BACK;
  47571. private static FACE_RIGHT;
  47572. private static FACE_LEFT;
  47573. private static FACE_DOWN;
  47574. private static FACE_UP;
  47575. /**
  47576. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47577. *
  47578. * @param float32Array The source data.
  47579. * @param inputWidth The width of the input panorama.
  47580. * @param inputHeight The height of the input panorama.
  47581. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47582. * @return The cubemap data
  47583. */
  47584. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47585. private static CreateCubemapTexture;
  47586. private static CalcProjectionSpherical;
  47587. }
  47588. }
  47589. declare module BABYLON {
  47590. /**
  47591. * Helper class dealing with the extraction of spherical polynomial dataArray
  47592. * from a cube map.
  47593. */
  47594. export class CubeMapToSphericalPolynomialTools {
  47595. private static FileFaces;
  47596. /**
  47597. * Converts a texture to the according Spherical Polynomial data.
  47598. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47599. *
  47600. * @param texture The texture to extract the information from.
  47601. * @return The Spherical Polynomial data.
  47602. */
  47603. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47604. /**
  47605. * Converts a cubemap to the according Spherical Polynomial data.
  47606. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47607. *
  47608. * @param cubeInfo The Cube map to extract the information from.
  47609. * @return The Spherical Polynomial data.
  47610. */
  47611. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47612. }
  47613. }
  47614. declare module BABYLON {
  47615. interface BaseTexture {
  47616. /**
  47617. * Get the polynomial representation of the texture data.
  47618. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47619. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47620. */
  47621. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47622. }
  47623. }
  47624. declare module BABYLON {
  47625. /** @hidden */
  47626. export var rgbdEncodePixelShader: {
  47627. name: string;
  47628. shader: string;
  47629. };
  47630. }
  47631. declare module BABYLON {
  47632. /** @hidden */
  47633. export var rgbdDecodePixelShader: {
  47634. name: string;
  47635. shader: string;
  47636. };
  47637. }
  47638. declare module BABYLON {
  47639. /**
  47640. * Raw texture data and descriptor sufficient for WebGL texture upload
  47641. */
  47642. export interface EnvironmentTextureInfo {
  47643. /**
  47644. * Version of the environment map
  47645. */
  47646. version: number;
  47647. /**
  47648. * Width of image
  47649. */
  47650. width: number;
  47651. /**
  47652. * Irradiance information stored in the file.
  47653. */
  47654. irradiance: any;
  47655. /**
  47656. * Specular information stored in the file.
  47657. */
  47658. specular: any;
  47659. }
  47660. /**
  47661. * Defines One Image in the file. It requires only the position in the file
  47662. * as well as the length.
  47663. */
  47664. interface BufferImageData {
  47665. /**
  47666. * Length of the image data.
  47667. */
  47668. length: number;
  47669. /**
  47670. * Position of the data from the null terminator delimiting the end of the JSON.
  47671. */
  47672. position: number;
  47673. }
  47674. /**
  47675. * Defines the specular data enclosed in the file.
  47676. * This corresponds to the version 1 of the data.
  47677. */
  47678. export interface EnvironmentTextureSpecularInfoV1 {
  47679. /**
  47680. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47681. */
  47682. specularDataPosition?: number;
  47683. /**
  47684. * This contains all the images data needed to reconstruct the cubemap.
  47685. */
  47686. mipmaps: Array<BufferImageData>;
  47687. /**
  47688. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47689. */
  47690. lodGenerationScale: number;
  47691. }
  47692. /**
  47693. * Sets of helpers addressing the serialization and deserialization of environment texture
  47694. * stored in a BabylonJS env file.
  47695. * Those files are usually stored as .env files.
  47696. */
  47697. export class EnvironmentTextureTools {
  47698. /**
  47699. * Magic number identifying the env file.
  47700. */
  47701. private static _MagicBytes;
  47702. /**
  47703. * Gets the environment info from an env file.
  47704. * @param data The array buffer containing the .env bytes.
  47705. * @returns the environment file info (the json header) if successfully parsed.
  47706. */
  47707. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47708. /**
  47709. * Creates an environment texture from a loaded cube texture.
  47710. * @param texture defines the cube texture to convert in env file
  47711. * @return a promise containing the environment data if succesfull.
  47712. */
  47713. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47714. /**
  47715. * Creates a JSON representation of the spherical data.
  47716. * @param texture defines the texture containing the polynomials
  47717. * @return the JSON representation of the spherical info
  47718. */
  47719. private static _CreateEnvTextureIrradiance;
  47720. /**
  47721. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47722. * @param data the image data
  47723. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47724. * @return the views described by info providing access to the underlying buffer
  47725. */
  47726. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47727. /**
  47728. * Uploads the texture info contained in the env file to the GPU.
  47729. * @param texture defines the internal texture to upload to
  47730. * @param data defines the data to load
  47731. * @param info defines the texture info retrieved through the GetEnvInfo method
  47732. * @returns a promise
  47733. */
  47734. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47735. private static _OnImageReadyAsync;
  47736. /**
  47737. * Uploads the levels of image data to the GPU.
  47738. * @param texture defines the internal texture to upload to
  47739. * @param imageData defines the array buffer views of image data [mipmap][face]
  47740. * @returns a promise
  47741. */
  47742. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47743. /**
  47744. * Uploads spherical polynomials information to the texture.
  47745. * @param texture defines the texture we are trying to upload the information to
  47746. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47747. */
  47748. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47749. /** @hidden */
  47750. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47751. }
  47752. }
  47753. declare module BABYLON {
  47754. /**
  47755. * Contains position and normal vectors for a vertex
  47756. */
  47757. export class PositionNormalVertex {
  47758. /** the position of the vertex (defaut: 0,0,0) */
  47759. position: Vector3;
  47760. /** the normal of the vertex (defaut: 0,1,0) */
  47761. normal: Vector3;
  47762. /**
  47763. * Creates a PositionNormalVertex
  47764. * @param position the position of the vertex (defaut: 0,0,0)
  47765. * @param normal the normal of the vertex (defaut: 0,1,0)
  47766. */
  47767. constructor(
  47768. /** the position of the vertex (defaut: 0,0,0) */
  47769. position?: Vector3,
  47770. /** the normal of the vertex (defaut: 0,1,0) */
  47771. normal?: Vector3);
  47772. /**
  47773. * Clones the PositionNormalVertex
  47774. * @returns the cloned PositionNormalVertex
  47775. */
  47776. clone(): PositionNormalVertex;
  47777. }
  47778. /**
  47779. * Contains position, normal and uv vectors for a vertex
  47780. */
  47781. export class PositionNormalTextureVertex {
  47782. /** the position of the vertex (defaut: 0,0,0) */
  47783. position: Vector3;
  47784. /** the normal of the vertex (defaut: 0,1,0) */
  47785. normal: Vector3;
  47786. /** the uv of the vertex (default: 0,0) */
  47787. uv: Vector2;
  47788. /**
  47789. * Creates a PositionNormalTextureVertex
  47790. * @param position the position of the vertex (defaut: 0,0,0)
  47791. * @param normal the normal of the vertex (defaut: 0,1,0)
  47792. * @param uv the uv of the vertex (default: 0,0)
  47793. */
  47794. constructor(
  47795. /** the position of the vertex (defaut: 0,0,0) */
  47796. position?: Vector3,
  47797. /** the normal of the vertex (defaut: 0,1,0) */
  47798. normal?: Vector3,
  47799. /** the uv of the vertex (default: 0,0) */
  47800. uv?: Vector2);
  47801. /**
  47802. * Clones the PositionNormalTextureVertex
  47803. * @returns the cloned PositionNormalTextureVertex
  47804. */
  47805. clone(): PositionNormalTextureVertex;
  47806. }
  47807. }
  47808. declare module BABYLON {
  47809. /** @hidden */
  47810. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47811. private _genericAttributeLocation;
  47812. private _varyingLocationCount;
  47813. private _varyingLocationMap;
  47814. private _replacements;
  47815. private _textureCount;
  47816. private _uniforms;
  47817. lineProcessor(line: string): string;
  47818. attributeProcessor(attribute: string): string;
  47819. varyingProcessor(varying: string, isFragment: boolean): string;
  47820. uniformProcessor(uniform: string): string;
  47821. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47822. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47823. }
  47824. }
  47825. declare module BABYLON {
  47826. /**
  47827. * Container for accessors for natively-stored mesh data buffers.
  47828. */
  47829. class NativeDataBuffer extends DataBuffer {
  47830. /**
  47831. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47832. */
  47833. nativeIndexBuffer?: any;
  47834. /**
  47835. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47836. */
  47837. nativeVertexBuffer?: any;
  47838. }
  47839. /** @hidden */
  47840. class NativeTexture extends InternalTexture {
  47841. getInternalTexture(): InternalTexture;
  47842. getViewCount(): number;
  47843. }
  47844. /** @hidden */
  47845. export class NativeEngine extends Engine {
  47846. private readonly _native;
  47847. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47848. private readonly INVALID_HANDLE;
  47849. getHardwareScalingLevel(): number;
  47850. constructor();
  47851. /**
  47852. * Can be used to override the current requestAnimationFrame requester.
  47853. * @hidden
  47854. */
  47855. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47856. /**
  47857. * Override default engine behavior.
  47858. * @param color
  47859. * @param backBuffer
  47860. * @param depth
  47861. * @param stencil
  47862. */
  47863. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47864. /**
  47865. * Gets host document
  47866. * @returns the host document object
  47867. */
  47868. getHostDocument(): Nullable<Document>;
  47869. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47870. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47871. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47872. recordVertexArrayObject(vertexBuffers: {
  47873. [key: string]: VertexBuffer;
  47874. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47875. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47876. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47877. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47878. /**
  47879. * Draw a list of indexed primitives
  47880. * @param fillMode defines the primitive to use
  47881. * @param indexStart defines the starting index
  47882. * @param indexCount defines the number of index to draw
  47883. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47884. */
  47885. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47886. /**
  47887. * Draw a list of unindexed primitives
  47888. * @param fillMode defines the primitive to use
  47889. * @param verticesStart defines the index of first vertex to draw
  47890. * @param verticesCount defines the count of vertices to draw
  47891. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47892. */
  47893. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47894. createPipelineContext(): IPipelineContext;
  47895. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47896. /** @hidden */
  47897. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47898. /** @hidden */
  47899. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47900. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47901. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47902. protected _setProgram(program: WebGLProgram): void;
  47903. _releaseEffect(effect: Effect): void;
  47904. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47905. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47906. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47907. bindSamplers(effect: Effect): void;
  47908. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47909. getRenderWidth(useScreen?: boolean): number;
  47910. getRenderHeight(useScreen?: boolean): number;
  47911. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47912. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47913. /**
  47914. * Set the z offset to apply to current rendering
  47915. * @param value defines the offset to apply
  47916. */
  47917. setZOffset(value: number): void;
  47918. /**
  47919. * Gets the current value of the zOffset
  47920. * @returns the current zOffset state
  47921. */
  47922. getZOffset(): number;
  47923. /**
  47924. * Enable or disable depth buffering
  47925. * @param enable defines the state to set
  47926. */
  47927. setDepthBuffer(enable: boolean): void;
  47928. /**
  47929. * Gets a boolean indicating if depth writing is enabled
  47930. * @returns the current depth writing state
  47931. */
  47932. getDepthWrite(): boolean;
  47933. /**
  47934. * Enable or disable depth writing
  47935. * @param enable defines the state to set
  47936. */
  47937. setDepthWrite(enable: boolean): void;
  47938. /**
  47939. * Enable or disable color writing
  47940. * @param enable defines the state to set
  47941. */
  47942. setColorWrite(enable: boolean): void;
  47943. /**
  47944. * Gets a boolean indicating if color writing is enabled
  47945. * @returns the current color writing state
  47946. */
  47947. getColorWrite(): boolean;
  47948. /**
  47949. * Sets alpha constants used by some alpha blending modes
  47950. * @param r defines the red component
  47951. * @param g defines the green component
  47952. * @param b defines the blue component
  47953. * @param a defines the alpha component
  47954. */
  47955. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47956. /**
  47957. * Sets the current alpha mode
  47958. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47959. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47960. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47961. */
  47962. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47963. /**
  47964. * Gets the current alpha mode
  47965. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47966. * @returns the current alpha mode
  47967. */
  47968. getAlphaMode(): number;
  47969. setInt(uniform: WebGLUniformLocation, int: number): void;
  47970. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47971. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47972. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47973. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47974. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47975. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47976. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47977. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47978. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47979. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47980. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47981. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47982. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47983. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47984. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47985. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47986. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47987. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47988. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47989. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47990. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47991. wipeCaches(bruteForce?: boolean): void;
  47992. _createTexture(): WebGLTexture;
  47993. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47994. /**
  47995. * Usually called from Texture.ts.
  47996. * Passed information to create a WebGLTexture
  47997. * @param urlArg defines a value which contains one of the following:
  47998. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47999. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48000. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48001. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48002. * @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)
  48003. * @param scene needed for loading to the correct scene
  48004. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48005. * @param onLoad optional callback to be called upon successful completion
  48006. * @param onError optional callback to be called upon failure
  48007. * @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
  48008. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48009. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48010. * @param forcedExtension defines the extension to use to pick the right loader
  48011. * @param mimeType defines an optional mime type
  48012. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48013. */
  48014. 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;
  48015. /**
  48016. * Creates a cube texture
  48017. * @param rootUrl defines the url where the files to load is located
  48018. * @param scene defines the current scene
  48019. * @param files defines the list of files to load (1 per face)
  48020. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48021. * @param onLoad defines an optional callback raised when the texture is loaded
  48022. * @param onError defines an optional callback raised if there is an issue to load the texture
  48023. * @param format defines the format of the data
  48024. * @param forcedExtension defines the extension to use to pick the right loader
  48025. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48026. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48027. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48028. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48029. * @returns the cube texture as an InternalTexture
  48030. */
  48031. 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;
  48032. private _getSamplingFilter;
  48033. private static _GetNativeTextureFormat;
  48034. createRenderTargetTexture(size: number | {
  48035. width: number;
  48036. height: number;
  48037. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48038. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48039. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48040. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48041. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48042. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48043. /**
  48044. * Updates a dynamic vertex buffer.
  48045. * @param vertexBuffer the vertex buffer to update
  48046. * @param data the data used to update the vertex buffer
  48047. * @param byteOffset the byte offset of the data (optional)
  48048. * @param byteLength the byte length of the data (optional)
  48049. */
  48050. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48051. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48052. private _updateAnisotropicLevel;
  48053. private _getAddressMode;
  48054. /** @hidden */
  48055. _bindTexture(channel: number, texture: InternalTexture): void;
  48056. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48057. releaseEffects(): void;
  48058. /** @hidden */
  48059. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48060. /** @hidden */
  48061. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48062. /** @hidden */
  48063. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48064. /** @hidden */
  48065. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48066. }
  48067. }
  48068. declare module BABYLON {
  48069. /**
  48070. * Gather the list of clipboard event types as constants.
  48071. */
  48072. export class ClipboardEventTypes {
  48073. /**
  48074. * The clipboard event is fired when a copy command is active (pressed).
  48075. */
  48076. static readonly COPY: number;
  48077. /**
  48078. * The clipboard event is fired when a cut command is active (pressed).
  48079. */
  48080. static readonly CUT: number;
  48081. /**
  48082. * The clipboard event is fired when a paste command is active (pressed).
  48083. */
  48084. static readonly PASTE: number;
  48085. }
  48086. /**
  48087. * This class is used to store clipboard related info for the onClipboardObservable event.
  48088. */
  48089. export class ClipboardInfo {
  48090. /**
  48091. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48092. */
  48093. type: number;
  48094. /**
  48095. * Defines the related dom event
  48096. */
  48097. event: ClipboardEvent;
  48098. /**
  48099. *Creates an instance of ClipboardInfo.
  48100. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48101. * @param event Defines the related dom event
  48102. */
  48103. constructor(
  48104. /**
  48105. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48106. */
  48107. type: number,
  48108. /**
  48109. * Defines the related dom event
  48110. */
  48111. event: ClipboardEvent);
  48112. /**
  48113. * Get the clipboard event's type from the keycode.
  48114. * @param keyCode Defines the keyCode for the current keyboard event.
  48115. * @return {number}
  48116. */
  48117. static GetTypeFromCharacter(keyCode: number): number;
  48118. }
  48119. }
  48120. declare module BABYLON {
  48121. /**
  48122. * Google Daydream controller
  48123. */
  48124. export class DaydreamController extends WebVRController {
  48125. /**
  48126. * Base Url for the controller model.
  48127. */
  48128. static MODEL_BASE_URL: string;
  48129. /**
  48130. * File name for the controller model.
  48131. */
  48132. static MODEL_FILENAME: string;
  48133. /**
  48134. * Gamepad Id prefix used to identify Daydream Controller.
  48135. */
  48136. static readonly GAMEPAD_ID_PREFIX: string;
  48137. /**
  48138. * Creates a new DaydreamController from a gamepad
  48139. * @param vrGamepad the gamepad that the controller should be created from
  48140. */
  48141. constructor(vrGamepad: any);
  48142. /**
  48143. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48144. * @param scene scene in which to add meshes
  48145. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48146. */
  48147. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48148. /**
  48149. * Called once for each button that changed state since the last frame
  48150. * @param buttonIdx Which button index changed
  48151. * @param state New state of the button
  48152. * @param changes Which properties on the state changed since last frame
  48153. */
  48154. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48155. }
  48156. }
  48157. declare module BABYLON {
  48158. /**
  48159. * Gear VR Controller
  48160. */
  48161. export class GearVRController extends WebVRController {
  48162. /**
  48163. * Base Url for the controller model.
  48164. */
  48165. static MODEL_BASE_URL: string;
  48166. /**
  48167. * File name for the controller model.
  48168. */
  48169. static MODEL_FILENAME: string;
  48170. /**
  48171. * Gamepad Id prefix used to identify this controller.
  48172. */
  48173. static readonly GAMEPAD_ID_PREFIX: string;
  48174. private readonly _buttonIndexToObservableNameMap;
  48175. /**
  48176. * Creates a new GearVRController from a gamepad
  48177. * @param vrGamepad the gamepad that the controller should be created from
  48178. */
  48179. constructor(vrGamepad: any);
  48180. /**
  48181. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48182. * @param scene scene in which to add meshes
  48183. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48184. */
  48185. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): 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. }
  48195. declare module BABYLON {
  48196. /**
  48197. * Generic Controller
  48198. */
  48199. export class GenericController extends WebVRController {
  48200. /**
  48201. * Base Url for the controller model.
  48202. */
  48203. static readonly MODEL_BASE_URL: string;
  48204. /**
  48205. * File name for the controller model.
  48206. */
  48207. static readonly MODEL_FILENAME: string;
  48208. /**
  48209. * Creates a new GenericController from a gamepad
  48210. * @param vrGamepad the gamepad that the controller should be created from
  48211. */
  48212. constructor(vrGamepad: any);
  48213. /**
  48214. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48215. * @param scene scene in which to add meshes
  48216. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48217. */
  48218. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48219. /**
  48220. * Called once for each button that changed state since the last frame
  48221. * @param buttonIdx Which button index changed
  48222. * @param state New state of the button
  48223. * @param changes Which properties on the state changed since last frame
  48224. */
  48225. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48226. }
  48227. }
  48228. declare module BABYLON {
  48229. /**
  48230. * Oculus Touch Controller
  48231. */
  48232. export class OculusTouchController extends WebVRController {
  48233. /**
  48234. * Base Url for the controller model.
  48235. */
  48236. static MODEL_BASE_URL: string;
  48237. /**
  48238. * File name for the left controller model.
  48239. */
  48240. static MODEL_LEFT_FILENAME: string;
  48241. /**
  48242. * File name for the right controller model.
  48243. */
  48244. static MODEL_RIGHT_FILENAME: string;
  48245. /**
  48246. * Base Url for the Quest controller model.
  48247. */
  48248. static QUEST_MODEL_BASE_URL: string;
  48249. /**
  48250. * @hidden
  48251. * If the controllers are running on a device that needs the updated Quest controller models
  48252. */
  48253. static _IsQuest: boolean;
  48254. /**
  48255. * Fired when the secondary trigger on this controller is modified
  48256. */
  48257. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48258. /**
  48259. * Fired when the thumb rest on this controller is modified
  48260. */
  48261. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48262. /**
  48263. * Creates a new OculusTouchController from a gamepad
  48264. * @param vrGamepad the gamepad that the controller should be created from
  48265. */
  48266. constructor(vrGamepad: any);
  48267. /**
  48268. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48269. * @param scene scene in which to add meshes
  48270. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48271. */
  48272. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48273. /**
  48274. * Fired when the A button on this controller is modified
  48275. */
  48276. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48277. /**
  48278. * Fired when the B button on this controller is modified
  48279. */
  48280. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48281. /**
  48282. * Fired when the X button on this controller is modified
  48283. */
  48284. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48285. /**
  48286. * Fired when the Y button on this controller is modified
  48287. */
  48288. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48289. /**
  48290. * Called once for each button that changed state since the last frame
  48291. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48292. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48293. * 2) secondary trigger (same)
  48294. * 3) A (right) X (left), touch, pressed = value
  48295. * 4) B / Y
  48296. * 5) thumb rest
  48297. * @param buttonIdx Which button index changed
  48298. * @param state New state of the button
  48299. * @param changes Which properties on the state changed since last frame
  48300. */
  48301. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48302. }
  48303. }
  48304. declare module BABYLON {
  48305. /**
  48306. * Vive Controller
  48307. */
  48308. export class ViveController extends WebVRController {
  48309. /**
  48310. * Base Url for the controller model.
  48311. */
  48312. static MODEL_BASE_URL: string;
  48313. /**
  48314. * File name for the controller model.
  48315. */
  48316. static MODEL_FILENAME: string;
  48317. /**
  48318. * Creates a new ViveController from a gamepad
  48319. * @param vrGamepad the gamepad that the controller should be created from
  48320. */
  48321. constructor(vrGamepad: any);
  48322. /**
  48323. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48324. * @param scene scene in which to add meshes
  48325. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48326. */
  48327. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48328. /**
  48329. * Fired when the left button on this controller is modified
  48330. */
  48331. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48332. /**
  48333. * Fired when the right button on this controller is modified
  48334. */
  48335. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48336. /**
  48337. * Fired when the menu button on this controller is modified
  48338. */
  48339. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48340. /**
  48341. * Called once for each button that changed state since the last frame
  48342. * Vive mapping:
  48343. * 0: touchpad
  48344. * 1: trigger
  48345. * 2: left AND right buttons
  48346. * 3: menu button
  48347. * @param buttonIdx Which button index changed
  48348. * @param state New state of the button
  48349. * @param changes Which properties on the state changed since last frame
  48350. */
  48351. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48352. }
  48353. }
  48354. declare module BABYLON {
  48355. /**
  48356. * Defines the WindowsMotionController object that the state of the windows motion controller
  48357. */
  48358. export class WindowsMotionController extends WebVRController {
  48359. /**
  48360. * The base url used to load the left and right controller models
  48361. */
  48362. static MODEL_BASE_URL: string;
  48363. /**
  48364. * The name of the left controller model file
  48365. */
  48366. static MODEL_LEFT_FILENAME: string;
  48367. /**
  48368. * The name of the right controller model file
  48369. */
  48370. static MODEL_RIGHT_FILENAME: string;
  48371. /**
  48372. * The controller name prefix for this controller type
  48373. */
  48374. static readonly GAMEPAD_ID_PREFIX: string;
  48375. /**
  48376. * The controller id pattern for this controller type
  48377. */
  48378. private static readonly GAMEPAD_ID_PATTERN;
  48379. private _loadedMeshInfo;
  48380. protected readonly _mapping: {
  48381. buttons: string[];
  48382. buttonMeshNames: {
  48383. 'trigger': string;
  48384. 'menu': string;
  48385. 'grip': string;
  48386. 'thumbstick': string;
  48387. 'trackpad': string;
  48388. };
  48389. buttonObservableNames: {
  48390. 'trigger': string;
  48391. 'menu': string;
  48392. 'grip': string;
  48393. 'thumbstick': string;
  48394. 'trackpad': string;
  48395. };
  48396. axisMeshNames: string[];
  48397. pointingPoseMeshName: string;
  48398. };
  48399. /**
  48400. * Fired when the trackpad on this controller is clicked
  48401. */
  48402. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48403. /**
  48404. * Fired when the trackpad on this controller is modified
  48405. */
  48406. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48407. /**
  48408. * The current x and y values of this controller's trackpad
  48409. */
  48410. trackpad: StickValues;
  48411. /**
  48412. * Creates a new WindowsMotionController from a gamepad
  48413. * @param vrGamepad the gamepad that the controller should be created from
  48414. */
  48415. constructor(vrGamepad: any);
  48416. /**
  48417. * Fired when the trigger on this controller is modified
  48418. */
  48419. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48420. /**
  48421. * Fired when the menu button on this controller is modified
  48422. */
  48423. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48424. /**
  48425. * Fired when the grip button on this controller is modified
  48426. */
  48427. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48428. /**
  48429. * Fired when the thumbstick button on this controller is modified
  48430. */
  48431. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48432. /**
  48433. * Fired when the touchpad button on this controller is modified
  48434. */
  48435. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48436. /**
  48437. * Fired when the touchpad values on this controller are modified
  48438. */
  48439. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48440. protected _updateTrackpad(): void;
  48441. /**
  48442. * Called once per frame by the engine.
  48443. */
  48444. update(): void;
  48445. /**
  48446. * Called once for each button that changed state since the last frame
  48447. * @param buttonIdx Which button index changed
  48448. * @param state New state of the button
  48449. * @param changes Which properties on the state changed since last frame
  48450. */
  48451. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48452. /**
  48453. * Moves the buttons on the controller mesh based on their current state
  48454. * @param buttonName the name of the button to move
  48455. * @param buttonValue the value of the button which determines the buttons new position
  48456. */
  48457. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48458. /**
  48459. * Moves the axis on the controller mesh based on its current state
  48460. * @param axis the index of the axis
  48461. * @param axisValue the value of the axis which determines the meshes new position
  48462. * @hidden
  48463. */
  48464. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48465. /**
  48466. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48467. * @param scene scene in which to add meshes
  48468. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48469. */
  48470. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48471. /**
  48472. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48473. * can be transformed by button presses and axes values, based on this._mapping.
  48474. *
  48475. * @param scene scene in which the meshes exist
  48476. * @param meshes list of meshes that make up the controller model to process
  48477. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48478. */
  48479. private processModel;
  48480. private createMeshInfo;
  48481. /**
  48482. * Gets the ray of the controller in the direction the controller is pointing
  48483. * @param length the length the resulting ray should be
  48484. * @returns a ray in the direction the controller is pointing
  48485. */
  48486. getForwardRay(length?: number): Ray;
  48487. /**
  48488. * Disposes of the controller
  48489. */
  48490. dispose(): void;
  48491. }
  48492. /**
  48493. * This class represents a new windows motion controller in XR.
  48494. */
  48495. export class XRWindowsMotionController extends WindowsMotionController {
  48496. /**
  48497. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48498. */
  48499. protected readonly _mapping: {
  48500. buttons: string[];
  48501. buttonMeshNames: {
  48502. 'trigger': string;
  48503. 'menu': string;
  48504. 'grip': string;
  48505. 'thumbstick': string;
  48506. 'trackpad': string;
  48507. };
  48508. buttonObservableNames: {
  48509. 'trigger': string;
  48510. 'menu': string;
  48511. 'grip': string;
  48512. 'thumbstick': string;
  48513. 'trackpad': string;
  48514. };
  48515. axisMeshNames: string[];
  48516. pointingPoseMeshName: string;
  48517. };
  48518. /**
  48519. * Construct a new XR-Based windows motion controller
  48520. *
  48521. * @param gamepadInfo the gamepad object from the browser
  48522. */
  48523. constructor(gamepadInfo: any);
  48524. /**
  48525. * holds the thumbstick values (X,Y)
  48526. */
  48527. thumbstickValues: StickValues;
  48528. /**
  48529. * Fired when the thumbstick on this controller is clicked
  48530. */
  48531. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48532. /**
  48533. * Fired when the thumbstick on this controller is modified
  48534. */
  48535. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48536. /**
  48537. * Fired when the touchpad button on this controller is modified
  48538. */
  48539. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48540. /**
  48541. * Fired when the touchpad values on this controller are modified
  48542. */
  48543. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48544. /**
  48545. * Fired when the thumbstick button on this controller is modified
  48546. * here to prevent breaking changes
  48547. */
  48548. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48549. /**
  48550. * updating the thumbstick(!) and not the trackpad.
  48551. * This is named this way due to the difference between WebVR and XR and to avoid
  48552. * changing the parent class.
  48553. */
  48554. protected _updateTrackpad(): void;
  48555. /**
  48556. * Disposes the class with joy
  48557. */
  48558. dispose(): void;
  48559. }
  48560. }
  48561. declare module BABYLON {
  48562. /**
  48563. * Class containing static functions to help procedurally build meshes
  48564. */
  48565. export class PolyhedronBuilder {
  48566. /**
  48567. * Creates a polyhedron mesh
  48568. * * 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
  48569. * * The parameter `size` (positive float, default 1) sets the polygon size
  48570. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48571. * * 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`
  48572. * * 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
  48573. * * 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)`)
  48574. * * 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
  48575. * * 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
  48576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48577. * * 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
  48578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48579. * @param name defines the name of the mesh
  48580. * @param options defines the options used to create the mesh
  48581. * @param scene defines the hosting scene
  48582. * @returns the polyhedron mesh
  48583. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48584. */
  48585. static CreatePolyhedron(name: string, options: {
  48586. type?: number;
  48587. size?: number;
  48588. sizeX?: number;
  48589. sizeY?: number;
  48590. sizeZ?: number;
  48591. custom?: any;
  48592. faceUV?: Vector4[];
  48593. faceColors?: Color4[];
  48594. flat?: boolean;
  48595. updatable?: boolean;
  48596. sideOrientation?: number;
  48597. frontUVs?: Vector4;
  48598. backUVs?: Vector4;
  48599. }, scene?: Nullable<Scene>): Mesh;
  48600. }
  48601. }
  48602. declare module BABYLON {
  48603. /**
  48604. * Gizmo that enables scaling a mesh along 3 axis
  48605. */
  48606. export class ScaleGizmo extends Gizmo {
  48607. /**
  48608. * Internal gizmo used for interactions on the x axis
  48609. */
  48610. xGizmo: AxisScaleGizmo;
  48611. /**
  48612. * Internal gizmo used for interactions on the y axis
  48613. */
  48614. yGizmo: AxisScaleGizmo;
  48615. /**
  48616. * Internal gizmo used for interactions on the z axis
  48617. */
  48618. zGizmo: AxisScaleGizmo;
  48619. /**
  48620. * Internal gizmo used to scale all axis equally
  48621. */
  48622. uniformScaleGizmo: AxisScaleGizmo;
  48623. private _meshAttached;
  48624. private _updateGizmoRotationToMatchAttachedMesh;
  48625. private _snapDistance;
  48626. private _scaleRatio;
  48627. private _uniformScalingMesh;
  48628. private _octahedron;
  48629. private _sensitivity;
  48630. /** Fires an event when any of it's sub gizmos are dragged */
  48631. onDragStartObservable: Observable<unknown>;
  48632. /** Fires an event when any of it's sub gizmos are released from dragging */
  48633. onDragEndObservable: Observable<unknown>;
  48634. get attachedMesh(): Nullable<AbstractMesh>;
  48635. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48636. /**
  48637. * Creates a ScaleGizmo
  48638. * @param gizmoLayer The utility layer the gizmo will be added to
  48639. */
  48640. constructor(gizmoLayer?: UtilityLayerRenderer);
  48641. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48642. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48643. /**
  48644. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48645. */
  48646. set snapDistance(value: number);
  48647. get snapDistance(): number;
  48648. /**
  48649. * Ratio for the scale of the gizmo (Default: 1)
  48650. */
  48651. set scaleRatio(value: number);
  48652. get scaleRatio(): number;
  48653. /**
  48654. * Sensitivity factor for dragging (Default: 1)
  48655. */
  48656. set sensitivity(value: number);
  48657. get sensitivity(): number;
  48658. /**
  48659. * Disposes of the gizmo
  48660. */
  48661. dispose(): void;
  48662. }
  48663. }
  48664. declare module BABYLON {
  48665. /**
  48666. * Single axis scale gizmo
  48667. */
  48668. export class AxisScaleGizmo extends Gizmo {
  48669. /**
  48670. * Drag behavior responsible for the gizmos dragging interactions
  48671. */
  48672. dragBehavior: PointerDragBehavior;
  48673. private _pointerObserver;
  48674. /**
  48675. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48676. */
  48677. snapDistance: number;
  48678. /**
  48679. * Event that fires each time the gizmo snaps to a new location.
  48680. * * snapDistance is the the change in distance
  48681. */
  48682. onSnapObservable: Observable<{
  48683. snapDistance: number;
  48684. }>;
  48685. /**
  48686. * If the scaling operation should be done on all axis (default: false)
  48687. */
  48688. uniformScaling: boolean;
  48689. /**
  48690. * Custom sensitivity value for the drag strength
  48691. */
  48692. sensitivity: number;
  48693. private _isEnabled;
  48694. private _parent;
  48695. private _arrow;
  48696. private _coloredMaterial;
  48697. private _hoverMaterial;
  48698. /**
  48699. * Creates an AxisScaleGizmo
  48700. * @param gizmoLayer The utility layer the gizmo will be added to
  48701. * @param dragAxis The axis which the gizmo will be able to scale on
  48702. * @param color The color of the gizmo
  48703. */
  48704. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48705. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48706. /**
  48707. * If the gizmo is enabled
  48708. */
  48709. set isEnabled(value: boolean);
  48710. get isEnabled(): boolean;
  48711. /**
  48712. * Disposes of the gizmo
  48713. */
  48714. dispose(): void;
  48715. /**
  48716. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48717. * @param mesh The mesh to replace the default mesh of the gizmo
  48718. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48719. */
  48720. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48721. }
  48722. }
  48723. declare module BABYLON {
  48724. /**
  48725. * Bounding box gizmo
  48726. */
  48727. export class BoundingBoxGizmo extends Gizmo {
  48728. private _lineBoundingBox;
  48729. private _rotateSpheresParent;
  48730. private _scaleBoxesParent;
  48731. private _boundingDimensions;
  48732. private _renderObserver;
  48733. private _pointerObserver;
  48734. private _scaleDragSpeed;
  48735. private _tmpQuaternion;
  48736. private _tmpVector;
  48737. private _tmpRotationMatrix;
  48738. /**
  48739. * 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)
  48740. */
  48741. ignoreChildren: boolean;
  48742. /**
  48743. * 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)
  48744. */
  48745. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48746. /**
  48747. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48748. */
  48749. rotationSphereSize: number;
  48750. /**
  48751. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48752. */
  48753. scaleBoxSize: number;
  48754. /**
  48755. * 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)
  48756. */
  48757. fixedDragMeshScreenSize: boolean;
  48758. /**
  48759. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48760. */
  48761. fixedDragMeshScreenSizeDistanceFactor: number;
  48762. /**
  48763. * Fired when a rotation sphere or scale box is dragged
  48764. */
  48765. onDragStartObservable: Observable<{}>;
  48766. /**
  48767. * Fired when a scale box is dragged
  48768. */
  48769. onScaleBoxDragObservable: Observable<{}>;
  48770. /**
  48771. * Fired when a scale box drag is ended
  48772. */
  48773. onScaleBoxDragEndObservable: Observable<{}>;
  48774. /**
  48775. * Fired when a rotation sphere is dragged
  48776. */
  48777. onRotationSphereDragObservable: Observable<{}>;
  48778. /**
  48779. * Fired when a rotation sphere drag is ended
  48780. */
  48781. onRotationSphereDragEndObservable: Observable<{}>;
  48782. /**
  48783. * 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)
  48784. */
  48785. scalePivot: Nullable<Vector3>;
  48786. /**
  48787. * Mesh used as a pivot to rotate the attached mesh
  48788. */
  48789. private _anchorMesh;
  48790. private _existingMeshScale;
  48791. private _dragMesh;
  48792. private pointerDragBehavior;
  48793. private coloredMaterial;
  48794. private hoverColoredMaterial;
  48795. /**
  48796. * Sets the color of the bounding box gizmo
  48797. * @param color the color to set
  48798. */
  48799. setColor(color: Color3): void;
  48800. /**
  48801. * Creates an BoundingBoxGizmo
  48802. * @param gizmoLayer The utility layer the gizmo will be added to
  48803. * @param color The color of the gizmo
  48804. */
  48805. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48806. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48807. private _selectNode;
  48808. /**
  48809. * Updates the bounding box information for the Gizmo
  48810. */
  48811. updateBoundingBox(): void;
  48812. private _updateRotationSpheres;
  48813. private _updateScaleBoxes;
  48814. /**
  48815. * Enables rotation on the specified axis and disables rotation on the others
  48816. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48817. */
  48818. setEnabledRotationAxis(axis: string): void;
  48819. /**
  48820. * Enables/disables scaling
  48821. * @param enable if scaling should be enabled
  48822. * @param homogeneousScaling defines if scaling should only be homogeneous
  48823. */
  48824. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  48825. private _updateDummy;
  48826. /**
  48827. * Enables a pointer drag behavior on the bounding box of the gizmo
  48828. */
  48829. enableDragBehavior(): void;
  48830. /**
  48831. * Disposes of the gizmo
  48832. */
  48833. dispose(): void;
  48834. /**
  48835. * 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)
  48836. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48837. * @returns the bounding box mesh with the passed in mesh as a child
  48838. */
  48839. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48840. /**
  48841. * CustomMeshes are not supported by this gizmo
  48842. * @param mesh The mesh to replace the default mesh of the gizmo
  48843. */
  48844. setCustomMesh(mesh: Mesh): void;
  48845. }
  48846. }
  48847. declare module BABYLON {
  48848. /**
  48849. * Single plane rotation gizmo
  48850. */
  48851. export class PlaneRotationGizmo extends Gizmo {
  48852. /**
  48853. * Drag behavior responsible for the gizmos dragging interactions
  48854. */
  48855. dragBehavior: PointerDragBehavior;
  48856. private _pointerObserver;
  48857. /**
  48858. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48859. */
  48860. snapDistance: number;
  48861. /**
  48862. * Event that fires each time the gizmo snaps to a new location.
  48863. * * snapDistance is the the change in distance
  48864. */
  48865. onSnapObservable: Observable<{
  48866. snapDistance: number;
  48867. }>;
  48868. private _isEnabled;
  48869. private _parent;
  48870. /**
  48871. * Creates a PlaneRotationGizmo
  48872. * @param gizmoLayer The utility layer the gizmo will be added to
  48873. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48874. * @param color The color of the gizmo
  48875. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48876. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48877. */
  48878. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48879. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48880. /**
  48881. * If the gizmo is enabled
  48882. */
  48883. set isEnabled(value: boolean);
  48884. get isEnabled(): boolean;
  48885. /**
  48886. * Disposes of the gizmo
  48887. */
  48888. dispose(): void;
  48889. }
  48890. }
  48891. declare module BABYLON {
  48892. /**
  48893. * Gizmo that enables rotating a mesh along 3 axis
  48894. */
  48895. export class RotationGizmo extends Gizmo {
  48896. /**
  48897. * Internal gizmo used for interactions on the x axis
  48898. */
  48899. xGizmo: PlaneRotationGizmo;
  48900. /**
  48901. * Internal gizmo used for interactions on the y axis
  48902. */
  48903. yGizmo: PlaneRotationGizmo;
  48904. /**
  48905. * Internal gizmo used for interactions on the z axis
  48906. */
  48907. zGizmo: PlaneRotationGizmo;
  48908. /** Fires an event when any of it's sub gizmos are dragged */
  48909. onDragStartObservable: Observable<unknown>;
  48910. /** Fires an event when any of it's sub gizmos are released from dragging */
  48911. onDragEndObservable: Observable<unknown>;
  48912. private _meshAttached;
  48913. get attachedMesh(): Nullable<AbstractMesh>;
  48914. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48915. /**
  48916. * Creates a RotationGizmo
  48917. * @param gizmoLayer The utility layer the gizmo will be added to
  48918. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48919. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48920. */
  48921. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48922. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48923. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48924. /**
  48925. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48926. */
  48927. set snapDistance(value: number);
  48928. get snapDistance(): number;
  48929. /**
  48930. * Ratio for the scale of the gizmo (Default: 1)
  48931. */
  48932. set scaleRatio(value: number);
  48933. get scaleRatio(): number;
  48934. /**
  48935. * Disposes of the gizmo
  48936. */
  48937. dispose(): void;
  48938. /**
  48939. * CustomMeshes are not supported by this gizmo
  48940. * @param mesh The mesh to replace the default mesh of the gizmo
  48941. */
  48942. setCustomMesh(mesh: Mesh): void;
  48943. }
  48944. }
  48945. declare module BABYLON {
  48946. /**
  48947. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48948. */
  48949. export class GizmoManager implements IDisposable {
  48950. private scene;
  48951. /**
  48952. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48953. */
  48954. gizmos: {
  48955. positionGizmo: Nullable<PositionGizmo>;
  48956. rotationGizmo: Nullable<RotationGizmo>;
  48957. scaleGizmo: Nullable<ScaleGizmo>;
  48958. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48959. };
  48960. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48961. clearGizmoOnEmptyPointerEvent: boolean;
  48962. /** Fires an event when the manager is attached to a mesh */
  48963. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48964. private _gizmosEnabled;
  48965. private _pointerObserver;
  48966. private _attachedMesh;
  48967. private _boundingBoxColor;
  48968. private _defaultUtilityLayer;
  48969. private _defaultKeepDepthUtilityLayer;
  48970. /**
  48971. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48972. */
  48973. boundingBoxDragBehavior: SixDofDragBehavior;
  48974. /**
  48975. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48976. */
  48977. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48978. /**
  48979. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48980. */
  48981. usePointerToAttachGizmos: boolean;
  48982. /**
  48983. * Utility layer that the bounding box gizmo belongs to
  48984. */
  48985. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48986. /**
  48987. * Utility layer that all gizmos besides bounding box belong to
  48988. */
  48989. get utilityLayer(): UtilityLayerRenderer;
  48990. /**
  48991. * Instatiates a gizmo manager
  48992. * @param scene the scene to overlay the gizmos on top of
  48993. */
  48994. constructor(scene: Scene);
  48995. /**
  48996. * Attaches a set of gizmos to the specified mesh
  48997. * @param mesh The mesh the gizmo's should be attached to
  48998. */
  48999. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49000. /**
  49001. * If the position gizmo is enabled
  49002. */
  49003. set positionGizmoEnabled(value: boolean);
  49004. get positionGizmoEnabled(): boolean;
  49005. /**
  49006. * If the rotation gizmo is enabled
  49007. */
  49008. set rotationGizmoEnabled(value: boolean);
  49009. get rotationGizmoEnabled(): boolean;
  49010. /**
  49011. * If the scale gizmo is enabled
  49012. */
  49013. set scaleGizmoEnabled(value: boolean);
  49014. get scaleGizmoEnabled(): boolean;
  49015. /**
  49016. * If the boundingBox gizmo is enabled
  49017. */
  49018. set boundingBoxGizmoEnabled(value: boolean);
  49019. get boundingBoxGizmoEnabled(): boolean;
  49020. /**
  49021. * Disposes of the gizmo manager
  49022. */
  49023. dispose(): void;
  49024. }
  49025. }
  49026. declare module BABYLON {
  49027. /**
  49028. * A directional light is defined by a direction (what a surprise!).
  49029. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49030. * 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.
  49031. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49032. */
  49033. export class DirectionalLight extends ShadowLight {
  49034. private _shadowFrustumSize;
  49035. /**
  49036. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49037. */
  49038. get shadowFrustumSize(): number;
  49039. /**
  49040. * Specifies a fix frustum size for the shadow generation.
  49041. */
  49042. set shadowFrustumSize(value: number);
  49043. private _shadowOrthoScale;
  49044. /**
  49045. * Gets the shadow projection scale against the optimal computed one.
  49046. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49047. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49048. */
  49049. get shadowOrthoScale(): number;
  49050. /**
  49051. * Sets the shadow projection scale against the optimal computed one.
  49052. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49053. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49054. */
  49055. set shadowOrthoScale(value: number);
  49056. /**
  49057. * Automatically compute the projection matrix to best fit (including all the casters)
  49058. * on each frame.
  49059. */
  49060. autoUpdateExtends: boolean;
  49061. /**
  49062. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49063. * on each frame. autoUpdateExtends must be set to true for this to work
  49064. */
  49065. autoCalcShadowZBounds: boolean;
  49066. private _orthoLeft;
  49067. private _orthoRight;
  49068. private _orthoTop;
  49069. private _orthoBottom;
  49070. /**
  49071. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49072. * The directional light is emitted from everywhere in the given direction.
  49073. * It can cast shadows.
  49074. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49075. * @param name The friendly name of the light
  49076. * @param direction The direction of the light
  49077. * @param scene The scene the light belongs to
  49078. */
  49079. constructor(name: string, direction: Vector3, scene: Scene);
  49080. /**
  49081. * Returns the string "DirectionalLight".
  49082. * @return The class name
  49083. */
  49084. getClassName(): string;
  49085. /**
  49086. * Returns the integer 1.
  49087. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49088. */
  49089. getTypeID(): number;
  49090. /**
  49091. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49092. * Returns the DirectionalLight Shadow projection matrix.
  49093. */
  49094. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49095. /**
  49096. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49097. * Returns the DirectionalLight Shadow projection matrix.
  49098. */
  49099. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49100. /**
  49101. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49102. * Returns the DirectionalLight Shadow projection matrix.
  49103. */
  49104. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49105. protected _buildUniformLayout(): void;
  49106. /**
  49107. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49108. * @param effect The effect to update
  49109. * @param lightIndex The index of the light in the effect to update
  49110. * @returns The directional light
  49111. */
  49112. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49113. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49114. /**
  49115. * Gets the minZ used for shadow according to both the scene and the light.
  49116. *
  49117. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49118. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49119. * @param activeCamera The camera we are returning the min for
  49120. * @returns the depth min z
  49121. */
  49122. getDepthMinZ(activeCamera: Camera): number;
  49123. /**
  49124. * Gets the maxZ used for shadow according to both the scene and the light.
  49125. *
  49126. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49127. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49128. * @param activeCamera The camera we are returning the max for
  49129. * @returns the depth max z
  49130. */
  49131. getDepthMaxZ(activeCamera: Camera): number;
  49132. /**
  49133. * Prepares the list of defines specific to the light type.
  49134. * @param defines the list of defines
  49135. * @param lightIndex defines the index of the light for the effect
  49136. */
  49137. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49138. }
  49139. }
  49140. declare module BABYLON {
  49141. /**
  49142. * Class containing static functions to help procedurally build meshes
  49143. */
  49144. export class HemisphereBuilder {
  49145. /**
  49146. * Creates a hemisphere mesh
  49147. * @param name defines the name of the mesh
  49148. * @param options defines the options used to create the mesh
  49149. * @param scene defines the hosting scene
  49150. * @returns the hemisphere mesh
  49151. */
  49152. static CreateHemisphere(name: string, options: {
  49153. segments?: number;
  49154. diameter?: number;
  49155. sideOrientation?: number;
  49156. }, scene: any): Mesh;
  49157. }
  49158. }
  49159. declare module BABYLON {
  49160. /**
  49161. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49162. * These values define a cone of light starting from the position, emitting toward the direction.
  49163. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49164. * and the exponent defines the speed of the decay of the light with distance (reach).
  49165. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49166. */
  49167. export class SpotLight extends ShadowLight {
  49168. private _angle;
  49169. private _innerAngle;
  49170. private _cosHalfAngle;
  49171. private _lightAngleScale;
  49172. private _lightAngleOffset;
  49173. /**
  49174. * Gets the cone angle of the spot light in Radians.
  49175. */
  49176. get angle(): number;
  49177. /**
  49178. * Sets the cone angle of the spot light in Radians.
  49179. */
  49180. set angle(value: number);
  49181. /**
  49182. * Only used in gltf falloff mode, this defines the angle where
  49183. * the directional falloff will start before cutting at angle which could be seen
  49184. * as outer angle.
  49185. */
  49186. get innerAngle(): number;
  49187. /**
  49188. * Only used in gltf falloff mode, this defines the angle where
  49189. * the directional falloff will start before cutting at angle which could be seen
  49190. * as outer angle.
  49191. */
  49192. set innerAngle(value: number);
  49193. private _shadowAngleScale;
  49194. /**
  49195. * Allows scaling the angle of the light for shadow generation only.
  49196. */
  49197. get shadowAngleScale(): number;
  49198. /**
  49199. * Allows scaling the angle of the light for shadow generation only.
  49200. */
  49201. set shadowAngleScale(value: number);
  49202. /**
  49203. * The light decay speed with the distance from the emission spot.
  49204. */
  49205. exponent: number;
  49206. private _projectionTextureMatrix;
  49207. /**
  49208. * Allows reading the projecton texture
  49209. */
  49210. get projectionTextureMatrix(): Matrix;
  49211. protected _projectionTextureLightNear: number;
  49212. /**
  49213. * Gets the near clip of the Spotlight for texture projection.
  49214. */
  49215. get projectionTextureLightNear(): number;
  49216. /**
  49217. * Sets the near clip of the Spotlight for texture projection.
  49218. */
  49219. set projectionTextureLightNear(value: number);
  49220. protected _projectionTextureLightFar: number;
  49221. /**
  49222. * Gets the far clip of the Spotlight for texture projection.
  49223. */
  49224. get projectionTextureLightFar(): number;
  49225. /**
  49226. * Sets the far clip of the Spotlight for texture projection.
  49227. */
  49228. set projectionTextureLightFar(value: number);
  49229. protected _projectionTextureUpDirection: Vector3;
  49230. /**
  49231. * Gets the Up vector of the Spotlight for texture projection.
  49232. */
  49233. get projectionTextureUpDirection(): Vector3;
  49234. /**
  49235. * Sets the Up vector of the Spotlight for texture projection.
  49236. */
  49237. set projectionTextureUpDirection(value: Vector3);
  49238. private _projectionTexture;
  49239. /**
  49240. * Gets the projection texture of the light.
  49241. */
  49242. get projectionTexture(): Nullable<BaseTexture>;
  49243. /**
  49244. * Sets the projection texture of the light.
  49245. */
  49246. set projectionTexture(value: Nullable<BaseTexture>);
  49247. private _projectionTextureViewLightDirty;
  49248. private _projectionTextureProjectionLightDirty;
  49249. private _projectionTextureDirty;
  49250. private _projectionTextureViewTargetVector;
  49251. private _projectionTextureViewLightMatrix;
  49252. private _projectionTextureProjectionLightMatrix;
  49253. private _projectionTextureScalingMatrix;
  49254. /**
  49255. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49256. * It can cast shadows.
  49257. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49258. * @param name The light friendly name
  49259. * @param position The position of the spot light in the scene
  49260. * @param direction The direction of the light in the scene
  49261. * @param angle The cone angle of the light in Radians
  49262. * @param exponent The light decay speed with the distance from the emission spot
  49263. * @param scene The scene the lights belongs to
  49264. */
  49265. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49266. /**
  49267. * Returns the string "SpotLight".
  49268. * @returns the class name
  49269. */
  49270. getClassName(): string;
  49271. /**
  49272. * Returns the integer 2.
  49273. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49274. */
  49275. getTypeID(): number;
  49276. /**
  49277. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49278. */
  49279. protected _setDirection(value: Vector3): void;
  49280. /**
  49281. * Overrides the position setter to recompute the projection texture view light Matrix.
  49282. */
  49283. protected _setPosition(value: Vector3): void;
  49284. /**
  49285. * 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.
  49286. * Returns the SpotLight.
  49287. */
  49288. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49289. protected _computeProjectionTextureViewLightMatrix(): void;
  49290. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49291. /**
  49292. * Main function for light texture projection matrix computing.
  49293. */
  49294. protected _computeProjectionTextureMatrix(): void;
  49295. protected _buildUniformLayout(): void;
  49296. private _computeAngleValues;
  49297. /**
  49298. * Sets the passed Effect "effect" with the Light textures.
  49299. * @param effect The effect to update
  49300. * @param lightIndex The index of the light in the effect to update
  49301. * @returns The light
  49302. */
  49303. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49304. /**
  49305. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49306. * @param effect The effect to update
  49307. * @param lightIndex The index of the light in the effect to update
  49308. * @returns The spot light
  49309. */
  49310. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49311. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49312. /**
  49313. * Disposes the light and the associated resources.
  49314. */
  49315. dispose(): void;
  49316. /**
  49317. * Prepares the list of defines specific to the light type.
  49318. * @param defines the list of defines
  49319. * @param lightIndex defines the index of the light for the effect
  49320. */
  49321. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49322. }
  49323. }
  49324. declare module BABYLON {
  49325. /**
  49326. * Gizmo that enables viewing a light
  49327. */
  49328. export class LightGizmo extends Gizmo {
  49329. private _lightMesh;
  49330. private _material;
  49331. private _cachedPosition;
  49332. private _cachedForward;
  49333. private _attachedMeshParent;
  49334. /**
  49335. * Creates a LightGizmo
  49336. * @param gizmoLayer The utility layer the gizmo will be added to
  49337. */
  49338. constructor(gizmoLayer?: UtilityLayerRenderer);
  49339. private _light;
  49340. /**
  49341. * The light that the gizmo is attached to
  49342. */
  49343. set light(light: Nullable<Light>);
  49344. get light(): Nullable<Light>;
  49345. /**
  49346. * Gets the material used to render the light gizmo
  49347. */
  49348. get material(): StandardMaterial;
  49349. /**
  49350. * @hidden
  49351. * Updates the gizmo to match the attached mesh's position/rotation
  49352. */
  49353. protected _update(): void;
  49354. private static _Scale;
  49355. /**
  49356. * Creates the lines for a light mesh
  49357. */
  49358. private static _CreateLightLines;
  49359. /**
  49360. * Disposes of the light gizmo
  49361. */
  49362. dispose(): void;
  49363. private static _CreateHemisphericLightMesh;
  49364. private static _CreatePointLightMesh;
  49365. private static _CreateSpotLightMesh;
  49366. private static _CreateDirectionalLightMesh;
  49367. }
  49368. }
  49369. declare module BABYLON {
  49370. /** @hidden */
  49371. export var backgroundFragmentDeclaration: {
  49372. name: string;
  49373. shader: string;
  49374. };
  49375. }
  49376. declare module BABYLON {
  49377. /** @hidden */
  49378. export var backgroundUboDeclaration: {
  49379. name: string;
  49380. shader: string;
  49381. };
  49382. }
  49383. declare module BABYLON {
  49384. /** @hidden */
  49385. export var backgroundPixelShader: {
  49386. name: string;
  49387. shader: string;
  49388. };
  49389. }
  49390. declare module BABYLON {
  49391. /** @hidden */
  49392. export var backgroundVertexDeclaration: {
  49393. name: string;
  49394. shader: string;
  49395. };
  49396. }
  49397. declare module BABYLON {
  49398. /** @hidden */
  49399. export var backgroundVertexShader: {
  49400. name: string;
  49401. shader: string;
  49402. };
  49403. }
  49404. declare module BABYLON {
  49405. /**
  49406. * Background material used to create an efficient environement around your scene.
  49407. */
  49408. export class BackgroundMaterial extends PushMaterial {
  49409. /**
  49410. * Standard reflectance value at parallel view angle.
  49411. */
  49412. static StandardReflectance0: number;
  49413. /**
  49414. * Standard reflectance value at grazing angle.
  49415. */
  49416. static StandardReflectance90: number;
  49417. protected _primaryColor: Color3;
  49418. /**
  49419. * Key light Color (multiply against the environement texture)
  49420. */
  49421. primaryColor: Color3;
  49422. protected __perceptualColor: Nullable<Color3>;
  49423. /**
  49424. * Experimental Internal Use Only.
  49425. *
  49426. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49427. * This acts as a helper to set the primary color to a more "human friendly" value.
  49428. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49429. * output color as close as possible from the chosen value.
  49430. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49431. * part of lighting setup.)
  49432. */
  49433. get _perceptualColor(): Nullable<Color3>;
  49434. set _perceptualColor(value: Nullable<Color3>);
  49435. protected _primaryColorShadowLevel: float;
  49436. /**
  49437. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49438. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49439. */
  49440. get primaryColorShadowLevel(): float;
  49441. set primaryColorShadowLevel(value: float);
  49442. protected _primaryColorHighlightLevel: float;
  49443. /**
  49444. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49445. * The primary color is used at the level chosen to define what the white area would look.
  49446. */
  49447. get primaryColorHighlightLevel(): float;
  49448. set primaryColorHighlightLevel(value: float);
  49449. protected _reflectionTexture: Nullable<BaseTexture>;
  49450. /**
  49451. * Reflection Texture used in the material.
  49452. * Should be author in a specific way for the best result (refer to the documentation).
  49453. */
  49454. reflectionTexture: Nullable<BaseTexture>;
  49455. protected _reflectionBlur: float;
  49456. /**
  49457. * Reflection Texture level of blur.
  49458. *
  49459. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49460. * texture twice.
  49461. */
  49462. reflectionBlur: float;
  49463. protected _diffuseTexture: Nullable<BaseTexture>;
  49464. /**
  49465. * Diffuse Texture used in the material.
  49466. * Should be author in a specific way for the best result (refer to the documentation).
  49467. */
  49468. diffuseTexture: Nullable<BaseTexture>;
  49469. protected _shadowLights: Nullable<IShadowLight[]>;
  49470. /**
  49471. * Specify the list of lights casting shadow on the material.
  49472. * All scene shadow lights will be included if null.
  49473. */
  49474. shadowLights: Nullable<IShadowLight[]>;
  49475. protected _shadowLevel: float;
  49476. /**
  49477. * Helps adjusting the shadow to a softer level if required.
  49478. * 0 means black shadows and 1 means no shadows.
  49479. */
  49480. shadowLevel: float;
  49481. protected _sceneCenter: Vector3;
  49482. /**
  49483. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49484. * It is usually zero but might be interesting to modify according to your setup.
  49485. */
  49486. sceneCenter: Vector3;
  49487. protected _opacityFresnel: boolean;
  49488. /**
  49489. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49490. * This helps ensuring a nice transition when the camera goes under the ground.
  49491. */
  49492. opacityFresnel: boolean;
  49493. protected _reflectionFresnel: boolean;
  49494. /**
  49495. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49496. * This helps adding a mirror texture on the ground.
  49497. */
  49498. reflectionFresnel: boolean;
  49499. protected _reflectionFalloffDistance: number;
  49500. /**
  49501. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49502. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49503. */
  49504. reflectionFalloffDistance: number;
  49505. protected _reflectionAmount: number;
  49506. /**
  49507. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49508. */
  49509. reflectionAmount: number;
  49510. protected _reflectionReflectance0: number;
  49511. /**
  49512. * This specifies the weight of the reflection at grazing angle.
  49513. */
  49514. reflectionReflectance0: number;
  49515. protected _reflectionReflectance90: number;
  49516. /**
  49517. * This specifies the weight of the reflection at a perpendicular point of view.
  49518. */
  49519. reflectionReflectance90: number;
  49520. /**
  49521. * Sets the reflection reflectance fresnel values according to the default standard
  49522. * empirically know to work well :-)
  49523. */
  49524. set reflectionStandardFresnelWeight(value: number);
  49525. protected _useRGBColor: boolean;
  49526. /**
  49527. * Helps to directly use the maps channels instead of their level.
  49528. */
  49529. useRGBColor: boolean;
  49530. protected _enableNoise: boolean;
  49531. /**
  49532. * This helps reducing the banding effect that could occur on the background.
  49533. */
  49534. enableNoise: boolean;
  49535. /**
  49536. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49537. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49538. * Recommended to be keep at 1.0 except for special cases.
  49539. */
  49540. get fovMultiplier(): number;
  49541. set fovMultiplier(value: number);
  49542. private _fovMultiplier;
  49543. /**
  49544. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49545. */
  49546. useEquirectangularFOV: boolean;
  49547. private _maxSimultaneousLights;
  49548. /**
  49549. * Number of Simultaneous lights allowed on the material.
  49550. */
  49551. maxSimultaneousLights: int;
  49552. /**
  49553. * Default configuration related to image processing available in the Background Material.
  49554. */
  49555. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49556. /**
  49557. * Keep track of the image processing observer to allow dispose and replace.
  49558. */
  49559. private _imageProcessingObserver;
  49560. /**
  49561. * Attaches a new image processing configuration to the PBR Material.
  49562. * @param configuration (if null the scene configuration will be use)
  49563. */
  49564. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49565. /**
  49566. * Gets the image processing configuration used either in this material.
  49567. */
  49568. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49569. /**
  49570. * Sets the Default image processing configuration used either in the this material.
  49571. *
  49572. * If sets to null, the scene one is in use.
  49573. */
  49574. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49575. /**
  49576. * Gets wether the color curves effect is enabled.
  49577. */
  49578. get cameraColorCurvesEnabled(): boolean;
  49579. /**
  49580. * Sets wether the color curves effect is enabled.
  49581. */
  49582. set cameraColorCurvesEnabled(value: boolean);
  49583. /**
  49584. * Gets wether the color grading effect is enabled.
  49585. */
  49586. get cameraColorGradingEnabled(): boolean;
  49587. /**
  49588. * Gets wether the color grading effect is enabled.
  49589. */
  49590. set cameraColorGradingEnabled(value: boolean);
  49591. /**
  49592. * Gets wether tonemapping is enabled or not.
  49593. */
  49594. get cameraToneMappingEnabled(): boolean;
  49595. /**
  49596. * Sets wether tonemapping is enabled or not
  49597. */
  49598. set cameraToneMappingEnabled(value: boolean);
  49599. /**
  49600. * The camera exposure used on this material.
  49601. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49602. * This corresponds to a photographic exposure.
  49603. */
  49604. get cameraExposure(): float;
  49605. /**
  49606. * The camera exposure used on this material.
  49607. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49608. * This corresponds to a photographic exposure.
  49609. */
  49610. set cameraExposure(value: float);
  49611. /**
  49612. * Gets The camera contrast used on this material.
  49613. */
  49614. get cameraContrast(): float;
  49615. /**
  49616. * Sets The camera contrast used on this material.
  49617. */
  49618. set cameraContrast(value: float);
  49619. /**
  49620. * Gets the Color Grading 2D Lookup Texture.
  49621. */
  49622. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49623. /**
  49624. * Sets the Color Grading 2D Lookup Texture.
  49625. */
  49626. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49627. /**
  49628. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49629. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49630. * 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;
  49631. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49632. */
  49633. get cameraColorCurves(): Nullable<ColorCurves>;
  49634. /**
  49635. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49636. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49637. * 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;
  49638. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49639. */
  49640. set cameraColorCurves(value: Nullable<ColorCurves>);
  49641. /**
  49642. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49643. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49644. */
  49645. switchToBGR: boolean;
  49646. private _renderTargets;
  49647. private _reflectionControls;
  49648. private _white;
  49649. private _primaryShadowColor;
  49650. private _primaryHighlightColor;
  49651. /**
  49652. * Instantiates a Background Material in the given scene
  49653. * @param name The friendly name of the material
  49654. * @param scene The scene to add the material to
  49655. */
  49656. constructor(name: string, scene: Scene);
  49657. /**
  49658. * Gets a boolean indicating that current material needs to register RTT
  49659. */
  49660. get hasRenderTargetTextures(): boolean;
  49661. /**
  49662. * The entire material has been created in order to prevent overdraw.
  49663. * @returns false
  49664. */
  49665. needAlphaTesting(): boolean;
  49666. /**
  49667. * The entire material has been created in order to prevent overdraw.
  49668. * @returns true if blending is enable
  49669. */
  49670. needAlphaBlending(): boolean;
  49671. /**
  49672. * Checks wether the material is ready to be rendered for a given mesh.
  49673. * @param mesh The mesh to render
  49674. * @param subMesh The submesh to check against
  49675. * @param useInstances Specify wether or not the material is used with instances
  49676. * @returns true if all the dependencies are ready (Textures, Effects...)
  49677. */
  49678. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49679. /**
  49680. * Compute the primary color according to the chosen perceptual color.
  49681. */
  49682. private _computePrimaryColorFromPerceptualColor;
  49683. /**
  49684. * Compute the highlights and shadow colors according to their chosen levels.
  49685. */
  49686. private _computePrimaryColors;
  49687. /**
  49688. * Build the uniform buffer used in the material.
  49689. */
  49690. buildUniformLayout(): void;
  49691. /**
  49692. * Unbind the material.
  49693. */
  49694. unbind(): void;
  49695. /**
  49696. * Bind only the world matrix to the material.
  49697. * @param world The world matrix to bind.
  49698. */
  49699. bindOnlyWorldMatrix(world: Matrix): void;
  49700. /**
  49701. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49702. * @param world The world matrix to bind.
  49703. * @param subMesh The submesh to bind for.
  49704. */
  49705. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49706. /**
  49707. * Checks to see if a texture is used in the material.
  49708. * @param texture - Base texture to use.
  49709. * @returns - Boolean specifying if a texture is used in the material.
  49710. */
  49711. hasTexture(texture: BaseTexture): boolean;
  49712. /**
  49713. * Dispose the material.
  49714. * @param forceDisposeEffect Force disposal of the associated effect.
  49715. * @param forceDisposeTextures Force disposal of the associated textures.
  49716. */
  49717. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49718. /**
  49719. * Clones the material.
  49720. * @param name The cloned name.
  49721. * @returns The cloned material.
  49722. */
  49723. clone(name: string): BackgroundMaterial;
  49724. /**
  49725. * Serializes the current material to its JSON representation.
  49726. * @returns The JSON representation.
  49727. */
  49728. serialize(): any;
  49729. /**
  49730. * Gets the class name of the material
  49731. * @returns "BackgroundMaterial"
  49732. */
  49733. getClassName(): string;
  49734. /**
  49735. * Parse a JSON input to create back a background material.
  49736. * @param source The JSON data to parse
  49737. * @param scene The scene to create the parsed material in
  49738. * @param rootUrl The root url of the assets the material depends upon
  49739. * @returns the instantiated BackgroundMaterial.
  49740. */
  49741. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49742. }
  49743. }
  49744. declare module BABYLON {
  49745. /**
  49746. * Represents the different options available during the creation of
  49747. * a Environment helper.
  49748. *
  49749. * This can control the default ground, skybox and image processing setup of your scene.
  49750. */
  49751. export interface IEnvironmentHelperOptions {
  49752. /**
  49753. * Specifies whether or not to create a ground.
  49754. * True by default.
  49755. */
  49756. createGround: boolean;
  49757. /**
  49758. * Specifies the ground size.
  49759. * 15 by default.
  49760. */
  49761. groundSize: number;
  49762. /**
  49763. * The texture used on the ground for the main color.
  49764. * Comes from the BabylonJS CDN by default.
  49765. *
  49766. * Remarks: Can be either a texture or a url.
  49767. */
  49768. groundTexture: string | BaseTexture;
  49769. /**
  49770. * The color mixed in the ground texture by default.
  49771. * BabylonJS clearColor by default.
  49772. */
  49773. groundColor: Color3;
  49774. /**
  49775. * Specifies the ground opacity.
  49776. * 1 by default.
  49777. */
  49778. groundOpacity: number;
  49779. /**
  49780. * Enables the ground to receive shadows.
  49781. * True by default.
  49782. */
  49783. enableGroundShadow: boolean;
  49784. /**
  49785. * Helps preventing the shadow to be fully black on the ground.
  49786. * 0.5 by default.
  49787. */
  49788. groundShadowLevel: number;
  49789. /**
  49790. * Creates a mirror texture attach to the ground.
  49791. * false by default.
  49792. */
  49793. enableGroundMirror: boolean;
  49794. /**
  49795. * Specifies the ground mirror size ratio.
  49796. * 0.3 by default as the default kernel is 64.
  49797. */
  49798. groundMirrorSizeRatio: number;
  49799. /**
  49800. * Specifies the ground mirror blur kernel size.
  49801. * 64 by default.
  49802. */
  49803. groundMirrorBlurKernel: number;
  49804. /**
  49805. * Specifies the ground mirror visibility amount.
  49806. * 1 by default
  49807. */
  49808. groundMirrorAmount: number;
  49809. /**
  49810. * Specifies the ground mirror reflectance weight.
  49811. * This uses the standard weight of the background material to setup the fresnel effect
  49812. * of the mirror.
  49813. * 1 by default.
  49814. */
  49815. groundMirrorFresnelWeight: number;
  49816. /**
  49817. * Specifies the ground mirror Falloff distance.
  49818. * This can helps reducing the size of the reflection.
  49819. * 0 by Default.
  49820. */
  49821. groundMirrorFallOffDistance: number;
  49822. /**
  49823. * Specifies the ground mirror texture type.
  49824. * Unsigned Int by Default.
  49825. */
  49826. groundMirrorTextureType: number;
  49827. /**
  49828. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49829. * the shown objects.
  49830. */
  49831. groundYBias: number;
  49832. /**
  49833. * Specifies whether or not to create a skybox.
  49834. * True by default.
  49835. */
  49836. createSkybox: boolean;
  49837. /**
  49838. * Specifies the skybox size.
  49839. * 20 by default.
  49840. */
  49841. skyboxSize: number;
  49842. /**
  49843. * The texture used on the skybox for the main color.
  49844. * Comes from the BabylonJS CDN by default.
  49845. *
  49846. * Remarks: Can be either a texture or a url.
  49847. */
  49848. skyboxTexture: string | BaseTexture;
  49849. /**
  49850. * The color mixed in the skybox texture by default.
  49851. * BabylonJS clearColor by default.
  49852. */
  49853. skyboxColor: Color3;
  49854. /**
  49855. * The background rotation around the Y axis of the scene.
  49856. * This helps aligning the key lights of your scene with the background.
  49857. * 0 by default.
  49858. */
  49859. backgroundYRotation: number;
  49860. /**
  49861. * Compute automatically the size of the elements to best fit with the scene.
  49862. */
  49863. sizeAuto: boolean;
  49864. /**
  49865. * Default position of the rootMesh if autoSize is not true.
  49866. */
  49867. rootPosition: Vector3;
  49868. /**
  49869. * Sets up the image processing in the scene.
  49870. * true by default.
  49871. */
  49872. setupImageProcessing: boolean;
  49873. /**
  49874. * The texture used as your environment texture in the scene.
  49875. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49876. *
  49877. * Remarks: Can be either a texture or a url.
  49878. */
  49879. environmentTexture: string | BaseTexture;
  49880. /**
  49881. * The value of the exposure to apply to the scene.
  49882. * 0.6 by default if setupImageProcessing is true.
  49883. */
  49884. cameraExposure: number;
  49885. /**
  49886. * The value of the contrast to apply to the scene.
  49887. * 1.6 by default if setupImageProcessing is true.
  49888. */
  49889. cameraContrast: number;
  49890. /**
  49891. * Specifies whether or not tonemapping should be enabled in the scene.
  49892. * true by default if setupImageProcessing is true.
  49893. */
  49894. toneMappingEnabled: boolean;
  49895. }
  49896. /**
  49897. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49898. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49899. * It also helps with the default setup of your imageProcessing configuration.
  49900. */
  49901. export class EnvironmentHelper {
  49902. /**
  49903. * Default ground texture URL.
  49904. */
  49905. private static _groundTextureCDNUrl;
  49906. /**
  49907. * Default skybox texture URL.
  49908. */
  49909. private static _skyboxTextureCDNUrl;
  49910. /**
  49911. * Default environment texture URL.
  49912. */
  49913. private static _environmentTextureCDNUrl;
  49914. /**
  49915. * Creates the default options for the helper.
  49916. */
  49917. private static _getDefaultOptions;
  49918. private _rootMesh;
  49919. /**
  49920. * Gets the root mesh created by the helper.
  49921. */
  49922. get rootMesh(): Mesh;
  49923. private _skybox;
  49924. /**
  49925. * Gets the skybox created by the helper.
  49926. */
  49927. get skybox(): Nullable<Mesh>;
  49928. private _skyboxTexture;
  49929. /**
  49930. * Gets the skybox texture created by the helper.
  49931. */
  49932. get skyboxTexture(): Nullable<BaseTexture>;
  49933. private _skyboxMaterial;
  49934. /**
  49935. * Gets the skybox material created by the helper.
  49936. */
  49937. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49938. private _ground;
  49939. /**
  49940. * Gets the ground mesh created by the helper.
  49941. */
  49942. get ground(): Nullable<Mesh>;
  49943. private _groundTexture;
  49944. /**
  49945. * Gets the ground texture created by the helper.
  49946. */
  49947. get groundTexture(): Nullable<BaseTexture>;
  49948. private _groundMirror;
  49949. /**
  49950. * Gets the ground mirror created by the helper.
  49951. */
  49952. get groundMirror(): Nullable<MirrorTexture>;
  49953. /**
  49954. * Gets the ground mirror render list to helps pushing the meshes
  49955. * you wish in the ground reflection.
  49956. */
  49957. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49958. private _groundMaterial;
  49959. /**
  49960. * Gets the ground material created by the helper.
  49961. */
  49962. get groundMaterial(): Nullable<BackgroundMaterial>;
  49963. /**
  49964. * Stores the creation options.
  49965. */
  49966. private readonly _scene;
  49967. private _options;
  49968. /**
  49969. * This observable will be notified with any error during the creation of the environment,
  49970. * mainly texture creation errors.
  49971. */
  49972. onErrorObservable: Observable<{
  49973. message?: string;
  49974. exception?: any;
  49975. }>;
  49976. /**
  49977. * constructor
  49978. * @param options Defines the options we want to customize the helper
  49979. * @param scene The scene to add the material to
  49980. */
  49981. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49982. /**
  49983. * Updates the background according to the new options
  49984. * @param options
  49985. */
  49986. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49987. /**
  49988. * Sets the primary color of all the available elements.
  49989. * @param color the main color to affect to the ground and the background
  49990. */
  49991. setMainColor(color: Color3): void;
  49992. /**
  49993. * Setup the image processing according to the specified options.
  49994. */
  49995. private _setupImageProcessing;
  49996. /**
  49997. * Setup the environment texture according to the specified options.
  49998. */
  49999. private _setupEnvironmentTexture;
  50000. /**
  50001. * Setup the background according to the specified options.
  50002. */
  50003. private _setupBackground;
  50004. /**
  50005. * Get the scene sizes according to the setup.
  50006. */
  50007. private _getSceneSize;
  50008. /**
  50009. * Setup the ground according to the specified options.
  50010. */
  50011. private _setupGround;
  50012. /**
  50013. * Setup the ground material according to the specified options.
  50014. */
  50015. private _setupGroundMaterial;
  50016. /**
  50017. * Setup the ground diffuse texture according to the specified options.
  50018. */
  50019. private _setupGroundDiffuseTexture;
  50020. /**
  50021. * Setup the ground mirror texture according to the specified options.
  50022. */
  50023. private _setupGroundMirrorTexture;
  50024. /**
  50025. * Setup the ground to receive the mirror texture.
  50026. */
  50027. private _setupMirrorInGroundMaterial;
  50028. /**
  50029. * Setup the skybox according to the specified options.
  50030. */
  50031. private _setupSkybox;
  50032. /**
  50033. * Setup the skybox material according to the specified options.
  50034. */
  50035. private _setupSkyboxMaterial;
  50036. /**
  50037. * Setup the skybox reflection texture according to the specified options.
  50038. */
  50039. private _setupSkyboxReflectionTexture;
  50040. private _errorHandler;
  50041. /**
  50042. * Dispose all the elements created by the Helper.
  50043. */
  50044. dispose(): void;
  50045. }
  50046. }
  50047. declare module BABYLON {
  50048. /**
  50049. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50050. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50051. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50052. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50053. */
  50054. export class PhotoDome extends TransformNode {
  50055. /**
  50056. * Define the image as a Monoscopic panoramic 360 image.
  50057. */
  50058. static readonly MODE_MONOSCOPIC: number;
  50059. /**
  50060. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50061. */
  50062. static readonly MODE_TOPBOTTOM: number;
  50063. /**
  50064. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50065. */
  50066. static readonly MODE_SIDEBYSIDE: number;
  50067. private _useDirectMapping;
  50068. /**
  50069. * The texture being displayed on the sphere
  50070. */
  50071. protected _photoTexture: Texture;
  50072. /**
  50073. * Gets or sets the texture being displayed on the sphere
  50074. */
  50075. get photoTexture(): Texture;
  50076. set photoTexture(value: Texture);
  50077. /**
  50078. * Observable raised when an error occured while loading the 360 image
  50079. */
  50080. onLoadErrorObservable: Observable<string>;
  50081. /**
  50082. * The skybox material
  50083. */
  50084. protected _material: BackgroundMaterial;
  50085. /**
  50086. * The surface used for the skybox
  50087. */
  50088. protected _mesh: Mesh;
  50089. /**
  50090. * Gets the mesh used for the skybox.
  50091. */
  50092. get mesh(): Mesh;
  50093. /**
  50094. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50095. * Also see the options.resolution property.
  50096. */
  50097. get fovMultiplier(): number;
  50098. set fovMultiplier(value: number);
  50099. private _imageMode;
  50100. /**
  50101. * Gets or set the current video mode for the video. It can be:
  50102. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50103. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50104. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50105. */
  50106. get imageMode(): number;
  50107. set imageMode(value: number);
  50108. /**
  50109. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50110. * @param name Element's name, child elements will append suffixes for their own names.
  50111. * @param urlsOfPhoto defines the url of the photo to display
  50112. * @param options defines an object containing optional or exposed sub element properties
  50113. * @param onError defines a callback called when an error occured while loading the texture
  50114. */
  50115. constructor(name: string, urlOfPhoto: string, options: {
  50116. resolution?: number;
  50117. size?: number;
  50118. useDirectMapping?: boolean;
  50119. faceForward?: boolean;
  50120. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50121. private _onBeforeCameraRenderObserver;
  50122. private _changeImageMode;
  50123. /**
  50124. * Releases resources associated with this node.
  50125. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50126. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50127. */
  50128. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50129. }
  50130. }
  50131. declare module BABYLON {
  50132. /**
  50133. * Class used to host RGBD texture specific utilities
  50134. */
  50135. export class RGBDTextureTools {
  50136. /**
  50137. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50138. * @param texture the texture to expand.
  50139. */
  50140. static ExpandRGBDTexture(texture: Texture): void;
  50141. }
  50142. }
  50143. declare module BABYLON {
  50144. /**
  50145. * Class used to host texture specific utilities
  50146. */
  50147. export class BRDFTextureTools {
  50148. /**
  50149. * Prevents texture cache collision
  50150. */
  50151. private static _instanceNumber;
  50152. /**
  50153. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50154. * @param scene defines the hosting scene
  50155. * @returns the environment BRDF texture
  50156. */
  50157. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50158. private static _environmentBRDFBase64Texture;
  50159. }
  50160. }
  50161. declare module BABYLON {
  50162. /**
  50163. * @hidden
  50164. */
  50165. export interface IMaterialClearCoatDefines {
  50166. CLEARCOAT: boolean;
  50167. CLEARCOAT_DEFAULTIOR: boolean;
  50168. CLEARCOAT_TEXTURE: boolean;
  50169. CLEARCOAT_TEXTUREDIRECTUV: number;
  50170. CLEARCOAT_BUMP: boolean;
  50171. CLEARCOAT_BUMPDIRECTUV: number;
  50172. CLEARCOAT_TINT: boolean;
  50173. CLEARCOAT_TINT_TEXTURE: boolean;
  50174. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50175. /** @hidden */
  50176. _areTexturesDirty: boolean;
  50177. }
  50178. /**
  50179. * Define the code related to the clear coat parameters of the pbr material.
  50180. */
  50181. export class PBRClearCoatConfiguration {
  50182. /**
  50183. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50184. * The default fits with a polyurethane material.
  50185. */
  50186. private static readonly _DefaultIndexOfRefraction;
  50187. private _isEnabled;
  50188. /**
  50189. * Defines if the clear coat is enabled in the material.
  50190. */
  50191. isEnabled: boolean;
  50192. /**
  50193. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50194. */
  50195. intensity: number;
  50196. /**
  50197. * Defines the clear coat layer roughness.
  50198. */
  50199. roughness: number;
  50200. private _indexOfRefraction;
  50201. /**
  50202. * Defines the index of refraction of the clear coat.
  50203. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50204. * The default fits with a polyurethane material.
  50205. * Changing the default value is more performance intensive.
  50206. */
  50207. indexOfRefraction: number;
  50208. private _texture;
  50209. /**
  50210. * Stores the clear coat values in a texture.
  50211. */
  50212. texture: Nullable<BaseTexture>;
  50213. private _bumpTexture;
  50214. /**
  50215. * Define the clear coat specific bump texture.
  50216. */
  50217. bumpTexture: Nullable<BaseTexture>;
  50218. private _isTintEnabled;
  50219. /**
  50220. * Defines if the clear coat tint is enabled in the material.
  50221. */
  50222. isTintEnabled: boolean;
  50223. /**
  50224. * Defines the clear coat tint of the material.
  50225. * This is only use if tint is enabled
  50226. */
  50227. tintColor: Color3;
  50228. /**
  50229. * Defines the distance at which the tint color should be found in the
  50230. * clear coat media.
  50231. * This is only use if tint is enabled
  50232. */
  50233. tintColorAtDistance: number;
  50234. /**
  50235. * Defines the clear coat layer thickness.
  50236. * This is only use if tint is enabled
  50237. */
  50238. tintThickness: number;
  50239. private _tintTexture;
  50240. /**
  50241. * Stores the clear tint values in a texture.
  50242. * rgb is tint
  50243. * a is a thickness factor
  50244. */
  50245. tintTexture: Nullable<BaseTexture>;
  50246. /** @hidden */
  50247. private _internalMarkAllSubMeshesAsTexturesDirty;
  50248. /** @hidden */
  50249. _markAllSubMeshesAsTexturesDirty(): void;
  50250. /**
  50251. * Instantiate a new istance of clear coat configuration.
  50252. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50253. */
  50254. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50255. /**
  50256. * Gets wehter the submesh is ready to be used or not.
  50257. * @param defines the list of "defines" to update.
  50258. * @param scene defines the scene the material belongs to.
  50259. * @param engine defines the engine the material belongs to.
  50260. * @param disableBumpMap defines wether the material disables bump or not.
  50261. * @returns - boolean indicating that the submesh is ready or not.
  50262. */
  50263. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50264. /**
  50265. * Checks to see if a texture is used in the material.
  50266. * @param defines the list of "defines" to update.
  50267. * @param scene defines the scene to the material belongs to.
  50268. */
  50269. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50270. /**
  50271. * Binds the material data.
  50272. * @param uniformBuffer defines the Uniform buffer to fill in.
  50273. * @param scene defines the scene the material belongs to.
  50274. * @param engine defines the engine the material belongs to.
  50275. * @param disableBumpMap defines wether the material disables bump or not.
  50276. * @param isFrozen defines wether the material is frozen or not.
  50277. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50278. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50279. */
  50280. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50281. /**
  50282. * Checks to see if a texture is used in the material.
  50283. * @param texture - Base texture to use.
  50284. * @returns - Boolean specifying if a texture is used in the material.
  50285. */
  50286. hasTexture(texture: BaseTexture): boolean;
  50287. /**
  50288. * Returns an array of the actively used textures.
  50289. * @param activeTextures Array of BaseTextures
  50290. */
  50291. getActiveTextures(activeTextures: BaseTexture[]): void;
  50292. /**
  50293. * Returns the animatable textures.
  50294. * @param animatables Array of animatable textures.
  50295. */
  50296. getAnimatables(animatables: IAnimatable[]): void;
  50297. /**
  50298. * Disposes the resources of the material.
  50299. * @param forceDisposeTextures - Forces the disposal of all textures.
  50300. */
  50301. dispose(forceDisposeTextures?: boolean): void;
  50302. /**
  50303. * Get the current class name of the texture useful for serialization or dynamic coding.
  50304. * @returns "PBRClearCoatConfiguration"
  50305. */
  50306. getClassName(): string;
  50307. /**
  50308. * Add fallbacks to the effect fallbacks list.
  50309. * @param defines defines the Base texture to use.
  50310. * @param fallbacks defines the current fallback list.
  50311. * @param currentRank defines the current fallback rank.
  50312. * @returns the new fallback rank.
  50313. */
  50314. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50315. /**
  50316. * Add the required uniforms to the current list.
  50317. * @param uniforms defines the current uniform list.
  50318. */
  50319. static AddUniforms(uniforms: string[]): void;
  50320. /**
  50321. * Add the required samplers to the current list.
  50322. * @param samplers defines the current sampler list.
  50323. */
  50324. static AddSamplers(samplers: string[]): void;
  50325. /**
  50326. * Add the required uniforms to the current buffer.
  50327. * @param uniformBuffer defines the current uniform buffer.
  50328. */
  50329. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50330. /**
  50331. * Makes a duplicate of the current configuration into another one.
  50332. * @param clearCoatConfiguration define the config where to copy the info
  50333. */
  50334. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50335. /**
  50336. * Serializes this clear coat configuration.
  50337. * @returns - An object with the serialized config.
  50338. */
  50339. serialize(): any;
  50340. /**
  50341. * Parses a anisotropy Configuration from a serialized object.
  50342. * @param source - Serialized object.
  50343. * @param scene Defines the scene we are parsing for
  50344. * @param rootUrl Defines the rootUrl to load from
  50345. */
  50346. parse(source: any, scene: Scene, rootUrl: string): void;
  50347. }
  50348. }
  50349. declare module BABYLON {
  50350. /**
  50351. * @hidden
  50352. */
  50353. export interface IMaterialAnisotropicDefines {
  50354. ANISOTROPIC: boolean;
  50355. ANISOTROPIC_TEXTURE: boolean;
  50356. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50357. MAINUV1: boolean;
  50358. _areTexturesDirty: boolean;
  50359. _needUVs: boolean;
  50360. }
  50361. /**
  50362. * Define the code related to the anisotropic parameters of the pbr material.
  50363. */
  50364. export class PBRAnisotropicConfiguration {
  50365. private _isEnabled;
  50366. /**
  50367. * Defines if the anisotropy is enabled in the material.
  50368. */
  50369. isEnabled: boolean;
  50370. /**
  50371. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50372. */
  50373. intensity: number;
  50374. /**
  50375. * Defines if the effect is along the tangents, bitangents or in between.
  50376. * By default, the effect is "strectching" the highlights along the tangents.
  50377. */
  50378. direction: Vector2;
  50379. private _texture;
  50380. /**
  50381. * Stores the anisotropy values in a texture.
  50382. * rg is direction (like normal from -1 to 1)
  50383. * b is a intensity
  50384. */
  50385. texture: Nullable<BaseTexture>;
  50386. /** @hidden */
  50387. private _internalMarkAllSubMeshesAsTexturesDirty;
  50388. /** @hidden */
  50389. _markAllSubMeshesAsTexturesDirty(): void;
  50390. /**
  50391. * Instantiate a new istance of anisotropy configuration.
  50392. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50393. */
  50394. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50395. /**
  50396. * Specifies that the submesh is ready to be used.
  50397. * @param defines the list of "defines" to update.
  50398. * @param scene defines the scene the material belongs to.
  50399. * @returns - boolean indicating that the submesh is ready or not.
  50400. */
  50401. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50402. /**
  50403. * Checks to see if a texture is used in the material.
  50404. * @param defines the list of "defines" to update.
  50405. * @param mesh the mesh we are preparing the defines for.
  50406. * @param scene defines the scene the material belongs to.
  50407. */
  50408. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50409. /**
  50410. * Binds the material data.
  50411. * @param uniformBuffer defines the Uniform buffer to fill in.
  50412. * @param scene defines the scene the material belongs to.
  50413. * @param isFrozen defines wether the material is frozen or not.
  50414. */
  50415. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50416. /**
  50417. * Checks to see if a texture is used in the material.
  50418. * @param texture - Base texture to use.
  50419. * @returns - Boolean specifying if a texture is used in the material.
  50420. */
  50421. hasTexture(texture: BaseTexture): boolean;
  50422. /**
  50423. * Returns an array of the actively used textures.
  50424. * @param activeTextures Array of BaseTextures
  50425. */
  50426. getActiveTextures(activeTextures: BaseTexture[]): void;
  50427. /**
  50428. * Returns the animatable textures.
  50429. * @param animatables Array of animatable textures.
  50430. */
  50431. getAnimatables(animatables: IAnimatable[]): void;
  50432. /**
  50433. * Disposes the resources of the material.
  50434. * @param forceDisposeTextures - Forces the disposal of all textures.
  50435. */
  50436. dispose(forceDisposeTextures?: boolean): void;
  50437. /**
  50438. * Get the current class name of the texture useful for serialization or dynamic coding.
  50439. * @returns "PBRAnisotropicConfiguration"
  50440. */
  50441. getClassName(): string;
  50442. /**
  50443. * Add fallbacks to the effect fallbacks list.
  50444. * @param defines defines the Base texture to use.
  50445. * @param fallbacks defines the current fallback list.
  50446. * @param currentRank defines the current fallback rank.
  50447. * @returns the new fallback rank.
  50448. */
  50449. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50450. /**
  50451. * Add the required uniforms to the current list.
  50452. * @param uniforms defines the current uniform list.
  50453. */
  50454. static AddUniforms(uniforms: string[]): void;
  50455. /**
  50456. * Add the required uniforms to the current buffer.
  50457. * @param uniformBuffer defines the current uniform buffer.
  50458. */
  50459. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50460. /**
  50461. * Add the required samplers to the current list.
  50462. * @param samplers defines the current sampler list.
  50463. */
  50464. static AddSamplers(samplers: string[]): void;
  50465. /**
  50466. * Makes a duplicate of the current configuration into another one.
  50467. * @param anisotropicConfiguration define the config where to copy the info
  50468. */
  50469. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50470. /**
  50471. * Serializes this anisotropy configuration.
  50472. * @returns - An object with the serialized config.
  50473. */
  50474. serialize(): any;
  50475. /**
  50476. * Parses a anisotropy Configuration from a serialized object.
  50477. * @param source - Serialized object.
  50478. * @param scene Defines the scene we are parsing for
  50479. * @param rootUrl Defines the rootUrl to load from
  50480. */
  50481. parse(source: any, scene: Scene, rootUrl: string): void;
  50482. }
  50483. }
  50484. declare module BABYLON {
  50485. /**
  50486. * @hidden
  50487. */
  50488. export interface IMaterialBRDFDefines {
  50489. BRDF_V_HEIGHT_CORRELATED: boolean;
  50490. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50491. SPHERICAL_HARMONICS: boolean;
  50492. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50493. /** @hidden */
  50494. _areMiscDirty: boolean;
  50495. }
  50496. /**
  50497. * Define the code related to the BRDF parameters of the pbr material.
  50498. */
  50499. export class PBRBRDFConfiguration {
  50500. /**
  50501. * Default value used for the energy conservation.
  50502. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50503. */
  50504. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50505. /**
  50506. * Default value used for the Smith Visibility Height Correlated mode.
  50507. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50508. */
  50509. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50510. /**
  50511. * Default value used for the IBL diffuse part.
  50512. * This can help switching back to the polynomials mode globally which is a tiny bit
  50513. * less GPU intensive at the drawback of a lower quality.
  50514. */
  50515. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50516. /**
  50517. * Default value used for activating energy conservation for the specular workflow.
  50518. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50519. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50520. */
  50521. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50522. private _useEnergyConservation;
  50523. /**
  50524. * Defines if the material uses energy conservation.
  50525. */
  50526. useEnergyConservation: boolean;
  50527. private _useSmithVisibilityHeightCorrelated;
  50528. /**
  50529. * LEGACY Mode set to false
  50530. * Defines if the material uses height smith correlated visibility term.
  50531. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50532. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50533. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50534. * Not relying on height correlated will also disable energy conservation.
  50535. */
  50536. useSmithVisibilityHeightCorrelated: boolean;
  50537. private _useSphericalHarmonics;
  50538. /**
  50539. * LEGACY Mode set to false
  50540. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50541. * diffuse part of the IBL.
  50542. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50543. * to the ground truth.
  50544. */
  50545. useSphericalHarmonics: boolean;
  50546. private _useSpecularGlossinessInputEnergyConservation;
  50547. /**
  50548. * Defines if the material uses energy conservation, when the specular workflow is active.
  50549. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50550. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50551. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50552. */
  50553. useSpecularGlossinessInputEnergyConservation: boolean;
  50554. /** @hidden */
  50555. private _internalMarkAllSubMeshesAsMiscDirty;
  50556. /** @hidden */
  50557. _markAllSubMeshesAsMiscDirty(): void;
  50558. /**
  50559. * Instantiate a new istance of clear coat configuration.
  50560. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50561. */
  50562. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50563. /**
  50564. * Checks to see if a texture is used in the material.
  50565. * @param defines the list of "defines" to update.
  50566. */
  50567. prepareDefines(defines: IMaterialBRDFDefines): void;
  50568. /**
  50569. * Get the current class name of the texture useful for serialization or dynamic coding.
  50570. * @returns "PBRClearCoatConfiguration"
  50571. */
  50572. getClassName(): string;
  50573. /**
  50574. * Makes a duplicate of the current configuration into another one.
  50575. * @param brdfConfiguration define the config where to copy the info
  50576. */
  50577. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50578. /**
  50579. * Serializes this BRDF configuration.
  50580. * @returns - An object with the serialized config.
  50581. */
  50582. serialize(): any;
  50583. /**
  50584. * Parses a anisotropy Configuration from a serialized object.
  50585. * @param source - Serialized object.
  50586. * @param scene Defines the scene we are parsing for
  50587. * @param rootUrl Defines the rootUrl to load from
  50588. */
  50589. parse(source: any, scene: Scene, rootUrl: string): void;
  50590. }
  50591. }
  50592. declare module BABYLON {
  50593. /**
  50594. * @hidden
  50595. */
  50596. export interface IMaterialSheenDefines {
  50597. SHEEN: boolean;
  50598. SHEEN_TEXTURE: boolean;
  50599. SHEEN_TEXTUREDIRECTUV: number;
  50600. SHEEN_LINKWITHALBEDO: boolean;
  50601. SHEEN_ROUGHNESS: boolean;
  50602. SHEEN_ALBEDOSCALING: boolean;
  50603. /** @hidden */
  50604. _areTexturesDirty: boolean;
  50605. }
  50606. /**
  50607. * Define the code related to the Sheen parameters of the pbr material.
  50608. */
  50609. export class PBRSheenConfiguration {
  50610. private _isEnabled;
  50611. /**
  50612. * Defines if the material uses sheen.
  50613. */
  50614. isEnabled: boolean;
  50615. private _linkSheenWithAlbedo;
  50616. /**
  50617. * Defines if the sheen is linked to the sheen color.
  50618. */
  50619. linkSheenWithAlbedo: boolean;
  50620. /**
  50621. * Defines the sheen intensity.
  50622. */
  50623. intensity: number;
  50624. /**
  50625. * Defines the sheen color.
  50626. */
  50627. color: Color3;
  50628. private _texture;
  50629. /**
  50630. * Stores the sheen tint values in a texture.
  50631. * rgb is tint
  50632. * a is a intensity
  50633. */
  50634. texture: Nullable<BaseTexture>;
  50635. private _roughness;
  50636. /**
  50637. * Defines the sheen roughness.
  50638. * It is not taken into account if linkSheenWithAlbedo is true.
  50639. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50640. */
  50641. roughness: Nullable<number>;
  50642. private _albedoScaling;
  50643. /**
  50644. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50645. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50646. * making it easier to setup and tweak the effect
  50647. */
  50648. albedoScaling: boolean;
  50649. /** @hidden */
  50650. private _internalMarkAllSubMeshesAsTexturesDirty;
  50651. /** @hidden */
  50652. _markAllSubMeshesAsTexturesDirty(): void;
  50653. /**
  50654. * Instantiate a new istance of clear coat configuration.
  50655. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50656. */
  50657. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50658. /**
  50659. * Specifies that the submesh is ready to be used.
  50660. * @param defines the list of "defines" to update.
  50661. * @param scene defines the scene the material belongs to.
  50662. * @returns - boolean indicating that the submesh is ready or not.
  50663. */
  50664. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50665. /**
  50666. * Checks to see if a texture is used in the material.
  50667. * @param defines the list of "defines" to update.
  50668. * @param scene defines the scene the material belongs to.
  50669. */
  50670. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50671. /**
  50672. * Binds the material data.
  50673. * @param uniformBuffer defines the Uniform buffer to fill in.
  50674. * @param scene defines the scene the material belongs to.
  50675. * @param isFrozen defines wether the material is frozen or not.
  50676. */
  50677. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50678. /**
  50679. * Checks to see if a texture is used in the material.
  50680. * @param texture - Base texture to use.
  50681. * @returns - Boolean specifying if a texture is used in the material.
  50682. */
  50683. hasTexture(texture: BaseTexture): boolean;
  50684. /**
  50685. * Returns an array of the actively used textures.
  50686. * @param activeTextures Array of BaseTextures
  50687. */
  50688. getActiveTextures(activeTextures: BaseTexture[]): void;
  50689. /**
  50690. * Returns the animatable textures.
  50691. * @param animatables Array of animatable textures.
  50692. */
  50693. getAnimatables(animatables: IAnimatable[]): void;
  50694. /**
  50695. * Disposes the resources of the material.
  50696. * @param forceDisposeTextures - Forces the disposal of all textures.
  50697. */
  50698. dispose(forceDisposeTextures?: boolean): void;
  50699. /**
  50700. * Get the current class name of the texture useful for serialization or dynamic coding.
  50701. * @returns "PBRSheenConfiguration"
  50702. */
  50703. getClassName(): string;
  50704. /**
  50705. * Add fallbacks to the effect fallbacks list.
  50706. * @param defines defines the Base texture to use.
  50707. * @param fallbacks defines the current fallback list.
  50708. * @param currentRank defines the current fallback rank.
  50709. * @returns the new fallback rank.
  50710. */
  50711. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50712. /**
  50713. * Add the required uniforms to the current list.
  50714. * @param uniforms defines the current uniform list.
  50715. */
  50716. static AddUniforms(uniforms: string[]): void;
  50717. /**
  50718. * Add the required uniforms to the current buffer.
  50719. * @param uniformBuffer defines the current uniform buffer.
  50720. */
  50721. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50722. /**
  50723. * Add the required samplers to the current list.
  50724. * @param samplers defines the current sampler list.
  50725. */
  50726. static AddSamplers(samplers: string[]): void;
  50727. /**
  50728. * Makes a duplicate of the current configuration into another one.
  50729. * @param sheenConfiguration define the config where to copy the info
  50730. */
  50731. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50732. /**
  50733. * Serializes this BRDF configuration.
  50734. * @returns - An object with the serialized config.
  50735. */
  50736. serialize(): any;
  50737. /**
  50738. * Parses a anisotropy Configuration from a serialized object.
  50739. * @param source - Serialized object.
  50740. * @param scene Defines the scene we are parsing for
  50741. * @param rootUrl Defines the rootUrl to load from
  50742. */
  50743. parse(source: any, scene: Scene, rootUrl: string): void;
  50744. }
  50745. }
  50746. declare module BABYLON {
  50747. /**
  50748. * @hidden
  50749. */
  50750. export interface IMaterialSubSurfaceDefines {
  50751. SUBSURFACE: boolean;
  50752. SS_REFRACTION: boolean;
  50753. SS_TRANSLUCENCY: boolean;
  50754. SS_SCATERRING: boolean;
  50755. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50756. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50757. SS_REFRACTIONMAP_3D: boolean;
  50758. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50759. SS_LODINREFRACTIONALPHA: boolean;
  50760. SS_GAMMAREFRACTION: boolean;
  50761. SS_RGBDREFRACTION: boolean;
  50762. SS_LINEARSPECULARREFRACTION: boolean;
  50763. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50764. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50765. /** @hidden */
  50766. _areTexturesDirty: boolean;
  50767. }
  50768. /**
  50769. * Define the code related to the sub surface parameters of the pbr material.
  50770. */
  50771. export class PBRSubSurfaceConfiguration {
  50772. private _isRefractionEnabled;
  50773. /**
  50774. * Defines if the refraction is enabled in the material.
  50775. */
  50776. isRefractionEnabled: boolean;
  50777. private _isTranslucencyEnabled;
  50778. /**
  50779. * Defines if the translucency is enabled in the material.
  50780. */
  50781. isTranslucencyEnabled: boolean;
  50782. private _isScatteringEnabled;
  50783. /**
  50784. * Defines the refraction intensity of the material.
  50785. * The refraction when enabled replaces the Diffuse part of the material.
  50786. * The intensity helps transitionning between diffuse and refraction.
  50787. */
  50788. refractionIntensity: number;
  50789. /**
  50790. * Defines the translucency intensity of the material.
  50791. * When translucency has been enabled, this defines how much of the "translucency"
  50792. * is addded to the diffuse part of the material.
  50793. */
  50794. translucencyIntensity: number;
  50795. /**
  50796. * Defines the scattering intensity of the material.
  50797. * When scattering has been enabled, this defines how much of the "scattered light"
  50798. * is addded to the diffuse part of the material.
  50799. */
  50800. scatteringIntensity: number;
  50801. private _thicknessTexture;
  50802. /**
  50803. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50804. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50805. * 0 would mean minimumThickness
  50806. * 1 would mean maximumThickness
  50807. * The other channels might be use as a mask to vary the different effects intensity.
  50808. */
  50809. thicknessTexture: Nullable<BaseTexture>;
  50810. private _refractionTexture;
  50811. /**
  50812. * Defines the texture to use for refraction.
  50813. */
  50814. refractionTexture: Nullable<BaseTexture>;
  50815. private _indexOfRefraction;
  50816. /**
  50817. * Defines the index of refraction used in the material.
  50818. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50819. */
  50820. indexOfRefraction: number;
  50821. private _invertRefractionY;
  50822. /**
  50823. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50824. */
  50825. invertRefractionY: boolean;
  50826. private _linkRefractionWithTransparency;
  50827. /**
  50828. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50829. * Materials half opaque for instance using refraction could benefit from this control.
  50830. */
  50831. linkRefractionWithTransparency: boolean;
  50832. /**
  50833. * Defines the minimum thickness stored in the thickness map.
  50834. * If no thickness map is defined, this value will be used to simulate thickness.
  50835. */
  50836. minimumThickness: number;
  50837. /**
  50838. * Defines the maximum thickness stored in the thickness map.
  50839. */
  50840. maximumThickness: number;
  50841. /**
  50842. * Defines the volume tint of the material.
  50843. * This is used for both translucency and scattering.
  50844. */
  50845. tintColor: Color3;
  50846. /**
  50847. * Defines the distance at which the tint color should be found in the media.
  50848. * This is used for refraction only.
  50849. */
  50850. tintColorAtDistance: number;
  50851. /**
  50852. * Defines how far each channel transmit through the media.
  50853. * It is defined as a color to simplify it selection.
  50854. */
  50855. diffusionDistance: Color3;
  50856. private _useMaskFromThicknessTexture;
  50857. /**
  50858. * Stores the intensity of the different subsurface effects in the thickness texture.
  50859. * * the green channel is the translucency intensity.
  50860. * * the blue channel is the scattering intensity.
  50861. * * the alpha channel is the refraction intensity.
  50862. */
  50863. useMaskFromThicknessTexture: boolean;
  50864. /** @hidden */
  50865. private _internalMarkAllSubMeshesAsTexturesDirty;
  50866. /** @hidden */
  50867. _markAllSubMeshesAsTexturesDirty(): void;
  50868. /**
  50869. * Instantiate a new istance of sub surface configuration.
  50870. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50871. */
  50872. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50873. /**
  50874. * Gets wehter the submesh is ready to be used or not.
  50875. * @param defines the list of "defines" to update.
  50876. * @param scene defines the scene the material belongs to.
  50877. * @returns - boolean indicating that the submesh is ready or not.
  50878. */
  50879. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50880. /**
  50881. * Checks to see if a texture is used in the material.
  50882. * @param defines the list of "defines" to update.
  50883. * @param scene defines the scene to the material belongs to.
  50884. */
  50885. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50886. /**
  50887. * Binds the material data.
  50888. * @param uniformBuffer defines the Uniform buffer to fill in.
  50889. * @param scene defines the scene the material belongs to.
  50890. * @param engine defines the engine the material belongs to.
  50891. * @param isFrozen defines wether the material is frozen or not.
  50892. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50893. */
  50894. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50895. /**
  50896. * Unbinds the material from the mesh.
  50897. * @param activeEffect defines the effect that should be unbound from.
  50898. * @returns true if unbound, otherwise false
  50899. */
  50900. unbind(activeEffect: Effect): boolean;
  50901. /**
  50902. * Returns the texture used for refraction or null if none is used.
  50903. * @param scene defines the scene the material belongs to.
  50904. * @returns - Refraction texture if present. If no refraction texture and refraction
  50905. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50906. */
  50907. private _getRefractionTexture;
  50908. /**
  50909. * Returns true if alpha blending should be disabled.
  50910. */
  50911. get disableAlphaBlending(): boolean;
  50912. /**
  50913. * Fills the list of render target textures.
  50914. * @param renderTargets the list of render targets to update
  50915. */
  50916. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50917. /**
  50918. * Checks to see if a texture is used in the material.
  50919. * @param texture - Base texture to use.
  50920. * @returns - Boolean specifying if a texture is used in the material.
  50921. */
  50922. hasTexture(texture: BaseTexture): boolean;
  50923. /**
  50924. * Gets a boolean indicating that current material needs to register RTT
  50925. * @returns true if this uses a render target otherwise false.
  50926. */
  50927. hasRenderTargetTextures(): boolean;
  50928. /**
  50929. * Returns an array of the actively used textures.
  50930. * @param activeTextures Array of BaseTextures
  50931. */
  50932. getActiveTextures(activeTextures: BaseTexture[]): void;
  50933. /**
  50934. * Returns the animatable textures.
  50935. * @param animatables Array of animatable textures.
  50936. */
  50937. getAnimatables(animatables: IAnimatable[]): void;
  50938. /**
  50939. * Disposes the resources of the material.
  50940. * @param forceDisposeTextures - Forces the disposal of all textures.
  50941. */
  50942. dispose(forceDisposeTextures?: boolean): void;
  50943. /**
  50944. * Get the current class name of the texture useful for serialization or dynamic coding.
  50945. * @returns "PBRSubSurfaceConfiguration"
  50946. */
  50947. getClassName(): string;
  50948. /**
  50949. * Add fallbacks to the effect fallbacks list.
  50950. * @param defines defines the Base texture to use.
  50951. * @param fallbacks defines the current fallback list.
  50952. * @param currentRank defines the current fallback rank.
  50953. * @returns the new fallback rank.
  50954. */
  50955. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50956. /**
  50957. * Add the required uniforms to the current list.
  50958. * @param uniforms defines the current uniform list.
  50959. */
  50960. static AddUniforms(uniforms: string[]): void;
  50961. /**
  50962. * Add the required samplers to the current list.
  50963. * @param samplers defines the current sampler list.
  50964. */
  50965. static AddSamplers(samplers: string[]): void;
  50966. /**
  50967. * Add the required uniforms to the current buffer.
  50968. * @param uniformBuffer defines the current uniform buffer.
  50969. */
  50970. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50971. /**
  50972. * Makes a duplicate of the current configuration into another one.
  50973. * @param configuration define the config where to copy the info
  50974. */
  50975. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50976. /**
  50977. * Serializes this Sub Surface configuration.
  50978. * @returns - An object with the serialized config.
  50979. */
  50980. serialize(): any;
  50981. /**
  50982. * Parses a anisotropy Configuration from a serialized object.
  50983. * @param source - Serialized object.
  50984. * @param scene Defines the scene we are parsing for
  50985. * @param rootUrl Defines the rootUrl to load from
  50986. */
  50987. parse(source: any, scene: Scene, rootUrl: string): void;
  50988. }
  50989. }
  50990. declare module BABYLON {
  50991. /** @hidden */
  50992. export var pbrFragmentDeclaration: {
  50993. name: string;
  50994. shader: string;
  50995. };
  50996. }
  50997. declare module BABYLON {
  50998. /** @hidden */
  50999. export var pbrUboDeclaration: {
  51000. name: string;
  51001. shader: string;
  51002. };
  51003. }
  51004. declare module BABYLON {
  51005. /** @hidden */
  51006. export var pbrFragmentExtraDeclaration: {
  51007. name: string;
  51008. shader: string;
  51009. };
  51010. }
  51011. declare module BABYLON {
  51012. /** @hidden */
  51013. export var pbrFragmentSamplersDeclaration: {
  51014. name: string;
  51015. shader: string;
  51016. };
  51017. }
  51018. declare module BABYLON {
  51019. /** @hidden */
  51020. export var pbrHelperFunctions: {
  51021. name: string;
  51022. shader: string;
  51023. };
  51024. }
  51025. declare module BABYLON {
  51026. /** @hidden */
  51027. export var harmonicsFunctions: {
  51028. name: string;
  51029. shader: string;
  51030. };
  51031. }
  51032. declare module BABYLON {
  51033. /** @hidden */
  51034. export var pbrDirectLightingSetupFunctions: {
  51035. name: string;
  51036. shader: string;
  51037. };
  51038. }
  51039. declare module BABYLON {
  51040. /** @hidden */
  51041. export var pbrDirectLightingFalloffFunctions: {
  51042. name: string;
  51043. shader: string;
  51044. };
  51045. }
  51046. declare module BABYLON {
  51047. /** @hidden */
  51048. export var pbrBRDFFunctions: {
  51049. name: string;
  51050. shader: string;
  51051. };
  51052. }
  51053. declare module BABYLON {
  51054. /** @hidden */
  51055. export var pbrDirectLightingFunctions: {
  51056. name: string;
  51057. shader: string;
  51058. };
  51059. }
  51060. declare module BABYLON {
  51061. /** @hidden */
  51062. export var pbrIBLFunctions: {
  51063. name: string;
  51064. shader: string;
  51065. };
  51066. }
  51067. declare module BABYLON {
  51068. /** @hidden */
  51069. export var pbrDebug: {
  51070. name: string;
  51071. shader: string;
  51072. };
  51073. }
  51074. declare module BABYLON {
  51075. /** @hidden */
  51076. export var pbrPixelShader: {
  51077. name: string;
  51078. shader: string;
  51079. };
  51080. }
  51081. declare module BABYLON {
  51082. /** @hidden */
  51083. export var pbrVertexDeclaration: {
  51084. name: string;
  51085. shader: string;
  51086. };
  51087. }
  51088. declare module BABYLON {
  51089. /** @hidden */
  51090. export var pbrVertexShader: {
  51091. name: string;
  51092. shader: string;
  51093. };
  51094. }
  51095. declare module BABYLON {
  51096. /**
  51097. * Manages the defines for the PBR Material.
  51098. * @hidden
  51099. */
  51100. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51101. PBR: boolean;
  51102. MAINUV1: boolean;
  51103. MAINUV2: boolean;
  51104. UV1: boolean;
  51105. UV2: boolean;
  51106. ALBEDO: boolean;
  51107. GAMMAALBEDO: boolean;
  51108. ALBEDODIRECTUV: number;
  51109. VERTEXCOLOR: boolean;
  51110. AMBIENT: boolean;
  51111. AMBIENTDIRECTUV: number;
  51112. AMBIENTINGRAYSCALE: boolean;
  51113. OPACITY: boolean;
  51114. VERTEXALPHA: boolean;
  51115. OPACITYDIRECTUV: number;
  51116. OPACITYRGB: boolean;
  51117. ALPHATEST: boolean;
  51118. DEPTHPREPASS: boolean;
  51119. ALPHABLEND: boolean;
  51120. ALPHAFROMALBEDO: boolean;
  51121. ALPHATESTVALUE: string;
  51122. SPECULAROVERALPHA: boolean;
  51123. RADIANCEOVERALPHA: boolean;
  51124. ALPHAFRESNEL: boolean;
  51125. LINEARALPHAFRESNEL: boolean;
  51126. PREMULTIPLYALPHA: boolean;
  51127. EMISSIVE: boolean;
  51128. EMISSIVEDIRECTUV: number;
  51129. REFLECTIVITY: boolean;
  51130. REFLECTIVITYDIRECTUV: number;
  51131. SPECULARTERM: boolean;
  51132. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51133. MICROSURFACEAUTOMATIC: boolean;
  51134. LODBASEDMICROSFURACE: boolean;
  51135. MICROSURFACEMAP: boolean;
  51136. MICROSURFACEMAPDIRECTUV: number;
  51137. METALLICWORKFLOW: boolean;
  51138. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51139. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51140. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51141. AOSTOREINMETALMAPRED: boolean;
  51142. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51143. ENVIRONMENTBRDF: boolean;
  51144. ENVIRONMENTBRDF_RGBD: boolean;
  51145. NORMAL: boolean;
  51146. TANGENT: boolean;
  51147. BUMP: boolean;
  51148. BUMPDIRECTUV: number;
  51149. OBJECTSPACE_NORMALMAP: boolean;
  51150. PARALLAX: boolean;
  51151. PARALLAXOCCLUSION: boolean;
  51152. NORMALXYSCALE: boolean;
  51153. LIGHTMAP: boolean;
  51154. LIGHTMAPDIRECTUV: number;
  51155. USELIGHTMAPASSHADOWMAP: boolean;
  51156. GAMMALIGHTMAP: boolean;
  51157. RGBDLIGHTMAP: boolean;
  51158. REFLECTION: boolean;
  51159. REFLECTIONMAP_3D: boolean;
  51160. REFLECTIONMAP_SPHERICAL: boolean;
  51161. REFLECTIONMAP_PLANAR: boolean;
  51162. REFLECTIONMAP_CUBIC: boolean;
  51163. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51164. REFLECTIONMAP_PROJECTION: boolean;
  51165. REFLECTIONMAP_SKYBOX: boolean;
  51166. REFLECTIONMAP_EXPLICIT: boolean;
  51167. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51168. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51169. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51170. INVERTCUBICMAP: boolean;
  51171. USESPHERICALFROMREFLECTIONMAP: boolean;
  51172. USEIRRADIANCEMAP: boolean;
  51173. SPHERICAL_HARMONICS: boolean;
  51174. USESPHERICALINVERTEX: boolean;
  51175. REFLECTIONMAP_OPPOSITEZ: boolean;
  51176. LODINREFLECTIONALPHA: boolean;
  51177. GAMMAREFLECTION: boolean;
  51178. RGBDREFLECTION: boolean;
  51179. LINEARSPECULARREFLECTION: boolean;
  51180. RADIANCEOCCLUSION: boolean;
  51181. HORIZONOCCLUSION: boolean;
  51182. INSTANCES: boolean;
  51183. NUM_BONE_INFLUENCERS: number;
  51184. BonesPerMesh: number;
  51185. BONETEXTURE: boolean;
  51186. NONUNIFORMSCALING: boolean;
  51187. MORPHTARGETS: boolean;
  51188. MORPHTARGETS_NORMAL: boolean;
  51189. MORPHTARGETS_TANGENT: boolean;
  51190. MORPHTARGETS_UV: boolean;
  51191. NUM_MORPH_INFLUENCERS: number;
  51192. IMAGEPROCESSING: boolean;
  51193. VIGNETTE: boolean;
  51194. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51195. VIGNETTEBLENDMODEOPAQUE: boolean;
  51196. TONEMAPPING: boolean;
  51197. TONEMAPPING_ACES: boolean;
  51198. CONTRAST: boolean;
  51199. COLORCURVES: boolean;
  51200. COLORGRADING: boolean;
  51201. COLORGRADING3D: boolean;
  51202. SAMPLER3DGREENDEPTH: boolean;
  51203. SAMPLER3DBGRMAP: boolean;
  51204. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51205. EXPOSURE: boolean;
  51206. MULTIVIEW: boolean;
  51207. USEPHYSICALLIGHTFALLOFF: boolean;
  51208. USEGLTFLIGHTFALLOFF: boolean;
  51209. TWOSIDEDLIGHTING: boolean;
  51210. SHADOWFLOAT: boolean;
  51211. CLIPPLANE: boolean;
  51212. CLIPPLANE2: boolean;
  51213. CLIPPLANE3: boolean;
  51214. CLIPPLANE4: boolean;
  51215. CLIPPLANE5: boolean;
  51216. CLIPPLANE6: boolean;
  51217. POINTSIZE: boolean;
  51218. FOG: boolean;
  51219. LOGARITHMICDEPTH: boolean;
  51220. FORCENORMALFORWARD: boolean;
  51221. SPECULARAA: boolean;
  51222. CLEARCOAT: boolean;
  51223. CLEARCOAT_DEFAULTIOR: boolean;
  51224. CLEARCOAT_TEXTURE: boolean;
  51225. CLEARCOAT_TEXTUREDIRECTUV: number;
  51226. CLEARCOAT_BUMP: boolean;
  51227. CLEARCOAT_BUMPDIRECTUV: number;
  51228. CLEARCOAT_TINT: boolean;
  51229. CLEARCOAT_TINT_TEXTURE: boolean;
  51230. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51231. ANISOTROPIC: boolean;
  51232. ANISOTROPIC_TEXTURE: boolean;
  51233. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51234. BRDF_V_HEIGHT_CORRELATED: boolean;
  51235. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51236. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51237. SHEEN: boolean;
  51238. SHEEN_TEXTURE: boolean;
  51239. SHEEN_TEXTUREDIRECTUV: number;
  51240. SHEEN_LINKWITHALBEDO: boolean;
  51241. SHEEN_ROUGHNESS: boolean;
  51242. SHEEN_ALBEDOSCALING: boolean;
  51243. SUBSURFACE: boolean;
  51244. SS_REFRACTION: boolean;
  51245. SS_TRANSLUCENCY: boolean;
  51246. SS_SCATERRING: boolean;
  51247. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51248. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51249. SS_REFRACTIONMAP_3D: boolean;
  51250. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51251. SS_LODINREFRACTIONALPHA: boolean;
  51252. SS_GAMMAREFRACTION: boolean;
  51253. SS_RGBDREFRACTION: boolean;
  51254. SS_LINEARSPECULARREFRACTION: boolean;
  51255. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51256. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51257. UNLIT: boolean;
  51258. DEBUGMODE: number;
  51259. /**
  51260. * Initializes the PBR Material defines.
  51261. */
  51262. constructor();
  51263. /**
  51264. * Resets the PBR Material defines.
  51265. */
  51266. reset(): void;
  51267. }
  51268. /**
  51269. * The Physically based material base class of BJS.
  51270. *
  51271. * This offers the main features of a standard PBR material.
  51272. * For more information, please refer to the documentation :
  51273. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51274. */
  51275. export abstract class PBRBaseMaterial extends PushMaterial {
  51276. /**
  51277. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51278. */
  51279. static readonly PBRMATERIAL_OPAQUE: number;
  51280. /**
  51281. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51282. */
  51283. static readonly PBRMATERIAL_ALPHATEST: number;
  51284. /**
  51285. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51286. */
  51287. static readonly PBRMATERIAL_ALPHABLEND: number;
  51288. /**
  51289. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51290. * They are also discarded below the alpha cutoff threshold to improve performances.
  51291. */
  51292. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51293. /**
  51294. * Defines the default value of how much AO map is occluding the analytical lights
  51295. * (point spot...).
  51296. */
  51297. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51298. /**
  51299. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51300. */
  51301. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51302. /**
  51303. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51304. * to enhance interoperability with other engines.
  51305. */
  51306. static readonly LIGHTFALLOFF_GLTF: number;
  51307. /**
  51308. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51309. * to enhance interoperability with other materials.
  51310. */
  51311. static readonly LIGHTFALLOFF_STANDARD: number;
  51312. /**
  51313. * Intensity of the direct lights e.g. the four lights available in your scene.
  51314. * This impacts both the direct diffuse and specular highlights.
  51315. */
  51316. protected _directIntensity: number;
  51317. /**
  51318. * Intensity of the emissive part of the material.
  51319. * This helps controlling the emissive effect without modifying the emissive color.
  51320. */
  51321. protected _emissiveIntensity: number;
  51322. /**
  51323. * Intensity of the environment e.g. how much the environment will light the object
  51324. * either through harmonics for rough material or through the refelction for shiny ones.
  51325. */
  51326. protected _environmentIntensity: number;
  51327. /**
  51328. * This is a special control allowing the reduction of the specular highlights coming from the
  51329. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51330. */
  51331. protected _specularIntensity: number;
  51332. /**
  51333. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51334. */
  51335. private _lightingInfos;
  51336. /**
  51337. * Debug Control allowing disabling the bump map on this material.
  51338. */
  51339. protected _disableBumpMap: boolean;
  51340. /**
  51341. * AKA Diffuse Texture in standard nomenclature.
  51342. */
  51343. protected _albedoTexture: Nullable<BaseTexture>;
  51344. /**
  51345. * AKA Occlusion Texture in other nomenclature.
  51346. */
  51347. protected _ambientTexture: Nullable<BaseTexture>;
  51348. /**
  51349. * AKA Occlusion Texture Intensity in other nomenclature.
  51350. */
  51351. protected _ambientTextureStrength: number;
  51352. /**
  51353. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51354. * 1 means it completely occludes it
  51355. * 0 mean it has no impact
  51356. */
  51357. protected _ambientTextureImpactOnAnalyticalLights: number;
  51358. /**
  51359. * Stores the alpha values in a texture.
  51360. */
  51361. protected _opacityTexture: Nullable<BaseTexture>;
  51362. /**
  51363. * Stores the reflection values in a texture.
  51364. */
  51365. protected _reflectionTexture: Nullable<BaseTexture>;
  51366. /**
  51367. * Stores the emissive values in a texture.
  51368. */
  51369. protected _emissiveTexture: Nullable<BaseTexture>;
  51370. /**
  51371. * AKA Specular texture in other nomenclature.
  51372. */
  51373. protected _reflectivityTexture: Nullable<BaseTexture>;
  51374. /**
  51375. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51376. */
  51377. protected _metallicTexture: Nullable<BaseTexture>;
  51378. /**
  51379. * Specifies the metallic scalar of the metallic/roughness workflow.
  51380. * Can also be used to scale the metalness values of the metallic texture.
  51381. */
  51382. protected _metallic: Nullable<number>;
  51383. /**
  51384. * Specifies the roughness scalar of the metallic/roughness workflow.
  51385. * Can also be used to scale the roughness values of the metallic texture.
  51386. */
  51387. protected _roughness: Nullable<number>;
  51388. /**
  51389. * Specifies the an F0 factor to help configuring the material F0.
  51390. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51391. * to 0.5 the previously hard coded value stays the same.
  51392. * Can also be used to scale the F0 values of the metallic texture.
  51393. */
  51394. protected _metallicF0Factor: number;
  51395. /**
  51396. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51397. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51398. * your expectation as it multiplies with the texture data.
  51399. */
  51400. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51401. /**
  51402. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51403. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51404. */
  51405. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51406. /**
  51407. * Stores surface normal data used to displace a mesh in a texture.
  51408. */
  51409. protected _bumpTexture: Nullable<BaseTexture>;
  51410. /**
  51411. * Stores the pre-calculated light information of a mesh in a texture.
  51412. */
  51413. protected _lightmapTexture: Nullable<BaseTexture>;
  51414. /**
  51415. * The color of a material in ambient lighting.
  51416. */
  51417. protected _ambientColor: Color3;
  51418. /**
  51419. * AKA Diffuse Color in other nomenclature.
  51420. */
  51421. protected _albedoColor: Color3;
  51422. /**
  51423. * AKA Specular Color in other nomenclature.
  51424. */
  51425. protected _reflectivityColor: Color3;
  51426. /**
  51427. * The color applied when light is reflected from a material.
  51428. */
  51429. protected _reflectionColor: Color3;
  51430. /**
  51431. * The color applied when light is emitted from a material.
  51432. */
  51433. protected _emissiveColor: Color3;
  51434. /**
  51435. * AKA Glossiness in other nomenclature.
  51436. */
  51437. protected _microSurface: number;
  51438. /**
  51439. * Specifies that the material will use the light map as a show map.
  51440. */
  51441. protected _useLightmapAsShadowmap: boolean;
  51442. /**
  51443. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51444. * makes the reflect vector face the model (under horizon).
  51445. */
  51446. protected _useHorizonOcclusion: boolean;
  51447. /**
  51448. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51449. * too much the area relying on ambient texture to define their ambient occlusion.
  51450. */
  51451. protected _useRadianceOcclusion: boolean;
  51452. /**
  51453. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51454. */
  51455. protected _useAlphaFromAlbedoTexture: boolean;
  51456. /**
  51457. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51458. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51459. */
  51460. protected _useSpecularOverAlpha: boolean;
  51461. /**
  51462. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51463. */
  51464. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51465. /**
  51466. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51467. */
  51468. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51469. /**
  51470. * Specifies if the metallic texture contains the roughness information in its green channel.
  51471. */
  51472. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51473. /**
  51474. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51475. */
  51476. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51477. /**
  51478. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51479. */
  51480. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51481. /**
  51482. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51483. */
  51484. protected _useAmbientInGrayScale: boolean;
  51485. /**
  51486. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51487. * The material will try to infer what glossiness each pixel should be.
  51488. */
  51489. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51490. /**
  51491. * Defines the falloff type used in this material.
  51492. * It by default is Physical.
  51493. */
  51494. protected _lightFalloff: number;
  51495. /**
  51496. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51497. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51498. */
  51499. protected _useRadianceOverAlpha: boolean;
  51500. /**
  51501. * Allows using an object space normal map (instead of tangent space).
  51502. */
  51503. protected _useObjectSpaceNormalMap: boolean;
  51504. /**
  51505. * Allows using the bump map in parallax mode.
  51506. */
  51507. protected _useParallax: boolean;
  51508. /**
  51509. * Allows using the bump map in parallax occlusion mode.
  51510. */
  51511. protected _useParallaxOcclusion: boolean;
  51512. /**
  51513. * Controls the scale bias of the parallax mode.
  51514. */
  51515. protected _parallaxScaleBias: number;
  51516. /**
  51517. * If sets to true, disables all the lights affecting the material.
  51518. */
  51519. protected _disableLighting: boolean;
  51520. /**
  51521. * Number of Simultaneous lights allowed on the material.
  51522. */
  51523. protected _maxSimultaneousLights: number;
  51524. /**
  51525. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51526. */
  51527. protected _invertNormalMapX: boolean;
  51528. /**
  51529. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51530. */
  51531. protected _invertNormalMapY: boolean;
  51532. /**
  51533. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51534. */
  51535. protected _twoSidedLighting: boolean;
  51536. /**
  51537. * Defines the alpha limits in alpha test mode.
  51538. */
  51539. protected _alphaCutOff: number;
  51540. /**
  51541. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51542. */
  51543. protected _forceAlphaTest: boolean;
  51544. /**
  51545. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51546. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51547. */
  51548. protected _useAlphaFresnel: boolean;
  51549. /**
  51550. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51551. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51552. */
  51553. protected _useLinearAlphaFresnel: boolean;
  51554. /**
  51555. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51556. * from cos thetav and roughness:
  51557. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51558. */
  51559. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51560. /**
  51561. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51562. */
  51563. protected _forceIrradianceInFragment: boolean;
  51564. /**
  51565. * Force normal to face away from face.
  51566. */
  51567. protected _forceNormalForward: boolean;
  51568. /**
  51569. * Enables specular anti aliasing in the PBR shader.
  51570. * It will both interacts on the Geometry for analytical and IBL lighting.
  51571. * It also prefilter the roughness map based on the bump values.
  51572. */
  51573. protected _enableSpecularAntiAliasing: boolean;
  51574. /**
  51575. * Default configuration related to image processing available in the PBR Material.
  51576. */
  51577. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51578. /**
  51579. * Keep track of the image processing observer to allow dispose and replace.
  51580. */
  51581. private _imageProcessingObserver;
  51582. /**
  51583. * Attaches a new image processing configuration to the PBR Material.
  51584. * @param configuration
  51585. */
  51586. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51587. /**
  51588. * Stores the available render targets.
  51589. */
  51590. private _renderTargets;
  51591. /**
  51592. * Sets the global ambient color for the material used in lighting calculations.
  51593. */
  51594. private _globalAmbientColor;
  51595. /**
  51596. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51597. */
  51598. private _useLogarithmicDepth;
  51599. /**
  51600. * If set to true, no lighting calculations will be applied.
  51601. */
  51602. private _unlit;
  51603. private _debugMode;
  51604. /**
  51605. * @hidden
  51606. * This is reserved for the inspector.
  51607. * Defines the material debug mode.
  51608. * It helps seeing only some components of the material while troubleshooting.
  51609. */
  51610. debugMode: number;
  51611. /**
  51612. * @hidden
  51613. * This is reserved for the inspector.
  51614. * Specify from where on screen the debug mode should start.
  51615. * The value goes from -1 (full screen) to 1 (not visible)
  51616. * It helps with side by side comparison against the final render
  51617. * This defaults to -1
  51618. */
  51619. private debugLimit;
  51620. /**
  51621. * @hidden
  51622. * This is reserved for the inspector.
  51623. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51624. * You can use the factor to better multiply the final value.
  51625. */
  51626. private debugFactor;
  51627. /**
  51628. * Defines the clear coat layer parameters for the material.
  51629. */
  51630. readonly clearCoat: PBRClearCoatConfiguration;
  51631. /**
  51632. * Defines the anisotropic parameters for the material.
  51633. */
  51634. readonly anisotropy: PBRAnisotropicConfiguration;
  51635. /**
  51636. * Defines the BRDF parameters for the material.
  51637. */
  51638. readonly brdf: PBRBRDFConfiguration;
  51639. /**
  51640. * Defines the Sheen parameters for the material.
  51641. */
  51642. readonly sheen: PBRSheenConfiguration;
  51643. /**
  51644. * Defines the SubSurface parameters for the material.
  51645. */
  51646. readonly subSurface: PBRSubSurfaceConfiguration;
  51647. /**
  51648. * Custom callback helping to override the default shader used in the material.
  51649. */
  51650. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51651. protected _rebuildInParallel: boolean;
  51652. /**
  51653. * Instantiates a new PBRMaterial instance.
  51654. *
  51655. * @param name The material name
  51656. * @param scene The scene the material will be use in.
  51657. */
  51658. constructor(name: string, scene: Scene);
  51659. /**
  51660. * Gets a boolean indicating that current material needs to register RTT
  51661. */
  51662. get hasRenderTargetTextures(): boolean;
  51663. /**
  51664. * Gets the name of the material class.
  51665. */
  51666. getClassName(): string;
  51667. /**
  51668. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51669. */
  51670. get useLogarithmicDepth(): boolean;
  51671. /**
  51672. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51673. */
  51674. set useLogarithmicDepth(value: boolean);
  51675. /**
  51676. * Returns true if alpha blending should be disabled.
  51677. */
  51678. protected get _disableAlphaBlending(): boolean;
  51679. /**
  51680. * Specifies whether or not this material should be rendered in alpha blend mode.
  51681. */
  51682. needAlphaBlending(): boolean;
  51683. /**
  51684. * Specifies whether or not this material should be rendered in alpha test mode.
  51685. */
  51686. needAlphaTesting(): boolean;
  51687. /**
  51688. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51689. */
  51690. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51691. /**
  51692. * Gets the texture used for the alpha test.
  51693. */
  51694. getAlphaTestTexture(): Nullable<BaseTexture>;
  51695. /**
  51696. * Specifies that the submesh is ready to be used.
  51697. * @param mesh - BJS mesh.
  51698. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51699. * @param useInstances - Specifies that instances should be used.
  51700. * @returns - boolean indicating that the submesh is ready or not.
  51701. */
  51702. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51703. /**
  51704. * Specifies if the material uses metallic roughness workflow.
  51705. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51706. */
  51707. isMetallicWorkflow(): boolean;
  51708. private _prepareEffect;
  51709. private _prepareDefines;
  51710. /**
  51711. * Force shader compilation
  51712. */
  51713. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51714. /**
  51715. * Initializes the uniform buffer layout for the shader.
  51716. */
  51717. buildUniformLayout(): void;
  51718. /**
  51719. * Unbinds the material from the mesh
  51720. */
  51721. unbind(): void;
  51722. /**
  51723. * Binds the submesh data.
  51724. * @param world - The world matrix.
  51725. * @param mesh - The BJS mesh.
  51726. * @param subMesh - A submesh of the BJS mesh.
  51727. */
  51728. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51729. /**
  51730. * Returns the animatable textures.
  51731. * @returns - Array of animatable textures.
  51732. */
  51733. getAnimatables(): IAnimatable[];
  51734. /**
  51735. * Returns the texture used for reflections.
  51736. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51737. */
  51738. private _getReflectionTexture;
  51739. /**
  51740. * Returns an array of the actively used textures.
  51741. * @returns - Array of BaseTextures
  51742. */
  51743. getActiveTextures(): BaseTexture[];
  51744. /**
  51745. * Checks to see if a texture is used in the material.
  51746. * @param texture - Base texture to use.
  51747. * @returns - Boolean specifying if a texture is used in the material.
  51748. */
  51749. hasTexture(texture: BaseTexture): boolean;
  51750. /**
  51751. * Disposes the resources of the material.
  51752. * @param forceDisposeEffect - Forces the disposal of effects.
  51753. * @param forceDisposeTextures - Forces the disposal of all textures.
  51754. */
  51755. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51756. }
  51757. }
  51758. declare module BABYLON {
  51759. /**
  51760. * The Physically based material of BJS.
  51761. *
  51762. * This offers the main features of a standard PBR material.
  51763. * For more information, please refer to the documentation :
  51764. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51765. */
  51766. export class PBRMaterial extends PBRBaseMaterial {
  51767. /**
  51768. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51769. */
  51770. static readonly PBRMATERIAL_OPAQUE: number;
  51771. /**
  51772. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51773. */
  51774. static readonly PBRMATERIAL_ALPHATEST: number;
  51775. /**
  51776. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51777. */
  51778. static readonly PBRMATERIAL_ALPHABLEND: number;
  51779. /**
  51780. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51781. * They are also discarded below the alpha cutoff threshold to improve performances.
  51782. */
  51783. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51784. /**
  51785. * Defines the default value of how much AO map is occluding the analytical lights
  51786. * (point spot...).
  51787. */
  51788. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51789. /**
  51790. * Intensity of the direct lights e.g. the four lights available in your scene.
  51791. * This impacts both the direct diffuse and specular highlights.
  51792. */
  51793. directIntensity: number;
  51794. /**
  51795. * Intensity of the emissive part of the material.
  51796. * This helps controlling the emissive effect without modifying the emissive color.
  51797. */
  51798. emissiveIntensity: number;
  51799. /**
  51800. * Intensity of the environment e.g. how much the environment will light the object
  51801. * either through harmonics for rough material or through the refelction for shiny ones.
  51802. */
  51803. environmentIntensity: number;
  51804. /**
  51805. * This is a special control allowing the reduction of the specular highlights coming from the
  51806. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51807. */
  51808. specularIntensity: number;
  51809. /**
  51810. * Debug Control allowing disabling the bump map on this material.
  51811. */
  51812. disableBumpMap: boolean;
  51813. /**
  51814. * AKA Diffuse Texture in standard nomenclature.
  51815. */
  51816. albedoTexture: BaseTexture;
  51817. /**
  51818. * AKA Occlusion Texture in other nomenclature.
  51819. */
  51820. ambientTexture: BaseTexture;
  51821. /**
  51822. * AKA Occlusion Texture Intensity in other nomenclature.
  51823. */
  51824. ambientTextureStrength: number;
  51825. /**
  51826. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51827. * 1 means it completely occludes it
  51828. * 0 mean it has no impact
  51829. */
  51830. ambientTextureImpactOnAnalyticalLights: number;
  51831. /**
  51832. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51833. */
  51834. opacityTexture: BaseTexture;
  51835. /**
  51836. * Stores the reflection values in a texture.
  51837. */
  51838. reflectionTexture: Nullable<BaseTexture>;
  51839. /**
  51840. * Stores the emissive values in a texture.
  51841. */
  51842. emissiveTexture: BaseTexture;
  51843. /**
  51844. * AKA Specular texture in other nomenclature.
  51845. */
  51846. reflectivityTexture: BaseTexture;
  51847. /**
  51848. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51849. */
  51850. metallicTexture: BaseTexture;
  51851. /**
  51852. * Specifies the metallic scalar of the metallic/roughness workflow.
  51853. * Can also be used to scale the metalness values of the metallic texture.
  51854. */
  51855. metallic: Nullable<number>;
  51856. /**
  51857. * Specifies the roughness scalar of the metallic/roughness workflow.
  51858. * Can also be used to scale the roughness values of the metallic texture.
  51859. */
  51860. roughness: Nullable<number>;
  51861. /**
  51862. * Specifies the an F0 factor to help configuring the material F0.
  51863. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51864. * to 0.5 the previously hard coded value stays the same.
  51865. * Can also be used to scale the F0 values of the metallic texture.
  51866. */
  51867. metallicF0Factor: number;
  51868. /**
  51869. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51870. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51871. * your expectation as it multiplies with the texture data.
  51872. */
  51873. useMetallicF0FactorFromMetallicTexture: boolean;
  51874. /**
  51875. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51876. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51877. */
  51878. microSurfaceTexture: BaseTexture;
  51879. /**
  51880. * Stores surface normal data used to displace a mesh in a texture.
  51881. */
  51882. bumpTexture: BaseTexture;
  51883. /**
  51884. * Stores the pre-calculated light information of a mesh in a texture.
  51885. */
  51886. lightmapTexture: BaseTexture;
  51887. /**
  51888. * Stores the refracted light information in a texture.
  51889. */
  51890. get refractionTexture(): Nullable<BaseTexture>;
  51891. set refractionTexture(value: Nullable<BaseTexture>);
  51892. /**
  51893. * The color of a material in ambient lighting.
  51894. */
  51895. ambientColor: Color3;
  51896. /**
  51897. * AKA Diffuse Color in other nomenclature.
  51898. */
  51899. albedoColor: Color3;
  51900. /**
  51901. * AKA Specular Color in other nomenclature.
  51902. */
  51903. reflectivityColor: Color3;
  51904. /**
  51905. * The color reflected from the material.
  51906. */
  51907. reflectionColor: Color3;
  51908. /**
  51909. * The color emitted from the material.
  51910. */
  51911. emissiveColor: Color3;
  51912. /**
  51913. * AKA Glossiness in other nomenclature.
  51914. */
  51915. microSurface: number;
  51916. /**
  51917. * source material index of refraction (IOR)' / 'destination material IOR.
  51918. */
  51919. get indexOfRefraction(): number;
  51920. set indexOfRefraction(value: number);
  51921. /**
  51922. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51923. */
  51924. get invertRefractionY(): boolean;
  51925. set invertRefractionY(value: boolean);
  51926. /**
  51927. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51928. * Materials half opaque for instance using refraction could benefit from this control.
  51929. */
  51930. get linkRefractionWithTransparency(): boolean;
  51931. set linkRefractionWithTransparency(value: boolean);
  51932. /**
  51933. * If true, the light map contains occlusion information instead of lighting info.
  51934. */
  51935. useLightmapAsShadowmap: boolean;
  51936. /**
  51937. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51938. */
  51939. useAlphaFromAlbedoTexture: boolean;
  51940. /**
  51941. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51942. */
  51943. forceAlphaTest: boolean;
  51944. /**
  51945. * Defines the alpha limits in alpha test mode.
  51946. */
  51947. alphaCutOff: number;
  51948. /**
  51949. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51950. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51951. */
  51952. useSpecularOverAlpha: boolean;
  51953. /**
  51954. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51955. */
  51956. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51957. /**
  51958. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51959. */
  51960. useRoughnessFromMetallicTextureAlpha: boolean;
  51961. /**
  51962. * Specifies if the metallic texture contains the roughness information in its green channel.
  51963. */
  51964. useRoughnessFromMetallicTextureGreen: boolean;
  51965. /**
  51966. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51967. */
  51968. useMetallnessFromMetallicTextureBlue: boolean;
  51969. /**
  51970. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51971. */
  51972. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51973. /**
  51974. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51975. */
  51976. useAmbientInGrayScale: boolean;
  51977. /**
  51978. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51979. * The material will try to infer what glossiness each pixel should be.
  51980. */
  51981. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51982. /**
  51983. * BJS is using an harcoded light falloff based on a manually sets up range.
  51984. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51985. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51986. */
  51987. get usePhysicalLightFalloff(): boolean;
  51988. /**
  51989. * BJS is using an harcoded light falloff based on a manually sets up range.
  51990. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51991. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51992. */
  51993. set usePhysicalLightFalloff(value: boolean);
  51994. /**
  51995. * In order to support the falloff compatibility with gltf, a special mode has been added
  51996. * to reproduce the gltf light falloff.
  51997. */
  51998. get useGLTFLightFalloff(): boolean;
  51999. /**
  52000. * In order to support the falloff compatibility with gltf, a special mode has been added
  52001. * to reproduce the gltf light falloff.
  52002. */
  52003. set useGLTFLightFalloff(value: boolean);
  52004. /**
  52005. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52006. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52007. */
  52008. useRadianceOverAlpha: boolean;
  52009. /**
  52010. * Allows using an object space normal map (instead of tangent space).
  52011. */
  52012. useObjectSpaceNormalMap: boolean;
  52013. /**
  52014. * Allows using the bump map in parallax mode.
  52015. */
  52016. useParallax: boolean;
  52017. /**
  52018. * Allows using the bump map in parallax occlusion mode.
  52019. */
  52020. useParallaxOcclusion: boolean;
  52021. /**
  52022. * Controls the scale bias of the parallax mode.
  52023. */
  52024. parallaxScaleBias: number;
  52025. /**
  52026. * If sets to true, disables all the lights affecting the material.
  52027. */
  52028. disableLighting: boolean;
  52029. /**
  52030. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52031. */
  52032. forceIrradianceInFragment: boolean;
  52033. /**
  52034. * Number of Simultaneous lights allowed on the material.
  52035. */
  52036. maxSimultaneousLights: number;
  52037. /**
  52038. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52039. */
  52040. invertNormalMapX: boolean;
  52041. /**
  52042. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52043. */
  52044. invertNormalMapY: boolean;
  52045. /**
  52046. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52047. */
  52048. twoSidedLighting: boolean;
  52049. /**
  52050. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52051. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52052. */
  52053. useAlphaFresnel: boolean;
  52054. /**
  52055. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52056. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52057. */
  52058. useLinearAlphaFresnel: boolean;
  52059. /**
  52060. * Let user defines the brdf lookup texture used for IBL.
  52061. * A default 8bit version is embedded but you could point at :
  52062. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52063. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52064. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52065. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52066. */
  52067. environmentBRDFTexture: Nullable<BaseTexture>;
  52068. /**
  52069. * Force normal to face away from face.
  52070. */
  52071. forceNormalForward: boolean;
  52072. /**
  52073. * Enables specular anti aliasing in the PBR shader.
  52074. * It will both interacts on the Geometry for analytical and IBL lighting.
  52075. * It also prefilter the roughness map based on the bump values.
  52076. */
  52077. enableSpecularAntiAliasing: boolean;
  52078. /**
  52079. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52080. * makes the reflect vector face the model (under horizon).
  52081. */
  52082. useHorizonOcclusion: boolean;
  52083. /**
  52084. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52085. * too much the area relying on ambient texture to define their ambient occlusion.
  52086. */
  52087. useRadianceOcclusion: boolean;
  52088. /**
  52089. * If set to true, no lighting calculations will be applied.
  52090. */
  52091. unlit: boolean;
  52092. /**
  52093. * Gets the image processing configuration used either in this material.
  52094. */
  52095. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52096. /**
  52097. * Sets the Default image processing configuration used either in the this material.
  52098. *
  52099. * If sets to null, the scene one is in use.
  52100. */
  52101. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52102. /**
  52103. * Gets wether the color curves effect is enabled.
  52104. */
  52105. get cameraColorCurvesEnabled(): boolean;
  52106. /**
  52107. * Sets wether the color curves effect is enabled.
  52108. */
  52109. set cameraColorCurvesEnabled(value: boolean);
  52110. /**
  52111. * Gets wether the color grading effect is enabled.
  52112. */
  52113. get cameraColorGradingEnabled(): boolean;
  52114. /**
  52115. * Gets wether the color grading effect is enabled.
  52116. */
  52117. set cameraColorGradingEnabled(value: boolean);
  52118. /**
  52119. * Gets wether tonemapping is enabled or not.
  52120. */
  52121. get cameraToneMappingEnabled(): boolean;
  52122. /**
  52123. * Sets wether tonemapping is enabled or not
  52124. */
  52125. set cameraToneMappingEnabled(value: boolean);
  52126. /**
  52127. * The camera exposure used on this material.
  52128. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52129. * This corresponds to a photographic exposure.
  52130. */
  52131. get cameraExposure(): number;
  52132. /**
  52133. * The camera exposure used on this material.
  52134. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52135. * This corresponds to a photographic exposure.
  52136. */
  52137. set cameraExposure(value: number);
  52138. /**
  52139. * Gets The camera contrast used on this material.
  52140. */
  52141. get cameraContrast(): number;
  52142. /**
  52143. * Sets The camera contrast used on this material.
  52144. */
  52145. set cameraContrast(value: number);
  52146. /**
  52147. * Gets the Color Grading 2D Lookup Texture.
  52148. */
  52149. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52150. /**
  52151. * Sets the Color Grading 2D Lookup Texture.
  52152. */
  52153. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52154. /**
  52155. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52156. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52157. * 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;
  52158. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52159. */
  52160. get cameraColorCurves(): Nullable<ColorCurves>;
  52161. /**
  52162. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52163. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52164. * 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;
  52165. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52166. */
  52167. set cameraColorCurves(value: Nullable<ColorCurves>);
  52168. /**
  52169. * Instantiates a new PBRMaterial instance.
  52170. *
  52171. * @param name The material name
  52172. * @param scene The scene the material will be use in.
  52173. */
  52174. constructor(name: string, scene: Scene);
  52175. /**
  52176. * Returns the name of this material class.
  52177. */
  52178. getClassName(): string;
  52179. /**
  52180. * Makes a duplicate of the current material.
  52181. * @param name - name to use for the new material.
  52182. */
  52183. clone(name: string): PBRMaterial;
  52184. /**
  52185. * Serializes this PBR Material.
  52186. * @returns - An object with the serialized material.
  52187. */
  52188. serialize(): any;
  52189. /**
  52190. * Parses a PBR Material from a serialized object.
  52191. * @param source - Serialized object.
  52192. * @param scene - BJS scene instance.
  52193. * @param rootUrl - url for the scene object
  52194. * @returns - PBRMaterial
  52195. */
  52196. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52197. }
  52198. }
  52199. declare module BABYLON {
  52200. /**
  52201. * Direct draw surface info
  52202. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52203. */
  52204. export interface DDSInfo {
  52205. /**
  52206. * Width of the texture
  52207. */
  52208. width: number;
  52209. /**
  52210. * Width of the texture
  52211. */
  52212. height: number;
  52213. /**
  52214. * Number of Mipmaps for the texture
  52215. * @see https://en.wikipedia.org/wiki/Mipmap
  52216. */
  52217. mipmapCount: number;
  52218. /**
  52219. * If the textures format is a known fourCC format
  52220. * @see https://www.fourcc.org/
  52221. */
  52222. isFourCC: boolean;
  52223. /**
  52224. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52225. */
  52226. isRGB: boolean;
  52227. /**
  52228. * If the texture is a lumincance format
  52229. */
  52230. isLuminance: boolean;
  52231. /**
  52232. * If this is a cube texture
  52233. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52234. */
  52235. isCube: boolean;
  52236. /**
  52237. * If the texture is a compressed format eg. FOURCC_DXT1
  52238. */
  52239. isCompressed: boolean;
  52240. /**
  52241. * The dxgiFormat of the texture
  52242. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52243. */
  52244. dxgiFormat: number;
  52245. /**
  52246. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52247. */
  52248. textureType: number;
  52249. /**
  52250. * Sphericle polynomial created for the dds texture
  52251. */
  52252. sphericalPolynomial?: SphericalPolynomial;
  52253. }
  52254. /**
  52255. * Class used to provide DDS decompression tools
  52256. */
  52257. export class DDSTools {
  52258. /**
  52259. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52260. */
  52261. static StoreLODInAlphaChannel: boolean;
  52262. /**
  52263. * Gets DDS information from an array buffer
  52264. * @param data defines the array buffer view to read data from
  52265. * @returns the DDS information
  52266. */
  52267. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52268. private static _FloatView;
  52269. private static _Int32View;
  52270. private static _ToHalfFloat;
  52271. private static _FromHalfFloat;
  52272. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52273. private static _GetHalfFloatRGBAArrayBuffer;
  52274. private static _GetFloatRGBAArrayBuffer;
  52275. private static _GetFloatAsUIntRGBAArrayBuffer;
  52276. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52277. private static _GetRGBAArrayBuffer;
  52278. private static _ExtractLongWordOrder;
  52279. private static _GetRGBArrayBuffer;
  52280. private static _GetLuminanceArrayBuffer;
  52281. /**
  52282. * Uploads DDS Levels to a Babylon Texture
  52283. * @hidden
  52284. */
  52285. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52286. }
  52287. interface ThinEngine {
  52288. /**
  52289. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52290. * @param rootUrl defines the url where the file to load is located
  52291. * @param scene defines the current scene
  52292. * @param lodScale defines scale to apply to the mip map selection
  52293. * @param lodOffset defines offset to apply to the mip map selection
  52294. * @param onLoad defines an optional callback raised when the texture is loaded
  52295. * @param onError defines an optional callback raised if there is an issue to load the texture
  52296. * @param format defines the format of the data
  52297. * @param forcedExtension defines the extension to use to pick the right loader
  52298. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52299. * @returns the cube texture as an InternalTexture
  52300. */
  52301. 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;
  52302. }
  52303. }
  52304. declare module BABYLON {
  52305. /**
  52306. * Implementation of the DDS Texture Loader.
  52307. * @hidden
  52308. */
  52309. export class _DDSTextureLoader implements IInternalTextureLoader {
  52310. /**
  52311. * Defines wether the loader supports cascade loading the different faces.
  52312. */
  52313. readonly supportCascades: boolean;
  52314. /**
  52315. * This returns if the loader support the current file information.
  52316. * @param extension defines the file extension of the file being loaded
  52317. * @returns true if the loader can load the specified file
  52318. */
  52319. canLoad(extension: string): boolean;
  52320. /**
  52321. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52322. * @param data contains the texture data
  52323. * @param texture defines the BabylonJS internal texture
  52324. * @param createPolynomials will be true if polynomials have been requested
  52325. * @param onLoad defines the callback to trigger once the texture is ready
  52326. * @param onError defines the callback to trigger in case of error
  52327. */
  52328. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52329. /**
  52330. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52331. * @param data contains the texture data
  52332. * @param texture defines the BabylonJS internal texture
  52333. * @param callback defines the method to call once ready to upload
  52334. */
  52335. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52336. }
  52337. }
  52338. declare module BABYLON {
  52339. /**
  52340. * Implementation of the ENV Texture Loader.
  52341. * @hidden
  52342. */
  52343. export class _ENVTextureLoader implements IInternalTextureLoader {
  52344. /**
  52345. * Defines wether the loader supports cascade loading the different faces.
  52346. */
  52347. readonly supportCascades: boolean;
  52348. /**
  52349. * This returns if the loader support the current file information.
  52350. * @param extension defines the file extension of the file being loaded
  52351. * @returns true if the loader can load the specified file
  52352. */
  52353. canLoad(extension: string): boolean;
  52354. /**
  52355. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52356. * @param data contains the texture data
  52357. * @param texture defines the BabylonJS internal texture
  52358. * @param createPolynomials will be true if polynomials have been requested
  52359. * @param onLoad defines the callback to trigger once the texture is ready
  52360. * @param onError defines the callback to trigger in case of error
  52361. */
  52362. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52363. /**
  52364. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52365. * @param data contains the texture data
  52366. * @param texture defines the BabylonJS internal texture
  52367. * @param callback defines the method to call once ready to upload
  52368. */
  52369. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52370. }
  52371. }
  52372. declare module BABYLON {
  52373. /**
  52374. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52375. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52376. */
  52377. export class KhronosTextureContainer {
  52378. /** contents of the KTX container file */
  52379. data: ArrayBufferView;
  52380. private static HEADER_LEN;
  52381. private static COMPRESSED_2D;
  52382. private static COMPRESSED_3D;
  52383. private static TEX_2D;
  52384. private static TEX_3D;
  52385. /**
  52386. * Gets the openGL type
  52387. */
  52388. glType: number;
  52389. /**
  52390. * Gets the openGL type size
  52391. */
  52392. glTypeSize: number;
  52393. /**
  52394. * Gets the openGL format
  52395. */
  52396. glFormat: number;
  52397. /**
  52398. * Gets the openGL internal format
  52399. */
  52400. glInternalFormat: number;
  52401. /**
  52402. * Gets the base internal format
  52403. */
  52404. glBaseInternalFormat: number;
  52405. /**
  52406. * Gets image width in pixel
  52407. */
  52408. pixelWidth: number;
  52409. /**
  52410. * Gets image height in pixel
  52411. */
  52412. pixelHeight: number;
  52413. /**
  52414. * Gets image depth in pixels
  52415. */
  52416. pixelDepth: number;
  52417. /**
  52418. * Gets the number of array elements
  52419. */
  52420. numberOfArrayElements: number;
  52421. /**
  52422. * Gets the number of faces
  52423. */
  52424. numberOfFaces: number;
  52425. /**
  52426. * Gets the number of mipmap levels
  52427. */
  52428. numberOfMipmapLevels: number;
  52429. /**
  52430. * Gets the bytes of key value data
  52431. */
  52432. bytesOfKeyValueData: number;
  52433. /**
  52434. * Gets the load type
  52435. */
  52436. loadType: number;
  52437. /**
  52438. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52439. */
  52440. isInvalid: boolean;
  52441. /**
  52442. * Creates a new KhronosTextureContainer
  52443. * @param data contents of the KTX container file
  52444. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52445. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52446. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52447. */
  52448. constructor(
  52449. /** contents of the KTX container file */
  52450. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52451. /**
  52452. * Uploads KTX content to a Babylon Texture.
  52453. * It is assumed that the texture has already been created & is currently bound
  52454. * @hidden
  52455. */
  52456. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52457. private _upload2DCompressedLevels;
  52458. /**
  52459. * Checks if the given data starts with a KTX file identifier.
  52460. * @param data the data to check
  52461. * @returns true if the data is a KTX file or false otherwise
  52462. */
  52463. static IsValid(data: ArrayBufferView): boolean;
  52464. }
  52465. }
  52466. declare module BABYLON {
  52467. /**
  52468. * Class for loading KTX2 files
  52469. * !!! Experimental Extension Subject to Changes !!!
  52470. * @hidden
  52471. */
  52472. export class KhronosTextureContainer2 {
  52473. private static _ModulePromise;
  52474. private static _TranscodeFormat;
  52475. constructor(engine: ThinEngine);
  52476. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52477. private _determineTranscodeFormat;
  52478. /**
  52479. * Checks if the given data starts with a KTX2 file identifier.
  52480. * @param data the data to check
  52481. * @returns true if the data is a KTX2 file or false otherwise
  52482. */
  52483. static IsValid(data: ArrayBufferView): boolean;
  52484. }
  52485. }
  52486. declare module BABYLON {
  52487. /**
  52488. * Implementation of the KTX Texture Loader.
  52489. * @hidden
  52490. */
  52491. export class _KTXTextureLoader implements IInternalTextureLoader {
  52492. /**
  52493. * Defines wether the loader supports cascade loading the different faces.
  52494. */
  52495. readonly supportCascades: boolean;
  52496. /**
  52497. * This returns if the loader support the current file information.
  52498. * @param extension defines the file extension of the file being loaded
  52499. * @returns true if the loader can load the specified file
  52500. */
  52501. canLoad(extension: string): boolean;
  52502. /**
  52503. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52504. * @param data contains the texture data
  52505. * @param texture defines the BabylonJS internal texture
  52506. * @param createPolynomials will be true if polynomials have been requested
  52507. * @param onLoad defines the callback to trigger once the texture is ready
  52508. * @param onError defines the callback to trigger in case of error
  52509. */
  52510. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52511. /**
  52512. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52513. * @param data contains the texture data
  52514. * @param texture defines the BabylonJS internal texture
  52515. * @param callback defines the method to call once ready to upload
  52516. */
  52517. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52518. }
  52519. }
  52520. declare module BABYLON {
  52521. /** @hidden */
  52522. export var _forceSceneHelpersToBundle: boolean;
  52523. interface Scene {
  52524. /**
  52525. * Creates a default light for the scene.
  52526. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52527. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52528. */
  52529. createDefaultLight(replace?: boolean): void;
  52530. /**
  52531. * Creates a default camera for the scene.
  52532. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52533. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52534. * @param replace has default false, when true replaces the active camera in the scene
  52535. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52536. */
  52537. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52538. /**
  52539. * Creates a default camera and a default light.
  52540. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52541. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52542. * @param replace has the default false, when true replaces the active camera/light in the scene
  52543. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52544. */
  52545. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52546. /**
  52547. * Creates a new sky box
  52548. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52549. * @param environmentTexture defines the texture to use as environment texture
  52550. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52551. * @param scale defines the overall scale of the skybox
  52552. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52553. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52554. * @returns a new mesh holding the sky box
  52555. */
  52556. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52557. /**
  52558. * Creates a new environment
  52559. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52560. * @param options defines the options you can use to configure the environment
  52561. * @returns the new EnvironmentHelper
  52562. */
  52563. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52564. /**
  52565. * Creates a new VREXperienceHelper
  52566. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52567. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52568. * @returns a new VREXperienceHelper
  52569. */
  52570. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52571. /**
  52572. * Creates a new WebXRDefaultExperience
  52573. * @see http://doc.babylonjs.com/how_to/webxr
  52574. * @param options experience options
  52575. * @returns a promise for a new WebXRDefaultExperience
  52576. */
  52577. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52578. }
  52579. }
  52580. declare module BABYLON {
  52581. /**
  52582. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52583. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52584. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52585. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52586. */
  52587. export class VideoDome extends TransformNode {
  52588. /**
  52589. * Define the video source as a Monoscopic panoramic 360 video.
  52590. */
  52591. static readonly MODE_MONOSCOPIC: number;
  52592. /**
  52593. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52594. */
  52595. static readonly MODE_TOPBOTTOM: number;
  52596. /**
  52597. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52598. */
  52599. static readonly MODE_SIDEBYSIDE: number;
  52600. private _halfDome;
  52601. private _useDirectMapping;
  52602. /**
  52603. * The video texture being displayed on the sphere
  52604. */
  52605. protected _videoTexture: VideoTexture;
  52606. /**
  52607. * Gets the video texture being displayed on the sphere
  52608. */
  52609. get videoTexture(): VideoTexture;
  52610. /**
  52611. * The skybox material
  52612. */
  52613. protected _material: BackgroundMaterial;
  52614. /**
  52615. * The surface used for the skybox
  52616. */
  52617. protected _mesh: Mesh;
  52618. /**
  52619. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52620. */
  52621. private _halfDomeMask;
  52622. /**
  52623. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52624. * Also see the options.resolution property.
  52625. */
  52626. get fovMultiplier(): number;
  52627. set fovMultiplier(value: number);
  52628. private _videoMode;
  52629. /**
  52630. * Gets or set the current video mode for the video. It can be:
  52631. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52632. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52633. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52634. */
  52635. get videoMode(): number;
  52636. set videoMode(value: number);
  52637. /**
  52638. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52639. *
  52640. */
  52641. get halfDome(): boolean;
  52642. /**
  52643. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52644. */
  52645. set halfDome(enabled: boolean);
  52646. /**
  52647. * Oberserver used in Stereoscopic VR Mode.
  52648. */
  52649. private _onBeforeCameraRenderObserver;
  52650. /**
  52651. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52652. * @param name Element's name, child elements will append suffixes for their own names.
  52653. * @param urlsOrVideo defines the url(s) or the video element to use
  52654. * @param options An object containing optional or exposed sub element properties
  52655. */
  52656. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52657. resolution?: number;
  52658. clickToPlay?: boolean;
  52659. autoPlay?: boolean;
  52660. loop?: boolean;
  52661. size?: number;
  52662. poster?: string;
  52663. faceForward?: boolean;
  52664. useDirectMapping?: boolean;
  52665. halfDomeMode?: boolean;
  52666. }, scene: Scene);
  52667. private _changeVideoMode;
  52668. /**
  52669. * Releases resources associated with this node.
  52670. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52671. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52672. */
  52673. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52674. }
  52675. }
  52676. declare module BABYLON {
  52677. /**
  52678. * This class can be used to get instrumentation data from a Babylon engine
  52679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52680. */
  52681. export class EngineInstrumentation implements IDisposable {
  52682. /**
  52683. * Define the instrumented engine.
  52684. */
  52685. engine: Engine;
  52686. private _captureGPUFrameTime;
  52687. private _gpuFrameTimeToken;
  52688. private _gpuFrameTime;
  52689. private _captureShaderCompilationTime;
  52690. private _shaderCompilationTime;
  52691. private _onBeginFrameObserver;
  52692. private _onEndFrameObserver;
  52693. private _onBeforeShaderCompilationObserver;
  52694. private _onAfterShaderCompilationObserver;
  52695. /**
  52696. * Gets the perf counter used for GPU frame time
  52697. */
  52698. get gpuFrameTimeCounter(): PerfCounter;
  52699. /**
  52700. * Gets the GPU frame time capture status
  52701. */
  52702. get captureGPUFrameTime(): boolean;
  52703. /**
  52704. * Enable or disable the GPU frame time capture
  52705. */
  52706. set captureGPUFrameTime(value: boolean);
  52707. /**
  52708. * Gets the perf counter used for shader compilation time
  52709. */
  52710. get shaderCompilationTimeCounter(): PerfCounter;
  52711. /**
  52712. * Gets the shader compilation time capture status
  52713. */
  52714. get captureShaderCompilationTime(): boolean;
  52715. /**
  52716. * Enable or disable the shader compilation time capture
  52717. */
  52718. set captureShaderCompilationTime(value: boolean);
  52719. /**
  52720. * Instantiates a new engine instrumentation.
  52721. * This class can be used to get instrumentation data from a Babylon engine
  52722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52723. * @param engine Defines the engine to instrument
  52724. */
  52725. constructor(
  52726. /**
  52727. * Define the instrumented engine.
  52728. */
  52729. engine: Engine);
  52730. /**
  52731. * Dispose and release associated resources.
  52732. */
  52733. dispose(): void;
  52734. }
  52735. }
  52736. declare module BABYLON {
  52737. /**
  52738. * This class can be used to get instrumentation data from a Babylon engine
  52739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52740. */
  52741. export class SceneInstrumentation implements IDisposable {
  52742. /**
  52743. * Defines the scene to instrument
  52744. */
  52745. scene: Scene;
  52746. private _captureActiveMeshesEvaluationTime;
  52747. private _activeMeshesEvaluationTime;
  52748. private _captureRenderTargetsRenderTime;
  52749. private _renderTargetsRenderTime;
  52750. private _captureFrameTime;
  52751. private _frameTime;
  52752. private _captureRenderTime;
  52753. private _renderTime;
  52754. private _captureInterFrameTime;
  52755. private _interFrameTime;
  52756. private _captureParticlesRenderTime;
  52757. private _particlesRenderTime;
  52758. private _captureSpritesRenderTime;
  52759. private _spritesRenderTime;
  52760. private _capturePhysicsTime;
  52761. private _physicsTime;
  52762. private _captureAnimationsTime;
  52763. private _animationsTime;
  52764. private _captureCameraRenderTime;
  52765. private _cameraRenderTime;
  52766. private _onBeforeActiveMeshesEvaluationObserver;
  52767. private _onAfterActiveMeshesEvaluationObserver;
  52768. private _onBeforeRenderTargetsRenderObserver;
  52769. private _onAfterRenderTargetsRenderObserver;
  52770. private _onAfterRenderObserver;
  52771. private _onBeforeDrawPhaseObserver;
  52772. private _onAfterDrawPhaseObserver;
  52773. private _onBeforeAnimationsObserver;
  52774. private _onBeforeParticlesRenderingObserver;
  52775. private _onAfterParticlesRenderingObserver;
  52776. private _onBeforeSpritesRenderingObserver;
  52777. private _onAfterSpritesRenderingObserver;
  52778. private _onBeforePhysicsObserver;
  52779. private _onAfterPhysicsObserver;
  52780. private _onAfterAnimationsObserver;
  52781. private _onBeforeCameraRenderObserver;
  52782. private _onAfterCameraRenderObserver;
  52783. /**
  52784. * Gets the perf counter used for active meshes evaluation time
  52785. */
  52786. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52787. /**
  52788. * Gets the active meshes evaluation time capture status
  52789. */
  52790. get captureActiveMeshesEvaluationTime(): boolean;
  52791. /**
  52792. * Enable or disable the active meshes evaluation time capture
  52793. */
  52794. set captureActiveMeshesEvaluationTime(value: boolean);
  52795. /**
  52796. * Gets the perf counter used for render targets render time
  52797. */
  52798. get renderTargetsRenderTimeCounter(): PerfCounter;
  52799. /**
  52800. * Gets the render targets render time capture status
  52801. */
  52802. get captureRenderTargetsRenderTime(): boolean;
  52803. /**
  52804. * Enable or disable the render targets render time capture
  52805. */
  52806. set captureRenderTargetsRenderTime(value: boolean);
  52807. /**
  52808. * Gets the perf counter used for particles render time
  52809. */
  52810. get particlesRenderTimeCounter(): PerfCounter;
  52811. /**
  52812. * Gets the particles render time capture status
  52813. */
  52814. get captureParticlesRenderTime(): boolean;
  52815. /**
  52816. * Enable or disable the particles render time capture
  52817. */
  52818. set captureParticlesRenderTime(value: boolean);
  52819. /**
  52820. * Gets the perf counter used for sprites render time
  52821. */
  52822. get spritesRenderTimeCounter(): PerfCounter;
  52823. /**
  52824. * Gets the sprites render time capture status
  52825. */
  52826. get captureSpritesRenderTime(): boolean;
  52827. /**
  52828. * Enable or disable the sprites render time capture
  52829. */
  52830. set captureSpritesRenderTime(value: boolean);
  52831. /**
  52832. * Gets the perf counter used for physics time
  52833. */
  52834. get physicsTimeCounter(): PerfCounter;
  52835. /**
  52836. * Gets the physics time capture status
  52837. */
  52838. get capturePhysicsTime(): boolean;
  52839. /**
  52840. * Enable or disable the physics time capture
  52841. */
  52842. set capturePhysicsTime(value: boolean);
  52843. /**
  52844. * Gets the perf counter used for animations time
  52845. */
  52846. get animationsTimeCounter(): PerfCounter;
  52847. /**
  52848. * Gets the animations time capture status
  52849. */
  52850. get captureAnimationsTime(): boolean;
  52851. /**
  52852. * Enable or disable the animations time capture
  52853. */
  52854. set captureAnimationsTime(value: boolean);
  52855. /**
  52856. * Gets the perf counter used for frame time capture
  52857. */
  52858. get frameTimeCounter(): PerfCounter;
  52859. /**
  52860. * Gets the frame time capture status
  52861. */
  52862. get captureFrameTime(): boolean;
  52863. /**
  52864. * Enable or disable the frame time capture
  52865. */
  52866. set captureFrameTime(value: boolean);
  52867. /**
  52868. * Gets the perf counter used for inter-frames time capture
  52869. */
  52870. get interFrameTimeCounter(): PerfCounter;
  52871. /**
  52872. * Gets the inter-frames time capture status
  52873. */
  52874. get captureInterFrameTime(): boolean;
  52875. /**
  52876. * Enable or disable the inter-frames time capture
  52877. */
  52878. set captureInterFrameTime(value: boolean);
  52879. /**
  52880. * Gets the perf counter used for render time capture
  52881. */
  52882. get renderTimeCounter(): PerfCounter;
  52883. /**
  52884. * Gets the render time capture status
  52885. */
  52886. get captureRenderTime(): boolean;
  52887. /**
  52888. * Enable or disable the render time capture
  52889. */
  52890. set captureRenderTime(value: boolean);
  52891. /**
  52892. * Gets the perf counter used for camera render time capture
  52893. */
  52894. get cameraRenderTimeCounter(): PerfCounter;
  52895. /**
  52896. * Gets the camera render time capture status
  52897. */
  52898. get captureCameraRenderTime(): boolean;
  52899. /**
  52900. * Enable or disable the camera render time capture
  52901. */
  52902. set captureCameraRenderTime(value: boolean);
  52903. /**
  52904. * Gets the perf counter used for draw calls
  52905. */
  52906. get drawCallsCounter(): PerfCounter;
  52907. /**
  52908. * Instantiates a new scene instrumentation.
  52909. * This class can be used to get instrumentation data from a Babylon engine
  52910. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52911. * @param scene Defines the scene to instrument
  52912. */
  52913. constructor(
  52914. /**
  52915. * Defines the scene to instrument
  52916. */
  52917. scene: Scene);
  52918. /**
  52919. * Dispose and release associated resources.
  52920. */
  52921. dispose(): void;
  52922. }
  52923. }
  52924. declare module BABYLON {
  52925. /** @hidden */
  52926. export var glowMapGenerationPixelShader: {
  52927. name: string;
  52928. shader: string;
  52929. };
  52930. }
  52931. declare module BABYLON {
  52932. /** @hidden */
  52933. export var glowMapGenerationVertexShader: {
  52934. name: string;
  52935. shader: string;
  52936. };
  52937. }
  52938. declare module BABYLON {
  52939. /**
  52940. * Effect layer options. This helps customizing the behaviour
  52941. * of the effect layer.
  52942. */
  52943. export interface IEffectLayerOptions {
  52944. /**
  52945. * Multiplication factor apply to the canvas size to compute the render target size
  52946. * used to generated the objects (the smaller the faster).
  52947. */
  52948. mainTextureRatio: number;
  52949. /**
  52950. * Enforces a fixed size texture to ensure effect stability across devices.
  52951. */
  52952. mainTextureFixedSize?: number;
  52953. /**
  52954. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52955. */
  52956. alphaBlendingMode: number;
  52957. /**
  52958. * The camera attached to the layer.
  52959. */
  52960. camera: Nullable<Camera>;
  52961. /**
  52962. * The rendering group to draw the layer in.
  52963. */
  52964. renderingGroupId: number;
  52965. }
  52966. /**
  52967. * The effect layer Helps adding post process effect blended with the main pass.
  52968. *
  52969. * This can be for instance use to generate glow or higlight effects on the scene.
  52970. *
  52971. * The effect layer class can not be used directly and is intented to inherited from to be
  52972. * customized per effects.
  52973. */
  52974. export abstract class EffectLayer {
  52975. private _vertexBuffers;
  52976. private _indexBuffer;
  52977. private _cachedDefines;
  52978. private _effectLayerMapGenerationEffect;
  52979. private _effectLayerOptions;
  52980. private _mergeEffect;
  52981. protected _scene: Scene;
  52982. protected _engine: Engine;
  52983. protected _maxSize: number;
  52984. protected _mainTextureDesiredSize: ISize;
  52985. protected _mainTexture: RenderTargetTexture;
  52986. protected _shouldRender: boolean;
  52987. protected _postProcesses: PostProcess[];
  52988. protected _textures: BaseTexture[];
  52989. protected _emissiveTextureAndColor: {
  52990. texture: Nullable<BaseTexture>;
  52991. color: Color4;
  52992. };
  52993. /**
  52994. * The name of the layer
  52995. */
  52996. name: string;
  52997. /**
  52998. * The clear color of the texture used to generate the glow map.
  52999. */
  53000. neutralColor: Color4;
  53001. /**
  53002. * Specifies whether the highlight layer is enabled or not.
  53003. */
  53004. isEnabled: boolean;
  53005. /**
  53006. * Gets the camera attached to the layer.
  53007. */
  53008. get camera(): Nullable<Camera>;
  53009. /**
  53010. * Gets the rendering group id the layer should render in.
  53011. */
  53012. get renderingGroupId(): number;
  53013. set renderingGroupId(renderingGroupId: number);
  53014. /**
  53015. * An event triggered when the effect layer has been disposed.
  53016. */
  53017. onDisposeObservable: Observable<EffectLayer>;
  53018. /**
  53019. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53020. */
  53021. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53022. /**
  53023. * An event triggered when the generated texture is being merged in the scene.
  53024. */
  53025. onBeforeComposeObservable: Observable<EffectLayer>;
  53026. /**
  53027. * An event triggered when the mesh is rendered into the effect render target.
  53028. */
  53029. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53030. /**
  53031. * An event triggered after the mesh has been rendered into the effect render target.
  53032. */
  53033. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53034. /**
  53035. * An event triggered when the generated texture has been merged in the scene.
  53036. */
  53037. onAfterComposeObservable: Observable<EffectLayer>;
  53038. /**
  53039. * An event triggered when the efffect layer changes its size.
  53040. */
  53041. onSizeChangedObservable: Observable<EffectLayer>;
  53042. /** @hidden */
  53043. static _SceneComponentInitialization: (scene: Scene) => void;
  53044. /**
  53045. * Instantiates a new effect Layer and references it in the scene.
  53046. * @param name The name of the layer
  53047. * @param scene The scene to use the layer in
  53048. */
  53049. constructor(
  53050. /** The Friendly of the effect in the scene */
  53051. name: string, scene: Scene);
  53052. /**
  53053. * Get the effect name of the layer.
  53054. * @return The effect name
  53055. */
  53056. abstract getEffectName(): string;
  53057. /**
  53058. * Checks for the readiness of the element composing the layer.
  53059. * @param subMesh the mesh to check for
  53060. * @param useInstances specify whether or not to use instances to render the mesh
  53061. * @return true if ready otherwise, false
  53062. */
  53063. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53064. /**
  53065. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53066. * @returns true if the effect requires stencil during the main canvas render pass.
  53067. */
  53068. abstract needStencil(): boolean;
  53069. /**
  53070. * Create the merge effect. This is the shader use to blit the information back
  53071. * to the main canvas at the end of the scene rendering.
  53072. * @returns The effect containing the shader used to merge the effect on the main canvas
  53073. */
  53074. protected abstract _createMergeEffect(): Effect;
  53075. /**
  53076. * Creates the render target textures and post processes used in the effect layer.
  53077. */
  53078. protected abstract _createTextureAndPostProcesses(): void;
  53079. /**
  53080. * Implementation specific of rendering the generating effect on the main canvas.
  53081. * @param effect The effect used to render through
  53082. */
  53083. protected abstract _internalRender(effect: Effect): void;
  53084. /**
  53085. * Sets the required values for both the emissive texture and and the main color.
  53086. */
  53087. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53088. /**
  53089. * Free any resources and references associated to a mesh.
  53090. * Internal use
  53091. * @param mesh The mesh to free.
  53092. */
  53093. abstract _disposeMesh(mesh: Mesh): void;
  53094. /**
  53095. * Serializes this layer (Glow or Highlight for example)
  53096. * @returns a serialized layer object
  53097. */
  53098. abstract serialize?(): any;
  53099. /**
  53100. * Initializes the effect layer with the required options.
  53101. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53102. */
  53103. protected _init(options: Partial<IEffectLayerOptions>): void;
  53104. /**
  53105. * Generates the index buffer of the full screen quad blending to the main canvas.
  53106. */
  53107. private _generateIndexBuffer;
  53108. /**
  53109. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53110. */
  53111. private _generateVertexBuffer;
  53112. /**
  53113. * Sets the main texture desired size which is the closest power of two
  53114. * of the engine canvas size.
  53115. */
  53116. private _setMainTextureSize;
  53117. /**
  53118. * Creates the main texture for the effect layer.
  53119. */
  53120. protected _createMainTexture(): void;
  53121. /**
  53122. * Adds specific effects defines.
  53123. * @param defines The defines to add specifics to.
  53124. */
  53125. protected _addCustomEffectDefines(defines: string[]): void;
  53126. /**
  53127. * Checks for the readiness of the element composing the layer.
  53128. * @param subMesh the mesh to check for
  53129. * @param useInstances specify whether or not to use instances to render the mesh
  53130. * @param emissiveTexture the associated emissive texture used to generate the glow
  53131. * @return true if ready otherwise, false
  53132. */
  53133. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53134. /**
  53135. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53136. */
  53137. render(): void;
  53138. /**
  53139. * Determine if a given mesh will be used in the current effect.
  53140. * @param mesh mesh to test
  53141. * @returns true if the mesh will be used
  53142. */
  53143. hasMesh(mesh: AbstractMesh): boolean;
  53144. /**
  53145. * Returns true if the layer contains information to display, otherwise false.
  53146. * @returns true if the glow layer should be rendered
  53147. */
  53148. shouldRender(): boolean;
  53149. /**
  53150. * Returns true if the mesh should render, otherwise false.
  53151. * @param mesh The mesh to render
  53152. * @returns true if it should render otherwise false
  53153. */
  53154. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53155. /**
  53156. * Returns true if the mesh can be rendered, otherwise false.
  53157. * @param mesh The mesh to render
  53158. * @param material The material used on the mesh
  53159. * @returns true if it can be rendered otherwise false
  53160. */
  53161. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53162. /**
  53163. * Returns true if the mesh should render, otherwise false.
  53164. * @param mesh The mesh to render
  53165. * @returns true if it should render otherwise false
  53166. */
  53167. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53168. /**
  53169. * Renders the submesh passed in parameter to the generation map.
  53170. */
  53171. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53172. /**
  53173. * Defines whether the current material of the mesh should be use to render the effect.
  53174. * @param mesh defines the current mesh to render
  53175. */
  53176. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53177. /**
  53178. * Rebuild the required buffers.
  53179. * @hidden Internal use only.
  53180. */
  53181. _rebuild(): void;
  53182. /**
  53183. * Dispose only the render target textures and post process.
  53184. */
  53185. private _disposeTextureAndPostProcesses;
  53186. /**
  53187. * Dispose the highlight layer and free resources.
  53188. */
  53189. dispose(): void;
  53190. /**
  53191. * Gets the class name of the effect layer
  53192. * @returns the string with the class name of the effect layer
  53193. */
  53194. getClassName(): string;
  53195. /**
  53196. * Creates an effect layer from parsed effect layer data
  53197. * @param parsedEffectLayer defines effect layer data
  53198. * @param scene defines the current scene
  53199. * @param rootUrl defines the root URL containing the effect layer information
  53200. * @returns a parsed effect Layer
  53201. */
  53202. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53203. }
  53204. }
  53205. declare module BABYLON {
  53206. interface AbstractScene {
  53207. /**
  53208. * The list of effect layers (highlights/glow) added to the scene
  53209. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53210. * @see http://doc.babylonjs.com/how_to/glow_layer
  53211. */
  53212. effectLayers: Array<EffectLayer>;
  53213. /**
  53214. * Removes the given effect layer from this scene.
  53215. * @param toRemove defines the effect layer to remove
  53216. * @returns the index of the removed effect layer
  53217. */
  53218. removeEffectLayer(toRemove: EffectLayer): number;
  53219. /**
  53220. * Adds the given effect layer to this scene
  53221. * @param newEffectLayer defines the effect layer to add
  53222. */
  53223. addEffectLayer(newEffectLayer: EffectLayer): void;
  53224. }
  53225. /**
  53226. * Defines the layer scene component responsible to manage any effect layers
  53227. * in a given scene.
  53228. */
  53229. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53230. /**
  53231. * The component name helpfull to identify the component in the list of scene components.
  53232. */
  53233. readonly name: string;
  53234. /**
  53235. * The scene the component belongs to.
  53236. */
  53237. scene: Scene;
  53238. private _engine;
  53239. private _renderEffects;
  53240. private _needStencil;
  53241. private _previousStencilState;
  53242. /**
  53243. * Creates a new instance of the component for the given scene
  53244. * @param scene Defines the scene to register the component in
  53245. */
  53246. constructor(scene: Scene);
  53247. /**
  53248. * Registers the component in a given scene
  53249. */
  53250. register(): void;
  53251. /**
  53252. * Rebuilds the elements related to this component in case of
  53253. * context lost for instance.
  53254. */
  53255. rebuild(): void;
  53256. /**
  53257. * Serializes the component data to the specified json object
  53258. * @param serializationObject The object to serialize to
  53259. */
  53260. serialize(serializationObject: any): void;
  53261. /**
  53262. * Adds all the elements from the container to the scene
  53263. * @param container the container holding the elements
  53264. */
  53265. addFromContainer(container: AbstractScene): void;
  53266. /**
  53267. * Removes all the elements in the container from the scene
  53268. * @param container contains the elements to remove
  53269. * @param dispose if the removed element should be disposed (default: false)
  53270. */
  53271. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53272. /**
  53273. * Disposes the component and the associated ressources.
  53274. */
  53275. dispose(): void;
  53276. private _isReadyForMesh;
  53277. private _renderMainTexture;
  53278. private _setStencil;
  53279. private _setStencilBack;
  53280. private _draw;
  53281. private _drawCamera;
  53282. private _drawRenderingGroup;
  53283. }
  53284. }
  53285. declare module BABYLON {
  53286. /** @hidden */
  53287. export var glowMapMergePixelShader: {
  53288. name: string;
  53289. shader: string;
  53290. };
  53291. }
  53292. declare module BABYLON {
  53293. /** @hidden */
  53294. export var glowMapMergeVertexShader: {
  53295. name: string;
  53296. shader: string;
  53297. };
  53298. }
  53299. declare module BABYLON {
  53300. interface AbstractScene {
  53301. /**
  53302. * Return a the first highlight layer of the scene with a given name.
  53303. * @param name The name of the highlight layer to look for.
  53304. * @return The highlight layer if found otherwise null.
  53305. */
  53306. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53307. }
  53308. /**
  53309. * Glow layer options. This helps customizing the behaviour
  53310. * of the glow layer.
  53311. */
  53312. export interface IGlowLayerOptions {
  53313. /**
  53314. * Multiplication factor apply to the canvas size to compute the render target size
  53315. * used to generated the glowing objects (the smaller the faster).
  53316. */
  53317. mainTextureRatio: number;
  53318. /**
  53319. * Enforces a fixed size texture to ensure resize independant blur.
  53320. */
  53321. mainTextureFixedSize?: number;
  53322. /**
  53323. * How big is the kernel of the blur texture.
  53324. */
  53325. blurKernelSize: number;
  53326. /**
  53327. * The camera attached to the layer.
  53328. */
  53329. camera: Nullable<Camera>;
  53330. /**
  53331. * Enable MSAA by chosing the number of samples.
  53332. */
  53333. mainTextureSamples?: number;
  53334. /**
  53335. * The rendering group to draw the layer in.
  53336. */
  53337. renderingGroupId: number;
  53338. }
  53339. /**
  53340. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53341. *
  53342. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53343. *
  53344. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53345. */
  53346. export class GlowLayer extends EffectLayer {
  53347. /**
  53348. * Effect Name of the layer.
  53349. */
  53350. static readonly EffectName: string;
  53351. /**
  53352. * The default blur kernel size used for the glow.
  53353. */
  53354. static DefaultBlurKernelSize: number;
  53355. /**
  53356. * The default texture size ratio used for the glow.
  53357. */
  53358. static DefaultTextureRatio: number;
  53359. /**
  53360. * Sets the kernel size of the blur.
  53361. */
  53362. set blurKernelSize(value: number);
  53363. /**
  53364. * Gets the kernel size of the blur.
  53365. */
  53366. get blurKernelSize(): number;
  53367. /**
  53368. * Sets the glow intensity.
  53369. */
  53370. set intensity(value: number);
  53371. /**
  53372. * Gets the glow intensity.
  53373. */
  53374. get intensity(): number;
  53375. private _options;
  53376. private _intensity;
  53377. private _horizontalBlurPostprocess1;
  53378. private _verticalBlurPostprocess1;
  53379. private _horizontalBlurPostprocess2;
  53380. private _verticalBlurPostprocess2;
  53381. private _blurTexture1;
  53382. private _blurTexture2;
  53383. private _postProcesses1;
  53384. private _postProcesses2;
  53385. private _includedOnlyMeshes;
  53386. private _excludedMeshes;
  53387. private _meshesUsingTheirOwnMaterials;
  53388. /**
  53389. * Callback used to let the user override the color selection on a per mesh basis
  53390. */
  53391. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53392. /**
  53393. * Callback used to let the user override the texture selection on a per mesh basis
  53394. */
  53395. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53396. /**
  53397. * Instantiates a new glow Layer and references it to the scene.
  53398. * @param name The name of the layer
  53399. * @param scene The scene to use the layer in
  53400. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53401. */
  53402. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53403. /**
  53404. * Get the effect name of the layer.
  53405. * @return The effect name
  53406. */
  53407. getEffectName(): string;
  53408. /**
  53409. * Create the merge effect. This is the shader use to blit the information back
  53410. * to the main canvas at the end of the scene rendering.
  53411. */
  53412. protected _createMergeEffect(): Effect;
  53413. /**
  53414. * Creates the render target textures and post processes used in the glow layer.
  53415. */
  53416. protected _createTextureAndPostProcesses(): void;
  53417. /**
  53418. * Checks for the readiness of the element composing the layer.
  53419. * @param subMesh the mesh to check for
  53420. * @param useInstances specify wether or not to use instances to render the mesh
  53421. * @param emissiveTexture the associated emissive texture used to generate the glow
  53422. * @return true if ready otherwise, false
  53423. */
  53424. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53425. /**
  53426. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53427. */
  53428. needStencil(): boolean;
  53429. /**
  53430. * Returns true if the mesh can be rendered, otherwise false.
  53431. * @param mesh The mesh to render
  53432. * @param material The material used on the mesh
  53433. * @returns true if it can be rendered otherwise false
  53434. */
  53435. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53436. /**
  53437. * Implementation specific of rendering the generating effect on the main canvas.
  53438. * @param effect The effect used to render through
  53439. */
  53440. protected _internalRender(effect: Effect): void;
  53441. /**
  53442. * Sets the required values for both the emissive texture and and the main color.
  53443. */
  53444. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53445. /**
  53446. * Returns true if the mesh should render, otherwise false.
  53447. * @param mesh The mesh to render
  53448. * @returns true if it should render otherwise false
  53449. */
  53450. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53451. /**
  53452. * Adds specific effects defines.
  53453. * @param defines The defines to add specifics to.
  53454. */
  53455. protected _addCustomEffectDefines(defines: string[]): void;
  53456. /**
  53457. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53458. * @param mesh The mesh to exclude from the glow layer
  53459. */
  53460. addExcludedMesh(mesh: Mesh): void;
  53461. /**
  53462. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53463. * @param mesh The mesh to remove
  53464. */
  53465. removeExcludedMesh(mesh: Mesh): void;
  53466. /**
  53467. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53468. * @param mesh The mesh to include in the glow layer
  53469. */
  53470. addIncludedOnlyMesh(mesh: Mesh): void;
  53471. /**
  53472. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53473. * @param mesh The mesh to remove
  53474. */
  53475. removeIncludedOnlyMesh(mesh: Mesh): void;
  53476. /**
  53477. * Determine if a given mesh will be used in the glow layer
  53478. * @param mesh The mesh to test
  53479. * @returns true if the mesh will be highlighted by the current glow layer
  53480. */
  53481. hasMesh(mesh: AbstractMesh): boolean;
  53482. /**
  53483. * Defines whether the current material of the mesh should be use to render the effect.
  53484. * @param mesh defines the current mesh to render
  53485. */
  53486. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53487. /**
  53488. * Add a mesh to be rendered through its own material and not with emissive only.
  53489. * @param mesh The mesh for which we need to use its material
  53490. */
  53491. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53492. /**
  53493. * Remove a mesh from being rendered through its own material and not with emissive only.
  53494. * @param mesh The mesh for which we need to not use its material
  53495. */
  53496. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53497. /**
  53498. * Free any resources and references associated to a mesh.
  53499. * Internal use
  53500. * @param mesh The mesh to free.
  53501. * @hidden
  53502. */
  53503. _disposeMesh(mesh: Mesh): void;
  53504. /**
  53505. * Gets the class name of the effect layer
  53506. * @returns the string with the class name of the effect layer
  53507. */
  53508. getClassName(): string;
  53509. /**
  53510. * Serializes this glow layer
  53511. * @returns a serialized glow layer object
  53512. */
  53513. serialize(): any;
  53514. /**
  53515. * Creates a Glow Layer from parsed glow layer data
  53516. * @param parsedGlowLayer defines glow layer data
  53517. * @param scene defines the current scene
  53518. * @param rootUrl defines the root URL containing the glow layer information
  53519. * @returns a parsed Glow Layer
  53520. */
  53521. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53522. }
  53523. }
  53524. declare module BABYLON {
  53525. /** @hidden */
  53526. export var glowBlurPostProcessPixelShader: {
  53527. name: string;
  53528. shader: string;
  53529. };
  53530. }
  53531. declare module BABYLON {
  53532. interface AbstractScene {
  53533. /**
  53534. * Return a the first highlight layer of the scene with a given name.
  53535. * @param name The name of the highlight layer to look for.
  53536. * @return The highlight layer if found otherwise null.
  53537. */
  53538. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53539. }
  53540. /**
  53541. * Highlight layer options. This helps customizing the behaviour
  53542. * of the highlight layer.
  53543. */
  53544. export interface IHighlightLayerOptions {
  53545. /**
  53546. * Multiplication factor apply to the canvas size to compute the render target size
  53547. * used to generated the glowing objects (the smaller the faster).
  53548. */
  53549. mainTextureRatio: number;
  53550. /**
  53551. * Enforces a fixed size texture to ensure resize independant blur.
  53552. */
  53553. mainTextureFixedSize?: number;
  53554. /**
  53555. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53556. * of the picture to blur (the smaller the faster).
  53557. */
  53558. blurTextureSizeRatio: number;
  53559. /**
  53560. * How big in texel of the blur texture is the vertical blur.
  53561. */
  53562. blurVerticalSize: number;
  53563. /**
  53564. * How big in texel of the blur texture is the horizontal blur.
  53565. */
  53566. blurHorizontalSize: number;
  53567. /**
  53568. * Alpha blending mode used to apply the blur. Default is combine.
  53569. */
  53570. alphaBlendingMode: number;
  53571. /**
  53572. * The camera attached to the layer.
  53573. */
  53574. camera: Nullable<Camera>;
  53575. /**
  53576. * Should we display highlight as a solid stroke?
  53577. */
  53578. isStroke?: boolean;
  53579. /**
  53580. * The rendering group to draw the layer in.
  53581. */
  53582. renderingGroupId: number;
  53583. }
  53584. /**
  53585. * The highlight layer Helps adding a glow effect around a mesh.
  53586. *
  53587. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53588. * glowy meshes to your scene.
  53589. *
  53590. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53591. */
  53592. export class HighlightLayer extends EffectLayer {
  53593. name: string;
  53594. /**
  53595. * Effect Name of the highlight layer.
  53596. */
  53597. static readonly EffectName: string;
  53598. /**
  53599. * The neutral color used during the preparation of the glow effect.
  53600. * This is black by default as the blend operation is a blend operation.
  53601. */
  53602. static NeutralColor: Color4;
  53603. /**
  53604. * Stencil value used for glowing meshes.
  53605. */
  53606. static GlowingMeshStencilReference: number;
  53607. /**
  53608. * Stencil value used for the other meshes in the scene.
  53609. */
  53610. static NormalMeshStencilReference: number;
  53611. /**
  53612. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53613. */
  53614. innerGlow: boolean;
  53615. /**
  53616. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53617. */
  53618. outerGlow: boolean;
  53619. /**
  53620. * Specifies the horizontal size of the blur.
  53621. */
  53622. set blurHorizontalSize(value: number);
  53623. /**
  53624. * Specifies the vertical size of the blur.
  53625. */
  53626. set blurVerticalSize(value: number);
  53627. /**
  53628. * Gets the horizontal size of the blur.
  53629. */
  53630. get blurHorizontalSize(): number;
  53631. /**
  53632. * Gets the vertical size of the blur.
  53633. */
  53634. get blurVerticalSize(): number;
  53635. /**
  53636. * An event triggered when the highlight layer is being blurred.
  53637. */
  53638. onBeforeBlurObservable: Observable<HighlightLayer>;
  53639. /**
  53640. * An event triggered when the highlight layer has been blurred.
  53641. */
  53642. onAfterBlurObservable: Observable<HighlightLayer>;
  53643. private _instanceGlowingMeshStencilReference;
  53644. private _options;
  53645. private _downSamplePostprocess;
  53646. private _horizontalBlurPostprocess;
  53647. private _verticalBlurPostprocess;
  53648. private _blurTexture;
  53649. private _meshes;
  53650. private _excludedMeshes;
  53651. /**
  53652. * Instantiates a new highlight Layer and references it to the scene..
  53653. * @param name The name of the layer
  53654. * @param scene The scene to use the layer in
  53655. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53656. */
  53657. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53658. /**
  53659. * Get the effect name of the layer.
  53660. * @return The effect name
  53661. */
  53662. getEffectName(): string;
  53663. /**
  53664. * Create the merge effect. This is the shader use to blit the information back
  53665. * to the main canvas at the end of the scene rendering.
  53666. */
  53667. protected _createMergeEffect(): Effect;
  53668. /**
  53669. * Creates the render target textures and post processes used in the highlight layer.
  53670. */
  53671. protected _createTextureAndPostProcesses(): void;
  53672. /**
  53673. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53674. */
  53675. needStencil(): boolean;
  53676. /**
  53677. * Checks for the readiness of the element composing the layer.
  53678. * @param subMesh the mesh to check for
  53679. * @param useInstances specify wether or not to use instances to render the mesh
  53680. * @param emissiveTexture the associated emissive texture used to generate the glow
  53681. * @return true if ready otherwise, false
  53682. */
  53683. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53684. /**
  53685. * Implementation specific of rendering the generating effect on the main canvas.
  53686. * @param effect The effect used to render through
  53687. */
  53688. protected _internalRender(effect: Effect): void;
  53689. /**
  53690. * Returns true if the layer contains information to display, otherwise false.
  53691. */
  53692. shouldRender(): boolean;
  53693. /**
  53694. * Returns true if the mesh should render, otherwise false.
  53695. * @param mesh The mesh to render
  53696. * @returns true if it should render otherwise false
  53697. */
  53698. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53699. /**
  53700. * Sets the required values for both the emissive texture and and the main color.
  53701. */
  53702. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53703. /**
  53704. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53705. * @param mesh The mesh to exclude from the highlight layer
  53706. */
  53707. addExcludedMesh(mesh: Mesh): void;
  53708. /**
  53709. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53710. * @param mesh The mesh to highlight
  53711. */
  53712. removeExcludedMesh(mesh: Mesh): void;
  53713. /**
  53714. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53715. * @param mesh mesh to test
  53716. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53717. */
  53718. hasMesh(mesh: AbstractMesh): boolean;
  53719. /**
  53720. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53721. * @param mesh The mesh to highlight
  53722. * @param color The color of the highlight
  53723. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53724. */
  53725. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53726. /**
  53727. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53728. * @param mesh The mesh to highlight
  53729. */
  53730. removeMesh(mesh: Mesh): void;
  53731. /**
  53732. * Remove all the meshes currently referenced in the highlight layer
  53733. */
  53734. removeAllMeshes(): void;
  53735. /**
  53736. * Force the stencil to the normal expected value for none glowing parts
  53737. */
  53738. private _defaultStencilReference;
  53739. /**
  53740. * Free any resources and references associated to a mesh.
  53741. * Internal use
  53742. * @param mesh The mesh to free.
  53743. * @hidden
  53744. */
  53745. _disposeMesh(mesh: Mesh): void;
  53746. /**
  53747. * Dispose the highlight layer and free resources.
  53748. */
  53749. dispose(): void;
  53750. /**
  53751. * Gets the class name of the effect layer
  53752. * @returns the string with the class name of the effect layer
  53753. */
  53754. getClassName(): string;
  53755. /**
  53756. * Serializes this Highlight layer
  53757. * @returns a serialized Highlight layer object
  53758. */
  53759. serialize(): any;
  53760. /**
  53761. * Creates a Highlight layer from parsed Highlight layer data
  53762. * @param parsedHightlightLayer defines the Highlight layer data
  53763. * @param scene defines the current scene
  53764. * @param rootUrl defines the root URL containing the Highlight layer information
  53765. * @returns a parsed Highlight layer
  53766. */
  53767. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53768. }
  53769. }
  53770. declare module BABYLON {
  53771. interface AbstractScene {
  53772. /**
  53773. * The list of layers (background and foreground) of the scene
  53774. */
  53775. layers: Array<Layer>;
  53776. }
  53777. /**
  53778. * Defines the layer scene component responsible to manage any layers
  53779. * in a given scene.
  53780. */
  53781. export class LayerSceneComponent implements ISceneComponent {
  53782. /**
  53783. * The component name helpfull to identify the component in the list of scene components.
  53784. */
  53785. readonly name: string;
  53786. /**
  53787. * The scene the component belongs to.
  53788. */
  53789. scene: Scene;
  53790. private _engine;
  53791. /**
  53792. * Creates a new instance of the component for the given scene
  53793. * @param scene Defines the scene to register the component in
  53794. */
  53795. constructor(scene: Scene);
  53796. /**
  53797. * Registers the component in a given scene
  53798. */
  53799. register(): void;
  53800. /**
  53801. * Rebuilds the elements related to this component in case of
  53802. * context lost for instance.
  53803. */
  53804. rebuild(): void;
  53805. /**
  53806. * Disposes the component and the associated ressources.
  53807. */
  53808. dispose(): void;
  53809. private _draw;
  53810. private _drawCameraPredicate;
  53811. private _drawCameraBackground;
  53812. private _drawCameraForeground;
  53813. private _drawRenderTargetPredicate;
  53814. private _drawRenderTargetBackground;
  53815. private _drawRenderTargetForeground;
  53816. /**
  53817. * Adds all the elements from the container to the scene
  53818. * @param container the container holding the elements
  53819. */
  53820. addFromContainer(container: AbstractScene): void;
  53821. /**
  53822. * Removes all the elements in the container from the scene
  53823. * @param container contains the elements to remove
  53824. * @param dispose if the removed element should be disposed (default: false)
  53825. */
  53826. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53827. }
  53828. }
  53829. declare module BABYLON {
  53830. /** @hidden */
  53831. export var layerPixelShader: {
  53832. name: string;
  53833. shader: string;
  53834. };
  53835. }
  53836. declare module BABYLON {
  53837. /** @hidden */
  53838. export var layerVertexShader: {
  53839. name: string;
  53840. shader: string;
  53841. };
  53842. }
  53843. declare module BABYLON {
  53844. /**
  53845. * This represents a full screen 2d layer.
  53846. * This can be useful to display a picture in the background of your scene for instance.
  53847. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53848. */
  53849. export class Layer {
  53850. /**
  53851. * Define the name of the layer.
  53852. */
  53853. name: string;
  53854. /**
  53855. * Define the texture the layer should display.
  53856. */
  53857. texture: Nullable<Texture>;
  53858. /**
  53859. * Is the layer in background or foreground.
  53860. */
  53861. isBackground: boolean;
  53862. /**
  53863. * Define the color of the layer (instead of texture).
  53864. */
  53865. color: Color4;
  53866. /**
  53867. * Define the scale of the layer in order to zoom in out of the texture.
  53868. */
  53869. scale: Vector2;
  53870. /**
  53871. * Define an offset for the layer in order to shift the texture.
  53872. */
  53873. offset: Vector2;
  53874. /**
  53875. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53876. */
  53877. alphaBlendingMode: number;
  53878. /**
  53879. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53880. * Alpha test will not mix with the background color in case of transparency.
  53881. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53882. */
  53883. alphaTest: boolean;
  53884. /**
  53885. * Define a mask to restrict the layer to only some of the scene cameras.
  53886. */
  53887. layerMask: number;
  53888. /**
  53889. * Define the list of render target the layer is visible into.
  53890. */
  53891. renderTargetTextures: RenderTargetTexture[];
  53892. /**
  53893. * Define if the layer is only used in renderTarget or if it also
  53894. * renders in the main frame buffer of the canvas.
  53895. */
  53896. renderOnlyInRenderTargetTextures: boolean;
  53897. private _scene;
  53898. private _vertexBuffers;
  53899. private _indexBuffer;
  53900. private _effect;
  53901. private _previousDefines;
  53902. /**
  53903. * An event triggered when the layer is disposed.
  53904. */
  53905. onDisposeObservable: Observable<Layer>;
  53906. private _onDisposeObserver;
  53907. /**
  53908. * Back compatibility with callback before the onDisposeObservable existed.
  53909. * The set callback will be triggered when the layer has been disposed.
  53910. */
  53911. set onDispose(callback: () => void);
  53912. /**
  53913. * An event triggered before rendering the scene
  53914. */
  53915. onBeforeRenderObservable: Observable<Layer>;
  53916. private _onBeforeRenderObserver;
  53917. /**
  53918. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53919. * The set callback will be triggered just before rendering the layer.
  53920. */
  53921. set onBeforeRender(callback: () => void);
  53922. /**
  53923. * An event triggered after rendering the scene
  53924. */
  53925. onAfterRenderObservable: Observable<Layer>;
  53926. private _onAfterRenderObserver;
  53927. /**
  53928. * Back compatibility with callback before the onAfterRenderObservable existed.
  53929. * The set callback will be triggered just after rendering the layer.
  53930. */
  53931. set onAfterRender(callback: () => void);
  53932. /**
  53933. * Instantiates a new layer.
  53934. * This represents a full screen 2d layer.
  53935. * This can be useful to display a picture in the background of your scene for instance.
  53936. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53937. * @param name Define the name of the layer in the scene
  53938. * @param imgUrl Define the url of the texture to display in the layer
  53939. * @param scene Define the scene the layer belongs to
  53940. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53941. * @param color Defines a color for the layer
  53942. */
  53943. constructor(
  53944. /**
  53945. * Define the name of the layer.
  53946. */
  53947. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53948. private _createIndexBuffer;
  53949. /** @hidden */
  53950. _rebuild(): void;
  53951. /**
  53952. * Renders the layer in the scene.
  53953. */
  53954. render(): void;
  53955. /**
  53956. * Disposes and releases the associated ressources.
  53957. */
  53958. dispose(): void;
  53959. }
  53960. }
  53961. declare module BABYLON {
  53962. /** @hidden */
  53963. export var lensFlarePixelShader: {
  53964. name: string;
  53965. shader: string;
  53966. };
  53967. }
  53968. declare module BABYLON {
  53969. /** @hidden */
  53970. export var lensFlareVertexShader: {
  53971. name: string;
  53972. shader: string;
  53973. };
  53974. }
  53975. declare module BABYLON {
  53976. /**
  53977. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53978. * It is usually composed of several `lensFlare`.
  53979. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53980. */
  53981. export class LensFlareSystem {
  53982. /**
  53983. * Define the name of the lens flare system
  53984. */
  53985. name: string;
  53986. /**
  53987. * List of lens flares used in this system.
  53988. */
  53989. lensFlares: LensFlare[];
  53990. /**
  53991. * Define a limit from the border the lens flare can be visible.
  53992. */
  53993. borderLimit: number;
  53994. /**
  53995. * Define a viewport border we do not want to see the lens flare in.
  53996. */
  53997. viewportBorder: number;
  53998. /**
  53999. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54000. */
  54001. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54002. /**
  54003. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54004. */
  54005. layerMask: number;
  54006. /**
  54007. * Define the id of the lens flare system in the scene.
  54008. * (equal to name by default)
  54009. */
  54010. id: string;
  54011. private _scene;
  54012. private _emitter;
  54013. private _vertexBuffers;
  54014. private _indexBuffer;
  54015. private _effect;
  54016. private _positionX;
  54017. private _positionY;
  54018. private _isEnabled;
  54019. /** @hidden */
  54020. static _SceneComponentInitialization: (scene: Scene) => void;
  54021. /**
  54022. * Instantiates a lens flare system.
  54023. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54024. * It is usually composed of several `lensFlare`.
  54025. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54026. * @param name Define the name of the lens flare system in the scene
  54027. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54028. * @param scene Define the scene the lens flare system belongs to
  54029. */
  54030. constructor(
  54031. /**
  54032. * Define the name of the lens flare system
  54033. */
  54034. name: string, emitter: any, scene: Scene);
  54035. /**
  54036. * Define if the lens flare system is enabled.
  54037. */
  54038. get isEnabled(): boolean;
  54039. set isEnabled(value: boolean);
  54040. /**
  54041. * Get the scene the effects belongs to.
  54042. * @returns the scene holding the lens flare system
  54043. */
  54044. getScene(): Scene;
  54045. /**
  54046. * Get the emitter of the lens flare system.
  54047. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54048. * @returns the emitter of the lens flare system
  54049. */
  54050. getEmitter(): any;
  54051. /**
  54052. * Set the emitter of the lens flare system.
  54053. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54054. * @param newEmitter Define the new emitter of the system
  54055. */
  54056. setEmitter(newEmitter: any): void;
  54057. /**
  54058. * Get the lens flare system emitter position.
  54059. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54060. * @returns the position
  54061. */
  54062. getEmitterPosition(): Vector3;
  54063. /**
  54064. * @hidden
  54065. */
  54066. computeEffectivePosition(globalViewport: Viewport): boolean;
  54067. /** @hidden */
  54068. _isVisible(): boolean;
  54069. /**
  54070. * @hidden
  54071. */
  54072. render(): boolean;
  54073. /**
  54074. * Dispose and release the lens flare with its associated resources.
  54075. */
  54076. dispose(): void;
  54077. /**
  54078. * Parse a lens flare system from a JSON repressentation
  54079. * @param parsedLensFlareSystem Define the JSON to parse
  54080. * @param scene Define the scene the parsed system should be instantiated in
  54081. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54082. * @returns the parsed system
  54083. */
  54084. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54085. /**
  54086. * Serialize the current Lens Flare System into a JSON representation.
  54087. * @returns the serialized JSON
  54088. */
  54089. serialize(): any;
  54090. }
  54091. }
  54092. declare module BABYLON {
  54093. /**
  54094. * This represents one of the lens effect in a `lensFlareSystem`.
  54095. * It controls one of the indiviual texture used in the effect.
  54096. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54097. */
  54098. export class LensFlare {
  54099. /**
  54100. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54101. */
  54102. size: number;
  54103. /**
  54104. * 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.
  54105. */
  54106. position: number;
  54107. /**
  54108. * Define the lens color.
  54109. */
  54110. color: Color3;
  54111. /**
  54112. * Define the lens texture.
  54113. */
  54114. texture: Nullable<Texture>;
  54115. /**
  54116. * Define the alpha mode to render this particular lens.
  54117. */
  54118. alphaMode: number;
  54119. private _system;
  54120. /**
  54121. * Creates a new Lens Flare.
  54122. * This represents one of the lens effect in a `lensFlareSystem`.
  54123. * It controls one of the indiviual texture used in the effect.
  54124. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54125. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54126. * @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.
  54127. * @param color Define the lens color
  54128. * @param imgUrl Define the lens texture url
  54129. * @param system Define the `lensFlareSystem` this flare is part of
  54130. * @returns The newly created Lens Flare
  54131. */
  54132. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54133. /**
  54134. * Instantiates a new Lens Flare.
  54135. * This represents one of the lens effect in a `lensFlareSystem`.
  54136. * It controls one of the indiviual texture used in the effect.
  54137. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54138. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54139. * @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.
  54140. * @param color Define the lens color
  54141. * @param imgUrl Define the lens texture url
  54142. * @param system Define the `lensFlareSystem` this flare is part of
  54143. */
  54144. constructor(
  54145. /**
  54146. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54147. */
  54148. size: number,
  54149. /**
  54150. * 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.
  54151. */
  54152. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54153. /**
  54154. * Dispose and release the lens flare with its associated resources.
  54155. */
  54156. dispose(): void;
  54157. }
  54158. }
  54159. declare module BABYLON {
  54160. interface AbstractScene {
  54161. /**
  54162. * The list of lens flare system added to the scene
  54163. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54164. */
  54165. lensFlareSystems: Array<LensFlareSystem>;
  54166. /**
  54167. * Removes the given lens flare system from this scene.
  54168. * @param toRemove The lens flare system to remove
  54169. * @returns The index of the removed lens flare system
  54170. */
  54171. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54172. /**
  54173. * Adds the given lens flare system to this scene
  54174. * @param newLensFlareSystem The lens flare system to add
  54175. */
  54176. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54177. /**
  54178. * Gets a lens flare system using its name
  54179. * @param name defines the name to look for
  54180. * @returns the lens flare system or null if not found
  54181. */
  54182. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54183. /**
  54184. * Gets a lens flare system using its id
  54185. * @param id defines the id to look for
  54186. * @returns the lens flare system or null if not found
  54187. */
  54188. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54189. }
  54190. /**
  54191. * Defines the lens flare scene component responsible to manage any lens flares
  54192. * in a given scene.
  54193. */
  54194. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54195. /**
  54196. * The component name helpfull to identify the component in the list of scene components.
  54197. */
  54198. readonly name: string;
  54199. /**
  54200. * The scene the component belongs to.
  54201. */
  54202. scene: Scene;
  54203. /**
  54204. * Creates a new instance of the component for the given scene
  54205. * @param scene Defines the scene to register the component in
  54206. */
  54207. constructor(scene: Scene);
  54208. /**
  54209. * Registers the component in a given scene
  54210. */
  54211. register(): void;
  54212. /**
  54213. * Rebuilds the elements related to this component in case of
  54214. * context lost for instance.
  54215. */
  54216. rebuild(): void;
  54217. /**
  54218. * Adds all the elements from the container to the scene
  54219. * @param container the container holding the elements
  54220. */
  54221. addFromContainer(container: AbstractScene): void;
  54222. /**
  54223. * Removes all the elements in the container from the scene
  54224. * @param container contains the elements to remove
  54225. * @param dispose if the removed element should be disposed (default: false)
  54226. */
  54227. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54228. /**
  54229. * Serializes the component data to the specified json object
  54230. * @param serializationObject The object to serialize to
  54231. */
  54232. serialize(serializationObject: any): void;
  54233. /**
  54234. * Disposes the component and the associated ressources.
  54235. */
  54236. dispose(): void;
  54237. private _draw;
  54238. }
  54239. }
  54240. declare module BABYLON {
  54241. /** @hidden */
  54242. export var depthPixelShader: {
  54243. name: string;
  54244. shader: string;
  54245. };
  54246. }
  54247. declare module BABYLON {
  54248. /** @hidden */
  54249. export var depthVertexShader: {
  54250. name: string;
  54251. shader: string;
  54252. };
  54253. }
  54254. declare module BABYLON {
  54255. /**
  54256. * This represents a depth renderer in Babylon.
  54257. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54258. */
  54259. export class DepthRenderer {
  54260. private _scene;
  54261. private _depthMap;
  54262. private _effect;
  54263. private readonly _storeNonLinearDepth;
  54264. private readonly _clearColor;
  54265. /** Get if the depth renderer is using packed depth or not */
  54266. readonly isPacked: boolean;
  54267. private _cachedDefines;
  54268. private _camera;
  54269. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54270. enabled: boolean;
  54271. /**
  54272. * Specifiess that the depth renderer will only be used within
  54273. * the camera it is created for.
  54274. * This can help forcing its rendering during the camera processing.
  54275. */
  54276. useOnlyInActiveCamera: boolean;
  54277. /** @hidden */
  54278. static _SceneComponentInitialization: (scene: Scene) => void;
  54279. /**
  54280. * Instantiates a depth renderer
  54281. * @param scene The scene the renderer belongs to
  54282. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54283. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54284. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54285. */
  54286. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54287. /**
  54288. * Creates the depth rendering effect and checks if the effect is ready.
  54289. * @param subMesh The submesh to be used to render the depth map of
  54290. * @param useInstances If multiple world instances should be used
  54291. * @returns if the depth renderer is ready to render the depth map
  54292. */
  54293. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54294. /**
  54295. * Gets the texture which the depth map will be written to.
  54296. * @returns The depth map texture
  54297. */
  54298. getDepthMap(): RenderTargetTexture;
  54299. /**
  54300. * Disposes of the depth renderer.
  54301. */
  54302. dispose(): void;
  54303. }
  54304. }
  54305. declare module BABYLON {
  54306. /** @hidden */
  54307. export var minmaxReduxPixelShader: {
  54308. name: string;
  54309. shader: string;
  54310. };
  54311. }
  54312. declare module BABYLON {
  54313. /**
  54314. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54315. * and maximum values from all values of the texture.
  54316. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54317. * The source values are read from the red channel of the texture.
  54318. */
  54319. export class MinMaxReducer {
  54320. /**
  54321. * Observable triggered when the computation has been performed
  54322. */
  54323. onAfterReductionPerformed: Observable<{
  54324. min: number;
  54325. max: number;
  54326. }>;
  54327. protected _camera: Camera;
  54328. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54329. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54330. protected _postProcessManager: PostProcessManager;
  54331. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54332. protected _forceFullscreenViewport: boolean;
  54333. /**
  54334. * Creates a min/max reducer
  54335. * @param camera The camera to use for the post processes
  54336. */
  54337. constructor(camera: Camera);
  54338. /**
  54339. * Gets the texture used to read the values from.
  54340. */
  54341. get sourceTexture(): Nullable<RenderTargetTexture>;
  54342. /**
  54343. * Sets the source texture to read the values from.
  54344. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54345. * because in such textures '1' value must not be taken into account to compute the maximum
  54346. * as this value is used to clear the texture.
  54347. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54348. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54349. * @param depthRedux Indicates if the texture is a depth texture or not
  54350. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54351. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54352. */
  54353. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54354. /**
  54355. * Defines the refresh rate of the computation.
  54356. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54357. */
  54358. get refreshRate(): number;
  54359. set refreshRate(value: number);
  54360. protected _activated: boolean;
  54361. /**
  54362. * Gets the activation status of the reducer
  54363. */
  54364. get activated(): boolean;
  54365. /**
  54366. * Activates the reduction computation.
  54367. * When activated, the observers registered in onAfterReductionPerformed are
  54368. * called after the compuation is performed
  54369. */
  54370. activate(): void;
  54371. /**
  54372. * Deactivates the reduction computation.
  54373. */
  54374. deactivate(): void;
  54375. /**
  54376. * Disposes the min/max reducer
  54377. * @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.
  54378. */
  54379. dispose(disposeAll?: boolean): void;
  54380. }
  54381. }
  54382. declare module BABYLON {
  54383. /**
  54384. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54385. */
  54386. export class DepthReducer extends MinMaxReducer {
  54387. private _depthRenderer;
  54388. private _depthRendererId;
  54389. /**
  54390. * Gets the depth renderer used for the computation.
  54391. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54392. */
  54393. get depthRenderer(): Nullable<DepthRenderer>;
  54394. /**
  54395. * Creates a depth reducer
  54396. * @param camera The camera used to render the depth texture
  54397. */
  54398. constructor(camera: Camera);
  54399. /**
  54400. * Sets the depth renderer to use to generate the depth map
  54401. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54402. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54403. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54404. */
  54405. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54406. /** @hidden */
  54407. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54408. /**
  54409. * Activates the reduction computation.
  54410. * When activated, the observers registered in onAfterReductionPerformed are
  54411. * called after the compuation is performed
  54412. */
  54413. activate(): void;
  54414. /**
  54415. * Deactivates the reduction computation.
  54416. */
  54417. deactivate(): void;
  54418. /**
  54419. * Disposes the depth reducer
  54420. * @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.
  54421. */
  54422. dispose(disposeAll?: boolean): void;
  54423. }
  54424. }
  54425. declare module BABYLON {
  54426. /**
  54427. * A CSM implementation allowing casting shadows on large scenes.
  54428. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54429. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54430. */
  54431. export class CascadedShadowGenerator extends ShadowGenerator {
  54432. private static readonly frustumCornersNDCSpace;
  54433. /**
  54434. * Name of the CSM class
  54435. */
  54436. static CLASSNAME: string;
  54437. /**
  54438. * Defines the default number of cascades used by the CSM.
  54439. */
  54440. static readonly DEFAULT_CASCADES_COUNT: number;
  54441. /**
  54442. * Defines the minimum number of cascades used by the CSM.
  54443. */
  54444. static readonly MIN_CASCADES_COUNT: number;
  54445. /**
  54446. * Defines the maximum number of cascades used by the CSM.
  54447. */
  54448. static readonly MAX_CASCADES_COUNT: number;
  54449. protected _validateFilter(filter: number): number;
  54450. /**
  54451. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54452. */
  54453. penumbraDarkness: number;
  54454. private _numCascades;
  54455. /**
  54456. * Gets or set the number of cascades used by the CSM.
  54457. */
  54458. get numCascades(): number;
  54459. set numCascades(value: number);
  54460. /**
  54461. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54462. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54463. */
  54464. stabilizeCascades: boolean;
  54465. private _freezeShadowCastersBoundingInfo;
  54466. private _freezeShadowCastersBoundingInfoObservable;
  54467. /**
  54468. * Enables or disables the shadow casters bounding info computation.
  54469. * If your shadow casters don't move, you can disable this feature.
  54470. * If it is enabled, the bounding box computation is done every frame.
  54471. */
  54472. get freezeShadowCastersBoundingInfo(): boolean;
  54473. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54474. private _scbiMin;
  54475. private _scbiMax;
  54476. protected _computeShadowCastersBoundingInfo(): void;
  54477. protected _shadowCastersBoundingInfo: BoundingInfo;
  54478. /**
  54479. * Gets or sets the shadow casters bounding info.
  54480. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54481. * so that the system won't overwrite the bounds you provide
  54482. */
  54483. get shadowCastersBoundingInfo(): BoundingInfo;
  54484. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54485. protected _breaksAreDirty: boolean;
  54486. protected _minDistance: number;
  54487. protected _maxDistance: number;
  54488. /**
  54489. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54490. *
  54491. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54492. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54493. * @param min minimal distance for the breaks (default to 0.)
  54494. * @param max maximal distance for the breaks (default to 1.)
  54495. */
  54496. setMinMaxDistance(min: number, max: number): void;
  54497. /** Gets the minimal distance used in the cascade break computation */
  54498. get minDistance(): number;
  54499. /** Gets the maximal distance used in the cascade break computation */
  54500. get maxDistance(): number;
  54501. /**
  54502. * Gets the class name of that object
  54503. * @returns "CascadedShadowGenerator"
  54504. */
  54505. getClassName(): string;
  54506. private _cascadeMinExtents;
  54507. private _cascadeMaxExtents;
  54508. /**
  54509. * Gets a cascade minimum extents
  54510. * @param cascadeIndex index of the cascade
  54511. * @returns the minimum cascade extents
  54512. */
  54513. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54514. /**
  54515. * Gets a cascade maximum extents
  54516. * @param cascadeIndex index of the cascade
  54517. * @returns the maximum cascade extents
  54518. */
  54519. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54520. private _cascades;
  54521. private _currentLayer;
  54522. private _viewSpaceFrustumsZ;
  54523. private _viewMatrices;
  54524. private _projectionMatrices;
  54525. private _transformMatrices;
  54526. private _transformMatricesAsArray;
  54527. private _frustumLengths;
  54528. private _lightSizeUVCorrection;
  54529. private _depthCorrection;
  54530. private _frustumCornersWorldSpace;
  54531. private _frustumCenter;
  54532. private _shadowCameraPos;
  54533. private _shadowMaxZ;
  54534. /**
  54535. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54536. * It defaults to camera.maxZ
  54537. */
  54538. get shadowMaxZ(): number;
  54539. /**
  54540. * Sets the shadow max z distance.
  54541. */
  54542. set shadowMaxZ(value: number);
  54543. protected _debug: boolean;
  54544. /**
  54545. * Gets or sets the debug flag.
  54546. * When enabled, the cascades are materialized by different colors on the screen.
  54547. */
  54548. get debug(): boolean;
  54549. set debug(dbg: boolean);
  54550. private _depthClamp;
  54551. /**
  54552. * Gets or sets the depth clamping value.
  54553. *
  54554. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54555. * to account for the shadow casters far away.
  54556. *
  54557. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54558. */
  54559. get depthClamp(): boolean;
  54560. set depthClamp(value: boolean);
  54561. private _cascadeBlendPercentage;
  54562. /**
  54563. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54564. * It defaults to 0.1 (10% blending).
  54565. */
  54566. get cascadeBlendPercentage(): number;
  54567. set cascadeBlendPercentage(value: number);
  54568. private _lambda;
  54569. /**
  54570. * Gets or set the lambda parameter.
  54571. * This parameter is used to split the camera frustum and create the cascades.
  54572. * 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.
  54573. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54574. */
  54575. get lambda(): number;
  54576. set lambda(value: number);
  54577. /**
  54578. * Gets the view matrix corresponding to a given cascade
  54579. * @param cascadeNum cascade to retrieve the view matrix from
  54580. * @returns the cascade view matrix
  54581. */
  54582. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54583. /**
  54584. * Gets the projection matrix corresponding to a given cascade
  54585. * @param cascadeNum cascade to retrieve the projection matrix from
  54586. * @returns the cascade projection matrix
  54587. */
  54588. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54589. /**
  54590. * Gets the transformation matrix corresponding to a given cascade
  54591. * @param cascadeNum cascade to retrieve the transformation matrix from
  54592. * @returns the cascade transformation matrix
  54593. */
  54594. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54595. private _depthRenderer;
  54596. /**
  54597. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54598. *
  54599. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54600. *
  54601. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54602. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54603. * @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
  54604. */
  54605. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54606. private _depthReducer;
  54607. private _autoCalcDepthBounds;
  54608. /**
  54609. * Gets or sets the autoCalcDepthBounds property.
  54610. *
  54611. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54612. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54613. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54614. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54615. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54616. */
  54617. get autoCalcDepthBounds(): boolean;
  54618. set autoCalcDepthBounds(value: boolean);
  54619. /**
  54620. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54621. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54622. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54623. * for setting the refresh rate on the renderer yourself!
  54624. */
  54625. get autoCalcDepthBoundsRefreshRate(): number;
  54626. set autoCalcDepthBoundsRefreshRate(value: number);
  54627. /**
  54628. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54629. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54630. * you change the camera near/far planes!
  54631. */
  54632. splitFrustum(): void;
  54633. private _splitFrustum;
  54634. private _computeMatrices;
  54635. private _computeFrustumInWorldSpace;
  54636. private _computeCascadeFrustum;
  54637. /**
  54638. * Support test.
  54639. */
  54640. static get IsSupported(): boolean;
  54641. /** @hidden */
  54642. static _SceneComponentInitialization: (scene: Scene) => void;
  54643. /**
  54644. * Creates a Cascaded Shadow Generator object.
  54645. * A ShadowGenerator is the required tool to use the shadows.
  54646. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54647. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54648. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54649. * @param light The directional light object generating the shadows.
  54650. * @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.
  54651. */
  54652. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54653. protected _initializeGenerator(): void;
  54654. protected _createTargetRenderTexture(): void;
  54655. protected _initializeShadowMap(): void;
  54656. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54657. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54658. /**
  54659. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54660. * @param defines Defines of the material we want to update
  54661. * @param lightIndex Index of the light in the enabled light list of the material
  54662. */
  54663. prepareDefines(defines: any, lightIndex: number): void;
  54664. /**
  54665. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54666. * defined in the generator but impacting the effect).
  54667. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54668. * @param effect The effect we are binfing the information for
  54669. */
  54670. bindShadowLight(lightIndex: string, effect: Effect): void;
  54671. /**
  54672. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54673. * (eq to view projection * shadow projection matrices)
  54674. * @returns The transform matrix used to create the shadow map
  54675. */
  54676. getTransformMatrix(): Matrix;
  54677. /**
  54678. * Disposes the ShadowGenerator.
  54679. * Returns nothing.
  54680. */
  54681. dispose(): void;
  54682. /**
  54683. * Serializes the shadow generator setup to a json object.
  54684. * @returns The serialized JSON object
  54685. */
  54686. serialize(): any;
  54687. /**
  54688. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54689. * @param parsedShadowGenerator The JSON object to parse
  54690. * @param scene The scene to create the shadow map for
  54691. * @returns The parsed shadow generator
  54692. */
  54693. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54694. }
  54695. }
  54696. declare module BABYLON {
  54697. /**
  54698. * Defines the shadow generator component responsible to manage any shadow generators
  54699. * in a given scene.
  54700. */
  54701. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54702. /**
  54703. * The component name helpfull to identify the component in the list of scene components.
  54704. */
  54705. readonly name: string;
  54706. /**
  54707. * The scene the component belongs to.
  54708. */
  54709. scene: Scene;
  54710. /**
  54711. * Creates a new instance of the component for the given scene
  54712. * @param scene Defines the scene to register the component in
  54713. */
  54714. constructor(scene: Scene);
  54715. /**
  54716. * Registers the component in a given scene
  54717. */
  54718. register(): void;
  54719. /**
  54720. * Rebuilds the elements related to this component in case of
  54721. * context lost for instance.
  54722. */
  54723. rebuild(): void;
  54724. /**
  54725. * Serializes the component data to the specified json object
  54726. * @param serializationObject The object to serialize to
  54727. */
  54728. serialize(serializationObject: any): void;
  54729. /**
  54730. * Adds all the elements from the container to the scene
  54731. * @param container the container holding the elements
  54732. */
  54733. addFromContainer(container: AbstractScene): void;
  54734. /**
  54735. * Removes all the elements in the container from the scene
  54736. * @param container contains the elements to remove
  54737. * @param dispose if the removed element should be disposed (default: false)
  54738. */
  54739. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54740. /**
  54741. * Rebuilds the elements related to this component in case of
  54742. * context lost for instance.
  54743. */
  54744. dispose(): void;
  54745. private _gatherRenderTargets;
  54746. }
  54747. }
  54748. declare module BABYLON {
  54749. /**
  54750. * A point light is a light defined by an unique point in world space.
  54751. * The light is emitted in every direction from this point.
  54752. * A good example of a point light is a standard light bulb.
  54753. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54754. */
  54755. export class PointLight extends ShadowLight {
  54756. private _shadowAngle;
  54757. /**
  54758. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54759. * This specifies what angle the shadow will use to be created.
  54760. *
  54761. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54762. */
  54763. get shadowAngle(): number;
  54764. /**
  54765. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54766. * This specifies what angle the shadow will use to be created.
  54767. *
  54768. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54769. */
  54770. set shadowAngle(value: number);
  54771. /**
  54772. * Gets the direction if it has been set.
  54773. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54774. */
  54775. get direction(): Vector3;
  54776. /**
  54777. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54778. */
  54779. set direction(value: Vector3);
  54780. /**
  54781. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54782. * A PointLight emits the light in every direction.
  54783. * It can cast shadows.
  54784. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54785. * ```javascript
  54786. * var pointLight = new PointLight("pl", camera.position, scene);
  54787. * ```
  54788. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54789. * @param name The light friendly name
  54790. * @param position The position of the point light in the scene
  54791. * @param scene The scene the lights belongs to
  54792. */
  54793. constructor(name: string, position: Vector3, scene: Scene);
  54794. /**
  54795. * Returns the string "PointLight"
  54796. * @returns the class name
  54797. */
  54798. getClassName(): string;
  54799. /**
  54800. * Returns the integer 0.
  54801. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54802. */
  54803. getTypeID(): number;
  54804. /**
  54805. * Specifies wether or not the shadowmap should be a cube texture.
  54806. * @returns true if the shadowmap needs to be a cube texture.
  54807. */
  54808. needCube(): boolean;
  54809. /**
  54810. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54811. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54812. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54813. */
  54814. getShadowDirection(faceIndex?: number): Vector3;
  54815. /**
  54816. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54817. * - fov = PI / 2
  54818. * - aspect ratio : 1.0
  54819. * - z-near and far equal to the active camera minZ and maxZ.
  54820. * Returns the PointLight.
  54821. */
  54822. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54823. protected _buildUniformLayout(): void;
  54824. /**
  54825. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54826. * @param effect The effect to update
  54827. * @param lightIndex The index of the light in the effect to update
  54828. * @returns The point light
  54829. */
  54830. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54831. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54832. /**
  54833. * Prepares the list of defines specific to the light type.
  54834. * @param defines the list of defines
  54835. * @param lightIndex defines the index of the light for the effect
  54836. */
  54837. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54838. }
  54839. }
  54840. declare module BABYLON {
  54841. /**
  54842. * Header information of HDR texture files.
  54843. */
  54844. export interface HDRInfo {
  54845. /**
  54846. * The height of the texture in pixels.
  54847. */
  54848. height: number;
  54849. /**
  54850. * The width of the texture in pixels.
  54851. */
  54852. width: number;
  54853. /**
  54854. * The index of the beginning of the data in the binary file.
  54855. */
  54856. dataPosition: number;
  54857. }
  54858. /**
  54859. * This groups tools to convert HDR texture to native colors array.
  54860. */
  54861. export class HDRTools {
  54862. private static Ldexp;
  54863. private static Rgbe2float;
  54864. private static readStringLine;
  54865. /**
  54866. * Reads header information from an RGBE texture stored in a native array.
  54867. * More information on this format are available here:
  54868. * https://en.wikipedia.org/wiki/RGBE_image_format
  54869. *
  54870. * @param uint8array The binary file stored in native array.
  54871. * @return The header information.
  54872. */
  54873. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54874. /**
  54875. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54876. * This RGBE texture needs to store the information as a panorama.
  54877. *
  54878. * More information on this format are available here:
  54879. * https://en.wikipedia.org/wiki/RGBE_image_format
  54880. *
  54881. * @param buffer The binary file stored in an array buffer.
  54882. * @param size The expected size of the extracted cubemap.
  54883. * @return The Cube Map information.
  54884. */
  54885. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54886. /**
  54887. * Returns the pixels data extracted from an RGBE texture.
  54888. * This pixels will be stored left to right up to down in the R G B order in one array.
  54889. *
  54890. * More information on this format are available here:
  54891. * https://en.wikipedia.org/wiki/RGBE_image_format
  54892. *
  54893. * @param uint8array The binary file stored in an array buffer.
  54894. * @param hdrInfo The header information of the file.
  54895. * @return The pixels data in RGB right to left up to down order.
  54896. */
  54897. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54898. private static RGBE_ReadPixels_RLE;
  54899. }
  54900. }
  54901. declare module BABYLON {
  54902. /**
  54903. * This represents a texture coming from an HDR input.
  54904. *
  54905. * The only supported format is currently panorama picture stored in RGBE format.
  54906. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54907. */
  54908. export class HDRCubeTexture extends BaseTexture {
  54909. private static _facesMapping;
  54910. private _generateHarmonics;
  54911. private _noMipmap;
  54912. private _textureMatrix;
  54913. private _size;
  54914. private _onLoad;
  54915. private _onError;
  54916. /**
  54917. * The texture URL.
  54918. */
  54919. url: string;
  54920. /**
  54921. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54922. */
  54923. coordinatesMode: number;
  54924. protected _isBlocking: boolean;
  54925. /**
  54926. * Sets wether or not the texture is blocking during loading.
  54927. */
  54928. set isBlocking(value: boolean);
  54929. /**
  54930. * Gets wether or not the texture is blocking during loading.
  54931. */
  54932. get isBlocking(): boolean;
  54933. protected _rotationY: number;
  54934. /**
  54935. * Sets texture matrix rotation angle around Y axis in radians.
  54936. */
  54937. set rotationY(value: number);
  54938. /**
  54939. * Gets texture matrix rotation angle around Y axis radians.
  54940. */
  54941. get rotationY(): number;
  54942. /**
  54943. * Gets or sets the center of the bounding box associated with the cube texture
  54944. * It must define where the camera used to render the texture was set
  54945. */
  54946. boundingBoxPosition: Vector3;
  54947. private _boundingBoxSize;
  54948. /**
  54949. * Gets or sets the size of the bounding box associated with the cube texture
  54950. * When defined, the cubemap will switch to local mode
  54951. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54952. * @example https://www.babylonjs-playground.com/#RNASML
  54953. */
  54954. set boundingBoxSize(value: Vector3);
  54955. get boundingBoxSize(): Vector3;
  54956. /**
  54957. * Instantiates an HDRTexture from the following parameters.
  54958. *
  54959. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54960. * @param scene The scene the texture will be used in
  54961. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54962. * @param noMipmap Forces to not generate the mipmap if true
  54963. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54964. * @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)
  54965. * @param reserved Reserved flag for internal use.
  54966. */
  54967. 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>);
  54968. /**
  54969. * Get the current class name of the texture useful for serialization or dynamic coding.
  54970. * @returns "HDRCubeTexture"
  54971. */
  54972. getClassName(): string;
  54973. /**
  54974. * Occurs when the file is raw .hdr file.
  54975. */
  54976. private loadTexture;
  54977. clone(): HDRCubeTexture;
  54978. delayLoad(): void;
  54979. /**
  54980. * Get the texture reflection matrix used to rotate/transform the reflection.
  54981. * @returns the reflection matrix
  54982. */
  54983. getReflectionTextureMatrix(): Matrix;
  54984. /**
  54985. * Set the texture reflection matrix used to rotate/transform the reflection.
  54986. * @param value Define the reflection matrix to set
  54987. */
  54988. setReflectionTextureMatrix(value: Matrix): void;
  54989. /**
  54990. * Parses a JSON representation of an HDR Texture in order to create the texture
  54991. * @param parsedTexture Define the JSON representation
  54992. * @param scene Define the scene the texture should be created in
  54993. * @param rootUrl Define the root url in case we need to load relative dependencies
  54994. * @returns the newly created texture after parsing
  54995. */
  54996. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54997. serialize(): any;
  54998. }
  54999. }
  55000. declare module BABYLON {
  55001. /**
  55002. * Class used to control physics engine
  55003. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55004. */
  55005. export class PhysicsEngine implements IPhysicsEngine {
  55006. private _physicsPlugin;
  55007. /**
  55008. * Global value used to control the smallest number supported by the simulation
  55009. */
  55010. static Epsilon: number;
  55011. private _impostors;
  55012. private _joints;
  55013. private _subTimeStep;
  55014. /**
  55015. * Gets the gravity vector used by the simulation
  55016. */
  55017. gravity: Vector3;
  55018. /**
  55019. * Factory used to create the default physics plugin.
  55020. * @returns The default physics plugin
  55021. */
  55022. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55023. /**
  55024. * Creates a new Physics Engine
  55025. * @param gravity defines the gravity vector used by the simulation
  55026. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55027. */
  55028. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55029. /**
  55030. * Sets the gravity vector used by the simulation
  55031. * @param gravity defines the gravity vector to use
  55032. */
  55033. setGravity(gravity: Vector3): void;
  55034. /**
  55035. * Set the time step of the physics engine.
  55036. * Default is 1/60.
  55037. * To slow it down, enter 1/600 for example.
  55038. * To speed it up, 1/30
  55039. * @param newTimeStep defines the new timestep to apply to this world.
  55040. */
  55041. setTimeStep(newTimeStep?: number): void;
  55042. /**
  55043. * Get the time step of the physics engine.
  55044. * @returns the current time step
  55045. */
  55046. getTimeStep(): number;
  55047. /**
  55048. * Set the sub time step of the physics engine.
  55049. * Default is 0 meaning there is no sub steps
  55050. * To increase physics resolution precision, set a small value (like 1 ms)
  55051. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55052. */
  55053. setSubTimeStep(subTimeStep?: number): void;
  55054. /**
  55055. * Get the sub time step of the physics engine.
  55056. * @returns the current sub time step
  55057. */
  55058. getSubTimeStep(): number;
  55059. /**
  55060. * Release all resources
  55061. */
  55062. dispose(): void;
  55063. /**
  55064. * Gets the name of the current physics plugin
  55065. * @returns the name of the plugin
  55066. */
  55067. getPhysicsPluginName(): string;
  55068. /**
  55069. * Adding a new impostor for the impostor tracking.
  55070. * This will be done by the impostor itself.
  55071. * @param impostor the impostor to add
  55072. */
  55073. addImpostor(impostor: PhysicsImpostor): void;
  55074. /**
  55075. * Remove an impostor from the engine.
  55076. * This impostor and its mesh will not longer be updated by the physics engine.
  55077. * @param impostor the impostor to remove
  55078. */
  55079. removeImpostor(impostor: PhysicsImpostor): void;
  55080. /**
  55081. * Add a joint to the physics engine
  55082. * @param mainImpostor defines the main impostor to which the joint is added.
  55083. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55084. * @param joint defines the joint that will connect both impostors.
  55085. */
  55086. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55087. /**
  55088. * Removes a joint from the simulation
  55089. * @param mainImpostor defines the impostor used with the joint
  55090. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55091. * @param joint defines the joint to remove
  55092. */
  55093. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55094. /**
  55095. * Called by the scene. No need to call it.
  55096. * @param delta defines the timespam between frames
  55097. */
  55098. _step(delta: number): void;
  55099. /**
  55100. * Gets the current plugin used to run the simulation
  55101. * @returns current plugin
  55102. */
  55103. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55104. /**
  55105. * Gets the list of physic impostors
  55106. * @returns an array of PhysicsImpostor
  55107. */
  55108. getImpostors(): Array<PhysicsImpostor>;
  55109. /**
  55110. * Gets the impostor for a physics enabled object
  55111. * @param object defines the object impersonated by the impostor
  55112. * @returns the PhysicsImpostor or null if not found
  55113. */
  55114. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55115. /**
  55116. * Gets the impostor for a physics body object
  55117. * @param body defines physics body used by the impostor
  55118. * @returns the PhysicsImpostor or null if not found
  55119. */
  55120. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55121. /**
  55122. * Does a raycast in the physics world
  55123. * @param from when should the ray start?
  55124. * @param to when should the ray end?
  55125. * @returns PhysicsRaycastResult
  55126. */
  55127. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55128. }
  55129. }
  55130. declare module BABYLON {
  55131. /** @hidden */
  55132. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55133. private _useDeltaForWorldStep;
  55134. world: any;
  55135. name: string;
  55136. private _physicsMaterials;
  55137. private _fixedTimeStep;
  55138. private _cannonRaycastResult;
  55139. private _raycastResult;
  55140. private _physicsBodysToRemoveAfterStep;
  55141. BJSCANNON: any;
  55142. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55143. setGravity(gravity: Vector3): void;
  55144. setTimeStep(timeStep: number): void;
  55145. getTimeStep(): number;
  55146. executeStep(delta: number): void;
  55147. private _removeMarkedPhysicsBodiesFromWorld;
  55148. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55149. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55150. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55151. private _processChildMeshes;
  55152. removePhysicsBody(impostor: PhysicsImpostor): void;
  55153. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55154. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55155. private _addMaterial;
  55156. private _checkWithEpsilon;
  55157. private _createShape;
  55158. private _createHeightmap;
  55159. private _minus90X;
  55160. private _plus90X;
  55161. private _tmpPosition;
  55162. private _tmpDeltaPosition;
  55163. private _tmpUnityRotation;
  55164. private _updatePhysicsBodyTransformation;
  55165. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55166. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55167. isSupported(): boolean;
  55168. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55169. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55170. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55171. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55172. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55173. getBodyMass(impostor: PhysicsImpostor): number;
  55174. getBodyFriction(impostor: PhysicsImpostor): number;
  55175. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55176. getBodyRestitution(impostor: PhysicsImpostor): number;
  55177. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55178. sleepBody(impostor: PhysicsImpostor): void;
  55179. wakeUpBody(impostor: PhysicsImpostor): void;
  55180. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55181. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55182. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55183. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55184. getRadius(impostor: PhysicsImpostor): number;
  55185. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55186. dispose(): void;
  55187. private _extendNamespace;
  55188. /**
  55189. * Does a raycast in the physics world
  55190. * @param from when should the ray start?
  55191. * @param to when should the ray end?
  55192. * @returns PhysicsRaycastResult
  55193. */
  55194. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55195. }
  55196. }
  55197. declare module BABYLON {
  55198. /** @hidden */
  55199. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55200. world: any;
  55201. name: string;
  55202. BJSOIMO: any;
  55203. private _raycastResult;
  55204. constructor(iterations?: number, oimoInjection?: any);
  55205. setGravity(gravity: Vector3): void;
  55206. setTimeStep(timeStep: number): void;
  55207. getTimeStep(): number;
  55208. private _tmpImpostorsArray;
  55209. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55210. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55211. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55212. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55213. private _tmpPositionVector;
  55214. removePhysicsBody(impostor: PhysicsImpostor): void;
  55215. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55216. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55217. isSupported(): boolean;
  55218. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55219. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55220. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55221. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55222. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55223. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55224. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55225. getBodyMass(impostor: PhysicsImpostor): number;
  55226. getBodyFriction(impostor: PhysicsImpostor): number;
  55227. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55228. getBodyRestitution(impostor: PhysicsImpostor): number;
  55229. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55230. sleepBody(impostor: PhysicsImpostor): void;
  55231. wakeUpBody(impostor: PhysicsImpostor): void;
  55232. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55233. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55234. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55235. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55236. getRadius(impostor: PhysicsImpostor): number;
  55237. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55238. dispose(): void;
  55239. /**
  55240. * Does a raycast in the physics world
  55241. * @param from when should the ray start?
  55242. * @param to when should the ray end?
  55243. * @returns PhysicsRaycastResult
  55244. */
  55245. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55246. }
  55247. }
  55248. declare module BABYLON {
  55249. /**
  55250. * Class containing static functions to help procedurally build meshes
  55251. */
  55252. export class RibbonBuilder {
  55253. /**
  55254. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55255. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55256. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55257. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55258. * * 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
  55259. * * 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
  55260. * * 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
  55261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55262. * * 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
  55263. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55264. * * 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
  55265. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55266. * * 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
  55267. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55269. * @param name defines the name of the mesh
  55270. * @param options defines the options used to create the mesh
  55271. * @param scene defines the hosting scene
  55272. * @returns the ribbon mesh
  55273. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55274. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55275. */
  55276. static CreateRibbon(name: string, options: {
  55277. pathArray: Vector3[][];
  55278. closeArray?: boolean;
  55279. closePath?: boolean;
  55280. offset?: number;
  55281. updatable?: boolean;
  55282. sideOrientation?: number;
  55283. frontUVs?: Vector4;
  55284. backUVs?: Vector4;
  55285. instance?: Mesh;
  55286. invertUV?: boolean;
  55287. uvs?: Vector2[];
  55288. colors?: Color4[];
  55289. }, scene?: Nullable<Scene>): Mesh;
  55290. }
  55291. }
  55292. declare module BABYLON {
  55293. /**
  55294. * Class containing static functions to help procedurally build meshes
  55295. */
  55296. export class ShapeBuilder {
  55297. /**
  55298. * 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.
  55299. * * 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.
  55300. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55301. * * 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.
  55302. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55303. * * 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
  55304. * * 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
  55305. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55307. * * 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
  55308. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55310. * @param name defines the name of the mesh
  55311. * @param options defines the options used to create the mesh
  55312. * @param scene defines the hosting scene
  55313. * @returns the extruded shape mesh
  55314. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55316. */
  55317. static ExtrudeShape(name: string, options: {
  55318. shape: Vector3[];
  55319. path: Vector3[];
  55320. scale?: number;
  55321. rotation?: number;
  55322. cap?: number;
  55323. updatable?: boolean;
  55324. sideOrientation?: number;
  55325. frontUVs?: Vector4;
  55326. backUVs?: Vector4;
  55327. instance?: Mesh;
  55328. invertUV?: boolean;
  55329. }, scene?: Nullable<Scene>): Mesh;
  55330. /**
  55331. * Creates an custom extruded shape mesh.
  55332. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55333. * * 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.
  55334. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55335. * * 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
  55336. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55337. * * 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
  55338. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55339. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55340. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55341. * * 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
  55342. * * 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
  55343. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55345. * * 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
  55346. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55348. * @param name defines the name of the mesh
  55349. * @param options defines the options used to create the mesh
  55350. * @param scene defines the hosting scene
  55351. * @returns the custom extruded shape mesh
  55352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55353. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55354. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55355. */
  55356. static ExtrudeShapeCustom(name: string, options: {
  55357. shape: Vector3[];
  55358. path: Vector3[];
  55359. scaleFunction?: any;
  55360. rotationFunction?: any;
  55361. ribbonCloseArray?: boolean;
  55362. ribbonClosePath?: boolean;
  55363. cap?: number;
  55364. updatable?: boolean;
  55365. sideOrientation?: number;
  55366. frontUVs?: Vector4;
  55367. backUVs?: Vector4;
  55368. instance?: Mesh;
  55369. invertUV?: boolean;
  55370. }, scene?: Nullable<Scene>): Mesh;
  55371. private static _ExtrudeShapeGeneric;
  55372. }
  55373. }
  55374. declare module BABYLON {
  55375. /**
  55376. * AmmoJS Physics plugin
  55377. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55378. * @see https://github.com/kripken/ammo.js/
  55379. */
  55380. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55381. private _useDeltaForWorldStep;
  55382. /**
  55383. * Reference to the Ammo library
  55384. */
  55385. bjsAMMO: any;
  55386. /**
  55387. * Created ammoJS world which physics bodies are added to
  55388. */
  55389. world: any;
  55390. /**
  55391. * Name of the plugin
  55392. */
  55393. name: string;
  55394. private _timeStep;
  55395. private _fixedTimeStep;
  55396. private _maxSteps;
  55397. private _tmpQuaternion;
  55398. private _tmpAmmoTransform;
  55399. private _tmpAmmoQuaternion;
  55400. private _tmpAmmoConcreteContactResultCallback;
  55401. private _collisionConfiguration;
  55402. private _dispatcher;
  55403. private _overlappingPairCache;
  55404. private _solver;
  55405. private _softBodySolver;
  55406. private _tmpAmmoVectorA;
  55407. private _tmpAmmoVectorB;
  55408. private _tmpAmmoVectorC;
  55409. private _tmpAmmoVectorD;
  55410. private _tmpContactCallbackResult;
  55411. private _tmpAmmoVectorRCA;
  55412. private _tmpAmmoVectorRCB;
  55413. private _raycastResult;
  55414. private static readonly DISABLE_COLLISION_FLAG;
  55415. private static readonly KINEMATIC_FLAG;
  55416. private static readonly DISABLE_DEACTIVATION_FLAG;
  55417. /**
  55418. * Initializes the ammoJS plugin
  55419. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55420. * @param ammoInjection can be used to inject your own ammo reference
  55421. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55422. */
  55423. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55424. /**
  55425. * Sets the gravity of the physics world (m/(s^2))
  55426. * @param gravity Gravity to set
  55427. */
  55428. setGravity(gravity: Vector3): void;
  55429. /**
  55430. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55431. * @param timeStep timestep to use in seconds
  55432. */
  55433. setTimeStep(timeStep: number): void;
  55434. /**
  55435. * 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)
  55436. * @param fixedTimeStep fixedTimeStep to use in seconds
  55437. */
  55438. setFixedTimeStep(fixedTimeStep: number): void;
  55439. /**
  55440. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55441. * @param maxSteps the maximum number of steps by the physics engine per frame
  55442. */
  55443. setMaxSteps(maxSteps: number): void;
  55444. /**
  55445. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55446. * @returns the current timestep in seconds
  55447. */
  55448. getTimeStep(): number;
  55449. /**
  55450. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55451. */
  55452. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55453. private _isImpostorInContact;
  55454. private _isImpostorPairInContact;
  55455. private _stepSimulation;
  55456. /**
  55457. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55458. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55459. * After the step the babylon meshes are set to the position of the physics imposters
  55460. * @param delta amount of time to step forward
  55461. * @param impostors array of imposters to update before/after the step
  55462. */
  55463. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55464. /**
  55465. * Update babylon mesh to match physics world object
  55466. * @param impostor imposter to match
  55467. */
  55468. private _afterSoftStep;
  55469. /**
  55470. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55471. * @param impostor imposter to match
  55472. */
  55473. private _ropeStep;
  55474. /**
  55475. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55476. * @param impostor imposter to match
  55477. */
  55478. private _softbodyOrClothStep;
  55479. private _tmpVector;
  55480. private _tmpMatrix;
  55481. /**
  55482. * Applies an impulse on the imposter
  55483. * @param impostor imposter to apply impulse to
  55484. * @param force amount of force to be applied to the imposter
  55485. * @param contactPoint the location to apply the impulse on the imposter
  55486. */
  55487. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55488. /**
  55489. * Applies a force on the imposter
  55490. * @param impostor imposter to apply force
  55491. * @param force amount of force to be applied to the imposter
  55492. * @param contactPoint the location to apply the force on the imposter
  55493. */
  55494. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55495. /**
  55496. * Creates a physics body using the plugin
  55497. * @param impostor the imposter to create the physics body on
  55498. */
  55499. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55500. /**
  55501. * Removes the physics body from the imposter and disposes of the body's memory
  55502. * @param impostor imposter to remove the physics body from
  55503. */
  55504. removePhysicsBody(impostor: PhysicsImpostor): void;
  55505. /**
  55506. * Generates a joint
  55507. * @param impostorJoint the imposter joint to create the joint with
  55508. */
  55509. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55510. /**
  55511. * Removes a joint
  55512. * @param impostorJoint the imposter joint to remove the joint from
  55513. */
  55514. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55515. private _addMeshVerts;
  55516. /**
  55517. * Initialise the soft body vertices to match its object's (mesh) vertices
  55518. * Softbody vertices (nodes) are in world space and to match this
  55519. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55520. * @param impostor to create the softbody for
  55521. */
  55522. private _softVertexData;
  55523. /**
  55524. * Create an impostor's soft body
  55525. * @param impostor to create the softbody for
  55526. */
  55527. private _createSoftbody;
  55528. /**
  55529. * Create cloth for an impostor
  55530. * @param impostor to create the softbody for
  55531. */
  55532. private _createCloth;
  55533. /**
  55534. * Create rope for an impostor
  55535. * @param impostor to create the softbody for
  55536. */
  55537. private _createRope;
  55538. /**
  55539. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55540. * @param impostor to create the custom physics shape for
  55541. */
  55542. private _createCustom;
  55543. private _addHullVerts;
  55544. private _createShape;
  55545. /**
  55546. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55547. * @param impostor imposter containing the physics body and babylon object
  55548. */
  55549. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55550. /**
  55551. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55552. * @param impostor imposter containing the physics body and babylon object
  55553. * @param newPosition new position
  55554. * @param newRotation new rotation
  55555. */
  55556. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55557. /**
  55558. * If this plugin is supported
  55559. * @returns true if its supported
  55560. */
  55561. isSupported(): boolean;
  55562. /**
  55563. * Sets the linear velocity of the physics body
  55564. * @param impostor imposter to set the velocity on
  55565. * @param velocity velocity to set
  55566. */
  55567. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55568. /**
  55569. * Sets the angular velocity of the physics body
  55570. * @param impostor imposter to set the velocity on
  55571. * @param velocity velocity to set
  55572. */
  55573. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55574. /**
  55575. * gets the linear velocity
  55576. * @param impostor imposter to get linear velocity from
  55577. * @returns linear velocity
  55578. */
  55579. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55580. /**
  55581. * gets the angular velocity
  55582. * @param impostor imposter to get angular velocity from
  55583. * @returns angular velocity
  55584. */
  55585. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55586. /**
  55587. * Sets the mass of physics body
  55588. * @param impostor imposter to set the mass on
  55589. * @param mass mass to set
  55590. */
  55591. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55592. /**
  55593. * Gets the mass of the physics body
  55594. * @param impostor imposter to get the mass from
  55595. * @returns mass
  55596. */
  55597. getBodyMass(impostor: PhysicsImpostor): number;
  55598. /**
  55599. * Gets friction of the impostor
  55600. * @param impostor impostor to get friction from
  55601. * @returns friction value
  55602. */
  55603. getBodyFriction(impostor: PhysicsImpostor): number;
  55604. /**
  55605. * Sets friction of the impostor
  55606. * @param impostor impostor to set friction on
  55607. * @param friction friction value
  55608. */
  55609. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55610. /**
  55611. * Gets restitution of the impostor
  55612. * @param impostor impostor to get restitution from
  55613. * @returns restitution value
  55614. */
  55615. getBodyRestitution(impostor: PhysicsImpostor): number;
  55616. /**
  55617. * Sets resitution of the impostor
  55618. * @param impostor impostor to set resitution on
  55619. * @param restitution resitution value
  55620. */
  55621. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55622. /**
  55623. * Gets pressure inside the impostor
  55624. * @param impostor impostor to get pressure from
  55625. * @returns pressure value
  55626. */
  55627. getBodyPressure(impostor: PhysicsImpostor): number;
  55628. /**
  55629. * Sets pressure inside a soft body impostor
  55630. * Cloth and rope must remain 0 pressure
  55631. * @param impostor impostor to set pressure on
  55632. * @param pressure pressure value
  55633. */
  55634. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55635. /**
  55636. * Gets stiffness of the impostor
  55637. * @param impostor impostor to get stiffness from
  55638. * @returns pressure value
  55639. */
  55640. getBodyStiffness(impostor: PhysicsImpostor): number;
  55641. /**
  55642. * Sets stiffness of the impostor
  55643. * @param impostor impostor to set stiffness on
  55644. * @param stiffness stiffness value from 0 to 1
  55645. */
  55646. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55647. /**
  55648. * Gets velocityIterations of the impostor
  55649. * @param impostor impostor to get velocity iterations from
  55650. * @returns velocityIterations value
  55651. */
  55652. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55653. /**
  55654. * Sets velocityIterations of the impostor
  55655. * @param impostor impostor to set velocity iterations on
  55656. * @param velocityIterations velocityIterations value
  55657. */
  55658. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55659. /**
  55660. * Gets positionIterations of the impostor
  55661. * @param impostor impostor to get position iterations from
  55662. * @returns positionIterations value
  55663. */
  55664. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55665. /**
  55666. * Sets positionIterations of the impostor
  55667. * @param impostor impostor to set position on
  55668. * @param positionIterations positionIterations value
  55669. */
  55670. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55671. /**
  55672. * Append an anchor to a cloth object
  55673. * @param impostor is the cloth impostor to add anchor to
  55674. * @param otherImpostor is the rigid impostor to anchor to
  55675. * @param width ratio across width from 0 to 1
  55676. * @param height ratio up height from 0 to 1
  55677. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55678. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55679. */
  55680. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55681. /**
  55682. * Append an hook to a rope object
  55683. * @param impostor is the rope impostor to add hook to
  55684. * @param otherImpostor is the rigid impostor to hook to
  55685. * @param length ratio along the rope from 0 to 1
  55686. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55687. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55688. */
  55689. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55690. /**
  55691. * Sleeps the physics body and stops it from being active
  55692. * @param impostor impostor to sleep
  55693. */
  55694. sleepBody(impostor: PhysicsImpostor): void;
  55695. /**
  55696. * Activates the physics body
  55697. * @param impostor impostor to activate
  55698. */
  55699. wakeUpBody(impostor: PhysicsImpostor): void;
  55700. /**
  55701. * Updates the distance parameters of the joint
  55702. * @param joint joint to update
  55703. * @param maxDistance maximum distance of the joint
  55704. * @param minDistance minimum distance of the joint
  55705. */
  55706. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55707. /**
  55708. * Sets a motor on the joint
  55709. * @param joint joint to set motor on
  55710. * @param speed speed of the motor
  55711. * @param maxForce maximum force of the motor
  55712. * @param motorIndex index of the motor
  55713. */
  55714. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55715. /**
  55716. * Sets the motors limit
  55717. * @param joint joint to set limit on
  55718. * @param upperLimit upper limit
  55719. * @param lowerLimit lower limit
  55720. */
  55721. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55722. /**
  55723. * Syncs the position and rotation of a mesh with the impostor
  55724. * @param mesh mesh to sync
  55725. * @param impostor impostor to update the mesh with
  55726. */
  55727. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55728. /**
  55729. * Gets the radius of the impostor
  55730. * @param impostor impostor to get radius from
  55731. * @returns the radius
  55732. */
  55733. getRadius(impostor: PhysicsImpostor): number;
  55734. /**
  55735. * Gets the box size of the impostor
  55736. * @param impostor impostor to get box size from
  55737. * @param result the resulting box size
  55738. */
  55739. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55740. /**
  55741. * Disposes of the impostor
  55742. */
  55743. dispose(): void;
  55744. /**
  55745. * Does a raycast in the physics world
  55746. * @param from when should the ray start?
  55747. * @param to when should the ray end?
  55748. * @returns PhysicsRaycastResult
  55749. */
  55750. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55751. }
  55752. }
  55753. declare module BABYLON {
  55754. interface AbstractScene {
  55755. /**
  55756. * The list of reflection probes added to the scene
  55757. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55758. */
  55759. reflectionProbes: Array<ReflectionProbe>;
  55760. /**
  55761. * Removes the given reflection probe from this scene.
  55762. * @param toRemove The reflection probe to remove
  55763. * @returns The index of the removed reflection probe
  55764. */
  55765. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55766. /**
  55767. * Adds the given reflection probe to this scene.
  55768. * @param newReflectionProbe The reflection probe to add
  55769. */
  55770. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55771. }
  55772. /**
  55773. * Class used to generate realtime reflection / refraction cube textures
  55774. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55775. */
  55776. export class ReflectionProbe {
  55777. /** defines the name of the probe */
  55778. name: string;
  55779. private _scene;
  55780. private _renderTargetTexture;
  55781. private _projectionMatrix;
  55782. private _viewMatrix;
  55783. private _target;
  55784. private _add;
  55785. private _attachedMesh;
  55786. private _invertYAxis;
  55787. /** Gets or sets probe position (center of the cube map) */
  55788. position: Vector3;
  55789. /**
  55790. * Creates a new reflection probe
  55791. * @param name defines the name of the probe
  55792. * @param size defines the texture resolution (for each face)
  55793. * @param scene defines the hosting scene
  55794. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55795. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55796. */
  55797. constructor(
  55798. /** defines the name of the probe */
  55799. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55800. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55801. get samples(): number;
  55802. set samples(value: number);
  55803. /** Gets or sets the refresh rate to use (on every frame by default) */
  55804. get refreshRate(): number;
  55805. set refreshRate(value: number);
  55806. /**
  55807. * Gets the hosting scene
  55808. * @returns a Scene
  55809. */
  55810. getScene(): Scene;
  55811. /** Gets the internal CubeTexture used to render to */
  55812. get cubeTexture(): RenderTargetTexture;
  55813. /** Gets the list of meshes to render */
  55814. get renderList(): Nullable<AbstractMesh[]>;
  55815. /**
  55816. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55817. * @param mesh defines the mesh to attach to
  55818. */
  55819. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55820. /**
  55821. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55822. * @param renderingGroupId The rendering group id corresponding to its index
  55823. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55824. */
  55825. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55826. /**
  55827. * Clean all associated resources
  55828. */
  55829. dispose(): void;
  55830. /**
  55831. * Converts the reflection probe information to a readable string for debug purpose.
  55832. * @param fullDetails Supports for multiple levels of logging within scene loading
  55833. * @returns the human readable reflection probe info
  55834. */
  55835. toString(fullDetails?: boolean): string;
  55836. /**
  55837. * Get the class name of the relfection probe.
  55838. * @returns "ReflectionProbe"
  55839. */
  55840. getClassName(): string;
  55841. /**
  55842. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55843. * @returns The JSON representation of the texture
  55844. */
  55845. serialize(): any;
  55846. /**
  55847. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55848. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55849. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55850. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55851. * @returns The parsed reflection probe if successful
  55852. */
  55853. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55854. }
  55855. }
  55856. declare module BABYLON {
  55857. /** @hidden */
  55858. export var _BabylonLoaderRegistered: boolean;
  55859. /**
  55860. * Helps setting up some configuration for the babylon file loader.
  55861. */
  55862. export class BabylonFileLoaderConfiguration {
  55863. /**
  55864. * The loader does not allow injecting custom physix engine into the plugins.
  55865. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55866. * So you could set this variable to your engine import to make it work.
  55867. */
  55868. static LoaderInjectedPhysicsEngine: any;
  55869. }
  55870. }
  55871. declare module BABYLON {
  55872. /**
  55873. * The Physically based simple base material of BJS.
  55874. *
  55875. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55876. * It is used as the base class for both the specGloss and metalRough conventions.
  55877. */
  55878. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55879. /**
  55880. * Number of Simultaneous lights allowed on the material.
  55881. */
  55882. maxSimultaneousLights: number;
  55883. /**
  55884. * If sets to true, disables all the lights affecting the material.
  55885. */
  55886. disableLighting: boolean;
  55887. /**
  55888. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55889. */
  55890. environmentTexture: BaseTexture;
  55891. /**
  55892. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55893. */
  55894. invertNormalMapX: boolean;
  55895. /**
  55896. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55897. */
  55898. invertNormalMapY: boolean;
  55899. /**
  55900. * Normal map used in the model.
  55901. */
  55902. normalTexture: BaseTexture;
  55903. /**
  55904. * Emissivie color used to self-illuminate the model.
  55905. */
  55906. emissiveColor: Color3;
  55907. /**
  55908. * Emissivie texture used to self-illuminate the model.
  55909. */
  55910. emissiveTexture: BaseTexture;
  55911. /**
  55912. * Occlusion Channel Strenght.
  55913. */
  55914. occlusionStrength: number;
  55915. /**
  55916. * Occlusion Texture of the material (adding extra occlusion effects).
  55917. */
  55918. occlusionTexture: BaseTexture;
  55919. /**
  55920. * Defines the alpha limits in alpha test mode.
  55921. */
  55922. alphaCutOff: number;
  55923. /**
  55924. * Gets the current double sided mode.
  55925. */
  55926. get doubleSided(): boolean;
  55927. /**
  55928. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55929. */
  55930. set doubleSided(value: boolean);
  55931. /**
  55932. * Stores the pre-calculated light information of a mesh in a texture.
  55933. */
  55934. lightmapTexture: BaseTexture;
  55935. /**
  55936. * If true, the light map contains occlusion information instead of lighting info.
  55937. */
  55938. useLightmapAsShadowmap: boolean;
  55939. /**
  55940. * Instantiates a new PBRMaterial instance.
  55941. *
  55942. * @param name The material name
  55943. * @param scene The scene the material will be use in.
  55944. */
  55945. constructor(name: string, scene: Scene);
  55946. getClassName(): string;
  55947. }
  55948. }
  55949. declare module BABYLON {
  55950. /**
  55951. * The PBR material of BJS following the metal roughness convention.
  55952. *
  55953. * This fits to the PBR convention in the GLTF definition:
  55954. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55955. */
  55956. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55957. /**
  55958. * The base color has two different interpretations depending on the value of metalness.
  55959. * When the material is a metal, the base color is the specific measured reflectance value
  55960. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55961. * of the material.
  55962. */
  55963. baseColor: Color3;
  55964. /**
  55965. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55966. * well as opacity information in the alpha channel.
  55967. */
  55968. baseTexture: BaseTexture;
  55969. /**
  55970. * Specifies the metallic scalar value of the material.
  55971. * Can also be used to scale the metalness values of the metallic texture.
  55972. */
  55973. metallic: number;
  55974. /**
  55975. * Specifies the roughness scalar value of the material.
  55976. * Can also be used to scale the roughness values of the metallic texture.
  55977. */
  55978. roughness: number;
  55979. /**
  55980. * Texture containing both the metallic value in the B channel and the
  55981. * roughness value in the G channel to keep better precision.
  55982. */
  55983. metallicRoughnessTexture: BaseTexture;
  55984. /**
  55985. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55986. *
  55987. * @param name The material name
  55988. * @param scene The scene the material will be use in.
  55989. */
  55990. constructor(name: string, scene: Scene);
  55991. /**
  55992. * Return the currrent class name of the material.
  55993. */
  55994. getClassName(): string;
  55995. /**
  55996. * Makes a duplicate of the current material.
  55997. * @param name - name to use for the new material.
  55998. */
  55999. clone(name: string): PBRMetallicRoughnessMaterial;
  56000. /**
  56001. * Serialize the material to a parsable JSON object.
  56002. */
  56003. serialize(): any;
  56004. /**
  56005. * Parses a JSON object correponding to the serialize function.
  56006. */
  56007. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56008. }
  56009. }
  56010. declare module BABYLON {
  56011. /**
  56012. * The PBR material of BJS following the specular glossiness convention.
  56013. *
  56014. * This fits to the PBR convention in the GLTF definition:
  56015. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56016. */
  56017. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56018. /**
  56019. * Specifies the diffuse color of the material.
  56020. */
  56021. diffuseColor: Color3;
  56022. /**
  56023. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56024. * channel.
  56025. */
  56026. diffuseTexture: BaseTexture;
  56027. /**
  56028. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56029. */
  56030. specularColor: Color3;
  56031. /**
  56032. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56033. */
  56034. glossiness: number;
  56035. /**
  56036. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56037. */
  56038. specularGlossinessTexture: BaseTexture;
  56039. /**
  56040. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56041. *
  56042. * @param name The material name
  56043. * @param scene The scene the material will be use in.
  56044. */
  56045. constructor(name: string, scene: Scene);
  56046. /**
  56047. * Return the currrent class name of the material.
  56048. */
  56049. getClassName(): string;
  56050. /**
  56051. * Makes a duplicate of the current material.
  56052. * @param name - name to use for the new material.
  56053. */
  56054. clone(name: string): PBRSpecularGlossinessMaterial;
  56055. /**
  56056. * Serialize the material to a parsable JSON object.
  56057. */
  56058. serialize(): any;
  56059. /**
  56060. * Parses a JSON object correponding to the serialize function.
  56061. */
  56062. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56063. }
  56064. }
  56065. declare module BABYLON {
  56066. /**
  56067. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56068. * It can help converting any input color in a desired output one. This can then be used to create effects
  56069. * from sepia, black and white to sixties or futuristic rendering...
  56070. *
  56071. * The only supported format is currently 3dl.
  56072. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56073. */
  56074. export class ColorGradingTexture extends BaseTexture {
  56075. /**
  56076. * The current texture matrix. (will always be identity in color grading texture)
  56077. */
  56078. private _textureMatrix;
  56079. /**
  56080. * The texture URL.
  56081. */
  56082. url: string;
  56083. /**
  56084. * Empty line regex stored for GC.
  56085. */
  56086. private static _noneEmptyLineRegex;
  56087. private _engine;
  56088. /**
  56089. * Instantiates a ColorGradingTexture from the following parameters.
  56090. *
  56091. * @param url The location of the color gradind data (currently only supporting 3dl)
  56092. * @param scene The scene the texture will be used in
  56093. */
  56094. constructor(url: string, scene: Scene);
  56095. /**
  56096. * Returns the texture matrix used in most of the material.
  56097. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56098. */
  56099. getTextureMatrix(): Matrix;
  56100. /**
  56101. * Occurs when the file being loaded is a .3dl LUT file.
  56102. */
  56103. private load3dlTexture;
  56104. /**
  56105. * Starts the loading process of the texture.
  56106. */
  56107. private loadTexture;
  56108. /**
  56109. * Clones the color gradind texture.
  56110. */
  56111. clone(): ColorGradingTexture;
  56112. /**
  56113. * Called during delayed load for textures.
  56114. */
  56115. delayLoad(): void;
  56116. /**
  56117. * Parses a color grading texture serialized by Babylon.
  56118. * @param parsedTexture The texture information being parsedTexture
  56119. * @param scene The scene to load the texture in
  56120. * @param rootUrl The root url of the data assets to load
  56121. * @return A color gradind texture
  56122. */
  56123. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56124. /**
  56125. * Serializes the LUT texture to json format.
  56126. */
  56127. serialize(): any;
  56128. }
  56129. }
  56130. declare module BABYLON {
  56131. /**
  56132. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56133. */
  56134. export class EquiRectangularCubeTexture extends BaseTexture {
  56135. /** The six faces of the cube. */
  56136. private static _FacesMapping;
  56137. private _noMipmap;
  56138. private _onLoad;
  56139. private _onError;
  56140. /** The size of the cubemap. */
  56141. private _size;
  56142. /** The buffer of the image. */
  56143. private _buffer;
  56144. /** The width of the input image. */
  56145. private _width;
  56146. /** The height of the input image. */
  56147. private _height;
  56148. /** The URL to the image. */
  56149. url: string;
  56150. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56151. coordinatesMode: number;
  56152. /**
  56153. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56154. * @param url The location of the image
  56155. * @param scene The scene the texture will be used in
  56156. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56157. * @param noMipmap Forces to not generate the mipmap if true
  56158. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56159. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56160. * @param onLoad — defines a callback called when texture is loaded
  56161. * @param onError — defines a callback called if there is an error
  56162. */
  56163. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56164. /**
  56165. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56166. */
  56167. private loadImage;
  56168. /**
  56169. * Convert the image buffer into a cubemap and create a CubeTexture.
  56170. */
  56171. private loadTexture;
  56172. /**
  56173. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56174. * @param buffer The ArrayBuffer that should be converted.
  56175. * @returns The buffer as Float32Array.
  56176. */
  56177. private getFloat32ArrayFromArrayBuffer;
  56178. /**
  56179. * Get the current class name of the texture useful for serialization or dynamic coding.
  56180. * @returns "EquiRectangularCubeTexture"
  56181. */
  56182. getClassName(): string;
  56183. /**
  56184. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56185. * @returns A clone of the current EquiRectangularCubeTexture.
  56186. */
  56187. clone(): EquiRectangularCubeTexture;
  56188. }
  56189. }
  56190. declare module BABYLON {
  56191. /**
  56192. * Based on jsTGALoader - Javascript loader for TGA file
  56193. * By Vincent Thibault
  56194. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56195. */
  56196. export class TGATools {
  56197. private static _TYPE_INDEXED;
  56198. private static _TYPE_RGB;
  56199. private static _TYPE_GREY;
  56200. private static _TYPE_RLE_INDEXED;
  56201. private static _TYPE_RLE_RGB;
  56202. private static _TYPE_RLE_GREY;
  56203. private static _ORIGIN_MASK;
  56204. private static _ORIGIN_SHIFT;
  56205. private static _ORIGIN_BL;
  56206. private static _ORIGIN_BR;
  56207. private static _ORIGIN_UL;
  56208. private static _ORIGIN_UR;
  56209. /**
  56210. * Gets the header of a TGA file
  56211. * @param data defines the TGA data
  56212. * @returns the header
  56213. */
  56214. static GetTGAHeader(data: Uint8Array): any;
  56215. /**
  56216. * Uploads TGA content to a Babylon Texture
  56217. * @hidden
  56218. */
  56219. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56220. /** @hidden */
  56221. 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;
  56222. /** @hidden */
  56223. 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;
  56224. /** @hidden */
  56225. 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;
  56226. /** @hidden */
  56227. 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;
  56228. /** @hidden */
  56229. 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;
  56230. /** @hidden */
  56231. 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;
  56232. }
  56233. }
  56234. declare module BABYLON {
  56235. /**
  56236. * Implementation of the TGA Texture Loader.
  56237. * @hidden
  56238. */
  56239. export class _TGATextureLoader implements IInternalTextureLoader {
  56240. /**
  56241. * Defines wether the loader supports cascade loading the different faces.
  56242. */
  56243. readonly supportCascades: boolean;
  56244. /**
  56245. * This returns if the loader support the current file information.
  56246. * @param extension defines the file extension of the file being loaded
  56247. * @returns true if the loader can load the specified file
  56248. */
  56249. canLoad(extension: string): boolean;
  56250. /**
  56251. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56252. * @param data contains the texture data
  56253. * @param texture defines the BabylonJS internal texture
  56254. * @param createPolynomials will be true if polynomials have been requested
  56255. * @param onLoad defines the callback to trigger once the texture is ready
  56256. * @param onError defines the callback to trigger in case of error
  56257. */
  56258. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56259. /**
  56260. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56261. * @param data contains the texture data
  56262. * @param texture defines the BabylonJS internal texture
  56263. * @param callback defines the method to call once ready to upload
  56264. */
  56265. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56266. }
  56267. }
  56268. declare module BABYLON {
  56269. /**
  56270. * Info about the .basis files
  56271. */
  56272. class BasisFileInfo {
  56273. /**
  56274. * If the file has alpha
  56275. */
  56276. hasAlpha: boolean;
  56277. /**
  56278. * Info about each image of the basis file
  56279. */
  56280. images: Array<{
  56281. levels: Array<{
  56282. width: number;
  56283. height: number;
  56284. transcodedPixels: ArrayBufferView;
  56285. }>;
  56286. }>;
  56287. }
  56288. /**
  56289. * Result of transcoding a basis file
  56290. */
  56291. class TranscodeResult {
  56292. /**
  56293. * Info about the .basis file
  56294. */
  56295. fileInfo: BasisFileInfo;
  56296. /**
  56297. * Format to use when loading the file
  56298. */
  56299. format: number;
  56300. }
  56301. /**
  56302. * Configuration options for the Basis transcoder
  56303. */
  56304. export class BasisTranscodeConfiguration {
  56305. /**
  56306. * Supported compression formats used to determine the supported output format of the transcoder
  56307. */
  56308. supportedCompressionFormats?: {
  56309. /**
  56310. * etc1 compression format
  56311. */
  56312. etc1?: boolean;
  56313. /**
  56314. * s3tc compression format
  56315. */
  56316. s3tc?: boolean;
  56317. /**
  56318. * pvrtc compression format
  56319. */
  56320. pvrtc?: boolean;
  56321. /**
  56322. * etc2 compression format
  56323. */
  56324. etc2?: boolean;
  56325. };
  56326. /**
  56327. * If mipmap levels should be loaded for transcoded images (Default: true)
  56328. */
  56329. loadMipmapLevels?: boolean;
  56330. /**
  56331. * Index of a single image to load (Default: all images)
  56332. */
  56333. loadSingleImage?: number;
  56334. }
  56335. /**
  56336. * Used to load .Basis files
  56337. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56338. */
  56339. export class BasisTools {
  56340. private static _IgnoreSupportedFormats;
  56341. /**
  56342. * URL to use when loading the basis transcoder
  56343. */
  56344. static JSModuleURL: string;
  56345. /**
  56346. * URL to use when loading the wasm module for the transcoder
  56347. */
  56348. static WasmModuleURL: string;
  56349. /**
  56350. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56351. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56352. * @returns internal format corresponding to the Basis format
  56353. */
  56354. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56355. private static _WorkerPromise;
  56356. private static _Worker;
  56357. private static _actionId;
  56358. private static _CreateWorkerAsync;
  56359. /**
  56360. * Transcodes a loaded image file to compressed pixel data
  56361. * @param data image data to transcode
  56362. * @param config configuration options for the transcoding
  56363. * @returns a promise resulting in the transcoded image
  56364. */
  56365. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56366. /**
  56367. * Loads a texture from the transcode result
  56368. * @param texture texture load to
  56369. * @param transcodeResult the result of transcoding the basis file to load from
  56370. */
  56371. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56372. }
  56373. }
  56374. declare module BABYLON {
  56375. /**
  56376. * Loader for .basis file format
  56377. */
  56378. export class _BasisTextureLoader implements IInternalTextureLoader {
  56379. /**
  56380. * Defines whether the loader supports cascade loading the different faces.
  56381. */
  56382. readonly supportCascades: boolean;
  56383. /**
  56384. * This returns if the loader support the current file information.
  56385. * @param extension defines the file extension of the file being loaded
  56386. * @returns true if the loader can load the specified file
  56387. */
  56388. canLoad(extension: string): boolean;
  56389. /**
  56390. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56391. * @param data contains the texture data
  56392. * @param texture defines the BabylonJS internal texture
  56393. * @param createPolynomials will be true if polynomials have been requested
  56394. * @param onLoad defines the callback to trigger once the texture is ready
  56395. * @param onError defines the callback to trigger in case of error
  56396. */
  56397. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56398. /**
  56399. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56400. * @param data contains the texture data
  56401. * @param texture defines the BabylonJS internal texture
  56402. * @param callback defines the method to call once ready to upload
  56403. */
  56404. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56405. }
  56406. }
  56407. declare module BABYLON {
  56408. /**
  56409. * 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.
  56410. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56411. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56412. */
  56413. export class CustomProceduralTexture extends ProceduralTexture {
  56414. private _animate;
  56415. private _time;
  56416. private _config;
  56417. private _texturePath;
  56418. /**
  56419. * Instantiates a new Custom Procedural Texture.
  56420. * 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.
  56421. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56422. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56423. * @param name Define the name of the texture
  56424. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56425. * @param size Define the size of the texture to create
  56426. * @param scene Define the scene the texture belongs to
  56427. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56428. * @param generateMipMaps Define if the texture should creates mip maps or not
  56429. */
  56430. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56431. private _loadJson;
  56432. /**
  56433. * Is the texture ready to be used ? (rendered at least once)
  56434. * @returns true if ready, otherwise, false.
  56435. */
  56436. isReady(): boolean;
  56437. /**
  56438. * Render the texture to its associated render target.
  56439. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56440. */
  56441. render(useCameraPostProcess?: boolean): void;
  56442. /**
  56443. * Update the list of dependant textures samplers in the shader.
  56444. */
  56445. updateTextures(): void;
  56446. /**
  56447. * Update the uniform values of the procedural texture in the shader.
  56448. */
  56449. updateShaderUniforms(): void;
  56450. /**
  56451. * Define if the texture animates or not.
  56452. */
  56453. get animate(): boolean;
  56454. set animate(value: boolean);
  56455. }
  56456. }
  56457. declare module BABYLON {
  56458. /** @hidden */
  56459. export var noisePixelShader: {
  56460. name: string;
  56461. shader: string;
  56462. };
  56463. }
  56464. declare module BABYLON {
  56465. /**
  56466. * Class used to generate noise procedural textures
  56467. */
  56468. export class NoiseProceduralTexture extends ProceduralTexture {
  56469. private _time;
  56470. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56471. brightness: number;
  56472. /** Defines the number of octaves to process */
  56473. octaves: number;
  56474. /** Defines the level of persistence (0.8 by default) */
  56475. persistence: number;
  56476. /** Gets or sets animation speed factor (default is 1) */
  56477. animationSpeedFactor: number;
  56478. /**
  56479. * Creates a new NoiseProceduralTexture
  56480. * @param name defines the name fo the texture
  56481. * @param size defines the size of the texture (default is 256)
  56482. * @param scene defines the hosting scene
  56483. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56484. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56485. */
  56486. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56487. private _updateShaderUniforms;
  56488. protected _getDefines(): string;
  56489. /** Generate the current state of the procedural texture */
  56490. render(useCameraPostProcess?: boolean): void;
  56491. /**
  56492. * Serializes this noise procedural texture
  56493. * @returns a serialized noise procedural texture object
  56494. */
  56495. serialize(): any;
  56496. /**
  56497. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56498. * @param parsedTexture defines parsed texture data
  56499. * @param scene defines the current scene
  56500. * @param rootUrl defines the root URL containing noise procedural texture information
  56501. * @returns a parsed NoiseProceduralTexture
  56502. */
  56503. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56504. }
  56505. }
  56506. declare module BABYLON {
  56507. /**
  56508. * Raw cube texture where the raw buffers are passed in
  56509. */
  56510. export class RawCubeTexture extends CubeTexture {
  56511. /**
  56512. * Creates a cube texture where the raw buffers are passed in.
  56513. * @param scene defines the scene the texture is attached to
  56514. * @param data defines the array of data to use to create each face
  56515. * @param size defines the size of the textures
  56516. * @param format defines the format of the data
  56517. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56518. * @param generateMipMaps defines if the engine should generate the mip levels
  56519. * @param invertY defines if data must be stored with Y axis inverted
  56520. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56521. * @param compression defines the compression used (null by default)
  56522. */
  56523. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56524. /**
  56525. * Updates the raw cube texture.
  56526. * @param data defines the data to store
  56527. * @param format defines the data format
  56528. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56529. * @param invertY defines if data must be stored with Y axis inverted
  56530. * @param compression defines the compression used (null by default)
  56531. * @param level defines which level of the texture to update
  56532. */
  56533. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56534. /**
  56535. * Updates a raw cube texture with RGBD encoded data.
  56536. * @param data defines the array of data [mipmap][face] to use to create each face
  56537. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56538. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56539. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56540. * @returns a promsie that resolves when the operation is complete
  56541. */
  56542. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56543. /**
  56544. * Clones the raw cube texture.
  56545. * @return a new cube texture
  56546. */
  56547. clone(): CubeTexture;
  56548. /** @hidden */
  56549. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56550. }
  56551. }
  56552. declare module BABYLON {
  56553. /**
  56554. * Class used to store 3D textures containing user data
  56555. */
  56556. export class RawTexture3D extends Texture {
  56557. /** Gets or sets the texture format to use */
  56558. format: number;
  56559. private _engine;
  56560. /**
  56561. * Create a new RawTexture3D
  56562. * @param data defines the data of the texture
  56563. * @param width defines the width of the texture
  56564. * @param height defines the height of the texture
  56565. * @param depth defines the depth of the texture
  56566. * @param format defines the texture format to use
  56567. * @param scene defines the hosting scene
  56568. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56569. * @param invertY defines if texture must be stored with Y axis inverted
  56570. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56571. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56572. */
  56573. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56574. /** Gets or sets the texture format to use */
  56575. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56576. /**
  56577. * Update the texture with new data
  56578. * @param data defines the data to store in the texture
  56579. */
  56580. update(data: ArrayBufferView): void;
  56581. }
  56582. }
  56583. declare module BABYLON {
  56584. /**
  56585. * Class used to store 2D array textures containing user data
  56586. */
  56587. export class RawTexture2DArray extends Texture {
  56588. /** Gets or sets the texture format to use */
  56589. format: number;
  56590. private _engine;
  56591. /**
  56592. * Create a new RawTexture2DArray
  56593. * @param data defines the data of the texture
  56594. * @param width defines the width of the texture
  56595. * @param height defines the height of the texture
  56596. * @param depth defines the number of layers of the texture
  56597. * @param format defines the texture format to use
  56598. * @param scene defines the hosting scene
  56599. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56600. * @param invertY defines if texture must be stored with Y axis inverted
  56601. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56602. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56603. */
  56604. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56605. /** Gets or sets the texture format to use */
  56606. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56607. /**
  56608. * Update the texture with new data
  56609. * @param data defines the data to store in the texture
  56610. */
  56611. update(data: ArrayBufferView): void;
  56612. }
  56613. }
  56614. declare module BABYLON {
  56615. /**
  56616. * Creates a refraction texture used by refraction channel of the standard material.
  56617. * It is like a mirror but to see through a material.
  56618. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56619. */
  56620. export class RefractionTexture extends RenderTargetTexture {
  56621. /**
  56622. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56623. * 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.
  56624. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56625. */
  56626. refractionPlane: Plane;
  56627. /**
  56628. * Define how deep under the surface we should see.
  56629. */
  56630. depth: number;
  56631. /**
  56632. * Creates a refraction texture used by refraction channel of the standard material.
  56633. * It is like a mirror but to see through a material.
  56634. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56635. * @param name Define the texture name
  56636. * @param size Define the size of the underlying texture
  56637. * @param scene Define the scene the refraction belongs to
  56638. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56639. */
  56640. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56641. /**
  56642. * Clone the refraction texture.
  56643. * @returns the cloned texture
  56644. */
  56645. clone(): RefractionTexture;
  56646. /**
  56647. * Serialize the texture to a JSON representation you could use in Parse later on
  56648. * @returns the serialized JSON representation
  56649. */
  56650. serialize(): any;
  56651. }
  56652. }
  56653. declare module BABYLON {
  56654. /**
  56655. * Defines the options related to the creation of an HtmlElementTexture
  56656. */
  56657. export interface IHtmlElementTextureOptions {
  56658. /**
  56659. * Defines wether mip maps should be created or not.
  56660. */
  56661. generateMipMaps?: boolean;
  56662. /**
  56663. * Defines the sampling mode of the texture.
  56664. */
  56665. samplingMode?: number;
  56666. /**
  56667. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56668. */
  56669. engine: Nullable<ThinEngine>;
  56670. /**
  56671. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56672. */
  56673. scene: Nullable<Scene>;
  56674. }
  56675. /**
  56676. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56677. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56678. * is automatically managed.
  56679. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56680. * in your application.
  56681. *
  56682. * As the update is not automatic, you need to call them manually.
  56683. */
  56684. export class HtmlElementTexture extends BaseTexture {
  56685. /**
  56686. * The texture URL.
  56687. */
  56688. element: HTMLVideoElement | HTMLCanvasElement;
  56689. private static readonly DefaultOptions;
  56690. private _textureMatrix;
  56691. private _engine;
  56692. private _isVideo;
  56693. private _generateMipMaps;
  56694. private _samplingMode;
  56695. /**
  56696. * Instantiates a HtmlElementTexture from the following parameters.
  56697. *
  56698. * @param name Defines the name of the texture
  56699. * @param element Defines the video or canvas the texture is filled with
  56700. * @param options Defines the other none mandatory texture creation options
  56701. */
  56702. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56703. private _createInternalTexture;
  56704. /**
  56705. * Returns the texture matrix used in most of the material.
  56706. */
  56707. getTextureMatrix(): Matrix;
  56708. /**
  56709. * Updates the content of the texture.
  56710. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56711. */
  56712. update(invertY?: Nullable<boolean>): void;
  56713. }
  56714. }
  56715. declare module BABYLON {
  56716. /**
  56717. * Defines the basic options interface of a TexturePacker Frame
  56718. */
  56719. export interface ITexturePackerFrame {
  56720. /**
  56721. * The frame ID
  56722. */
  56723. id: number;
  56724. /**
  56725. * The frames Scale
  56726. */
  56727. scale: Vector2;
  56728. /**
  56729. * The Frames offset
  56730. */
  56731. offset: Vector2;
  56732. }
  56733. /**
  56734. * This is a support class for frame Data on texture packer sets.
  56735. */
  56736. export class TexturePackerFrame implements ITexturePackerFrame {
  56737. /**
  56738. * The frame ID
  56739. */
  56740. id: number;
  56741. /**
  56742. * The frames Scale
  56743. */
  56744. scale: Vector2;
  56745. /**
  56746. * The Frames offset
  56747. */
  56748. offset: Vector2;
  56749. /**
  56750. * Initializes a texture package frame.
  56751. * @param id The numerical frame identifier
  56752. * @param scale Scalar Vector2 for UV frame
  56753. * @param offset Vector2 for the frame position in UV units.
  56754. * @returns TexturePackerFrame
  56755. */
  56756. constructor(id: number, scale: Vector2, offset: Vector2);
  56757. }
  56758. }
  56759. declare module BABYLON {
  56760. /**
  56761. * Defines the basic options interface of a TexturePacker
  56762. */
  56763. export interface ITexturePackerOptions {
  56764. /**
  56765. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56766. */
  56767. map?: string[];
  56768. /**
  56769. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56770. */
  56771. uvsIn?: string;
  56772. /**
  56773. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56774. */
  56775. uvsOut?: string;
  56776. /**
  56777. * number representing the layout style. Defaults to LAYOUT_STRIP
  56778. */
  56779. layout?: number;
  56780. /**
  56781. * number of columns if using custom column count layout(2). This defaults to 4.
  56782. */
  56783. colnum?: number;
  56784. /**
  56785. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56786. */
  56787. updateInputMeshes?: boolean;
  56788. /**
  56789. * boolean flag to dispose all the source textures. Defaults to true.
  56790. */
  56791. disposeSources?: boolean;
  56792. /**
  56793. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56794. */
  56795. fillBlanks?: boolean;
  56796. /**
  56797. * string value representing the context fill style color. Defaults to 'black'.
  56798. */
  56799. customFillColor?: string;
  56800. /**
  56801. * Width and Height Value of each Frame in the TexturePacker Sets
  56802. */
  56803. frameSize?: number;
  56804. /**
  56805. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56806. */
  56807. paddingRatio?: number;
  56808. /**
  56809. * Number that declares the fill method for the padding gutter.
  56810. */
  56811. paddingMode?: number;
  56812. /**
  56813. * If in SUBUV_COLOR padding mode what color to use.
  56814. */
  56815. paddingColor?: Color3 | Color4;
  56816. }
  56817. /**
  56818. * Defines the basic interface of a TexturePacker JSON File
  56819. */
  56820. export interface ITexturePackerJSON {
  56821. /**
  56822. * The frame ID
  56823. */
  56824. name: string;
  56825. /**
  56826. * The base64 channel data
  56827. */
  56828. sets: any;
  56829. /**
  56830. * The options of the Packer
  56831. */
  56832. options: ITexturePackerOptions;
  56833. /**
  56834. * The frame data of the Packer
  56835. */
  56836. frames: Array<number>;
  56837. }
  56838. /**
  56839. * This is a support class that generates a series of packed texture sets.
  56840. * @see https://doc.babylonjs.com/babylon101/materials
  56841. */
  56842. export class TexturePacker {
  56843. /** Packer Layout Constant 0 */
  56844. static readonly LAYOUT_STRIP: number;
  56845. /** Packer Layout Constant 1 */
  56846. static readonly LAYOUT_POWER2: number;
  56847. /** Packer Layout Constant 2 */
  56848. static readonly LAYOUT_COLNUM: number;
  56849. /** Packer Layout Constant 0 */
  56850. static readonly SUBUV_WRAP: number;
  56851. /** Packer Layout Constant 1 */
  56852. static readonly SUBUV_EXTEND: number;
  56853. /** Packer Layout Constant 2 */
  56854. static readonly SUBUV_COLOR: number;
  56855. /** The Name of the Texture Package */
  56856. name: string;
  56857. /** The scene scope of the TexturePacker */
  56858. scene: Scene;
  56859. /** The Meshes to target */
  56860. meshes: AbstractMesh[];
  56861. /** Arguments passed with the Constructor */
  56862. options: ITexturePackerOptions;
  56863. /** The promise that is started upon initialization */
  56864. promise: Nullable<Promise<TexturePacker | string>>;
  56865. /** The Container object for the channel sets that are generated */
  56866. sets: object;
  56867. /** The Container array for the frames that are generated */
  56868. frames: TexturePackerFrame[];
  56869. /** The expected number of textures the system is parsing. */
  56870. private _expecting;
  56871. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56872. private _paddingValue;
  56873. /**
  56874. * Initializes a texture package series from an array of meshes or a single mesh.
  56875. * @param name The name of the package
  56876. * @param meshes The target meshes to compose the package from
  56877. * @param options The arguments that texture packer should follow while building.
  56878. * @param scene The scene which the textures are scoped to.
  56879. * @returns TexturePacker
  56880. */
  56881. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56882. /**
  56883. * Starts the package process
  56884. * @param resolve The promises resolution function
  56885. * @returns TexturePacker
  56886. */
  56887. private _createFrames;
  56888. /**
  56889. * Calculates the Size of the Channel Sets
  56890. * @returns Vector2
  56891. */
  56892. private _calculateSize;
  56893. /**
  56894. * Calculates the UV data for the frames.
  56895. * @param baseSize the base frameSize
  56896. * @param padding the base frame padding
  56897. * @param dtSize size of the Dynamic Texture for that channel
  56898. * @param dtUnits is 1/dtSize
  56899. * @param update flag to update the input meshes
  56900. */
  56901. private _calculateMeshUVFrames;
  56902. /**
  56903. * Calculates the frames Offset.
  56904. * @param index of the frame
  56905. * @returns Vector2
  56906. */
  56907. private _getFrameOffset;
  56908. /**
  56909. * Updates a Mesh to the frame data
  56910. * @param mesh that is the target
  56911. * @param frameID or the frame index
  56912. */
  56913. private _updateMeshUV;
  56914. /**
  56915. * Updates a Meshes materials to use the texture packer channels
  56916. * @param m is the mesh to target
  56917. * @param force all channels on the packer to be set.
  56918. */
  56919. private _updateTextureReferences;
  56920. /**
  56921. * Public method to set a Mesh to a frame
  56922. * @param m that is the target
  56923. * @param frameID or the frame index
  56924. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56925. */
  56926. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56927. /**
  56928. * Starts the async promise to compile the texture packer.
  56929. * @returns Promise<void>
  56930. */
  56931. processAsync(): Promise<void>;
  56932. /**
  56933. * Disposes all textures associated with this packer
  56934. */
  56935. dispose(): void;
  56936. /**
  56937. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56938. * @param imageType is the image type to use.
  56939. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56940. */
  56941. download(imageType?: string, quality?: number): void;
  56942. /**
  56943. * Public method to load a texturePacker JSON file.
  56944. * @param data of the JSON file in string format.
  56945. */
  56946. updateFromJSON(data: string): void;
  56947. }
  56948. }
  56949. declare module BABYLON {
  56950. /**
  56951. * Enum used to define the target of a block
  56952. */
  56953. export enum NodeMaterialBlockTargets {
  56954. /** Vertex shader */
  56955. Vertex = 1,
  56956. /** Fragment shader */
  56957. Fragment = 2,
  56958. /** Neutral */
  56959. Neutral = 4,
  56960. /** Vertex and Fragment */
  56961. VertexAndFragment = 3
  56962. }
  56963. }
  56964. declare module BABYLON {
  56965. /**
  56966. * Defines the kind of connection point for node based material
  56967. */
  56968. export enum NodeMaterialBlockConnectionPointTypes {
  56969. /** Float */
  56970. Float = 1,
  56971. /** Int */
  56972. Int = 2,
  56973. /** Vector2 */
  56974. Vector2 = 4,
  56975. /** Vector3 */
  56976. Vector3 = 8,
  56977. /** Vector4 */
  56978. Vector4 = 16,
  56979. /** Color3 */
  56980. Color3 = 32,
  56981. /** Color4 */
  56982. Color4 = 64,
  56983. /** Matrix */
  56984. Matrix = 128,
  56985. /** Detect type based on connection */
  56986. AutoDetect = 1024,
  56987. /** Output type that will be defined by input type */
  56988. BasedOnInput = 2048
  56989. }
  56990. }
  56991. declare module BABYLON {
  56992. /**
  56993. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56994. */
  56995. export enum NodeMaterialBlockConnectionPointMode {
  56996. /** Value is an uniform */
  56997. Uniform = 0,
  56998. /** Value is a mesh attribute */
  56999. Attribute = 1,
  57000. /** Value is a varying between vertex and fragment shaders */
  57001. Varying = 2,
  57002. /** Mode is undefined */
  57003. Undefined = 3
  57004. }
  57005. }
  57006. declare module BABYLON {
  57007. /**
  57008. * Enum used to define system values e.g. values automatically provided by the system
  57009. */
  57010. export enum NodeMaterialSystemValues {
  57011. /** World */
  57012. World = 1,
  57013. /** View */
  57014. View = 2,
  57015. /** Projection */
  57016. Projection = 3,
  57017. /** ViewProjection */
  57018. ViewProjection = 4,
  57019. /** WorldView */
  57020. WorldView = 5,
  57021. /** WorldViewProjection */
  57022. WorldViewProjection = 6,
  57023. /** CameraPosition */
  57024. CameraPosition = 7,
  57025. /** Fog Color */
  57026. FogColor = 8,
  57027. /** Delta time */
  57028. DeltaTime = 9
  57029. }
  57030. }
  57031. declare module BABYLON {
  57032. /**
  57033. * Root class for all node material optimizers
  57034. */
  57035. export class NodeMaterialOptimizer {
  57036. /**
  57037. * Function used to optimize a NodeMaterial graph
  57038. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57039. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57040. */
  57041. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57042. }
  57043. }
  57044. declare module BABYLON {
  57045. /**
  57046. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57047. */
  57048. export class TransformBlock extends NodeMaterialBlock {
  57049. /**
  57050. * Defines the value to use to complement W value to transform it to a Vector4
  57051. */
  57052. complementW: number;
  57053. /**
  57054. * Defines the value to use to complement z value to transform it to a Vector4
  57055. */
  57056. complementZ: number;
  57057. /**
  57058. * Creates a new TransformBlock
  57059. * @param name defines the block name
  57060. */
  57061. constructor(name: string);
  57062. /**
  57063. * Gets the current class name
  57064. * @returns the class name
  57065. */
  57066. getClassName(): string;
  57067. /**
  57068. * Gets the vector input
  57069. */
  57070. get vector(): NodeMaterialConnectionPoint;
  57071. /**
  57072. * Gets the output component
  57073. */
  57074. get output(): NodeMaterialConnectionPoint;
  57075. /**
  57076. * Gets the xyz output component
  57077. */
  57078. get xyz(): NodeMaterialConnectionPoint;
  57079. /**
  57080. * Gets the matrix transform input
  57081. */
  57082. get transform(): NodeMaterialConnectionPoint;
  57083. protected _buildBlock(state: NodeMaterialBuildState): this;
  57084. serialize(): any;
  57085. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57086. protected _dumpPropertiesCode(): string;
  57087. }
  57088. }
  57089. declare module BABYLON {
  57090. /**
  57091. * Block used to output the vertex position
  57092. */
  57093. export class VertexOutputBlock extends NodeMaterialBlock {
  57094. /**
  57095. * Creates a new VertexOutputBlock
  57096. * @param name defines the block name
  57097. */
  57098. constructor(name: string);
  57099. /**
  57100. * Gets the current class name
  57101. * @returns the class name
  57102. */
  57103. getClassName(): string;
  57104. /**
  57105. * Gets the vector input component
  57106. */
  57107. get vector(): NodeMaterialConnectionPoint;
  57108. protected _buildBlock(state: NodeMaterialBuildState): this;
  57109. }
  57110. }
  57111. declare module BABYLON {
  57112. /**
  57113. * Block used to output the final color
  57114. */
  57115. export class FragmentOutputBlock extends NodeMaterialBlock {
  57116. /**
  57117. * Create a new FragmentOutputBlock
  57118. * @param name defines the block name
  57119. */
  57120. constructor(name: string);
  57121. /**
  57122. * Gets the current class name
  57123. * @returns the class name
  57124. */
  57125. getClassName(): string;
  57126. /**
  57127. * Gets the rgba input component
  57128. */
  57129. get rgba(): NodeMaterialConnectionPoint;
  57130. /**
  57131. * Gets the rgb input component
  57132. */
  57133. get rgb(): NodeMaterialConnectionPoint;
  57134. /**
  57135. * Gets the a input component
  57136. */
  57137. get a(): NodeMaterialConnectionPoint;
  57138. protected _buildBlock(state: NodeMaterialBuildState): this;
  57139. }
  57140. }
  57141. declare module BABYLON {
  57142. /**
  57143. * Block used to read a reflection texture from a sampler
  57144. */
  57145. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57146. private _define3DName;
  57147. private _defineCubicName;
  57148. private _defineExplicitName;
  57149. private _defineProjectionName;
  57150. private _defineLocalCubicName;
  57151. private _defineSphericalName;
  57152. private _definePlanarName;
  57153. private _defineEquirectangularName;
  57154. private _defineMirroredEquirectangularFixedName;
  57155. private _defineEquirectangularFixedName;
  57156. private _defineSkyboxName;
  57157. private _cubeSamplerName;
  57158. private _2DSamplerName;
  57159. private _positionUVWName;
  57160. private _directionWName;
  57161. private _reflectionCoordsName;
  57162. private _reflection2DCoordsName;
  57163. private _reflectionColorName;
  57164. private _reflectionMatrixName;
  57165. /**
  57166. * Gets or sets the texture associated with the node
  57167. */
  57168. texture: Nullable<BaseTexture>;
  57169. /**
  57170. * Create a new TextureBlock
  57171. * @param name defines the block name
  57172. */
  57173. constructor(name: string);
  57174. /**
  57175. * Gets the current class name
  57176. * @returns the class name
  57177. */
  57178. getClassName(): string;
  57179. /**
  57180. * Gets the world position input component
  57181. */
  57182. get position(): NodeMaterialConnectionPoint;
  57183. /**
  57184. * Gets the world position input component
  57185. */
  57186. get worldPosition(): NodeMaterialConnectionPoint;
  57187. /**
  57188. * Gets the world normal input component
  57189. */
  57190. get worldNormal(): NodeMaterialConnectionPoint;
  57191. /**
  57192. * Gets the world input component
  57193. */
  57194. get world(): NodeMaterialConnectionPoint;
  57195. /**
  57196. * Gets the camera (or eye) position component
  57197. */
  57198. get cameraPosition(): NodeMaterialConnectionPoint;
  57199. /**
  57200. * Gets the view input component
  57201. */
  57202. get view(): NodeMaterialConnectionPoint;
  57203. /**
  57204. * Gets the rgb output component
  57205. */
  57206. get rgb(): NodeMaterialConnectionPoint;
  57207. /**
  57208. * Gets the r output component
  57209. */
  57210. get r(): NodeMaterialConnectionPoint;
  57211. /**
  57212. * Gets the g output component
  57213. */
  57214. get g(): NodeMaterialConnectionPoint;
  57215. /**
  57216. * Gets the b output component
  57217. */
  57218. get b(): NodeMaterialConnectionPoint;
  57219. autoConfigure(material: NodeMaterial): void;
  57220. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57221. isReady(): boolean;
  57222. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57223. private _injectVertexCode;
  57224. private _writeOutput;
  57225. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57226. protected _dumpPropertiesCode(): string;
  57227. serialize(): any;
  57228. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57229. }
  57230. }
  57231. declare module BABYLON {
  57232. /**
  57233. * Interface used to configure the node material editor
  57234. */
  57235. export interface INodeMaterialEditorOptions {
  57236. /** Define the URl to load node editor script */
  57237. editorURL?: string;
  57238. }
  57239. /** @hidden */
  57240. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57241. NORMAL: boolean;
  57242. TANGENT: boolean;
  57243. UV1: boolean;
  57244. /** BONES */
  57245. NUM_BONE_INFLUENCERS: number;
  57246. BonesPerMesh: number;
  57247. BONETEXTURE: boolean;
  57248. /** MORPH TARGETS */
  57249. MORPHTARGETS: boolean;
  57250. MORPHTARGETS_NORMAL: boolean;
  57251. MORPHTARGETS_TANGENT: boolean;
  57252. MORPHTARGETS_UV: boolean;
  57253. NUM_MORPH_INFLUENCERS: number;
  57254. /** IMAGE PROCESSING */
  57255. IMAGEPROCESSING: boolean;
  57256. VIGNETTE: boolean;
  57257. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57258. VIGNETTEBLENDMODEOPAQUE: boolean;
  57259. TONEMAPPING: boolean;
  57260. TONEMAPPING_ACES: boolean;
  57261. CONTRAST: boolean;
  57262. EXPOSURE: boolean;
  57263. COLORCURVES: boolean;
  57264. COLORGRADING: boolean;
  57265. COLORGRADING3D: boolean;
  57266. SAMPLER3DGREENDEPTH: boolean;
  57267. SAMPLER3DBGRMAP: boolean;
  57268. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57269. /** MISC. */
  57270. BUMPDIRECTUV: number;
  57271. constructor();
  57272. setValue(name: string, value: boolean): void;
  57273. }
  57274. /**
  57275. * Class used to configure NodeMaterial
  57276. */
  57277. export interface INodeMaterialOptions {
  57278. /**
  57279. * Defines if blocks should emit comments
  57280. */
  57281. emitComments: boolean;
  57282. }
  57283. /**
  57284. * Class used to create a node based material built by assembling shader blocks
  57285. */
  57286. export class NodeMaterial extends PushMaterial {
  57287. private static _BuildIdGenerator;
  57288. private _options;
  57289. private _vertexCompilationState;
  57290. private _fragmentCompilationState;
  57291. private _sharedData;
  57292. private _buildId;
  57293. private _buildWasSuccessful;
  57294. private _cachedWorldViewMatrix;
  57295. private _cachedWorldViewProjectionMatrix;
  57296. private _optimizers;
  57297. private _animationFrame;
  57298. /** Define the Url to load node editor script */
  57299. static EditorURL: string;
  57300. /** Define the Url to load snippets */
  57301. static SnippetUrl: string;
  57302. private BJSNODEMATERIALEDITOR;
  57303. /** Get the inspector from bundle or global */
  57304. private _getGlobalNodeMaterialEditor;
  57305. /**
  57306. * Gets or sets data used by visual editor
  57307. * @see https://nme.babylonjs.com
  57308. */
  57309. editorData: any;
  57310. /**
  57311. * 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)
  57312. */
  57313. ignoreAlpha: boolean;
  57314. /**
  57315. * Defines the maximum number of lights that can be used in the material
  57316. */
  57317. maxSimultaneousLights: number;
  57318. /**
  57319. * Observable raised when the material is built
  57320. */
  57321. onBuildObservable: Observable<NodeMaterial>;
  57322. /**
  57323. * Gets or sets the root nodes of the material vertex shader
  57324. */
  57325. _vertexOutputNodes: NodeMaterialBlock[];
  57326. /**
  57327. * Gets or sets the root nodes of the material fragment (pixel) shader
  57328. */
  57329. _fragmentOutputNodes: NodeMaterialBlock[];
  57330. /** Gets or sets options to control the node material overall behavior */
  57331. get options(): INodeMaterialOptions;
  57332. set options(options: INodeMaterialOptions);
  57333. /**
  57334. * Default configuration related to image processing available in the standard Material.
  57335. */
  57336. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57337. /**
  57338. * Gets the image processing configuration used either in this material.
  57339. */
  57340. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57341. /**
  57342. * Sets the Default image processing configuration used either in the this material.
  57343. *
  57344. * If sets to null, the scene one is in use.
  57345. */
  57346. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57347. /**
  57348. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57349. */
  57350. attachedBlocks: NodeMaterialBlock[];
  57351. /**
  57352. * Create a new node based material
  57353. * @param name defines the material name
  57354. * @param scene defines the hosting scene
  57355. * @param options defines creation option
  57356. */
  57357. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57358. /**
  57359. * Gets the current class name of the material e.g. "NodeMaterial"
  57360. * @returns the class name
  57361. */
  57362. getClassName(): string;
  57363. /**
  57364. * Keep track of the image processing observer to allow dispose and replace.
  57365. */
  57366. private _imageProcessingObserver;
  57367. /**
  57368. * Attaches a new image processing configuration to the Standard Material.
  57369. * @param configuration
  57370. */
  57371. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57372. /**
  57373. * Get a block by its name
  57374. * @param name defines the name of the block to retrieve
  57375. * @returns the required block or null if not found
  57376. */
  57377. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57378. /**
  57379. * Get a block by its name
  57380. * @param predicate defines the predicate used to find the good candidate
  57381. * @returns the required block or null if not found
  57382. */
  57383. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57384. /**
  57385. * Get an input block by its name
  57386. * @param predicate defines the predicate used to find the good candidate
  57387. * @returns the required input block or null if not found
  57388. */
  57389. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57390. /**
  57391. * Gets the list of input blocks attached to this material
  57392. * @returns an array of InputBlocks
  57393. */
  57394. getInputBlocks(): InputBlock[];
  57395. /**
  57396. * Adds a new optimizer to the list of optimizers
  57397. * @param optimizer defines the optimizers to add
  57398. * @returns the current material
  57399. */
  57400. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57401. /**
  57402. * Remove an optimizer from the list of optimizers
  57403. * @param optimizer defines the optimizers to remove
  57404. * @returns the current material
  57405. */
  57406. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57407. /**
  57408. * Add a new block to the list of output nodes
  57409. * @param node defines the node to add
  57410. * @returns the current material
  57411. */
  57412. addOutputNode(node: NodeMaterialBlock): this;
  57413. /**
  57414. * Remove a block from the list of root nodes
  57415. * @param node defines the node to remove
  57416. * @returns the current material
  57417. */
  57418. removeOutputNode(node: NodeMaterialBlock): this;
  57419. private _addVertexOutputNode;
  57420. private _removeVertexOutputNode;
  57421. private _addFragmentOutputNode;
  57422. private _removeFragmentOutputNode;
  57423. /**
  57424. * Specifies if the material will require alpha blending
  57425. * @returns a boolean specifying if alpha blending is needed
  57426. */
  57427. needAlphaBlending(): boolean;
  57428. /**
  57429. * Specifies if this material should be rendered in alpha test mode
  57430. * @returns a boolean specifying if an alpha test is needed.
  57431. */
  57432. needAlphaTesting(): boolean;
  57433. private _initializeBlock;
  57434. private _resetDualBlocks;
  57435. /**
  57436. * Remove a block from the current node material
  57437. * @param block defines the block to remove
  57438. */
  57439. removeBlock(block: NodeMaterialBlock): void;
  57440. /**
  57441. * Build the material and generates the inner effect
  57442. * @param verbose defines if the build should log activity
  57443. */
  57444. build(verbose?: boolean): void;
  57445. /**
  57446. * Runs an otpimization phase to try to improve the shader code
  57447. */
  57448. optimize(): void;
  57449. private _prepareDefinesForAttributes;
  57450. /**
  57451. * Get if the submesh is ready to be used and all its information available.
  57452. * Child classes can use it to update shaders
  57453. * @param mesh defines the mesh to check
  57454. * @param subMesh defines which submesh to check
  57455. * @param useInstances specifies that instances should be used
  57456. * @returns a boolean indicating that the submesh is ready or not
  57457. */
  57458. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57459. /**
  57460. * Get a string representing the shaders built by the current node graph
  57461. */
  57462. get compiledShaders(): string;
  57463. /**
  57464. * Binds the world matrix to the material
  57465. * @param world defines the world transformation matrix
  57466. */
  57467. bindOnlyWorldMatrix(world: Matrix): void;
  57468. /**
  57469. * Binds the submesh to this material by preparing the effect and shader to draw
  57470. * @param world defines the world transformation matrix
  57471. * @param mesh defines the mesh containing the submesh
  57472. * @param subMesh defines the submesh to bind the material to
  57473. */
  57474. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57475. /**
  57476. * Gets the active textures from the material
  57477. * @returns an array of textures
  57478. */
  57479. getActiveTextures(): BaseTexture[];
  57480. /**
  57481. * Gets the list of texture blocks
  57482. * @returns an array of texture blocks
  57483. */
  57484. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57485. /**
  57486. * Specifies if the material uses a texture
  57487. * @param texture defines the texture to check against the material
  57488. * @returns a boolean specifying if the material uses the texture
  57489. */
  57490. hasTexture(texture: BaseTexture): boolean;
  57491. /**
  57492. * Disposes the material
  57493. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57494. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57495. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57496. */
  57497. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57498. /** Creates the node editor window. */
  57499. private _createNodeEditor;
  57500. /**
  57501. * Launch the node material editor
  57502. * @param config Define the configuration of the editor
  57503. * @return a promise fulfilled when the node editor is visible
  57504. */
  57505. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57506. /**
  57507. * Clear the current material
  57508. */
  57509. clear(): void;
  57510. /**
  57511. * Clear the current material and set it to a default state
  57512. */
  57513. setToDefault(): void;
  57514. /**
  57515. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57516. * @param url defines the url to load from
  57517. * @returns a promise that will fullfil when the material is fully loaded
  57518. */
  57519. loadAsync(url: string): Promise<void>;
  57520. private _gatherBlocks;
  57521. /**
  57522. * Generate a string containing the code declaration required to create an equivalent of this material
  57523. * @returns a string
  57524. */
  57525. generateCode(): string;
  57526. /**
  57527. * Serializes this material in a JSON representation
  57528. * @returns the serialized material object
  57529. */
  57530. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57531. private _restoreConnections;
  57532. /**
  57533. * Clear the current graph and load a new one from a serialization object
  57534. * @param source defines the JSON representation of the material
  57535. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57536. */
  57537. loadFromSerialization(source: any, rootUrl?: string): void;
  57538. /**
  57539. * Makes a duplicate of the current material.
  57540. * @param name - name to use for the new material.
  57541. */
  57542. clone(name: string): NodeMaterial;
  57543. /**
  57544. * Creates a node material from parsed material data
  57545. * @param source defines the JSON representation of the material
  57546. * @param scene defines the hosting scene
  57547. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57548. * @returns a new node material
  57549. */
  57550. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57551. /**
  57552. * Creates a node material from a snippet saved in a remote file
  57553. * @param name defines the name of the material to create
  57554. * @param url defines the url to load from
  57555. * @param scene defines the hosting scene
  57556. * @returns a promise that will resolve to the new node material
  57557. */
  57558. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57559. /**
  57560. * Creates a node material from a snippet saved by the node material editor
  57561. * @param snippetId defines the snippet to load
  57562. * @param scene defines the hosting scene
  57563. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57564. * @returns a promise that will resolve to the new node material
  57565. */
  57566. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57567. /**
  57568. * Creates a new node material set to default basic configuration
  57569. * @param name defines the name of the material
  57570. * @param scene defines the hosting scene
  57571. * @returns a new NodeMaterial
  57572. */
  57573. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57574. }
  57575. }
  57576. declare module BABYLON {
  57577. /**
  57578. * Block used to read a texture from a sampler
  57579. */
  57580. export class TextureBlock extends NodeMaterialBlock {
  57581. private _defineName;
  57582. private _linearDefineName;
  57583. private _tempTextureRead;
  57584. private _samplerName;
  57585. private _transformedUVName;
  57586. private _textureTransformName;
  57587. private _textureInfoName;
  57588. private _mainUVName;
  57589. private _mainUVDefineName;
  57590. /**
  57591. * Gets or sets the texture associated with the node
  57592. */
  57593. texture: Nullable<Texture>;
  57594. /**
  57595. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57596. */
  57597. convertToGammaSpace: boolean;
  57598. /**
  57599. * Create a new TextureBlock
  57600. * @param name defines the block name
  57601. */
  57602. constructor(name: string);
  57603. /**
  57604. * Gets the current class name
  57605. * @returns the class name
  57606. */
  57607. getClassName(): string;
  57608. /**
  57609. * Gets the uv input component
  57610. */
  57611. get uv(): NodeMaterialConnectionPoint;
  57612. /**
  57613. * Gets the rgba output component
  57614. */
  57615. get rgba(): NodeMaterialConnectionPoint;
  57616. /**
  57617. * Gets the rgb output component
  57618. */
  57619. get rgb(): NodeMaterialConnectionPoint;
  57620. /**
  57621. * Gets the r output component
  57622. */
  57623. get r(): NodeMaterialConnectionPoint;
  57624. /**
  57625. * Gets the g output component
  57626. */
  57627. get g(): NodeMaterialConnectionPoint;
  57628. /**
  57629. * Gets the b output component
  57630. */
  57631. get b(): NodeMaterialConnectionPoint;
  57632. /**
  57633. * Gets the a output component
  57634. */
  57635. get a(): NodeMaterialConnectionPoint;
  57636. get target(): NodeMaterialBlockTargets;
  57637. autoConfigure(material: NodeMaterial): void;
  57638. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57639. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57640. isReady(): boolean;
  57641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57642. private get _isMixed();
  57643. private _injectVertexCode;
  57644. private _writeTextureRead;
  57645. private _writeOutput;
  57646. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57647. protected _dumpPropertiesCode(): string;
  57648. serialize(): any;
  57649. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57650. }
  57651. }
  57652. declare module BABYLON {
  57653. /**
  57654. * Class used to store shared data between 2 NodeMaterialBuildState
  57655. */
  57656. export class NodeMaterialBuildStateSharedData {
  57657. /**
  57658. * Gets the list of emitted varyings
  57659. */
  57660. temps: string[];
  57661. /**
  57662. * Gets the list of emitted varyings
  57663. */
  57664. varyings: string[];
  57665. /**
  57666. * Gets the varying declaration string
  57667. */
  57668. varyingDeclaration: string;
  57669. /**
  57670. * Input blocks
  57671. */
  57672. inputBlocks: InputBlock[];
  57673. /**
  57674. * Input blocks
  57675. */
  57676. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57677. /**
  57678. * Bindable blocks (Blocks that need to set data to the effect)
  57679. */
  57680. bindableBlocks: NodeMaterialBlock[];
  57681. /**
  57682. * List of blocks that can provide a compilation fallback
  57683. */
  57684. blocksWithFallbacks: NodeMaterialBlock[];
  57685. /**
  57686. * List of blocks that can provide a define update
  57687. */
  57688. blocksWithDefines: NodeMaterialBlock[];
  57689. /**
  57690. * List of blocks that can provide a repeatable content
  57691. */
  57692. repeatableContentBlocks: NodeMaterialBlock[];
  57693. /**
  57694. * List of blocks that can provide a dynamic list of uniforms
  57695. */
  57696. dynamicUniformBlocks: NodeMaterialBlock[];
  57697. /**
  57698. * List of blocks that can block the isReady function for the material
  57699. */
  57700. blockingBlocks: NodeMaterialBlock[];
  57701. /**
  57702. * Gets the list of animated inputs
  57703. */
  57704. animatedInputs: InputBlock[];
  57705. /**
  57706. * Build Id used to avoid multiple recompilations
  57707. */
  57708. buildId: number;
  57709. /** List of emitted variables */
  57710. variableNames: {
  57711. [key: string]: number;
  57712. };
  57713. /** List of emitted defines */
  57714. defineNames: {
  57715. [key: string]: number;
  57716. };
  57717. /** Should emit comments? */
  57718. emitComments: boolean;
  57719. /** Emit build activity */
  57720. verbose: boolean;
  57721. /** Gets or sets the hosting scene */
  57722. scene: Scene;
  57723. /**
  57724. * Gets the compilation hints emitted at compilation time
  57725. */
  57726. hints: {
  57727. needWorldViewMatrix: boolean;
  57728. needWorldViewProjectionMatrix: boolean;
  57729. needAlphaBlending: boolean;
  57730. needAlphaTesting: boolean;
  57731. };
  57732. /**
  57733. * List of compilation checks
  57734. */
  57735. checks: {
  57736. emitVertex: boolean;
  57737. emitFragment: boolean;
  57738. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57739. };
  57740. /** Creates a new shared data */
  57741. constructor();
  57742. /**
  57743. * Emits console errors and exceptions if there is a failing check
  57744. */
  57745. emitErrors(): void;
  57746. }
  57747. }
  57748. declare module BABYLON {
  57749. /**
  57750. * Class used to store node based material build state
  57751. */
  57752. export class NodeMaterialBuildState {
  57753. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57754. supportUniformBuffers: boolean;
  57755. /**
  57756. * Gets the list of emitted attributes
  57757. */
  57758. attributes: string[];
  57759. /**
  57760. * Gets the list of emitted uniforms
  57761. */
  57762. uniforms: string[];
  57763. /**
  57764. * Gets the list of emitted constants
  57765. */
  57766. constants: string[];
  57767. /**
  57768. * Gets the list of emitted samplers
  57769. */
  57770. samplers: string[];
  57771. /**
  57772. * Gets the list of emitted functions
  57773. */
  57774. functions: {
  57775. [key: string]: string;
  57776. };
  57777. /**
  57778. * Gets the list of emitted extensions
  57779. */
  57780. extensions: {
  57781. [key: string]: string;
  57782. };
  57783. /**
  57784. * Gets the target of the compilation state
  57785. */
  57786. target: NodeMaterialBlockTargets;
  57787. /**
  57788. * Gets the list of emitted counters
  57789. */
  57790. counters: {
  57791. [key: string]: number;
  57792. };
  57793. /**
  57794. * Shared data between multiple NodeMaterialBuildState instances
  57795. */
  57796. sharedData: NodeMaterialBuildStateSharedData;
  57797. /** @hidden */
  57798. _vertexState: NodeMaterialBuildState;
  57799. /** @hidden */
  57800. _attributeDeclaration: string;
  57801. /** @hidden */
  57802. _uniformDeclaration: string;
  57803. /** @hidden */
  57804. _constantDeclaration: string;
  57805. /** @hidden */
  57806. _samplerDeclaration: string;
  57807. /** @hidden */
  57808. _varyingTransfer: string;
  57809. private _repeatableContentAnchorIndex;
  57810. /** @hidden */
  57811. _builtCompilationString: string;
  57812. /**
  57813. * Gets the emitted compilation strings
  57814. */
  57815. compilationString: string;
  57816. /**
  57817. * Finalize the compilation strings
  57818. * @param state defines the current compilation state
  57819. */
  57820. finalize(state: NodeMaterialBuildState): void;
  57821. /** @hidden */
  57822. get _repeatableContentAnchor(): string;
  57823. /** @hidden */
  57824. _getFreeVariableName(prefix: string): string;
  57825. /** @hidden */
  57826. _getFreeDefineName(prefix: string): string;
  57827. /** @hidden */
  57828. _excludeVariableName(name: string): void;
  57829. /** @hidden */
  57830. _emit2DSampler(name: string): void;
  57831. /** @hidden */
  57832. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57833. /** @hidden */
  57834. _emitExtension(name: string, extension: string): void;
  57835. /** @hidden */
  57836. _emitFunction(name: string, code: string, comments: string): void;
  57837. /** @hidden */
  57838. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57839. replaceStrings?: {
  57840. search: RegExp;
  57841. replace: string;
  57842. }[];
  57843. repeatKey?: string;
  57844. }): string;
  57845. /** @hidden */
  57846. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57847. repeatKey?: string;
  57848. removeAttributes?: boolean;
  57849. removeUniforms?: boolean;
  57850. removeVaryings?: boolean;
  57851. removeIfDef?: boolean;
  57852. replaceStrings?: {
  57853. search: RegExp;
  57854. replace: string;
  57855. }[];
  57856. }, storeKey?: string): void;
  57857. /** @hidden */
  57858. _registerTempVariable(name: string): boolean;
  57859. /** @hidden */
  57860. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57861. /** @hidden */
  57862. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57863. /** @hidden */
  57864. _emitFloat(value: number): string;
  57865. }
  57866. }
  57867. declare module BABYLON {
  57868. /**
  57869. * Defines a block that can be used inside a node based material
  57870. */
  57871. export class NodeMaterialBlock {
  57872. private _buildId;
  57873. private _buildTarget;
  57874. private _target;
  57875. private _isFinalMerger;
  57876. private _isInput;
  57877. protected _isUnique: boolean;
  57878. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57879. inputsAreExclusive: boolean;
  57880. /** @hidden */
  57881. _codeVariableName: string;
  57882. /** @hidden */
  57883. _inputs: NodeMaterialConnectionPoint[];
  57884. /** @hidden */
  57885. _outputs: NodeMaterialConnectionPoint[];
  57886. /** @hidden */
  57887. _preparationId: number;
  57888. /**
  57889. * Gets or sets the name of the block
  57890. */
  57891. name: string;
  57892. /**
  57893. * Gets or sets the unique id of the node
  57894. */
  57895. uniqueId: number;
  57896. /**
  57897. * Gets or sets the comments associated with this block
  57898. */
  57899. comments: string;
  57900. /**
  57901. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57902. */
  57903. get isUnique(): boolean;
  57904. /**
  57905. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57906. */
  57907. get isFinalMerger(): boolean;
  57908. /**
  57909. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57910. */
  57911. get isInput(): boolean;
  57912. /**
  57913. * Gets or sets the build Id
  57914. */
  57915. get buildId(): number;
  57916. set buildId(value: number);
  57917. /**
  57918. * Gets or sets the target of the block
  57919. */
  57920. get target(): NodeMaterialBlockTargets;
  57921. set target(value: NodeMaterialBlockTargets);
  57922. /**
  57923. * Gets the list of input points
  57924. */
  57925. get inputs(): NodeMaterialConnectionPoint[];
  57926. /** Gets the list of output points */
  57927. get outputs(): NodeMaterialConnectionPoint[];
  57928. /**
  57929. * Find an input by its name
  57930. * @param name defines the name of the input to look for
  57931. * @returns the input or null if not found
  57932. */
  57933. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57934. /**
  57935. * Find an output by its name
  57936. * @param name defines the name of the outputto look for
  57937. * @returns the output or null if not found
  57938. */
  57939. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57940. /**
  57941. * Creates a new NodeMaterialBlock
  57942. * @param name defines the block name
  57943. * @param target defines the target of that block (Vertex by default)
  57944. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57945. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57946. */
  57947. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57948. /**
  57949. * Initialize the block and prepare the context for build
  57950. * @param state defines the state that will be used for the build
  57951. */
  57952. initialize(state: NodeMaterialBuildState): void;
  57953. /**
  57954. * Bind data to effect. Will only be called for blocks with isBindable === true
  57955. * @param effect defines the effect to bind data to
  57956. * @param nodeMaterial defines the hosting NodeMaterial
  57957. * @param mesh defines the mesh that will be rendered
  57958. */
  57959. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57960. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57961. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57962. protected _writeFloat(value: number): string;
  57963. /**
  57964. * Gets the current class name e.g. "NodeMaterialBlock"
  57965. * @returns the class name
  57966. */
  57967. getClassName(): string;
  57968. /**
  57969. * Register a new input. Must be called inside a block constructor
  57970. * @param name defines the connection point name
  57971. * @param type defines the connection point type
  57972. * @param isOptional defines a boolean indicating that this input can be omitted
  57973. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57974. * @returns the current block
  57975. */
  57976. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57977. /**
  57978. * Register a new output. Must be called inside a block constructor
  57979. * @param name defines the connection point name
  57980. * @param type defines the connection point type
  57981. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57982. * @returns the current block
  57983. */
  57984. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57985. /**
  57986. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57987. * @param forOutput defines an optional connection point to check compatibility with
  57988. * @returns the first available input or null
  57989. */
  57990. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57991. /**
  57992. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57993. * @param forBlock defines an optional block to check compatibility with
  57994. * @returns the first available input or null
  57995. */
  57996. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57997. /**
  57998. * Gets the sibling of the given output
  57999. * @param current defines the current output
  58000. * @returns the next output in the list or null
  58001. */
  58002. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58003. /**
  58004. * Connect current block with another block
  58005. * @param other defines the block to connect with
  58006. * @param options define the various options to help pick the right connections
  58007. * @returns the current block
  58008. */
  58009. connectTo(other: NodeMaterialBlock, options?: {
  58010. input?: string;
  58011. output?: string;
  58012. outputSwizzle?: string;
  58013. }): this | undefined;
  58014. protected _buildBlock(state: NodeMaterialBuildState): void;
  58015. /**
  58016. * Add uniforms, samplers and uniform buffers at compilation time
  58017. * @param state defines the state to update
  58018. * @param nodeMaterial defines the node material requesting the update
  58019. * @param defines defines the material defines to update
  58020. * @param uniformBuffers defines the list of uniform buffer names
  58021. */
  58022. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58023. /**
  58024. * Add potential fallbacks if shader compilation fails
  58025. * @param mesh defines the mesh to be rendered
  58026. * @param fallbacks defines the current prioritized list of fallbacks
  58027. */
  58028. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58029. /**
  58030. * Initialize defines for shader compilation
  58031. * @param mesh defines the mesh to be rendered
  58032. * @param nodeMaterial defines the node material requesting the update
  58033. * @param defines defines the material defines to update
  58034. * @param useInstances specifies that instances should be used
  58035. */
  58036. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58037. /**
  58038. * Update defines for shader compilation
  58039. * @param mesh defines the mesh to be rendered
  58040. * @param nodeMaterial defines the node material requesting the update
  58041. * @param defines defines the material defines to update
  58042. * @param useInstances specifies that instances should be used
  58043. */
  58044. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58045. /**
  58046. * Lets the block try to connect some inputs automatically
  58047. * @param material defines the hosting NodeMaterial
  58048. */
  58049. autoConfigure(material: NodeMaterial): void;
  58050. /**
  58051. * Function called when a block is declared as repeatable content generator
  58052. * @param vertexShaderState defines the current compilation state for the vertex shader
  58053. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58054. * @param mesh defines the mesh to be rendered
  58055. * @param defines defines the material defines to update
  58056. */
  58057. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58058. /**
  58059. * Checks if the block is ready
  58060. * @param mesh defines the mesh to be rendered
  58061. * @param nodeMaterial defines the node material requesting the update
  58062. * @param defines defines the material defines to update
  58063. * @param useInstances specifies that instances should be used
  58064. * @returns true if the block is ready
  58065. */
  58066. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58067. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58068. private _processBuild;
  58069. /**
  58070. * Compile the current node and generate the shader code
  58071. * @param state defines the current compilation state (uniforms, samplers, current string)
  58072. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58073. * @returns true if already built
  58074. */
  58075. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58076. protected _inputRename(name: string): string;
  58077. protected _outputRename(name: string): string;
  58078. protected _dumpPropertiesCode(): string;
  58079. /** @hidden */
  58080. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58081. /** @hidden */
  58082. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58083. /**
  58084. * Clone the current block to a new identical block
  58085. * @param scene defines the hosting scene
  58086. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58087. * @returns a copy of the current block
  58088. */
  58089. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58090. /**
  58091. * Serializes this block in a JSON representation
  58092. * @returns the serialized block object
  58093. */
  58094. serialize(): any;
  58095. /** @hidden */
  58096. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58097. /**
  58098. * Release resources
  58099. */
  58100. dispose(): void;
  58101. }
  58102. }
  58103. declare module BABYLON {
  58104. /**
  58105. * Enum defining the type of animations supported by InputBlock
  58106. */
  58107. export enum AnimatedInputBlockTypes {
  58108. /** No animation */
  58109. None = 0,
  58110. /** Time based animation. Will only work for floats */
  58111. Time = 1
  58112. }
  58113. }
  58114. declare module BABYLON {
  58115. /**
  58116. * Block used to expose an input value
  58117. */
  58118. export class InputBlock extends NodeMaterialBlock {
  58119. private _mode;
  58120. private _associatedVariableName;
  58121. private _storedValue;
  58122. private _valueCallback;
  58123. private _type;
  58124. private _animationType;
  58125. /** Gets or set a value used to limit the range of float values */
  58126. min: number;
  58127. /** Gets or set a value used to limit the range of float values */
  58128. max: number;
  58129. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58130. isBoolean: boolean;
  58131. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58132. matrixMode: number;
  58133. /** @hidden */
  58134. _systemValue: Nullable<NodeMaterialSystemValues>;
  58135. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58136. visibleInInspector: boolean;
  58137. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58138. isConstant: boolean;
  58139. /** Gets or sets the group to use to display this block in the Inspector */
  58140. groupInInspector: string;
  58141. /** Gets an observable raised when the value is changed */
  58142. onValueChangedObservable: Observable<InputBlock>;
  58143. /**
  58144. * Gets or sets the connection point type (default is float)
  58145. */
  58146. get type(): NodeMaterialBlockConnectionPointTypes;
  58147. /**
  58148. * Creates a new InputBlock
  58149. * @param name defines the block name
  58150. * @param target defines the target of that block (Vertex by default)
  58151. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58152. */
  58153. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58154. /**
  58155. * Gets the output component
  58156. */
  58157. get output(): NodeMaterialConnectionPoint;
  58158. /**
  58159. * Set the source of this connection point to a vertex attribute
  58160. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58161. * @returns the current connection point
  58162. */
  58163. setAsAttribute(attributeName?: string): InputBlock;
  58164. /**
  58165. * Set the source of this connection point to a system value
  58166. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58167. * @returns the current connection point
  58168. */
  58169. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58170. /**
  58171. * Gets or sets the value of that point.
  58172. * Please note that this value will be ignored if valueCallback is defined
  58173. */
  58174. get value(): any;
  58175. set value(value: any);
  58176. /**
  58177. * Gets or sets a callback used to get the value of that point.
  58178. * Please note that setting this value will force the connection point to ignore the value property
  58179. */
  58180. get valueCallback(): () => any;
  58181. set valueCallback(value: () => any);
  58182. /**
  58183. * Gets or sets the associated variable name in the shader
  58184. */
  58185. get associatedVariableName(): string;
  58186. set associatedVariableName(value: string);
  58187. /** Gets or sets the type of animation applied to the input */
  58188. get animationType(): AnimatedInputBlockTypes;
  58189. set animationType(value: AnimatedInputBlockTypes);
  58190. /**
  58191. * Gets a boolean indicating that this connection point not defined yet
  58192. */
  58193. get isUndefined(): boolean;
  58194. /**
  58195. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58196. * In this case the connection point name must be the name of the uniform to use.
  58197. * Can only be set on inputs
  58198. */
  58199. get isUniform(): boolean;
  58200. set isUniform(value: boolean);
  58201. /**
  58202. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58203. * In this case the connection point name must be the name of the attribute to use
  58204. * Can only be set on inputs
  58205. */
  58206. get isAttribute(): boolean;
  58207. set isAttribute(value: boolean);
  58208. /**
  58209. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58210. * Can only be set on exit points
  58211. */
  58212. get isVarying(): boolean;
  58213. set isVarying(value: boolean);
  58214. /**
  58215. * Gets a boolean indicating that the current connection point is a system value
  58216. */
  58217. get isSystemValue(): boolean;
  58218. /**
  58219. * Gets or sets the current well known value or null if not defined as a system value
  58220. */
  58221. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58222. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58223. /**
  58224. * Gets the current class name
  58225. * @returns the class name
  58226. */
  58227. getClassName(): string;
  58228. /**
  58229. * Animate the input if animationType !== None
  58230. * @param scene defines the rendering scene
  58231. */
  58232. animate(scene: Scene): void;
  58233. private _emitDefine;
  58234. initialize(state: NodeMaterialBuildState): void;
  58235. /**
  58236. * Set the input block to its default value (based on its type)
  58237. */
  58238. setDefaultValue(): void;
  58239. private _emitConstant;
  58240. private _emit;
  58241. /** @hidden */
  58242. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58243. /** @hidden */
  58244. _transmit(effect: Effect, scene: Scene): void;
  58245. protected _buildBlock(state: NodeMaterialBuildState): void;
  58246. protected _dumpPropertiesCode(): string;
  58247. dispose(): void;
  58248. serialize(): any;
  58249. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58250. }
  58251. }
  58252. declare module BABYLON {
  58253. /**
  58254. * Enum used to define the compatibility state between two connection points
  58255. */
  58256. export enum NodeMaterialConnectionPointCompatibilityStates {
  58257. /** Points are compatibles */
  58258. Compatible = 0,
  58259. /** Points are incompatible because of their types */
  58260. TypeIncompatible = 1,
  58261. /** Points are incompatible because of their targets (vertex vs fragment) */
  58262. TargetIncompatible = 2
  58263. }
  58264. /**
  58265. * Defines the direction of a connection point
  58266. */
  58267. export enum NodeMaterialConnectionPointDirection {
  58268. /** Input */
  58269. Input = 0,
  58270. /** Output */
  58271. Output = 1
  58272. }
  58273. /**
  58274. * Defines a connection point for a block
  58275. */
  58276. export class NodeMaterialConnectionPoint {
  58277. /** @hidden */
  58278. _ownerBlock: NodeMaterialBlock;
  58279. /** @hidden */
  58280. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58281. private _endpoints;
  58282. private _associatedVariableName;
  58283. private _direction;
  58284. /** @hidden */
  58285. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58286. /** @hidden */
  58287. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58288. private _type;
  58289. /** @hidden */
  58290. _enforceAssociatedVariableName: boolean;
  58291. /** Gets the direction of the point */
  58292. get direction(): NodeMaterialConnectionPointDirection;
  58293. /**
  58294. * Gets or sets the additional types supported by this connection point
  58295. */
  58296. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58297. /**
  58298. * Gets or sets the additional types excluded by this connection point
  58299. */
  58300. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58301. /**
  58302. * Observable triggered when this point is connected
  58303. */
  58304. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58305. /**
  58306. * Gets or sets the associated variable name in the shader
  58307. */
  58308. get associatedVariableName(): string;
  58309. set associatedVariableName(value: string);
  58310. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58311. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58312. /**
  58313. * Gets or sets the connection point type (default is float)
  58314. */
  58315. get type(): NodeMaterialBlockConnectionPointTypes;
  58316. set type(value: NodeMaterialBlockConnectionPointTypes);
  58317. /**
  58318. * Gets or sets the connection point name
  58319. */
  58320. name: string;
  58321. /**
  58322. * Gets or sets a boolean indicating that this connection point can be omitted
  58323. */
  58324. isOptional: boolean;
  58325. /**
  58326. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58327. */
  58328. define: string;
  58329. /** @hidden */
  58330. _prioritizeVertex: boolean;
  58331. private _target;
  58332. /** Gets or sets the target of that connection point */
  58333. get target(): NodeMaterialBlockTargets;
  58334. set target(value: NodeMaterialBlockTargets);
  58335. /**
  58336. * Gets a boolean indicating that the current point is connected
  58337. */
  58338. get isConnected(): boolean;
  58339. /**
  58340. * Gets a boolean indicating that the current point is connected to an input block
  58341. */
  58342. get isConnectedToInputBlock(): boolean;
  58343. /**
  58344. * Gets a the connected input block (if any)
  58345. */
  58346. get connectInputBlock(): Nullable<InputBlock>;
  58347. /** Get the other side of the connection (if any) */
  58348. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58349. /** Get the block that owns this connection point */
  58350. get ownerBlock(): NodeMaterialBlock;
  58351. /** Get the block connected on the other side of this connection (if any) */
  58352. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58353. /** Get the block connected on the endpoints of this connection (if any) */
  58354. get connectedBlocks(): Array<NodeMaterialBlock>;
  58355. /** Gets the list of connected endpoints */
  58356. get endpoints(): NodeMaterialConnectionPoint[];
  58357. /** Gets a boolean indicating if that output point is connected to at least one input */
  58358. get hasEndpoints(): boolean;
  58359. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58360. get isConnectedInVertexShader(): boolean;
  58361. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58362. get isConnectedInFragmentShader(): boolean;
  58363. /**
  58364. * Creates a new connection point
  58365. * @param name defines the connection point name
  58366. * @param ownerBlock defines the block hosting this connection point
  58367. * @param direction defines the direction of the connection point
  58368. */
  58369. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58370. /**
  58371. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58372. * @returns the class name
  58373. */
  58374. getClassName(): string;
  58375. /**
  58376. * Gets a boolean indicating if the current point can be connected to another point
  58377. * @param connectionPoint defines the other connection point
  58378. * @returns a boolean
  58379. */
  58380. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58381. /**
  58382. * Gets a number indicating if the current point can be connected to another point
  58383. * @param connectionPoint defines the other connection point
  58384. * @returns a number defining the compatibility state
  58385. */
  58386. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58387. /**
  58388. * Connect this point to another connection point
  58389. * @param connectionPoint defines the other connection point
  58390. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58391. * @returns the current connection point
  58392. */
  58393. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58394. /**
  58395. * Disconnect this point from one of his endpoint
  58396. * @param endpoint defines the other connection point
  58397. * @returns the current connection point
  58398. */
  58399. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58400. /**
  58401. * Serializes this point in a JSON representation
  58402. * @returns the serialized point object
  58403. */
  58404. serialize(): any;
  58405. /**
  58406. * Release resources
  58407. */
  58408. dispose(): void;
  58409. }
  58410. }
  58411. declare module BABYLON {
  58412. /**
  58413. * Block used to add support for vertex skinning (bones)
  58414. */
  58415. export class BonesBlock extends NodeMaterialBlock {
  58416. /**
  58417. * Creates a new BonesBlock
  58418. * @param name defines the block name
  58419. */
  58420. constructor(name: string);
  58421. /**
  58422. * Initialize the block and prepare the context for build
  58423. * @param state defines the state that will be used for the build
  58424. */
  58425. initialize(state: NodeMaterialBuildState): void;
  58426. /**
  58427. * Gets the current class name
  58428. * @returns the class name
  58429. */
  58430. getClassName(): string;
  58431. /**
  58432. * Gets the matrix indices input component
  58433. */
  58434. get matricesIndices(): NodeMaterialConnectionPoint;
  58435. /**
  58436. * Gets the matrix weights input component
  58437. */
  58438. get matricesWeights(): NodeMaterialConnectionPoint;
  58439. /**
  58440. * Gets the extra matrix indices input component
  58441. */
  58442. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58443. /**
  58444. * Gets the extra matrix weights input component
  58445. */
  58446. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58447. /**
  58448. * Gets the world input component
  58449. */
  58450. get world(): NodeMaterialConnectionPoint;
  58451. /**
  58452. * Gets the output component
  58453. */
  58454. get output(): NodeMaterialConnectionPoint;
  58455. autoConfigure(material: NodeMaterial): void;
  58456. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58457. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58459. protected _buildBlock(state: NodeMaterialBuildState): this;
  58460. }
  58461. }
  58462. declare module BABYLON {
  58463. /**
  58464. * Block used to add support for instances
  58465. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58466. */
  58467. export class InstancesBlock extends NodeMaterialBlock {
  58468. /**
  58469. * Creates a new InstancesBlock
  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 first world row input component
  58480. */
  58481. get world0(): NodeMaterialConnectionPoint;
  58482. /**
  58483. * Gets the second world row input component
  58484. */
  58485. get world1(): NodeMaterialConnectionPoint;
  58486. /**
  58487. * Gets the third world row input component
  58488. */
  58489. get world2(): NodeMaterialConnectionPoint;
  58490. /**
  58491. * Gets the forth world row input component
  58492. */
  58493. get world3(): NodeMaterialConnectionPoint;
  58494. /**
  58495. * Gets the world input component
  58496. */
  58497. get world(): NodeMaterialConnectionPoint;
  58498. /**
  58499. * Gets the output component
  58500. */
  58501. get output(): NodeMaterialConnectionPoint;
  58502. /**
  58503. * Gets the isntanceID component
  58504. */
  58505. get instanceID(): NodeMaterialConnectionPoint;
  58506. autoConfigure(material: NodeMaterial): void;
  58507. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58508. protected _buildBlock(state: NodeMaterialBuildState): this;
  58509. }
  58510. }
  58511. declare module BABYLON {
  58512. /**
  58513. * Block used to add morph targets support to vertex shader
  58514. */
  58515. export class MorphTargetsBlock extends NodeMaterialBlock {
  58516. private _repeatableContentAnchor;
  58517. /**
  58518. * Create a new MorphTargetsBlock
  58519. * @param name defines the block name
  58520. */
  58521. constructor(name: string);
  58522. /**
  58523. * Gets the current class name
  58524. * @returns the class name
  58525. */
  58526. getClassName(): string;
  58527. /**
  58528. * Gets the position input component
  58529. */
  58530. get position(): NodeMaterialConnectionPoint;
  58531. /**
  58532. * Gets the normal input component
  58533. */
  58534. get normal(): NodeMaterialConnectionPoint;
  58535. /**
  58536. * Gets the tangent input component
  58537. */
  58538. get tangent(): NodeMaterialConnectionPoint;
  58539. /**
  58540. * Gets the tangent input component
  58541. */
  58542. get uv(): NodeMaterialConnectionPoint;
  58543. /**
  58544. * Gets the position output component
  58545. */
  58546. get positionOutput(): NodeMaterialConnectionPoint;
  58547. /**
  58548. * Gets the normal output component
  58549. */
  58550. get normalOutput(): NodeMaterialConnectionPoint;
  58551. /**
  58552. * Gets the tangent output component
  58553. */
  58554. get tangentOutput(): NodeMaterialConnectionPoint;
  58555. /**
  58556. * Gets the tangent output component
  58557. */
  58558. get uvOutput(): NodeMaterialConnectionPoint;
  58559. initialize(state: NodeMaterialBuildState): void;
  58560. autoConfigure(material: NodeMaterial): void;
  58561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58563. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58564. protected _buildBlock(state: NodeMaterialBuildState): this;
  58565. }
  58566. }
  58567. declare module BABYLON {
  58568. /**
  58569. * Block used to get data information from a light
  58570. */
  58571. export class LightInformationBlock extends NodeMaterialBlock {
  58572. private _lightDataUniformName;
  58573. private _lightColorUniformName;
  58574. private _lightTypeDefineName;
  58575. /**
  58576. * Gets or sets the light associated with this block
  58577. */
  58578. light: Nullable<Light>;
  58579. /**
  58580. * Creates a new LightInformationBlock
  58581. * @param name defines the block name
  58582. */
  58583. constructor(name: string);
  58584. /**
  58585. * Gets the current class name
  58586. * @returns the class name
  58587. */
  58588. getClassName(): string;
  58589. /**
  58590. * Gets the world position input component
  58591. */
  58592. get worldPosition(): NodeMaterialConnectionPoint;
  58593. /**
  58594. * Gets the direction output component
  58595. */
  58596. get direction(): NodeMaterialConnectionPoint;
  58597. /**
  58598. * Gets the direction output component
  58599. */
  58600. get color(): NodeMaterialConnectionPoint;
  58601. /**
  58602. * Gets the direction output component
  58603. */
  58604. get intensity(): NodeMaterialConnectionPoint;
  58605. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58606. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58607. protected _buildBlock(state: NodeMaterialBuildState): this;
  58608. serialize(): any;
  58609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58610. }
  58611. }
  58612. declare module BABYLON {
  58613. /**
  58614. * Block used to add image processing support to fragment shader
  58615. */
  58616. export class ImageProcessingBlock extends NodeMaterialBlock {
  58617. /**
  58618. * Create a new ImageProcessingBlock
  58619. * @param name defines the block name
  58620. */
  58621. constructor(name: string);
  58622. /**
  58623. * Gets the current class name
  58624. * @returns the class name
  58625. */
  58626. getClassName(): string;
  58627. /**
  58628. * Gets the color input component
  58629. */
  58630. get color(): NodeMaterialConnectionPoint;
  58631. /**
  58632. * Gets the output component
  58633. */
  58634. get output(): NodeMaterialConnectionPoint;
  58635. /**
  58636. * Initialize the block and prepare the context for build
  58637. * @param state defines the state that will be used for the build
  58638. */
  58639. initialize(state: NodeMaterialBuildState): void;
  58640. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58641. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58642. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58643. protected _buildBlock(state: NodeMaterialBuildState): this;
  58644. }
  58645. }
  58646. declare module BABYLON {
  58647. /**
  58648. * Block used to pertub normals based on a normal map
  58649. */
  58650. export class PerturbNormalBlock extends NodeMaterialBlock {
  58651. private _tangentSpaceParameterName;
  58652. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58653. invertX: boolean;
  58654. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58655. invertY: boolean;
  58656. /**
  58657. * Create a new PerturbNormalBlock
  58658. * @param name defines the block name
  58659. */
  58660. constructor(name: string);
  58661. /**
  58662. * Gets the current class name
  58663. * @returns the class name
  58664. */
  58665. getClassName(): string;
  58666. /**
  58667. * Gets the world position input component
  58668. */
  58669. get worldPosition(): NodeMaterialConnectionPoint;
  58670. /**
  58671. * Gets the world normal input component
  58672. */
  58673. get worldNormal(): NodeMaterialConnectionPoint;
  58674. /**
  58675. * Gets the world tangent input component
  58676. */
  58677. get worldTangent(): NodeMaterialConnectionPoint;
  58678. /**
  58679. * Gets the uv input component
  58680. */
  58681. get uv(): NodeMaterialConnectionPoint;
  58682. /**
  58683. * Gets the normal map color input component
  58684. */
  58685. get normalMapColor(): NodeMaterialConnectionPoint;
  58686. /**
  58687. * Gets the strength input component
  58688. */
  58689. get strength(): NodeMaterialConnectionPoint;
  58690. /**
  58691. * Gets the output component
  58692. */
  58693. get output(): NodeMaterialConnectionPoint;
  58694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58695. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58696. autoConfigure(material: NodeMaterial): void;
  58697. protected _buildBlock(state: NodeMaterialBuildState): this;
  58698. protected _dumpPropertiesCode(): string;
  58699. serialize(): any;
  58700. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58701. }
  58702. }
  58703. declare module BABYLON {
  58704. /**
  58705. * Block used to discard a pixel if a value is smaller than a cutoff
  58706. */
  58707. export class DiscardBlock extends NodeMaterialBlock {
  58708. /**
  58709. * Create a new DiscardBlock
  58710. * @param name defines the block name
  58711. */
  58712. constructor(name: string);
  58713. /**
  58714. * Gets the current class name
  58715. * @returns the class name
  58716. */
  58717. getClassName(): string;
  58718. /**
  58719. * Gets the color input component
  58720. */
  58721. get value(): NodeMaterialConnectionPoint;
  58722. /**
  58723. * Gets the cutoff input component
  58724. */
  58725. get cutoff(): NodeMaterialConnectionPoint;
  58726. protected _buildBlock(state: NodeMaterialBuildState): this;
  58727. }
  58728. }
  58729. declare module BABYLON {
  58730. /**
  58731. * Block used to test if the fragment shader is front facing
  58732. */
  58733. export class FrontFacingBlock extends NodeMaterialBlock {
  58734. /**
  58735. * Creates a new FrontFacingBlock
  58736. * @param name defines the block name
  58737. */
  58738. constructor(name: string);
  58739. /**
  58740. * Gets the current class name
  58741. * @returns the class name
  58742. */
  58743. getClassName(): string;
  58744. /**
  58745. * Gets the output component
  58746. */
  58747. get output(): NodeMaterialConnectionPoint;
  58748. protected _buildBlock(state: NodeMaterialBuildState): this;
  58749. }
  58750. }
  58751. declare module BABYLON {
  58752. /**
  58753. * Block used to get the derivative value on x and y of a given input
  58754. */
  58755. export class DerivativeBlock extends NodeMaterialBlock {
  58756. /**
  58757. * Create a new DerivativeBlock
  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 input component
  58768. */
  58769. get input(): NodeMaterialConnectionPoint;
  58770. /**
  58771. * Gets the derivative output on x
  58772. */
  58773. get dx(): NodeMaterialConnectionPoint;
  58774. /**
  58775. * Gets the derivative output on y
  58776. */
  58777. get dy(): NodeMaterialConnectionPoint;
  58778. protected _buildBlock(state: NodeMaterialBuildState): this;
  58779. }
  58780. }
  58781. declare module BABYLON {
  58782. /**
  58783. * Block used to add support for scene fog
  58784. */
  58785. export class FogBlock extends NodeMaterialBlock {
  58786. private _fogDistanceName;
  58787. private _fogParameters;
  58788. /**
  58789. * Create a new FogBlock
  58790. * @param name defines the block name
  58791. */
  58792. constructor(name: string);
  58793. /**
  58794. * Gets the current class name
  58795. * @returns the class name
  58796. */
  58797. getClassName(): string;
  58798. /**
  58799. * Gets the world position input component
  58800. */
  58801. get worldPosition(): NodeMaterialConnectionPoint;
  58802. /**
  58803. * Gets the view input component
  58804. */
  58805. get view(): NodeMaterialConnectionPoint;
  58806. /**
  58807. * Gets the color input component
  58808. */
  58809. get input(): NodeMaterialConnectionPoint;
  58810. /**
  58811. * Gets the fog color input component
  58812. */
  58813. get fogColor(): NodeMaterialConnectionPoint;
  58814. /**
  58815. * Gets the output component
  58816. */
  58817. get output(): NodeMaterialConnectionPoint;
  58818. autoConfigure(material: NodeMaterial): void;
  58819. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58820. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58821. protected _buildBlock(state: NodeMaterialBuildState): this;
  58822. }
  58823. }
  58824. declare module BABYLON {
  58825. /**
  58826. * Block used to add light in the fragment shader
  58827. */
  58828. export class LightBlock extends NodeMaterialBlock {
  58829. private _lightId;
  58830. /**
  58831. * Gets or sets the light associated with this block
  58832. */
  58833. light: Nullable<Light>;
  58834. /**
  58835. * Create a new LightBlock
  58836. * @param name defines the block name
  58837. */
  58838. constructor(name: string);
  58839. /**
  58840. * Gets the current class name
  58841. * @returns the class name
  58842. */
  58843. getClassName(): string;
  58844. /**
  58845. * Gets the world position input component
  58846. */
  58847. get worldPosition(): NodeMaterialConnectionPoint;
  58848. /**
  58849. * Gets the world normal input component
  58850. */
  58851. get worldNormal(): NodeMaterialConnectionPoint;
  58852. /**
  58853. * Gets the camera (or eye) position component
  58854. */
  58855. get cameraPosition(): NodeMaterialConnectionPoint;
  58856. /**
  58857. * Gets the glossiness component
  58858. */
  58859. get glossiness(): NodeMaterialConnectionPoint;
  58860. /**
  58861. * Gets the glossinness power component
  58862. */
  58863. get glossPower(): NodeMaterialConnectionPoint;
  58864. /**
  58865. * Gets the diffuse color component
  58866. */
  58867. get diffuseColor(): NodeMaterialConnectionPoint;
  58868. /**
  58869. * Gets the specular color component
  58870. */
  58871. get specularColor(): NodeMaterialConnectionPoint;
  58872. /**
  58873. * Gets the diffuse output component
  58874. */
  58875. get diffuseOutput(): NodeMaterialConnectionPoint;
  58876. /**
  58877. * Gets the specular output component
  58878. */
  58879. get specularOutput(): NodeMaterialConnectionPoint;
  58880. /**
  58881. * Gets the shadow output component
  58882. */
  58883. get shadow(): NodeMaterialConnectionPoint;
  58884. autoConfigure(material: NodeMaterial): void;
  58885. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58886. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58887. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58888. private _injectVertexCode;
  58889. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58890. serialize(): any;
  58891. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58892. }
  58893. }
  58894. declare module BABYLON {
  58895. /**
  58896. * Block used to multiply 2 values
  58897. */
  58898. export class MultiplyBlock extends NodeMaterialBlock {
  58899. /**
  58900. * Creates a new MultiplyBlock
  58901. * @param name defines the block name
  58902. */
  58903. constructor(name: string);
  58904. /**
  58905. * Gets the current class name
  58906. * @returns the class name
  58907. */
  58908. getClassName(): string;
  58909. /**
  58910. * Gets the left operand input component
  58911. */
  58912. get left(): NodeMaterialConnectionPoint;
  58913. /**
  58914. * Gets the right operand input component
  58915. */
  58916. get right(): NodeMaterialConnectionPoint;
  58917. /**
  58918. * Gets the output component
  58919. */
  58920. get output(): NodeMaterialConnectionPoint;
  58921. protected _buildBlock(state: NodeMaterialBuildState): this;
  58922. }
  58923. }
  58924. declare module BABYLON {
  58925. /**
  58926. * Block used to add 2 vectors
  58927. */
  58928. export class AddBlock extends NodeMaterialBlock {
  58929. /**
  58930. * Creates a new AddBlock
  58931. * @param name defines the block name
  58932. */
  58933. constructor(name: string);
  58934. /**
  58935. * Gets the current class name
  58936. * @returns the class name
  58937. */
  58938. getClassName(): string;
  58939. /**
  58940. * Gets the left operand input component
  58941. */
  58942. get left(): NodeMaterialConnectionPoint;
  58943. /**
  58944. * Gets the right operand input component
  58945. */
  58946. get right(): NodeMaterialConnectionPoint;
  58947. /**
  58948. * Gets the output component
  58949. */
  58950. get output(): NodeMaterialConnectionPoint;
  58951. protected _buildBlock(state: NodeMaterialBuildState): this;
  58952. }
  58953. }
  58954. declare module BABYLON {
  58955. /**
  58956. * Block used to scale a vector by a float
  58957. */
  58958. export class ScaleBlock extends NodeMaterialBlock {
  58959. /**
  58960. * Creates a new ScaleBlock
  58961. * @param name defines the block name
  58962. */
  58963. constructor(name: string);
  58964. /**
  58965. * Gets the current class name
  58966. * @returns the class name
  58967. */
  58968. getClassName(): string;
  58969. /**
  58970. * Gets the input component
  58971. */
  58972. get input(): NodeMaterialConnectionPoint;
  58973. /**
  58974. * Gets the factor input component
  58975. */
  58976. get factor(): NodeMaterialConnectionPoint;
  58977. /**
  58978. * Gets the output component
  58979. */
  58980. get output(): NodeMaterialConnectionPoint;
  58981. protected _buildBlock(state: NodeMaterialBuildState): this;
  58982. }
  58983. }
  58984. declare module BABYLON {
  58985. /**
  58986. * Block used to clamp a float
  58987. */
  58988. export class ClampBlock extends NodeMaterialBlock {
  58989. /** Gets or sets the minimum range */
  58990. minimum: number;
  58991. /** Gets or sets the maximum range */
  58992. maximum: number;
  58993. /**
  58994. * Creates a new ClampBlock
  58995. * @param name defines the block name
  58996. */
  58997. constructor(name: string);
  58998. /**
  58999. * Gets the current class name
  59000. * @returns the class name
  59001. */
  59002. getClassName(): string;
  59003. /**
  59004. * Gets the value input component
  59005. */
  59006. get value(): NodeMaterialConnectionPoint;
  59007. /**
  59008. * Gets the output component
  59009. */
  59010. get output(): NodeMaterialConnectionPoint;
  59011. protected _buildBlock(state: NodeMaterialBuildState): this;
  59012. protected _dumpPropertiesCode(): string;
  59013. serialize(): any;
  59014. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59015. }
  59016. }
  59017. declare module BABYLON {
  59018. /**
  59019. * Block used to apply a cross product between 2 vectors
  59020. */
  59021. export class CrossBlock extends NodeMaterialBlock {
  59022. /**
  59023. * Creates a new CrossBlock
  59024. * @param name defines the block name
  59025. */
  59026. constructor(name: string);
  59027. /**
  59028. * Gets the current class name
  59029. * @returns the class name
  59030. */
  59031. getClassName(): string;
  59032. /**
  59033. * Gets the left operand input component
  59034. */
  59035. get left(): NodeMaterialConnectionPoint;
  59036. /**
  59037. * Gets the right operand input component
  59038. */
  59039. get right(): NodeMaterialConnectionPoint;
  59040. /**
  59041. * Gets the output component
  59042. */
  59043. get output(): NodeMaterialConnectionPoint;
  59044. protected _buildBlock(state: NodeMaterialBuildState): this;
  59045. }
  59046. }
  59047. declare module BABYLON {
  59048. /**
  59049. * Block used to apply a dot product between 2 vectors
  59050. */
  59051. export class DotBlock extends NodeMaterialBlock {
  59052. /**
  59053. * Creates a new DotBlock
  59054. * @param name defines the block name
  59055. */
  59056. constructor(name: string);
  59057. /**
  59058. * Gets the current class name
  59059. * @returns the class name
  59060. */
  59061. getClassName(): string;
  59062. /**
  59063. * Gets the left operand input component
  59064. */
  59065. get left(): NodeMaterialConnectionPoint;
  59066. /**
  59067. * Gets the right operand input component
  59068. */
  59069. get right(): NodeMaterialConnectionPoint;
  59070. /**
  59071. * Gets the output component
  59072. */
  59073. get output(): NodeMaterialConnectionPoint;
  59074. protected _buildBlock(state: NodeMaterialBuildState): this;
  59075. }
  59076. }
  59077. declare module BABYLON {
  59078. /**
  59079. * Block used to remap a float from a range to a new one
  59080. */
  59081. export class RemapBlock extends NodeMaterialBlock {
  59082. /**
  59083. * Gets or sets the source range
  59084. */
  59085. sourceRange: Vector2;
  59086. /**
  59087. * Gets or sets the target range
  59088. */
  59089. targetRange: Vector2;
  59090. /**
  59091. * Creates a new RemapBlock
  59092. * @param name defines the block name
  59093. */
  59094. constructor(name: string);
  59095. /**
  59096. * Gets the current class name
  59097. * @returns the class name
  59098. */
  59099. getClassName(): string;
  59100. /**
  59101. * Gets the input component
  59102. */
  59103. get input(): NodeMaterialConnectionPoint;
  59104. /**
  59105. * Gets the source min input component
  59106. */
  59107. get sourceMin(): NodeMaterialConnectionPoint;
  59108. /**
  59109. * Gets the source max input component
  59110. */
  59111. get sourceMax(): NodeMaterialConnectionPoint;
  59112. /**
  59113. * Gets the target min input component
  59114. */
  59115. get targetMin(): NodeMaterialConnectionPoint;
  59116. /**
  59117. * Gets the target max input component
  59118. */
  59119. get targetMax(): NodeMaterialConnectionPoint;
  59120. /**
  59121. * Gets the output component
  59122. */
  59123. get output(): NodeMaterialConnectionPoint;
  59124. protected _buildBlock(state: NodeMaterialBuildState): this;
  59125. protected _dumpPropertiesCode(): string;
  59126. serialize(): any;
  59127. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59128. }
  59129. }
  59130. declare module BABYLON {
  59131. /**
  59132. * Block used to normalize a vector
  59133. */
  59134. export class NormalizeBlock extends NodeMaterialBlock {
  59135. /**
  59136. * Creates a new NormalizeBlock
  59137. * @param name defines the block name
  59138. */
  59139. constructor(name: string);
  59140. /**
  59141. * Gets the current class name
  59142. * @returns the class name
  59143. */
  59144. getClassName(): string;
  59145. /**
  59146. * Gets the input component
  59147. */
  59148. get input(): NodeMaterialConnectionPoint;
  59149. /**
  59150. * Gets the output component
  59151. */
  59152. get output(): NodeMaterialConnectionPoint;
  59153. protected _buildBlock(state: NodeMaterialBuildState): this;
  59154. }
  59155. }
  59156. declare module BABYLON {
  59157. /**
  59158. * Operations supported by the Trigonometry block
  59159. */
  59160. export enum TrigonometryBlockOperations {
  59161. /** Cos */
  59162. Cos = 0,
  59163. /** Sin */
  59164. Sin = 1,
  59165. /** Abs */
  59166. Abs = 2,
  59167. /** Exp */
  59168. Exp = 3,
  59169. /** Exp2 */
  59170. Exp2 = 4,
  59171. /** Round */
  59172. Round = 5,
  59173. /** Floor */
  59174. Floor = 6,
  59175. /** Ceiling */
  59176. Ceiling = 7,
  59177. /** Square root */
  59178. Sqrt = 8,
  59179. /** Log */
  59180. Log = 9,
  59181. /** Tangent */
  59182. Tan = 10,
  59183. /** Arc tangent */
  59184. ArcTan = 11,
  59185. /** Arc cosinus */
  59186. ArcCos = 12,
  59187. /** Arc sinus */
  59188. ArcSin = 13,
  59189. /** Fraction */
  59190. Fract = 14,
  59191. /** Sign */
  59192. Sign = 15,
  59193. /** To radians (from degrees) */
  59194. Radians = 16,
  59195. /** To degrees (from radians) */
  59196. Degrees = 17
  59197. }
  59198. /**
  59199. * Block used to apply trigonometry operation to floats
  59200. */
  59201. export class TrigonometryBlock extends NodeMaterialBlock {
  59202. /**
  59203. * Gets or sets the operation applied by the block
  59204. */
  59205. operation: TrigonometryBlockOperations;
  59206. /**
  59207. * Creates a new TrigonometryBlock
  59208. * @param name defines the block name
  59209. */
  59210. constructor(name: string);
  59211. /**
  59212. * Gets the current class name
  59213. * @returns the class name
  59214. */
  59215. getClassName(): string;
  59216. /**
  59217. * Gets the input component
  59218. */
  59219. get input(): NodeMaterialConnectionPoint;
  59220. /**
  59221. * Gets the output component
  59222. */
  59223. get output(): NodeMaterialConnectionPoint;
  59224. protected _buildBlock(state: NodeMaterialBuildState): this;
  59225. serialize(): any;
  59226. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59227. protected _dumpPropertiesCode(): string;
  59228. }
  59229. }
  59230. declare module BABYLON {
  59231. /**
  59232. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59233. */
  59234. export class ColorMergerBlock extends NodeMaterialBlock {
  59235. /**
  59236. * Create a new ColorMergerBlock
  59237. * @param name defines the block name
  59238. */
  59239. constructor(name: string);
  59240. /**
  59241. * Gets the current class name
  59242. * @returns the class name
  59243. */
  59244. getClassName(): string;
  59245. /**
  59246. * Gets the rgb component (input)
  59247. */
  59248. get rgbIn(): NodeMaterialConnectionPoint;
  59249. /**
  59250. * Gets the r component (input)
  59251. */
  59252. get r(): NodeMaterialConnectionPoint;
  59253. /**
  59254. * Gets the g component (input)
  59255. */
  59256. get g(): NodeMaterialConnectionPoint;
  59257. /**
  59258. * Gets the b component (input)
  59259. */
  59260. get b(): NodeMaterialConnectionPoint;
  59261. /**
  59262. * Gets the a component (input)
  59263. */
  59264. get a(): NodeMaterialConnectionPoint;
  59265. /**
  59266. * Gets the rgba component (output)
  59267. */
  59268. get rgba(): NodeMaterialConnectionPoint;
  59269. /**
  59270. * Gets the rgb component (output)
  59271. */
  59272. get rgbOut(): NodeMaterialConnectionPoint;
  59273. /**
  59274. * Gets the rgb component (output)
  59275. * @deprecated Please use rgbOut instead.
  59276. */
  59277. get rgb(): NodeMaterialConnectionPoint;
  59278. protected _buildBlock(state: NodeMaterialBuildState): this;
  59279. }
  59280. }
  59281. declare module BABYLON {
  59282. /**
  59283. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59284. */
  59285. export class VectorMergerBlock extends NodeMaterialBlock {
  59286. /**
  59287. * Create a new VectorMergerBlock
  59288. * @param name defines the block name
  59289. */
  59290. constructor(name: string);
  59291. /**
  59292. * Gets the current class name
  59293. * @returns the class name
  59294. */
  59295. getClassName(): string;
  59296. /**
  59297. * Gets the xyz component (input)
  59298. */
  59299. get xyzIn(): NodeMaterialConnectionPoint;
  59300. /**
  59301. * Gets the xy component (input)
  59302. */
  59303. get xyIn(): NodeMaterialConnectionPoint;
  59304. /**
  59305. * Gets the x component (input)
  59306. */
  59307. get x(): NodeMaterialConnectionPoint;
  59308. /**
  59309. * Gets the y component (input)
  59310. */
  59311. get y(): NodeMaterialConnectionPoint;
  59312. /**
  59313. * Gets the z component (input)
  59314. */
  59315. get z(): NodeMaterialConnectionPoint;
  59316. /**
  59317. * Gets the w component (input)
  59318. */
  59319. get w(): NodeMaterialConnectionPoint;
  59320. /**
  59321. * Gets the xyzw component (output)
  59322. */
  59323. get xyzw(): NodeMaterialConnectionPoint;
  59324. /**
  59325. * Gets the xyz component (output)
  59326. */
  59327. get xyzOut(): NodeMaterialConnectionPoint;
  59328. /**
  59329. * Gets the xy component (output)
  59330. */
  59331. get xyOut(): NodeMaterialConnectionPoint;
  59332. /**
  59333. * Gets the xy component (output)
  59334. * @deprecated Please use xyOut instead.
  59335. */
  59336. get xy(): NodeMaterialConnectionPoint;
  59337. /**
  59338. * Gets the xyz component (output)
  59339. * @deprecated Please use xyzOut instead.
  59340. */
  59341. get xyz(): NodeMaterialConnectionPoint;
  59342. protected _buildBlock(state: NodeMaterialBuildState): this;
  59343. }
  59344. }
  59345. declare module BABYLON {
  59346. /**
  59347. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59348. */
  59349. export class ColorSplitterBlock extends NodeMaterialBlock {
  59350. /**
  59351. * Create a new ColorSplitterBlock
  59352. * @param name defines the block name
  59353. */
  59354. constructor(name: string);
  59355. /**
  59356. * Gets the current class name
  59357. * @returns the class name
  59358. */
  59359. getClassName(): string;
  59360. /**
  59361. * Gets the rgba component (input)
  59362. */
  59363. get rgba(): NodeMaterialConnectionPoint;
  59364. /**
  59365. * Gets the rgb component (input)
  59366. */
  59367. get rgbIn(): NodeMaterialConnectionPoint;
  59368. /**
  59369. * Gets the rgb component (output)
  59370. */
  59371. get rgbOut(): NodeMaterialConnectionPoint;
  59372. /**
  59373. * Gets the r component (output)
  59374. */
  59375. get r(): NodeMaterialConnectionPoint;
  59376. /**
  59377. * Gets the g component (output)
  59378. */
  59379. get g(): NodeMaterialConnectionPoint;
  59380. /**
  59381. * Gets the b component (output)
  59382. */
  59383. get b(): NodeMaterialConnectionPoint;
  59384. /**
  59385. * Gets the a component (output)
  59386. */
  59387. get a(): NodeMaterialConnectionPoint;
  59388. protected _inputRename(name: string): string;
  59389. protected _outputRename(name: string): string;
  59390. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59391. }
  59392. }
  59393. declare module BABYLON {
  59394. /**
  59395. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59396. */
  59397. export class VectorSplitterBlock extends NodeMaterialBlock {
  59398. /**
  59399. * Create a new VectorSplitterBlock
  59400. * @param name defines the block name
  59401. */
  59402. constructor(name: string);
  59403. /**
  59404. * Gets the current class name
  59405. * @returns the class name
  59406. */
  59407. getClassName(): string;
  59408. /**
  59409. * Gets the xyzw component (input)
  59410. */
  59411. get xyzw(): NodeMaterialConnectionPoint;
  59412. /**
  59413. * Gets the xyz component (input)
  59414. */
  59415. get xyzIn(): NodeMaterialConnectionPoint;
  59416. /**
  59417. * Gets the xy component (input)
  59418. */
  59419. get xyIn(): NodeMaterialConnectionPoint;
  59420. /**
  59421. * Gets the xyz component (output)
  59422. */
  59423. get xyzOut(): NodeMaterialConnectionPoint;
  59424. /**
  59425. * Gets the xy component (output)
  59426. */
  59427. get xyOut(): NodeMaterialConnectionPoint;
  59428. /**
  59429. * Gets the x component (output)
  59430. */
  59431. get x(): NodeMaterialConnectionPoint;
  59432. /**
  59433. * Gets the y component (output)
  59434. */
  59435. get y(): NodeMaterialConnectionPoint;
  59436. /**
  59437. * Gets the z component (output)
  59438. */
  59439. get z(): NodeMaterialConnectionPoint;
  59440. /**
  59441. * Gets the w component (output)
  59442. */
  59443. get w(): NodeMaterialConnectionPoint;
  59444. protected _inputRename(name: string): string;
  59445. protected _outputRename(name: string): string;
  59446. protected _buildBlock(state: NodeMaterialBuildState): this;
  59447. }
  59448. }
  59449. declare module BABYLON {
  59450. /**
  59451. * Block used to lerp between 2 values
  59452. */
  59453. export class LerpBlock extends NodeMaterialBlock {
  59454. /**
  59455. * Creates a new LerpBlock
  59456. * @param name defines the block name
  59457. */
  59458. constructor(name: string);
  59459. /**
  59460. * Gets the current class name
  59461. * @returns the class name
  59462. */
  59463. getClassName(): string;
  59464. /**
  59465. * Gets the left operand input component
  59466. */
  59467. get left(): NodeMaterialConnectionPoint;
  59468. /**
  59469. * Gets the right operand input component
  59470. */
  59471. get right(): NodeMaterialConnectionPoint;
  59472. /**
  59473. * Gets the gradient operand input component
  59474. */
  59475. get gradient(): NodeMaterialConnectionPoint;
  59476. /**
  59477. * Gets the output component
  59478. */
  59479. get output(): NodeMaterialConnectionPoint;
  59480. protected _buildBlock(state: NodeMaterialBuildState): this;
  59481. }
  59482. }
  59483. declare module BABYLON {
  59484. /**
  59485. * Block used to divide 2 vectors
  59486. */
  59487. export class DivideBlock extends NodeMaterialBlock {
  59488. /**
  59489. * Creates a new DivideBlock
  59490. * @param name defines the block name
  59491. */
  59492. constructor(name: string);
  59493. /**
  59494. * Gets the current class name
  59495. * @returns the class name
  59496. */
  59497. getClassName(): string;
  59498. /**
  59499. * Gets the left operand input component
  59500. */
  59501. get left(): NodeMaterialConnectionPoint;
  59502. /**
  59503. * Gets the right operand input component
  59504. */
  59505. get right(): NodeMaterialConnectionPoint;
  59506. /**
  59507. * Gets the output component
  59508. */
  59509. get output(): NodeMaterialConnectionPoint;
  59510. protected _buildBlock(state: NodeMaterialBuildState): this;
  59511. }
  59512. }
  59513. declare module BABYLON {
  59514. /**
  59515. * Block used to subtract 2 vectors
  59516. */
  59517. export class SubtractBlock extends NodeMaterialBlock {
  59518. /**
  59519. * Creates a new SubtractBlock
  59520. * @param name defines the block name
  59521. */
  59522. constructor(name: string);
  59523. /**
  59524. * Gets the current class name
  59525. * @returns the class name
  59526. */
  59527. getClassName(): string;
  59528. /**
  59529. * Gets the left operand input component
  59530. */
  59531. get left(): NodeMaterialConnectionPoint;
  59532. /**
  59533. * Gets the right operand input component
  59534. */
  59535. get right(): NodeMaterialConnectionPoint;
  59536. /**
  59537. * Gets the output component
  59538. */
  59539. get output(): NodeMaterialConnectionPoint;
  59540. protected _buildBlock(state: NodeMaterialBuildState): this;
  59541. }
  59542. }
  59543. declare module BABYLON {
  59544. /**
  59545. * Block used to step a value
  59546. */
  59547. export class StepBlock extends NodeMaterialBlock {
  59548. /**
  59549. * Creates a new StepBlock
  59550. * @param name defines the block name
  59551. */
  59552. constructor(name: string);
  59553. /**
  59554. * Gets the current class name
  59555. * @returns the class name
  59556. */
  59557. getClassName(): string;
  59558. /**
  59559. * Gets the value operand input component
  59560. */
  59561. get value(): NodeMaterialConnectionPoint;
  59562. /**
  59563. * Gets the edge operand input component
  59564. */
  59565. get edge(): NodeMaterialConnectionPoint;
  59566. /**
  59567. * Gets the output component
  59568. */
  59569. get output(): NodeMaterialConnectionPoint;
  59570. protected _buildBlock(state: NodeMaterialBuildState): this;
  59571. }
  59572. }
  59573. declare module BABYLON {
  59574. /**
  59575. * Block used to get the opposite (1 - x) of a value
  59576. */
  59577. export class OneMinusBlock extends NodeMaterialBlock {
  59578. /**
  59579. * Creates a new OneMinusBlock
  59580. * @param name defines the block name
  59581. */
  59582. constructor(name: string);
  59583. /**
  59584. * Gets the current class name
  59585. * @returns the class name
  59586. */
  59587. getClassName(): string;
  59588. /**
  59589. * Gets the input component
  59590. */
  59591. get input(): NodeMaterialConnectionPoint;
  59592. /**
  59593. * Gets the output component
  59594. */
  59595. get output(): NodeMaterialConnectionPoint;
  59596. protected _buildBlock(state: NodeMaterialBuildState): this;
  59597. }
  59598. }
  59599. declare module BABYLON {
  59600. /**
  59601. * Block used to get the view direction
  59602. */
  59603. export class ViewDirectionBlock extends NodeMaterialBlock {
  59604. /**
  59605. * Creates a new ViewDirectionBlock
  59606. * @param name defines the block name
  59607. */
  59608. constructor(name: string);
  59609. /**
  59610. * Gets the current class name
  59611. * @returns the class name
  59612. */
  59613. getClassName(): string;
  59614. /**
  59615. * Gets the world position component
  59616. */
  59617. get worldPosition(): NodeMaterialConnectionPoint;
  59618. /**
  59619. * Gets the camera position component
  59620. */
  59621. get cameraPosition(): NodeMaterialConnectionPoint;
  59622. /**
  59623. * Gets the output component
  59624. */
  59625. get output(): NodeMaterialConnectionPoint;
  59626. autoConfigure(material: NodeMaterial): void;
  59627. protected _buildBlock(state: NodeMaterialBuildState): this;
  59628. }
  59629. }
  59630. declare module BABYLON {
  59631. /**
  59632. * Block used to compute fresnel value
  59633. */
  59634. export class FresnelBlock extends NodeMaterialBlock {
  59635. /**
  59636. * Create a new FresnelBlock
  59637. * @param name defines the block name
  59638. */
  59639. constructor(name: string);
  59640. /**
  59641. * Gets the current class name
  59642. * @returns the class name
  59643. */
  59644. getClassName(): string;
  59645. /**
  59646. * Gets the world normal input component
  59647. */
  59648. get worldNormal(): NodeMaterialConnectionPoint;
  59649. /**
  59650. * Gets the view direction input component
  59651. */
  59652. get viewDirection(): NodeMaterialConnectionPoint;
  59653. /**
  59654. * Gets the bias input component
  59655. */
  59656. get bias(): NodeMaterialConnectionPoint;
  59657. /**
  59658. * Gets the camera (or eye) position component
  59659. */
  59660. get power(): NodeMaterialConnectionPoint;
  59661. /**
  59662. * Gets the fresnel output component
  59663. */
  59664. get fresnel(): NodeMaterialConnectionPoint;
  59665. autoConfigure(material: NodeMaterial): void;
  59666. protected _buildBlock(state: NodeMaterialBuildState): this;
  59667. }
  59668. }
  59669. declare module BABYLON {
  59670. /**
  59671. * Block used to get the max of 2 values
  59672. */
  59673. export class MaxBlock extends NodeMaterialBlock {
  59674. /**
  59675. * Creates a new MaxBlock
  59676. * @param name defines the block name
  59677. */
  59678. constructor(name: string);
  59679. /**
  59680. * Gets the current class name
  59681. * @returns the class name
  59682. */
  59683. getClassName(): string;
  59684. /**
  59685. * Gets the left operand input component
  59686. */
  59687. get left(): NodeMaterialConnectionPoint;
  59688. /**
  59689. * Gets the right operand input component
  59690. */
  59691. get right(): NodeMaterialConnectionPoint;
  59692. /**
  59693. * Gets the output component
  59694. */
  59695. get output(): NodeMaterialConnectionPoint;
  59696. protected _buildBlock(state: NodeMaterialBuildState): this;
  59697. }
  59698. }
  59699. declare module BABYLON {
  59700. /**
  59701. * Block used to get the min of 2 values
  59702. */
  59703. export class MinBlock extends NodeMaterialBlock {
  59704. /**
  59705. * Creates a new MinBlock
  59706. * @param name defines the block name
  59707. */
  59708. constructor(name: string);
  59709. /**
  59710. * Gets the current class name
  59711. * @returns the class name
  59712. */
  59713. getClassName(): string;
  59714. /**
  59715. * Gets the left operand input component
  59716. */
  59717. get left(): NodeMaterialConnectionPoint;
  59718. /**
  59719. * Gets the right operand input component
  59720. */
  59721. get right(): 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 get the distance between 2 values
  59732. */
  59733. export class DistanceBlock extends NodeMaterialBlock {
  59734. /**
  59735. * Creates a new DistanceBlock
  59736. * @param name defines the block name
  59737. */
  59738. constructor(name: string);
  59739. /**
  59740. * Gets the current class name
  59741. * @returns the class name
  59742. */
  59743. getClassName(): string;
  59744. /**
  59745. * Gets the left operand input component
  59746. */
  59747. get left(): NodeMaterialConnectionPoint;
  59748. /**
  59749. * Gets the right operand input component
  59750. */
  59751. get right(): NodeMaterialConnectionPoint;
  59752. /**
  59753. * Gets the output component
  59754. */
  59755. get output(): NodeMaterialConnectionPoint;
  59756. protected _buildBlock(state: NodeMaterialBuildState): this;
  59757. }
  59758. }
  59759. declare module BABYLON {
  59760. /**
  59761. * Block used to get the length of a vector
  59762. */
  59763. export class LengthBlock extends NodeMaterialBlock {
  59764. /**
  59765. * Creates a new LengthBlock
  59766. * @param name defines the block name
  59767. */
  59768. constructor(name: string);
  59769. /**
  59770. * Gets the current class name
  59771. * @returns the class name
  59772. */
  59773. getClassName(): string;
  59774. /**
  59775. * Gets the value input component
  59776. */
  59777. get value(): NodeMaterialConnectionPoint;
  59778. /**
  59779. * Gets the output component
  59780. */
  59781. get output(): NodeMaterialConnectionPoint;
  59782. protected _buildBlock(state: NodeMaterialBuildState): this;
  59783. }
  59784. }
  59785. declare module BABYLON {
  59786. /**
  59787. * Block used to get negative version of a value (i.e. x * -1)
  59788. */
  59789. export class NegateBlock extends NodeMaterialBlock {
  59790. /**
  59791. * Creates a new NegateBlock
  59792. * @param name defines the block name
  59793. */
  59794. constructor(name: string);
  59795. /**
  59796. * Gets the current class name
  59797. * @returns the class name
  59798. */
  59799. getClassName(): string;
  59800. /**
  59801. * Gets the value input component
  59802. */
  59803. get value(): NodeMaterialConnectionPoint;
  59804. /**
  59805. * Gets the output component
  59806. */
  59807. get output(): NodeMaterialConnectionPoint;
  59808. protected _buildBlock(state: NodeMaterialBuildState): this;
  59809. }
  59810. }
  59811. declare module BABYLON {
  59812. /**
  59813. * Block used to get the value of the first parameter raised to the power of the second
  59814. */
  59815. export class PowBlock extends NodeMaterialBlock {
  59816. /**
  59817. * Creates a new PowBlock
  59818. * @param name defines the block name
  59819. */
  59820. constructor(name: string);
  59821. /**
  59822. * Gets the current class name
  59823. * @returns the class name
  59824. */
  59825. getClassName(): string;
  59826. /**
  59827. * Gets the value operand input component
  59828. */
  59829. get value(): NodeMaterialConnectionPoint;
  59830. /**
  59831. * Gets the power operand input component
  59832. */
  59833. get power(): NodeMaterialConnectionPoint;
  59834. /**
  59835. * Gets the output component
  59836. */
  59837. get output(): NodeMaterialConnectionPoint;
  59838. protected _buildBlock(state: NodeMaterialBuildState): this;
  59839. }
  59840. }
  59841. declare module BABYLON {
  59842. /**
  59843. * Block used to get a random number
  59844. */
  59845. export class RandomNumberBlock extends NodeMaterialBlock {
  59846. /**
  59847. * Creates a new RandomNumberBlock
  59848. * @param name defines the block name
  59849. */
  59850. constructor(name: string);
  59851. /**
  59852. * Gets the current class name
  59853. * @returns the class name
  59854. */
  59855. getClassName(): string;
  59856. /**
  59857. * Gets the seed input component
  59858. */
  59859. get seed(): NodeMaterialConnectionPoint;
  59860. /**
  59861. * Gets the output component
  59862. */
  59863. get output(): NodeMaterialConnectionPoint;
  59864. protected _buildBlock(state: NodeMaterialBuildState): this;
  59865. }
  59866. }
  59867. declare module BABYLON {
  59868. /**
  59869. * Block used to compute arc tangent of 2 values
  59870. */
  59871. export class ArcTan2Block extends NodeMaterialBlock {
  59872. /**
  59873. * Creates a new ArcTan2Block
  59874. * @param name defines the block name
  59875. */
  59876. constructor(name: string);
  59877. /**
  59878. * Gets the current class name
  59879. * @returns the class name
  59880. */
  59881. getClassName(): string;
  59882. /**
  59883. * Gets the x operand input component
  59884. */
  59885. get x(): NodeMaterialConnectionPoint;
  59886. /**
  59887. * Gets the y operand input component
  59888. */
  59889. get y(): NodeMaterialConnectionPoint;
  59890. /**
  59891. * Gets the output component
  59892. */
  59893. get output(): NodeMaterialConnectionPoint;
  59894. protected _buildBlock(state: NodeMaterialBuildState): this;
  59895. }
  59896. }
  59897. declare module BABYLON {
  59898. /**
  59899. * Block used to smooth step a value
  59900. */
  59901. export class SmoothStepBlock extends NodeMaterialBlock {
  59902. /**
  59903. * Creates a new SmoothStepBlock
  59904. * @param name defines the block name
  59905. */
  59906. constructor(name: string);
  59907. /**
  59908. * Gets the current class name
  59909. * @returns the class name
  59910. */
  59911. getClassName(): string;
  59912. /**
  59913. * Gets the value operand input component
  59914. */
  59915. get value(): NodeMaterialConnectionPoint;
  59916. /**
  59917. * Gets the first edge operand input component
  59918. */
  59919. get edge0(): NodeMaterialConnectionPoint;
  59920. /**
  59921. * Gets the second edge operand input component
  59922. */
  59923. get edge1(): NodeMaterialConnectionPoint;
  59924. /**
  59925. * Gets the output component
  59926. */
  59927. get output(): NodeMaterialConnectionPoint;
  59928. protected _buildBlock(state: NodeMaterialBuildState): this;
  59929. }
  59930. }
  59931. declare module BABYLON {
  59932. /**
  59933. * Block used to get the reciprocal (1 / x) of a value
  59934. */
  59935. export class ReciprocalBlock extends NodeMaterialBlock {
  59936. /**
  59937. * Creates a new ReciprocalBlock
  59938. * @param name defines the block name
  59939. */
  59940. constructor(name: string);
  59941. /**
  59942. * Gets the current class name
  59943. * @returns the class name
  59944. */
  59945. getClassName(): string;
  59946. /**
  59947. * Gets the input component
  59948. */
  59949. get input(): NodeMaterialConnectionPoint;
  59950. /**
  59951. * Gets the output component
  59952. */
  59953. get output(): NodeMaterialConnectionPoint;
  59954. protected _buildBlock(state: NodeMaterialBuildState): this;
  59955. }
  59956. }
  59957. declare module BABYLON {
  59958. /**
  59959. * Block used to replace a color by another one
  59960. */
  59961. export class ReplaceColorBlock extends NodeMaterialBlock {
  59962. /**
  59963. * Creates a new ReplaceColorBlock
  59964. * @param name defines the block name
  59965. */
  59966. constructor(name: string);
  59967. /**
  59968. * Gets the current class name
  59969. * @returns the class name
  59970. */
  59971. getClassName(): string;
  59972. /**
  59973. * Gets the value input component
  59974. */
  59975. get value(): NodeMaterialConnectionPoint;
  59976. /**
  59977. * Gets the reference input component
  59978. */
  59979. get reference(): NodeMaterialConnectionPoint;
  59980. /**
  59981. * Gets the distance input component
  59982. */
  59983. get distance(): NodeMaterialConnectionPoint;
  59984. /**
  59985. * Gets the replacement input component
  59986. */
  59987. get replacement(): NodeMaterialConnectionPoint;
  59988. /**
  59989. * Gets the output component
  59990. */
  59991. get output(): NodeMaterialConnectionPoint;
  59992. protected _buildBlock(state: NodeMaterialBuildState): this;
  59993. }
  59994. }
  59995. declare module BABYLON {
  59996. /**
  59997. * Block used to posterize a value
  59998. * @see https://en.wikipedia.org/wiki/Posterization
  59999. */
  60000. export class PosterizeBlock extends NodeMaterialBlock {
  60001. /**
  60002. * Creates a new PosterizeBlock
  60003. * @param name defines the block name
  60004. */
  60005. constructor(name: string);
  60006. /**
  60007. * Gets the current class name
  60008. * @returns the class name
  60009. */
  60010. getClassName(): string;
  60011. /**
  60012. * Gets the value input component
  60013. */
  60014. get value(): NodeMaterialConnectionPoint;
  60015. /**
  60016. * Gets the steps input component
  60017. */
  60018. get steps(): NodeMaterialConnectionPoint;
  60019. /**
  60020. * Gets the output component
  60021. */
  60022. get output(): NodeMaterialConnectionPoint;
  60023. protected _buildBlock(state: NodeMaterialBuildState): this;
  60024. }
  60025. }
  60026. declare module BABYLON {
  60027. /**
  60028. * Operations supported by the Wave block
  60029. */
  60030. export enum WaveBlockKind {
  60031. /** SawTooth */
  60032. SawTooth = 0,
  60033. /** Square */
  60034. Square = 1,
  60035. /** Triangle */
  60036. Triangle = 2
  60037. }
  60038. /**
  60039. * Block used to apply wave operation to floats
  60040. */
  60041. export class WaveBlock extends NodeMaterialBlock {
  60042. /**
  60043. * Gets or sets the kibnd of wave to be applied by the block
  60044. */
  60045. kind: WaveBlockKind;
  60046. /**
  60047. * Creates a new WaveBlock
  60048. * @param name defines the block name
  60049. */
  60050. constructor(name: string);
  60051. /**
  60052. * Gets the current class name
  60053. * @returns the class name
  60054. */
  60055. getClassName(): string;
  60056. /**
  60057. * Gets the input component
  60058. */
  60059. get input(): NodeMaterialConnectionPoint;
  60060. /**
  60061. * Gets the output component
  60062. */
  60063. get output(): NodeMaterialConnectionPoint;
  60064. protected _buildBlock(state: NodeMaterialBuildState): this;
  60065. serialize(): any;
  60066. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60067. }
  60068. }
  60069. declare module BABYLON {
  60070. /**
  60071. * Class used to store a color step for the GradientBlock
  60072. */
  60073. export class GradientBlockColorStep {
  60074. /**
  60075. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60076. */
  60077. step: number;
  60078. /**
  60079. * Gets or sets the color associated with this step
  60080. */
  60081. color: Color3;
  60082. /**
  60083. * Creates a new GradientBlockColorStep
  60084. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60085. * @param color defines the color associated with this step
  60086. */
  60087. constructor(
  60088. /**
  60089. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60090. */
  60091. step: number,
  60092. /**
  60093. * Gets or sets the color associated with this step
  60094. */
  60095. color: Color3);
  60096. }
  60097. /**
  60098. * Block used to return a color from a gradient based on an input value between 0 and 1
  60099. */
  60100. export class GradientBlock extends NodeMaterialBlock {
  60101. /**
  60102. * Gets or sets the list of color steps
  60103. */
  60104. colorSteps: GradientBlockColorStep[];
  60105. /**
  60106. * Creates a new GradientBlock
  60107. * @param name defines the block name
  60108. */
  60109. constructor(name: string);
  60110. /**
  60111. * Gets the current class name
  60112. * @returns the class name
  60113. */
  60114. getClassName(): string;
  60115. /**
  60116. * Gets the gradient input component
  60117. */
  60118. get gradient(): NodeMaterialConnectionPoint;
  60119. /**
  60120. * Gets the output component
  60121. */
  60122. get output(): NodeMaterialConnectionPoint;
  60123. private _writeColorConstant;
  60124. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60125. serialize(): any;
  60126. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60127. protected _dumpPropertiesCode(): string;
  60128. }
  60129. }
  60130. declare module BABYLON {
  60131. /**
  60132. * Block used to normalize lerp between 2 values
  60133. */
  60134. export class NLerpBlock extends NodeMaterialBlock {
  60135. /**
  60136. * Creates a new NLerpBlock
  60137. * @param name defines the block name
  60138. */
  60139. constructor(name: string);
  60140. /**
  60141. * Gets the current class name
  60142. * @returns the class name
  60143. */
  60144. getClassName(): string;
  60145. /**
  60146. * Gets the left operand input component
  60147. */
  60148. get left(): NodeMaterialConnectionPoint;
  60149. /**
  60150. * Gets the right operand input component
  60151. */
  60152. get right(): NodeMaterialConnectionPoint;
  60153. /**
  60154. * Gets the gradient operand input component
  60155. */
  60156. get gradient(): NodeMaterialConnectionPoint;
  60157. /**
  60158. * Gets the output component
  60159. */
  60160. get output(): NodeMaterialConnectionPoint;
  60161. protected _buildBlock(state: NodeMaterialBuildState): this;
  60162. }
  60163. }
  60164. declare module BABYLON {
  60165. /**
  60166. * block used to Generate a Worley Noise 3D Noise Pattern
  60167. */
  60168. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60169. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60170. manhattanDistance: boolean;
  60171. /**
  60172. * Creates a new WorleyNoise3DBlock
  60173. * @param name defines the block name
  60174. */
  60175. constructor(name: string);
  60176. /**
  60177. * Gets the current class name
  60178. * @returns the class name
  60179. */
  60180. getClassName(): string;
  60181. /**
  60182. * Gets the seed input component
  60183. */
  60184. get seed(): NodeMaterialConnectionPoint;
  60185. /**
  60186. * Gets the jitter input component
  60187. */
  60188. get jitter(): NodeMaterialConnectionPoint;
  60189. /**
  60190. * Gets the output component
  60191. */
  60192. get output(): NodeMaterialConnectionPoint;
  60193. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60194. /**
  60195. * Exposes the properties to the UI?
  60196. */
  60197. protected _dumpPropertiesCode(): string;
  60198. /**
  60199. * Exposes the properties to the Seralize?
  60200. */
  60201. serialize(): any;
  60202. /**
  60203. * Exposes the properties to the deseralize?
  60204. */
  60205. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60206. }
  60207. }
  60208. declare module BABYLON {
  60209. /**
  60210. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60211. */
  60212. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60213. /**
  60214. * Creates a new SimplexPerlin3DBlock
  60215. * @param name defines the block name
  60216. */
  60217. constructor(name: string);
  60218. /**
  60219. * Gets the current class name
  60220. * @returns the class name
  60221. */
  60222. getClassName(): string;
  60223. /**
  60224. * Gets the seed operand input component
  60225. */
  60226. get seed(): NodeMaterialConnectionPoint;
  60227. /**
  60228. * Gets the output component
  60229. */
  60230. get output(): NodeMaterialConnectionPoint;
  60231. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60232. }
  60233. }
  60234. declare module BABYLON {
  60235. /**
  60236. * Block used to blend normals
  60237. */
  60238. export class NormalBlendBlock extends NodeMaterialBlock {
  60239. /**
  60240. * Creates a new NormalBlendBlock
  60241. * @param name defines the block name
  60242. */
  60243. constructor(name: string);
  60244. /**
  60245. * Gets the current class name
  60246. * @returns the class name
  60247. */
  60248. getClassName(): string;
  60249. /**
  60250. * Gets the first input component
  60251. */
  60252. get normalMap0(): NodeMaterialConnectionPoint;
  60253. /**
  60254. * Gets the second input component
  60255. */
  60256. get normalMap1(): NodeMaterialConnectionPoint;
  60257. /**
  60258. * Gets the output component
  60259. */
  60260. get output(): NodeMaterialConnectionPoint;
  60261. protected _buildBlock(state: NodeMaterialBuildState): this;
  60262. }
  60263. }
  60264. declare module BABYLON {
  60265. /**
  60266. * Block used to rotate a 2d vector by a given angle
  60267. */
  60268. export class Rotate2dBlock extends NodeMaterialBlock {
  60269. /**
  60270. * Creates a new Rotate2dBlock
  60271. * @param name defines the block name
  60272. */
  60273. constructor(name: string);
  60274. /**
  60275. * Gets the current class name
  60276. * @returns the class name
  60277. */
  60278. getClassName(): string;
  60279. /**
  60280. * Gets the input vector
  60281. */
  60282. get input(): NodeMaterialConnectionPoint;
  60283. /**
  60284. * Gets the input angle
  60285. */
  60286. get angle(): NodeMaterialConnectionPoint;
  60287. /**
  60288. * Gets the output component
  60289. */
  60290. get output(): NodeMaterialConnectionPoint;
  60291. autoConfigure(material: NodeMaterial): void;
  60292. protected _buildBlock(state: NodeMaterialBuildState): this;
  60293. }
  60294. }
  60295. declare module BABYLON {
  60296. /**
  60297. * Block used to get the reflected vector from a direction and a normal
  60298. */
  60299. export class ReflectBlock extends NodeMaterialBlock {
  60300. /**
  60301. * Creates a new ReflectBlock
  60302. * @param name defines the block name
  60303. */
  60304. constructor(name: string);
  60305. /**
  60306. * Gets the current class name
  60307. * @returns the class name
  60308. */
  60309. getClassName(): string;
  60310. /**
  60311. * Gets the incident component
  60312. */
  60313. get incident(): NodeMaterialConnectionPoint;
  60314. /**
  60315. * Gets the normal component
  60316. */
  60317. get normal(): NodeMaterialConnectionPoint;
  60318. /**
  60319. * Gets the output component
  60320. */
  60321. get output(): NodeMaterialConnectionPoint;
  60322. protected _buildBlock(state: NodeMaterialBuildState): this;
  60323. }
  60324. }
  60325. declare module BABYLON {
  60326. /**
  60327. * Block used to get the refracted vector from a direction and a normal
  60328. */
  60329. export class RefractBlock extends NodeMaterialBlock {
  60330. /**
  60331. * Creates a new RefractBlock
  60332. * @param name defines the block name
  60333. */
  60334. constructor(name: string);
  60335. /**
  60336. * Gets the current class name
  60337. * @returns the class name
  60338. */
  60339. getClassName(): string;
  60340. /**
  60341. * Gets the incident component
  60342. */
  60343. get incident(): NodeMaterialConnectionPoint;
  60344. /**
  60345. * Gets the normal component
  60346. */
  60347. get normal(): NodeMaterialConnectionPoint;
  60348. /**
  60349. * Gets the index of refraction component
  60350. */
  60351. get ior(): NodeMaterialConnectionPoint;
  60352. /**
  60353. * Gets the output component
  60354. */
  60355. get output(): NodeMaterialConnectionPoint;
  60356. protected _buildBlock(state: NodeMaterialBuildState): this;
  60357. }
  60358. }
  60359. declare module BABYLON {
  60360. /**
  60361. * Block used to desaturate a color
  60362. */
  60363. export class DesaturateBlock extends NodeMaterialBlock {
  60364. /**
  60365. * Creates a new DesaturateBlock
  60366. * @param name defines the block name
  60367. */
  60368. constructor(name: string);
  60369. /**
  60370. * Gets the current class name
  60371. * @returns the class name
  60372. */
  60373. getClassName(): string;
  60374. /**
  60375. * Gets the color operand input component
  60376. */
  60377. get color(): NodeMaterialConnectionPoint;
  60378. /**
  60379. * Gets the level operand input component
  60380. */
  60381. get level(): NodeMaterialConnectionPoint;
  60382. /**
  60383. * Gets the output component
  60384. */
  60385. get output(): NodeMaterialConnectionPoint;
  60386. protected _buildBlock(state: NodeMaterialBuildState): this;
  60387. }
  60388. }
  60389. declare module BABYLON {
  60390. /**
  60391. * Effect Render Options
  60392. */
  60393. export interface IEffectRendererOptions {
  60394. /**
  60395. * Defines the vertices positions.
  60396. */
  60397. positions?: number[];
  60398. /**
  60399. * Defines the indices.
  60400. */
  60401. indices?: number[];
  60402. }
  60403. /**
  60404. * Helper class to render one or more effects
  60405. */
  60406. export class EffectRenderer {
  60407. private engine;
  60408. private static _DefaultOptions;
  60409. private _vertexBuffers;
  60410. private _indexBuffer;
  60411. private _ringBufferIndex;
  60412. private _ringScreenBuffer;
  60413. private _fullscreenViewport;
  60414. private _getNextFrameBuffer;
  60415. /**
  60416. * Creates an effect renderer
  60417. * @param engine the engine to use for rendering
  60418. * @param options defines the options of the effect renderer
  60419. */
  60420. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60421. /**
  60422. * Sets the current viewport in normalized coordinates 0-1
  60423. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60424. */
  60425. setViewport(viewport?: Viewport): void;
  60426. /**
  60427. * Binds the embedded attributes buffer to the effect.
  60428. * @param effect Defines the effect to bind the attributes for
  60429. */
  60430. bindBuffers(effect: Effect): void;
  60431. /**
  60432. * Sets the current effect wrapper to use during draw.
  60433. * The effect needs to be ready before calling this api.
  60434. * This also sets the default full screen position attribute.
  60435. * @param effectWrapper Defines the effect to draw with
  60436. */
  60437. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60438. /**
  60439. * Draws a full screen quad.
  60440. */
  60441. draw(): void;
  60442. /**
  60443. * renders one or more effects to a specified texture
  60444. * @param effectWrappers list of effects to renderer
  60445. * @param outputTexture texture to draw to, if null it will render to the screen
  60446. */
  60447. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60448. /**
  60449. * Disposes of the effect renderer
  60450. */
  60451. dispose(): void;
  60452. }
  60453. /**
  60454. * Options to create an EffectWrapper
  60455. */
  60456. interface EffectWrapperCreationOptions {
  60457. /**
  60458. * Engine to use to create the effect
  60459. */
  60460. engine: ThinEngine;
  60461. /**
  60462. * Fragment shader for the effect
  60463. */
  60464. fragmentShader: string;
  60465. /**
  60466. * Vertex shader for the effect
  60467. */
  60468. vertexShader?: string;
  60469. /**
  60470. * Attributes to use in the shader
  60471. */
  60472. attributeNames?: Array<string>;
  60473. /**
  60474. * Uniforms to use in the shader
  60475. */
  60476. uniformNames?: Array<string>;
  60477. /**
  60478. * Texture sampler names to use in the shader
  60479. */
  60480. samplerNames?: Array<string>;
  60481. /**
  60482. * The friendly name of the effect displayed in Spector.
  60483. */
  60484. name?: string;
  60485. }
  60486. /**
  60487. * Wraps an effect to be used for rendering
  60488. */
  60489. export class EffectWrapper {
  60490. /**
  60491. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60492. */
  60493. onApplyObservable: Observable<{}>;
  60494. /**
  60495. * The underlying effect
  60496. */
  60497. effect: Effect;
  60498. /**
  60499. * Creates an effect to be renderer
  60500. * @param creationOptions options to create the effect
  60501. */
  60502. constructor(creationOptions: EffectWrapperCreationOptions);
  60503. /**
  60504. * Disposes of the effect wrapper
  60505. */
  60506. dispose(): void;
  60507. }
  60508. }
  60509. declare module BABYLON {
  60510. /**
  60511. * Helper class to push actions to a pool of workers.
  60512. */
  60513. export class WorkerPool implements IDisposable {
  60514. private _workerInfos;
  60515. private _pendingActions;
  60516. /**
  60517. * Constructor
  60518. * @param workers Array of workers to use for actions
  60519. */
  60520. constructor(workers: Array<Worker>);
  60521. /**
  60522. * Terminates all workers and clears any pending actions.
  60523. */
  60524. dispose(): void;
  60525. /**
  60526. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60527. * pended until a worker has completed its action.
  60528. * @param action The action to perform. Call onComplete when the action is complete.
  60529. */
  60530. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60531. private _execute;
  60532. }
  60533. }
  60534. declare module BABYLON {
  60535. /**
  60536. * Configuration for Draco compression
  60537. */
  60538. export interface IDracoCompressionConfiguration {
  60539. /**
  60540. * Configuration for the decoder.
  60541. */
  60542. decoder: {
  60543. /**
  60544. * The url to the WebAssembly module.
  60545. */
  60546. wasmUrl?: string;
  60547. /**
  60548. * The url to the WebAssembly binary.
  60549. */
  60550. wasmBinaryUrl?: string;
  60551. /**
  60552. * The url to the fallback JavaScript module.
  60553. */
  60554. fallbackUrl?: string;
  60555. };
  60556. }
  60557. /**
  60558. * Draco compression (https://google.github.io/draco/)
  60559. *
  60560. * This class wraps the Draco module.
  60561. *
  60562. * **Encoder**
  60563. *
  60564. * The encoder is not currently implemented.
  60565. *
  60566. * **Decoder**
  60567. *
  60568. * 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.
  60569. *
  60570. * To update the configuration, use the following code:
  60571. * ```javascript
  60572. * DracoCompression.Configuration = {
  60573. * decoder: {
  60574. * wasmUrl: "<url to the WebAssembly library>",
  60575. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60576. * fallbackUrl: "<url to the fallback JavaScript library>",
  60577. * }
  60578. * };
  60579. * ```
  60580. *
  60581. * 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.
  60582. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60583. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60584. *
  60585. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60586. * ```javascript
  60587. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60588. * ```
  60589. *
  60590. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60591. */
  60592. export class DracoCompression implements IDisposable {
  60593. private _workerPoolPromise?;
  60594. private _decoderModulePromise?;
  60595. /**
  60596. * The configuration. Defaults to the following urls:
  60597. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60598. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60599. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60600. */
  60601. static Configuration: IDracoCompressionConfiguration;
  60602. /**
  60603. * Returns true if the decoder configuration is available.
  60604. */
  60605. static get DecoderAvailable(): boolean;
  60606. /**
  60607. * Default number of workers to create when creating the draco compression object.
  60608. */
  60609. static DefaultNumWorkers: number;
  60610. private static GetDefaultNumWorkers;
  60611. private static _Default;
  60612. /**
  60613. * Default instance for the draco compression object.
  60614. */
  60615. static get Default(): DracoCompression;
  60616. /**
  60617. * Constructor
  60618. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60619. */
  60620. constructor(numWorkers?: number);
  60621. /**
  60622. * Stop all async operations and release resources.
  60623. */
  60624. dispose(): void;
  60625. /**
  60626. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60627. * @returns a promise that resolves when ready
  60628. */
  60629. whenReadyAsync(): Promise<void>;
  60630. /**
  60631. * Decode Draco compressed mesh data to vertex data.
  60632. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60633. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60634. * @returns A promise that resolves with the decoded vertex data
  60635. */
  60636. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60637. [kind: string]: number;
  60638. }): Promise<VertexData>;
  60639. }
  60640. }
  60641. declare module BABYLON {
  60642. /**
  60643. * Class for building Constructive Solid Geometry
  60644. */
  60645. export class CSG {
  60646. private polygons;
  60647. /**
  60648. * The world matrix
  60649. */
  60650. matrix: Matrix;
  60651. /**
  60652. * Stores the position
  60653. */
  60654. position: Vector3;
  60655. /**
  60656. * Stores the rotation
  60657. */
  60658. rotation: Vector3;
  60659. /**
  60660. * Stores the rotation quaternion
  60661. */
  60662. rotationQuaternion: Nullable<Quaternion>;
  60663. /**
  60664. * Stores the scaling vector
  60665. */
  60666. scaling: Vector3;
  60667. /**
  60668. * Convert the Mesh to CSG
  60669. * @param mesh The Mesh to convert to CSG
  60670. * @returns A new CSG from the Mesh
  60671. */
  60672. static FromMesh(mesh: Mesh): CSG;
  60673. /**
  60674. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60675. * @param polygons Polygons used to construct a CSG solid
  60676. */
  60677. private static FromPolygons;
  60678. /**
  60679. * Clones, or makes a deep copy, of the CSG
  60680. * @returns A new CSG
  60681. */
  60682. clone(): CSG;
  60683. /**
  60684. * Unions this CSG with another CSG
  60685. * @param csg The CSG to union against this CSG
  60686. * @returns The unioned CSG
  60687. */
  60688. union(csg: CSG): CSG;
  60689. /**
  60690. * Unions this CSG with another CSG in place
  60691. * @param csg The CSG to union against this CSG
  60692. */
  60693. unionInPlace(csg: CSG): void;
  60694. /**
  60695. * Subtracts this CSG with another CSG
  60696. * @param csg The CSG to subtract against this CSG
  60697. * @returns A new CSG
  60698. */
  60699. subtract(csg: CSG): CSG;
  60700. /**
  60701. * Subtracts this CSG with another CSG in place
  60702. * @param csg The CSG to subtact against this CSG
  60703. */
  60704. subtractInPlace(csg: CSG): void;
  60705. /**
  60706. * Intersect this CSG with another CSG
  60707. * @param csg The CSG to intersect against this CSG
  60708. * @returns A new CSG
  60709. */
  60710. intersect(csg: CSG): CSG;
  60711. /**
  60712. * Intersects this CSG with another CSG in place
  60713. * @param csg The CSG to intersect against this CSG
  60714. */
  60715. intersectInPlace(csg: CSG): void;
  60716. /**
  60717. * Return a new CSG solid with solid and empty space switched. This solid is
  60718. * not modified.
  60719. * @returns A new CSG solid with solid and empty space switched
  60720. */
  60721. inverse(): CSG;
  60722. /**
  60723. * Inverses the CSG in place
  60724. */
  60725. inverseInPlace(): void;
  60726. /**
  60727. * This is used to keep meshes transformations so they can be restored
  60728. * when we build back a Babylon Mesh
  60729. * NB : All CSG operations are performed in world coordinates
  60730. * @param csg The CSG to copy the transform attributes from
  60731. * @returns This CSG
  60732. */
  60733. copyTransformAttributes(csg: CSG): CSG;
  60734. /**
  60735. * Build Raw mesh from CSG
  60736. * Coordinates here are in world space
  60737. * @param name The name of the mesh geometry
  60738. * @param scene The Scene
  60739. * @param keepSubMeshes Specifies if the submeshes should be kept
  60740. * @returns A new Mesh
  60741. */
  60742. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60743. /**
  60744. * Build Mesh from CSG taking material and transforms into account
  60745. * @param name The name of the Mesh
  60746. * @param material The material of the Mesh
  60747. * @param scene The Scene
  60748. * @param keepSubMeshes Specifies if submeshes should be kept
  60749. * @returns The new Mesh
  60750. */
  60751. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60752. }
  60753. }
  60754. declare module BABYLON {
  60755. /**
  60756. * Class used to create a trail following a mesh
  60757. */
  60758. export class TrailMesh extends Mesh {
  60759. private _generator;
  60760. private _autoStart;
  60761. private _running;
  60762. private _diameter;
  60763. private _length;
  60764. private _sectionPolygonPointsCount;
  60765. private _sectionVectors;
  60766. private _sectionNormalVectors;
  60767. private _beforeRenderObserver;
  60768. /**
  60769. * @constructor
  60770. * @param name The value used by scene.getMeshByName() to do a lookup.
  60771. * @param generator The mesh or transform node to generate a trail.
  60772. * @param scene The scene to add this mesh to.
  60773. * @param diameter Diameter of trailing mesh. Default is 1.
  60774. * @param length Length of trailing mesh. Default is 60.
  60775. * @param autoStart Automatically start trailing mesh. Default true.
  60776. */
  60777. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60778. /**
  60779. * "TrailMesh"
  60780. * @returns "TrailMesh"
  60781. */
  60782. getClassName(): string;
  60783. private _createMesh;
  60784. /**
  60785. * Start trailing mesh.
  60786. */
  60787. start(): void;
  60788. /**
  60789. * Stop trailing mesh.
  60790. */
  60791. stop(): void;
  60792. /**
  60793. * Update trailing mesh geometry.
  60794. */
  60795. update(): void;
  60796. /**
  60797. * Returns a new TrailMesh object.
  60798. * @param name is a string, the name given to the new mesh
  60799. * @param newGenerator use new generator object for cloned trail mesh
  60800. * @returns a new mesh
  60801. */
  60802. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60803. /**
  60804. * Serializes this trail mesh
  60805. * @param serializationObject object to write serialization to
  60806. */
  60807. serialize(serializationObject: any): void;
  60808. /**
  60809. * Parses a serialized trail mesh
  60810. * @param parsedMesh the serialized mesh
  60811. * @param scene the scene to create the trail mesh in
  60812. * @returns the created trail mesh
  60813. */
  60814. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60815. }
  60816. }
  60817. declare module BABYLON {
  60818. /**
  60819. * Class containing static functions to help procedurally build meshes
  60820. */
  60821. export class TiledBoxBuilder {
  60822. /**
  60823. * Creates a box mesh
  60824. * 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)
  60825. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60827. * * 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
  60828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60829. * @param name defines the name of the mesh
  60830. * @param options defines the options used to create the mesh
  60831. * @param scene defines the hosting scene
  60832. * @returns the box mesh
  60833. */
  60834. static CreateTiledBox(name: string, options: {
  60835. pattern?: number;
  60836. width?: number;
  60837. height?: number;
  60838. depth?: number;
  60839. tileSize?: number;
  60840. tileWidth?: number;
  60841. tileHeight?: number;
  60842. alignHorizontal?: number;
  60843. alignVertical?: number;
  60844. faceUV?: Vector4[];
  60845. faceColors?: Color4[];
  60846. sideOrientation?: number;
  60847. updatable?: boolean;
  60848. }, scene?: Nullable<Scene>): Mesh;
  60849. }
  60850. }
  60851. declare module BABYLON {
  60852. /**
  60853. * Class containing static functions to help procedurally build meshes
  60854. */
  60855. export class TorusKnotBuilder {
  60856. /**
  60857. * Creates a torus knot mesh
  60858. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60859. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60860. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60861. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60863. * * 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
  60864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60865. * @param name defines the name of the mesh
  60866. * @param options defines the options used to create the mesh
  60867. * @param scene defines the hosting scene
  60868. * @returns the torus knot mesh
  60869. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60870. */
  60871. static CreateTorusKnot(name: string, options: {
  60872. radius?: number;
  60873. tube?: number;
  60874. radialSegments?: number;
  60875. tubularSegments?: number;
  60876. p?: number;
  60877. q?: number;
  60878. updatable?: boolean;
  60879. sideOrientation?: number;
  60880. frontUVs?: Vector4;
  60881. backUVs?: Vector4;
  60882. }, scene: any): Mesh;
  60883. }
  60884. }
  60885. declare module BABYLON {
  60886. /**
  60887. * Polygon
  60888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60889. */
  60890. export class Polygon {
  60891. /**
  60892. * Creates a rectangle
  60893. * @param xmin bottom X coord
  60894. * @param ymin bottom Y coord
  60895. * @param xmax top X coord
  60896. * @param ymax top Y coord
  60897. * @returns points that make the resulting rectation
  60898. */
  60899. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60900. /**
  60901. * Creates a circle
  60902. * @param radius radius of circle
  60903. * @param cx scale in x
  60904. * @param cy scale in y
  60905. * @param numberOfSides number of sides that make up the circle
  60906. * @returns points that make the resulting circle
  60907. */
  60908. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60909. /**
  60910. * Creates a polygon from input string
  60911. * @param input Input polygon data
  60912. * @returns the parsed points
  60913. */
  60914. static Parse(input: string): Vector2[];
  60915. /**
  60916. * Starts building a polygon from x and y coordinates
  60917. * @param x x coordinate
  60918. * @param y y coordinate
  60919. * @returns the started path2
  60920. */
  60921. static StartingAt(x: number, y: number): Path2;
  60922. }
  60923. /**
  60924. * Builds a polygon
  60925. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60926. */
  60927. export class PolygonMeshBuilder {
  60928. private _points;
  60929. private _outlinepoints;
  60930. private _holes;
  60931. private _name;
  60932. private _scene;
  60933. private _epoints;
  60934. private _eholes;
  60935. private _addToepoint;
  60936. /**
  60937. * Babylon reference to the earcut plugin.
  60938. */
  60939. bjsEarcut: any;
  60940. /**
  60941. * Creates a PolygonMeshBuilder
  60942. * @param name name of the builder
  60943. * @param contours Path of the polygon
  60944. * @param scene scene to add to when creating the mesh
  60945. * @param earcutInjection can be used to inject your own earcut reference
  60946. */
  60947. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60948. /**
  60949. * Adds a whole within the polygon
  60950. * @param hole Array of points defining the hole
  60951. * @returns this
  60952. */
  60953. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60954. /**
  60955. * Creates the polygon
  60956. * @param updatable If the mesh should be updatable
  60957. * @param depth The depth of the mesh created
  60958. * @returns the created mesh
  60959. */
  60960. build(updatable?: boolean, depth?: number): Mesh;
  60961. /**
  60962. * Creates the polygon
  60963. * @param depth The depth of the mesh created
  60964. * @returns the created VertexData
  60965. */
  60966. buildVertexData(depth?: number): VertexData;
  60967. /**
  60968. * Adds a side to the polygon
  60969. * @param positions points that make the polygon
  60970. * @param normals normals of the polygon
  60971. * @param uvs uvs of the polygon
  60972. * @param indices indices of the polygon
  60973. * @param bounds bounds of the polygon
  60974. * @param points points of the polygon
  60975. * @param depth depth of the polygon
  60976. * @param flip flip of the polygon
  60977. */
  60978. private addSide;
  60979. }
  60980. }
  60981. declare module BABYLON {
  60982. /**
  60983. * Class containing static functions to help procedurally build meshes
  60984. */
  60985. export class PolygonBuilder {
  60986. /**
  60987. * Creates a polygon mesh
  60988. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60989. * * 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
  60990. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60992. * * 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)
  60993. * * Remember you can only change the shape positions, not their number when updating a polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  60998. * @returns the polygon mesh
  60999. */
  61000. static CreatePolygon(name: string, options: {
  61001. shape: Vector3[];
  61002. holes?: Vector3[][];
  61003. depth?: number;
  61004. faceUV?: Vector4[];
  61005. faceColors?: Color4[];
  61006. updatable?: boolean;
  61007. sideOrientation?: number;
  61008. frontUVs?: Vector4;
  61009. backUVs?: Vector4;
  61010. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61011. /**
  61012. * Creates an extruded polygon mesh, with depth in the Y direction.
  61013. * * 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)
  61014. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61015. * @param name defines the name of the mesh
  61016. * @param options defines the options used to create the mesh
  61017. * @param scene defines the hosting scene
  61018. * @param earcutInjection can be used to inject your own earcut reference
  61019. * @returns the polygon mesh
  61020. */
  61021. static ExtrudePolygon(name: string, options: {
  61022. shape: Vector3[];
  61023. holes?: Vector3[][];
  61024. depth?: number;
  61025. faceUV?: Vector4[];
  61026. faceColors?: Color4[];
  61027. updatable?: boolean;
  61028. sideOrientation?: number;
  61029. frontUVs?: Vector4;
  61030. backUVs?: Vector4;
  61031. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61032. }
  61033. }
  61034. declare module BABYLON {
  61035. /**
  61036. * Class containing static functions to help procedurally build meshes
  61037. */
  61038. export class LatheBuilder {
  61039. /**
  61040. * Creates lathe mesh.
  61041. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61042. * * 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
  61043. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61044. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61045. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61046. * * 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
  61047. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61048. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61053. * @param name defines the name of the mesh
  61054. * @param options defines the options used to create the mesh
  61055. * @param scene defines the hosting scene
  61056. * @returns the lathe mesh
  61057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61058. */
  61059. static CreateLathe(name: string, options: {
  61060. shape: Vector3[];
  61061. radius?: number;
  61062. tessellation?: number;
  61063. clip?: number;
  61064. arc?: number;
  61065. closed?: boolean;
  61066. updatable?: boolean;
  61067. sideOrientation?: number;
  61068. frontUVs?: Vector4;
  61069. backUVs?: Vector4;
  61070. cap?: number;
  61071. invertUV?: boolean;
  61072. }, scene?: Nullable<Scene>): Mesh;
  61073. }
  61074. }
  61075. declare module BABYLON {
  61076. /**
  61077. * Class containing static functions to help procedurally build meshes
  61078. */
  61079. export class TiledPlaneBuilder {
  61080. /**
  61081. * Creates a tiled plane mesh
  61082. * * The parameter `pattern` will, depending on value, do nothing or
  61083. * * * flip (reflect about central vertical) alternate tiles across and up
  61084. * * * flip every tile on alternate rows
  61085. * * * rotate (180 degs) alternate tiles across and up
  61086. * * * rotate every tile on alternate rows
  61087. * * * flip and rotate alternate tiles across and up
  61088. * * * flip and rotate every tile on alternate rows
  61089. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61090. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61091. * * 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
  61092. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61093. * * 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)
  61094. * * 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)
  61095. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61096. * @param name defines the name of the mesh
  61097. * @param options defines the options used to create the mesh
  61098. * @param scene defines the hosting scene
  61099. * @returns the box mesh
  61100. */
  61101. static CreateTiledPlane(name: string, options: {
  61102. pattern?: number;
  61103. tileSize?: number;
  61104. tileWidth?: number;
  61105. tileHeight?: number;
  61106. size?: number;
  61107. width?: number;
  61108. height?: number;
  61109. alignHorizontal?: number;
  61110. alignVertical?: number;
  61111. sideOrientation?: number;
  61112. frontUVs?: Vector4;
  61113. backUVs?: Vector4;
  61114. updatable?: boolean;
  61115. }, scene?: Nullable<Scene>): Mesh;
  61116. }
  61117. }
  61118. declare module BABYLON {
  61119. /**
  61120. * Class containing static functions to help procedurally build meshes
  61121. */
  61122. export class TubeBuilder {
  61123. /**
  61124. * Creates a tube mesh.
  61125. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61126. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61127. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61128. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61129. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61130. * * 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)
  61131. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61132. * * 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
  61133. * * 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
  61134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61135. * * 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
  61136. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61138. * @param name defines the name of the mesh
  61139. * @param options defines the options used to create the mesh
  61140. * @param scene defines the hosting scene
  61141. * @returns the tube mesh
  61142. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61143. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61144. */
  61145. static CreateTube(name: string, options: {
  61146. path: Vector3[];
  61147. radius?: number;
  61148. tessellation?: number;
  61149. radiusFunction?: {
  61150. (i: number, distance: number): number;
  61151. };
  61152. cap?: number;
  61153. arc?: number;
  61154. updatable?: boolean;
  61155. sideOrientation?: number;
  61156. frontUVs?: Vector4;
  61157. backUVs?: Vector4;
  61158. instance?: Mesh;
  61159. invertUV?: boolean;
  61160. }, scene?: Nullable<Scene>): Mesh;
  61161. }
  61162. }
  61163. declare module BABYLON {
  61164. /**
  61165. * Class containing static functions to help procedurally build meshes
  61166. */
  61167. export class IcoSphereBuilder {
  61168. /**
  61169. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61170. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61171. * * 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`)
  61172. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61173. * * 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
  61174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61175. * * 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
  61176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61177. * @param name defines the name of the mesh
  61178. * @param options defines the options used to create the mesh
  61179. * @param scene defines the hosting scene
  61180. * @returns the icosahedron mesh
  61181. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61182. */
  61183. static CreateIcoSphere(name: string, options: {
  61184. radius?: number;
  61185. radiusX?: number;
  61186. radiusY?: number;
  61187. radiusZ?: number;
  61188. flat?: boolean;
  61189. subdivisions?: number;
  61190. sideOrientation?: number;
  61191. frontUVs?: Vector4;
  61192. backUVs?: Vector4;
  61193. updatable?: boolean;
  61194. }, scene?: Nullable<Scene>): Mesh;
  61195. }
  61196. }
  61197. declare module BABYLON {
  61198. /**
  61199. * Class containing static functions to help procedurally build meshes
  61200. */
  61201. export class DecalBuilder {
  61202. /**
  61203. * Creates a decal mesh.
  61204. * 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
  61205. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61206. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61207. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61208. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61209. * @param name defines the name of the mesh
  61210. * @param sourceMesh defines the mesh where the decal must be applied
  61211. * @param options defines the options used to create the mesh
  61212. * @param scene defines the hosting scene
  61213. * @returns the decal mesh
  61214. * @see https://doc.babylonjs.com/how_to/decals
  61215. */
  61216. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61217. position?: Vector3;
  61218. normal?: Vector3;
  61219. size?: Vector3;
  61220. angle?: number;
  61221. }): Mesh;
  61222. }
  61223. }
  61224. declare module BABYLON {
  61225. /**
  61226. * Class containing static functions to help procedurally build meshes
  61227. */
  61228. export class MeshBuilder {
  61229. /**
  61230. * Creates a box mesh
  61231. * * The parameter `size` sets the size (float) of each box side (default 1)
  61232. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61233. * * 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)
  61234. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61238. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61239. * @param name defines the name of the mesh
  61240. * @param options defines the options used to create the mesh
  61241. * @param scene defines the hosting scene
  61242. * @returns the box mesh
  61243. */
  61244. static CreateBox(name: string, options: {
  61245. size?: number;
  61246. width?: number;
  61247. height?: number;
  61248. depth?: number;
  61249. faceUV?: Vector4[];
  61250. faceColors?: Color4[];
  61251. sideOrientation?: number;
  61252. frontUVs?: Vector4;
  61253. backUVs?: Vector4;
  61254. wrap?: boolean;
  61255. topBaseAt?: number;
  61256. bottomBaseAt?: number;
  61257. updatable?: boolean;
  61258. }, scene?: Nullable<Scene>): Mesh;
  61259. /**
  61260. * Creates a tiled box mesh
  61261. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61263. * @param name defines the name of the mesh
  61264. * @param options defines the options used to create the mesh
  61265. * @param scene defines the hosting scene
  61266. * @returns the tiled box mesh
  61267. */
  61268. static CreateTiledBox(name: string, options: {
  61269. pattern?: number;
  61270. size?: number;
  61271. width?: number;
  61272. height?: number;
  61273. depth: number;
  61274. tileSize?: number;
  61275. tileWidth?: number;
  61276. tileHeight?: number;
  61277. faceUV?: Vector4[];
  61278. faceColors?: Color4[];
  61279. alignHorizontal?: number;
  61280. alignVertical?: number;
  61281. sideOrientation?: number;
  61282. updatable?: boolean;
  61283. }, scene?: Nullable<Scene>): Mesh;
  61284. /**
  61285. * Creates a sphere mesh
  61286. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61287. * * 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`)
  61288. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61289. * * 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
  61290. * * 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)
  61291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61292. * * 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
  61293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61294. * @param name defines the name of the mesh
  61295. * @param options defines the options used to create the mesh
  61296. * @param scene defines the hosting scene
  61297. * @returns the sphere mesh
  61298. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61299. */
  61300. static CreateSphere(name: string, options: {
  61301. segments?: number;
  61302. diameter?: number;
  61303. diameterX?: number;
  61304. diameterY?: number;
  61305. diameterZ?: number;
  61306. arc?: number;
  61307. slice?: number;
  61308. sideOrientation?: number;
  61309. frontUVs?: Vector4;
  61310. backUVs?: Vector4;
  61311. updatable?: boolean;
  61312. }, scene?: Nullable<Scene>): Mesh;
  61313. /**
  61314. * Creates a plane polygonal mesh. By default, this is a disc
  61315. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61316. * * 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
  61317. * * 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
  61318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61319. * * 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
  61320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61321. * @param name defines the name of the mesh
  61322. * @param options defines the options used to create the mesh
  61323. * @param scene defines the hosting scene
  61324. * @returns the plane polygonal mesh
  61325. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61326. */
  61327. static CreateDisc(name: string, options: {
  61328. radius?: number;
  61329. tessellation?: number;
  61330. arc?: number;
  61331. updatable?: boolean;
  61332. sideOrientation?: number;
  61333. frontUVs?: Vector4;
  61334. backUVs?: Vector4;
  61335. }, scene?: Nullable<Scene>): Mesh;
  61336. /**
  61337. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61338. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61339. * * 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`)
  61340. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61341. * * 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
  61342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61345. * @param name defines the name of the mesh
  61346. * @param options defines the options used to create the mesh
  61347. * @param scene defines the hosting scene
  61348. * @returns the icosahedron mesh
  61349. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61350. */
  61351. static CreateIcoSphere(name: string, options: {
  61352. radius?: number;
  61353. radiusX?: number;
  61354. radiusY?: number;
  61355. radiusZ?: number;
  61356. flat?: boolean;
  61357. subdivisions?: number;
  61358. sideOrientation?: number;
  61359. frontUVs?: Vector4;
  61360. backUVs?: Vector4;
  61361. updatable?: boolean;
  61362. }, scene?: Nullable<Scene>): Mesh;
  61363. /**
  61364. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61365. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61366. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61367. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61368. * * 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
  61369. * * 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
  61370. * * 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
  61371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61372. * * 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
  61373. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61374. * * 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
  61375. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61376. * * 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
  61377. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61379. * @param name defines the name of the mesh
  61380. * @param options defines the options used to create the mesh
  61381. * @param scene defines the hosting scene
  61382. * @returns the ribbon mesh
  61383. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61384. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61385. */
  61386. static CreateRibbon(name: string, options: {
  61387. pathArray: Vector3[][];
  61388. closeArray?: boolean;
  61389. closePath?: boolean;
  61390. offset?: number;
  61391. updatable?: boolean;
  61392. sideOrientation?: number;
  61393. frontUVs?: Vector4;
  61394. backUVs?: Vector4;
  61395. instance?: Mesh;
  61396. invertUV?: boolean;
  61397. uvs?: Vector2[];
  61398. colors?: Color4[];
  61399. }, scene?: Nullable<Scene>): Mesh;
  61400. /**
  61401. * Creates a cylinder or a cone mesh
  61402. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61403. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61404. * * 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.
  61405. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61406. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61407. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61408. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61409. * * 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).
  61410. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61411. * * 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).
  61412. * * 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
  61413. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61414. * * 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
  61415. * * 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.
  61416. * * If `enclose` is false, a ring surface is one element.
  61417. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61418. * * 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
  61419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61420. * * 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
  61421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61422. * @param name defines the name of the mesh
  61423. * @param options defines the options used to create the mesh
  61424. * @param scene defines the hosting scene
  61425. * @returns the cylinder mesh
  61426. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61427. */
  61428. static CreateCylinder(name: string, options: {
  61429. height?: number;
  61430. diameterTop?: number;
  61431. diameterBottom?: number;
  61432. diameter?: number;
  61433. tessellation?: number;
  61434. subdivisions?: number;
  61435. arc?: number;
  61436. faceColors?: Color4[];
  61437. faceUV?: Vector4[];
  61438. updatable?: boolean;
  61439. hasRings?: boolean;
  61440. enclose?: boolean;
  61441. cap?: number;
  61442. sideOrientation?: number;
  61443. frontUVs?: Vector4;
  61444. backUVs?: Vector4;
  61445. }, scene?: Nullable<Scene>): Mesh;
  61446. /**
  61447. * Creates a torus mesh
  61448. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61449. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61450. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61452. * * 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
  61453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61454. * @param name defines the name of the mesh
  61455. * @param options defines the options used to create the mesh
  61456. * @param scene defines the hosting scene
  61457. * @returns the torus mesh
  61458. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61459. */
  61460. static CreateTorus(name: string, options: {
  61461. diameter?: number;
  61462. thickness?: number;
  61463. tessellation?: number;
  61464. updatable?: boolean;
  61465. sideOrientation?: number;
  61466. frontUVs?: Vector4;
  61467. backUVs?: Vector4;
  61468. }, scene?: Nullable<Scene>): Mesh;
  61469. /**
  61470. * Creates a torus knot mesh
  61471. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61472. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61473. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61474. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61476. * * 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
  61477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61478. * @param name defines the name of the mesh
  61479. * @param options defines the options used to create the mesh
  61480. * @param scene defines the hosting scene
  61481. * @returns the torus knot mesh
  61482. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61483. */
  61484. static CreateTorusKnot(name: string, options: {
  61485. radius?: number;
  61486. tube?: number;
  61487. radialSegments?: number;
  61488. tubularSegments?: number;
  61489. p?: number;
  61490. q?: number;
  61491. updatable?: boolean;
  61492. sideOrientation?: number;
  61493. frontUVs?: Vector4;
  61494. backUVs?: Vector4;
  61495. }, scene?: Nullable<Scene>): Mesh;
  61496. /**
  61497. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61498. * * 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
  61499. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61500. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61501. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61502. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61503. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61504. * * 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
  61505. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61508. * @param name defines the name of the new line system
  61509. * @param options defines the options used to create the line system
  61510. * @param scene defines the hosting scene
  61511. * @returns a new line system mesh
  61512. */
  61513. static CreateLineSystem(name: string, options: {
  61514. lines: Vector3[][];
  61515. updatable?: boolean;
  61516. instance?: Nullable<LinesMesh>;
  61517. colors?: Nullable<Color4[][]>;
  61518. useVertexAlpha?: boolean;
  61519. }, scene: Nullable<Scene>): LinesMesh;
  61520. /**
  61521. * Creates a line mesh
  61522. * 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
  61523. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61524. * * The parameter `points` is an array successive Vector3
  61525. * * 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
  61526. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61527. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61528. * * When updating an instance, remember that only point positions can change, not the number of points
  61529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61530. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61531. * @param name defines the name of the new line system
  61532. * @param options defines the options used to create the line system
  61533. * @param scene defines the hosting scene
  61534. * @returns a new line mesh
  61535. */
  61536. static CreateLines(name: string, options: {
  61537. points: Vector3[];
  61538. updatable?: boolean;
  61539. instance?: Nullable<LinesMesh>;
  61540. colors?: Color4[];
  61541. useVertexAlpha?: boolean;
  61542. }, scene?: Nullable<Scene>): LinesMesh;
  61543. /**
  61544. * Creates a dashed line mesh
  61545. * * 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
  61546. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61547. * * The parameter `points` is an array successive Vector3
  61548. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61549. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61550. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61551. * * 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
  61552. * * When updating an instance, remember that only point positions can change, not the number of points
  61553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61554. * @param name defines the name of the mesh
  61555. * @param options defines the options used to create the mesh
  61556. * @param scene defines the hosting scene
  61557. * @returns the dashed line mesh
  61558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61559. */
  61560. static CreateDashedLines(name: string, options: {
  61561. points: Vector3[];
  61562. dashSize?: number;
  61563. gapSize?: number;
  61564. dashNb?: number;
  61565. updatable?: boolean;
  61566. instance?: LinesMesh;
  61567. }, scene?: Nullable<Scene>): LinesMesh;
  61568. /**
  61569. * 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.
  61570. * * 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.
  61571. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61572. * * 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.
  61573. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61574. * * 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
  61575. * * 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
  61576. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61578. * * 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
  61579. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61581. * @param name defines the name of the mesh
  61582. * @param options defines the options used to create the mesh
  61583. * @param scene defines the hosting scene
  61584. * @returns the extruded shape mesh
  61585. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61587. */
  61588. static ExtrudeShape(name: string, options: {
  61589. shape: Vector3[];
  61590. path: Vector3[];
  61591. scale?: number;
  61592. rotation?: number;
  61593. cap?: number;
  61594. updatable?: boolean;
  61595. sideOrientation?: number;
  61596. frontUVs?: Vector4;
  61597. backUVs?: Vector4;
  61598. instance?: Mesh;
  61599. invertUV?: boolean;
  61600. }, scene?: Nullable<Scene>): Mesh;
  61601. /**
  61602. * Creates an custom extruded shape mesh.
  61603. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61604. * * 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.
  61605. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61606. * * 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
  61607. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61608. * * 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
  61609. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61610. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61611. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61612. * * 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
  61613. * * 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
  61614. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61616. * * 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
  61617. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61619. * @param name defines the name of the mesh
  61620. * @param options defines the options used to create the mesh
  61621. * @param scene defines the hosting scene
  61622. * @returns the custom extruded shape mesh
  61623. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61624. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61625. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61626. */
  61627. static ExtrudeShapeCustom(name: string, options: {
  61628. shape: Vector3[];
  61629. path: Vector3[];
  61630. scaleFunction?: any;
  61631. rotationFunction?: any;
  61632. ribbonCloseArray?: boolean;
  61633. ribbonClosePath?: boolean;
  61634. cap?: number;
  61635. updatable?: boolean;
  61636. sideOrientation?: number;
  61637. frontUVs?: Vector4;
  61638. backUVs?: Vector4;
  61639. instance?: Mesh;
  61640. invertUV?: boolean;
  61641. }, scene?: Nullable<Scene>): Mesh;
  61642. /**
  61643. * Creates lathe mesh.
  61644. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61645. * * 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
  61646. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61647. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61648. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61649. * * 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
  61650. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61651. * * 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
  61652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61653. * * 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
  61654. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61656. * @param name defines the name of the mesh
  61657. * @param options defines the options used to create the mesh
  61658. * @param scene defines the hosting scene
  61659. * @returns the lathe mesh
  61660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61661. */
  61662. static CreateLathe(name: string, options: {
  61663. shape: Vector3[];
  61664. radius?: number;
  61665. tessellation?: number;
  61666. clip?: number;
  61667. arc?: number;
  61668. closed?: boolean;
  61669. updatable?: boolean;
  61670. sideOrientation?: number;
  61671. frontUVs?: Vector4;
  61672. backUVs?: Vector4;
  61673. cap?: number;
  61674. invertUV?: boolean;
  61675. }, scene?: Nullable<Scene>): Mesh;
  61676. /**
  61677. * Creates a tiled plane mesh
  61678. * * You can set a limited pattern arrangement with the tiles
  61679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61680. * * 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
  61681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61682. * @param name defines the name of the mesh
  61683. * @param options defines the options used to create the mesh
  61684. * @param scene defines the hosting scene
  61685. * @returns the plane mesh
  61686. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61687. */
  61688. static CreateTiledPlane(name: string, options: {
  61689. pattern?: number;
  61690. tileSize?: number;
  61691. tileWidth?: number;
  61692. tileHeight?: number;
  61693. size?: number;
  61694. width?: number;
  61695. height?: number;
  61696. alignHorizontal?: number;
  61697. alignVertical?: number;
  61698. sideOrientation?: number;
  61699. frontUVs?: Vector4;
  61700. backUVs?: Vector4;
  61701. updatable?: boolean;
  61702. }, scene?: Nullable<Scene>): Mesh;
  61703. /**
  61704. * Creates a plane mesh
  61705. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61706. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61707. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61709. * * 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
  61710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61711. * @param name defines the name of the mesh
  61712. * @param options defines the options used to create the mesh
  61713. * @param scene defines the hosting scene
  61714. * @returns the plane mesh
  61715. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61716. */
  61717. static CreatePlane(name: string, options: {
  61718. size?: number;
  61719. width?: number;
  61720. height?: number;
  61721. sideOrientation?: number;
  61722. frontUVs?: Vector4;
  61723. backUVs?: Vector4;
  61724. updatable?: boolean;
  61725. sourcePlane?: Plane;
  61726. }, scene?: Nullable<Scene>): Mesh;
  61727. /**
  61728. * Creates a ground mesh
  61729. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61730. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61732. * @param name defines the name of the mesh
  61733. * @param options defines the options used to create the mesh
  61734. * @param scene defines the hosting scene
  61735. * @returns the ground mesh
  61736. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61737. */
  61738. static CreateGround(name: string, options: {
  61739. width?: number;
  61740. height?: number;
  61741. subdivisions?: number;
  61742. subdivisionsX?: number;
  61743. subdivisionsY?: number;
  61744. updatable?: boolean;
  61745. }, scene?: Nullable<Scene>): Mesh;
  61746. /**
  61747. * Creates a tiled ground mesh
  61748. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61749. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61750. * * 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
  61751. * * 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
  61752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61753. * @param name defines the name of the mesh
  61754. * @param options defines the options used to create the mesh
  61755. * @param scene defines the hosting scene
  61756. * @returns the tiled ground mesh
  61757. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61758. */
  61759. static CreateTiledGround(name: string, options: {
  61760. xmin: number;
  61761. zmin: number;
  61762. xmax: number;
  61763. zmax: number;
  61764. subdivisions?: {
  61765. w: number;
  61766. h: number;
  61767. };
  61768. precision?: {
  61769. w: number;
  61770. h: number;
  61771. };
  61772. updatable?: boolean;
  61773. }, scene?: Nullable<Scene>): Mesh;
  61774. /**
  61775. * Creates a ground mesh from a height map
  61776. * * The parameter `url` sets the URL of the height map image resource.
  61777. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61778. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61779. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61780. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61781. * * 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.
  61782. * * 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).
  61783. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61785. * @param name defines the name of the mesh
  61786. * @param url defines the url to the height map
  61787. * @param options defines the options used to create the mesh
  61788. * @param scene defines the hosting scene
  61789. * @returns the ground mesh
  61790. * @see https://doc.babylonjs.com/babylon101/height_map
  61791. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61792. */
  61793. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61794. width?: number;
  61795. height?: number;
  61796. subdivisions?: number;
  61797. minHeight?: number;
  61798. maxHeight?: number;
  61799. colorFilter?: Color3;
  61800. alphaFilter?: number;
  61801. updatable?: boolean;
  61802. onReady?: (mesh: GroundMesh) => void;
  61803. }, scene?: Nullable<Scene>): GroundMesh;
  61804. /**
  61805. * Creates a polygon mesh
  61806. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61807. * * 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
  61808. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61810. * * 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)
  61811. * * Remember you can only change the shape positions, not their number when updating a polygon
  61812. * @param name defines the name of the mesh
  61813. * @param options defines the options used to create the mesh
  61814. * @param scene defines the hosting scene
  61815. * @param earcutInjection can be used to inject your own earcut reference
  61816. * @returns the polygon mesh
  61817. */
  61818. static CreatePolygon(name: string, options: {
  61819. shape: Vector3[];
  61820. holes?: Vector3[][];
  61821. depth?: number;
  61822. faceUV?: Vector4[];
  61823. faceColors?: Color4[];
  61824. updatable?: boolean;
  61825. sideOrientation?: number;
  61826. frontUVs?: Vector4;
  61827. backUVs?: Vector4;
  61828. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61829. /**
  61830. * Creates an extruded polygon mesh, with depth in the Y direction.
  61831. * * 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)
  61832. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61833. * @param name defines the name of the mesh
  61834. * @param options defines the options used to create the mesh
  61835. * @param scene defines the hosting scene
  61836. * @param earcutInjection can be used to inject your own earcut reference
  61837. * @returns the polygon mesh
  61838. */
  61839. static ExtrudePolygon(name: string, options: {
  61840. shape: Vector3[];
  61841. holes?: Vector3[][];
  61842. depth?: number;
  61843. faceUV?: Vector4[];
  61844. faceColors?: Color4[];
  61845. updatable?: boolean;
  61846. sideOrientation?: number;
  61847. frontUVs?: Vector4;
  61848. backUVs?: Vector4;
  61849. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61850. /**
  61851. * Creates a tube mesh.
  61852. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61853. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61854. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61855. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61856. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61857. * * 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)
  61858. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61859. * * 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
  61860. * * 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
  61861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61862. * * 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
  61863. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61865. * @param name defines the name of the mesh
  61866. * @param options defines the options used to create the mesh
  61867. * @param scene defines the hosting scene
  61868. * @returns the tube mesh
  61869. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61870. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61871. */
  61872. static CreateTube(name: string, options: {
  61873. path: Vector3[];
  61874. radius?: number;
  61875. tessellation?: number;
  61876. radiusFunction?: {
  61877. (i: number, distance: number): number;
  61878. };
  61879. cap?: number;
  61880. arc?: number;
  61881. updatable?: boolean;
  61882. sideOrientation?: number;
  61883. frontUVs?: Vector4;
  61884. backUVs?: Vector4;
  61885. instance?: Mesh;
  61886. invertUV?: boolean;
  61887. }, scene?: Nullable<Scene>): Mesh;
  61888. /**
  61889. * Creates a polyhedron mesh
  61890. * * 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
  61891. * * The parameter `size` (positive float, default 1) sets the polygon size
  61892. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61893. * * 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`
  61894. * * 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
  61895. * * 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)`)
  61896. * * 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
  61897. * * 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
  61898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61899. * * 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
  61900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61901. * @param name defines the name of the mesh
  61902. * @param options defines the options used to create the mesh
  61903. * @param scene defines the hosting scene
  61904. * @returns the polyhedron mesh
  61905. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61906. */
  61907. static CreatePolyhedron(name: string, options: {
  61908. type?: number;
  61909. size?: number;
  61910. sizeX?: number;
  61911. sizeY?: number;
  61912. sizeZ?: number;
  61913. custom?: any;
  61914. faceUV?: Vector4[];
  61915. faceColors?: Color4[];
  61916. flat?: boolean;
  61917. updatable?: boolean;
  61918. sideOrientation?: number;
  61919. frontUVs?: Vector4;
  61920. backUVs?: Vector4;
  61921. }, scene?: Nullable<Scene>): Mesh;
  61922. /**
  61923. * Creates a decal mesh.
  61924. * 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
  61925. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61926. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61927. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61928. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61929. * @param name defines the name of the mesh
  61930. * @param sourceMesh defines the mesh where the decal must be applied
  61931. * @param options defines the options used to create the mesh
  61932. * @param scene defines the hosting scene
  61933. * @returns the decal mesh
  61934. * @see https://doc.babylonjs.com/how_to/decals
  61935. */
  61936. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61937. position?: Vector3;
  61938. normal?: Vector3;
  61939. size?: Vector3;
  61940. angle?: number;
  61941. }): Mesh;
  61942. }
  61943. }
  61944. declare module BABYLON {
  61945. /**
  61946. * A simplifier interface for future simplification implementations
  61947. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61948. */
  61949. export interface ISimplifier {
  61950. /**
  61951. * Simplification of a given mesh according to the given settings.
  61952. * Since this requires computation, it is assumed that the function runs async.
  61953. * @param settings The settings of the simplification, including quality and distance
  61954. * @param successCallback A callback that will be called after the mesh was simplified.
  61955. * @param errorCallback in case of an error, this callback will be called. optional.
  61956. */
  61957. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61958. }
  61959. /**
  61960. * Expected simplification settings.
  61961. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61962. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61963. */
  61964. export interface ISimplificationSettings {
  61965. /**
  61966. * Gets or sets the expected quality
  61967. */
  61968. quality: number;
  61969. /**
  61970. * Gets or sets the distance when this optimized version should be used
  61971. */
  61972. distance: number;
  61973. /**
  61974. * Gets an already optimized mesh
  61975. */
  61976. optimizeMesh?: boolean;
  61977. }
  61978. /**
  61979. * Class used to specify simplification options
  61980. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61981. */
  61982. export class SimplificationSettings implements ISimplificationSettings {
  61983. /** expected quality */
  61984. quality: number;
  61985. /** distance when this optimized version should be used */
  61986. distance: number;
  61987. /** already optimized mesh */
  61988. optimizeMesh?: boolean | undefined;
  61989. /**
  61990. * Creates a SimplificationSettings
  61991. * @param quality expected quality
  61992. * @param distance distance when this optimized version should be used
  61993. * @param optimizeMesh already optimized mesh
  61994. */
  61995. constructor(
  61996. /** expected quality */
  61997. quality: number,
  61998. /** distance when this optimized version should be used */
  61999. distance: number,
  62000. /** already optimized mesh */
  62001. optimizeMesh?: boolean | undefined);
  62002. }
  62003. /**
  62004. * Interface used to define a simplification task
  62005. */
  62006. export interface ISimplificationTask {
  62007. /**
  62008. * Array of settings
  62009. */
  62010. settings: Array<ISimplificationSettings>;
  62011. /**
  62012. * Simplification type
  62013. */
  62014. simplificationType: SimplificationType;
  62015. /**
  62016. * Mesh to simplify
  62017. */
  62018. mesh: Mesh;
  62019. /**
  62020. * Callback called on success
  62021. */
  62022. successCallback?: () => void;
  62023. /**
  62024. * Defines if parallel processing can be used
  62025. */
  62026. parallelProcessing: boolean;
  62027. }
  62028. /**
  62029. * Queue used to order the simplification tasks
  62030. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62031. */
  62032. export class SimplificationQueue {
  62033. private _simplificationArray;
  62034. /**
  62035. * Gets a boolean indicating that the process is still running
  62036. */
  62037. running: boolean;
  62038. /**
  62039. * Creates a new queue
  62040. */
  62041. constructor();
  62042. /**
  62043. * Adds a new simplification task
  62044. * @param task defines a task to add
  62045. */
  62046. addTask(task: ISimplificationTask): void;
  62047. /**
  62048. * Execute next task
  62049. */
  62050. executeNext(): void;
  62051. /**
  62052. * Execute a simplification task
  62053. * @param task defines the task to run
  62054. */
  62055. runSimplification(task: ISimplificationTask): void;
  62056. private getSimplifier;
  62057. }
  62058. /**
  62059. * The implemented types of simplification
  62060. * At the moment only Quadratic Error Decimation is implemented
  62061. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62062. */
  62063. export enum SimplificationType {
  62064. /** Quadratic error decimation */
  62065. QUADRATIC = 0
  62066. }
  62067. /**
  62068. * An implementation of the Quadratic Error simplification algorithm.
  62069. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62070. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62071. * @author RaananW
  62072. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62073. */
  62074. export class QuadraticErrorSimplification implements ISimplifier {
  62075. private _mesh;
  62076. private triangles;
  62077. private vertices;
  62078. private references;
  62079. private _reconstructedMesh;
  62080. /** Gets or sets the number pf sync interations */
  62081. syncIterations: number;
  62082. /** Gets or sets the aggressiveness of the simplifier */
  62083. aggressiveness: number;
  62084. /** Gets or sets the number of allowed iterations for decimation */
  62085. decimationIterations: number;
  62086. /** Gets or sets the espilon to use for bounding box computation */
  62087. boundingBoxEpsilon: number;
  62088. /**
  62089. * Creates a new QuadraticErrorSimplification
  62090. * @param _mesh defines the target mesh
  62091. */
  62092. constructor(_mesh: Mesh);
  62093. /**
  62094. * Simplification of a given mesh according to the given settings.
  62095. * Since this requires computation, it is assumed that the function runs async.
  62096. * @param settings The settings of the simplification, including quality and distance
  62097. * @param successCallback A callback that will be called after the mesh was simplified.
  62098. */
  62099. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62100. private runDecimation;
  62101. private initWithMesh;
  62102. private init;
  62103. private reconstructMesh;
  62104. private initDecimatedMesh;
  62105. private isFlipped;
  62106. private updateTriangles;
  62107. private identifyBorder;
  62108. private updateMesh;
  62109. private vertexError;
  62110. private calculateError;
  62111. }
  62112. }
  62113. declare module BABYLON {
  62114. interface Scene {
  62115. /** @hidden (Backing field) */
  62116. _simplificationQueue: SimplificationQueue;
  62117. /**
  62118. * Gets or sets the simplification queue attached to the scene
  62119. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62120. */
  62121. simplificationQueue: SimplificationQueue;
  62122. }
  62123. interface Mesh {
  62124. /**
  62125. * Simplify the mesh according to the given array of settings.
  62126. * Function will return immediately and will simplify async
  62127. * @param settings a collection of simplification settings
  62128. * @param parallelProcessing should all levels calculate parallel or one after the other
  62129. * @param simplificationType the type of simplification to run
  62130. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62131. * @returns the current mesh
  62132. */
  62133. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62134. }
  62135. /**
  62136. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62137. * created in a scene
  62138. */
  62139. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62140. /**
  62141. * The component name helpfull to identify the component in the list of scene components.
  62142. */
  62143. readonly name: string;
  62144. /**
  62145. * The scene the component belongs to.
  62146. */
  62147. scene: Scene;
  62148. /**
  62149. * Creates a new instance of the component for the given scene
  62150. * @param scene Defines the scene to register the component in
  62151. */
  62152. constructor(scene: Scene);
  62153. /**
  62154. * Registers the component in a given scene
  62155. */
  62156. register(): void;
  62157. /**
  62158. * Rebuilds the elements related to this component in case of
  62159. * context lost for instance.
  62160. */
  62161. rebuild(): void;
  62162. /**
  62163. * Disposes the component and the associated ressources
  62164. */
  62165. dispose(): void;
  62166. private _beforeCameraUpdate;
  62167. }
  62168. }
  62169. declare module BABYLON {
  62170. /**
  62171. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62172. */
  62173. export interface INavigationEnginePlugin {
  62174. /**
  62175. * plugin name
  62176. */
  62177. name: string;
  62178. /**
  62179. * Creates a navigation mesh
  62180. * @param meshes array of all the geometry used to compute the navigatio mesh
  62181. * @param parameters bunch of parameters used to filter geometry
  62182. */
  62183. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62184. /**
  62185. * Create a navigation mesh debug mesh
  62186. * @param scene is where the mesh will be added
  62187. * @returns debug display mesh
  62188. */
  62189. createDebugNavMesh(scene: Scene): Mesh;
  62190. /**
  62191. * Get a navigation mesh constrained position, closest to the parameter position
  62192. * @param position world position
  62193. * @returns the closest point to position constrained by the navigation mesh
  62194. */
  62195. getClosestPoint(position: Vector3): Vector3;
  62196. /**
  62197. * Get a navigation mesh constrained position, closest to the parameter position
  62198. * @param position world position
  62199. * @param result output the closest point to position constrained by the navigation mesh
  62200. */
  62201. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62202. /**
  62203. * Get a navigation mesh constrained position, within a particular radius
  62204. * @param position world position
  62205. * @param maxRadius the maximum distance to the constrained world position
  62206. * @returns the closest point to position constrained by the navigation mesh
  62207. */
  62208. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62209. /**
  62210. * Get a navigation mesh constrained position, within a particular radius
  62211. * @param position world position
  62212. * @param maxRadius the maximum distance to the constrained world position
  62213. * @param result output the closest point to position constrained by the navigation mesh
  62214. */
  62215. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62216. /**
  62217. * Compute the final position from a segment made of destination-position
  62218. * @param position world position
  62219. * @param destination world position
  62220. * @returns the resulting point along the navmesh
  62221. */
  62222. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62223. /**
  62224. * Compute the final position from a segment made of destination-position
  62225. * @param position world position
  62226. * @param destination world position
  62227. * @param result output the resulting point along the navmesh
  62228. */
  62229. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62230. /**
  62231. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62232. * @param start world position
  62233. * @param end world position
  62234. * @returns array containing world position composing the path
  62235. */
  62236. computePath(start: Vector3, end: Vector3): Vector3[];
  62237. /**
  62238. * If this plugin is supported
  62239. * @returns true if plugin is supported
  62240. */
  62241. isSupported(): boolean;
  62242. /**
  62243. * Create a new Crowd so you can add agents
  62244. * @param maxAgents the maximum agent count in the crowd
  62245. * @param maxAgentRadius the maximum radius an agent can have
  62246. * @param scene to attach the crowd to
  62247. * @returns the crowd you can add agents to
  62248. */
  62249. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62250. /**
  62251. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62252. * The queries will try to find a solution within those bounds
  62253. * default is (1,1,1)
  62254. * @param extent x,y,z value that define the extent around the queries point of reference
  62255. */
  62256. setDefaultQueryExtent(extent: Vector3): void;
  62257. /**
  62258. * Get the Bounding box extent specified by setDefaultQueryExtent
  62259. * @returns the box extent values
  62260. */
  62261. getDefaultQueryExtent(): Vector3;
  62262. /**
  62263. * build the navmesh from a previously saved state using getNavmeshData
  62264. * @param data the Uint8Array returned by getNavmeshData
  62265. */
  62266. buildFromNavmeshData(data: Uint8Array): void;
  62267. /**
  62268. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62269. * @returns data the Uint8Array that can be saved and reused
  62270. */
  62271. getNavmeshData(): Uint8Array;
  62272. /**
  62273. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62274. * @param result output the box extent values
  62275. */
  62276. getDefaultQueryExtentToRef(result: Vector3): void;
  62277. /**
  62278. * Release all resources
  62279. */
  62280. dispose(): void;
  62281. }
  62282. /**
  62283. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62284. */
  62285. export interface ICrowd {
  62286. /**
  62287. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62288. * You can attach anything to that node. The node position is updated in the scene update tick.
  62289. * @param pos world position that will be constrained by the navigation mesh
  62290. * @param parameters agent parameters
  62291. * @param transform hooked to the agent that will be update by the scene
  62292. * @returns agent index
  62293. */
  62294. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62295. /**
  62296. * Returns the agent position in world space
  62297. * @param index agent index returned by addAgent
  62298. * @returns world space position
  62299. */
  62300. getAgentPosition(index: number): Vector3;
  62301. /**
  62302. * Gets the agent position result in world space
  62303. * @param index agent index returned by addAgent
  62304. * @param result output world space position
  62305. */
  62306. getAgentPositionToRef(index: number, result: Vector3): void;
  62307. /**
  62308. * Gets the agent velocity in world space
  62309. * @param index agent index returned by addAgent
  62310. * @returns world space velocity
  62311. */
  62312. getAgentVelocity(index: number): Vector3;
  62313. /**
  62314. * Gets the agent velocity result in world space
  62315. * @param index agent index returned by addAgent
  62316. * @param result output world space velocity
  62317. */
  62318. getAgentVelocityToRef(index: number, result: Vector3): void;
  62319. /**
  62320. * remove a particular agent previously created
  62321. * @param index agent index returned by addAgent
  62322. */
  62323. removeAgent(index: number): void;
  62324. /**
  62325. * get the list of all agents attached to this crowd
  62326. * @returns list of agent indices
  62327. */
  62328. getAgents(): number[];
  62329. /**
  62330. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62331. * @param deltaTime in seconds
  62332. */
  62333. update(deltaTime: number): void;
  62334. /**
  62335. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62336. * @param index agent index returned by addAgent
  62337. * @param destination targeted world position
  62338. */
  62339. agentGoto(index: number, destination: Vector3): void;
  62340. /**
  62341. * Teleport the agent to a new position
  62342. * @param index agent index returned by addAgent
  62343. * @param destination targeted world position
  62344. */
  62345. agentTeleport(index: number, destination: Vector3): void;
  62346. /**
  62347. * Update agent parameters
  62348. * @param index agent index returned by addAgent
  62349. * @param parameters agent parameters
  62350. */
  62351. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62352. /**
  62353. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62354. * The queries will try to find a solution within those bounds
  62355. * default is (1,1,1)
  62356. * @param extent x,y,z value that define the extent around the queries point of reference
  62357. */
  62358. setDefaultQueryExtent(extent: Vector3): void;
  62359. /**
  62360. * Get the Bounding box extent specified by setDefaultQueryExtent
  62361. * @returns the box extent values
  62362. */
  62363. getDefaultQueryExtent(): Vector3;
  62364. /**
  62365. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62366. * @param result output the box extent values
  62367. */
  62368. getDefaultQueryExtentToRef(result: Vector3): void;
  62369. /**
  62370. * Release all resources
  62371. */
  62372. dispose(): void;
  62373. }
  62374. /**
  62375. * Configures an agent
  62376. */
  62377. export interface IAgentParameters {
  62378. /**
  62379. * Agent radius. [Limit: >= 0]
  62380. */
  62381. radius: number;
  62382. /**
  62383. * Agent height. [Limit: > 0]
  62384. */
  62385. height: number;
  62386. /**
  62387. * Maximum allowed acceleration. [Limit: >= 0]
  62388. */
  62389. maxAcceleration: number;
  62390. /**
  62391. * Maximum allowed speed. [Limit: >= 0]
  62392. */
  62393. maxSpeed: number;
  62394. /**
  62395. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62396. */
  62397. collisionQueryRange: number;
  62398. /**
  62399. * The path visibility optimization range. [Limit: > 0]
  62400. */
  62401. pathOptimizationRange: number;
  62402. /**
  62403. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62404. */
  62405. separationWeight: number;
  62406. }
  62407. /**
  62408. * Configures the navigation mesh creation
  62409. */
  62410. export interface INavMeshParameters {
  62411. /**
  62412. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62413. */
  62414. cs: number;
  62415. /**
  62416. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62417. */
  62418. ch: number;
  62419. /**
  62420. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62421. */
  62422. walkableSlopeAngle: number;
  62423. /**
  62424. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62425. * be considered walkable. [Limit: >= 3] [Units: vx]
  62426. */
  62427. walkableHeight: number;
  62428. /**
  62429. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62430. */
  62431. walkableClimb: number;
  62432. /**
  62433. * The distance to erode/shrink the walkable area of the heightfield away from
  62434. * obstructions. [Limit: >=0] [Units: vx]
  62435. */
  62436. walkableRadius: number;
  62437. /**
  62438. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62439. */
  62440. maxEdgeLen: number;
  62441. /**
  62442. * The maximum distance a simplfied contour's border edges should deviate
  62443. * the original raw contour. [Limit: >=0] [Units: vx]
  62444. */
  62445. maxSimplificationError: number;
  62446. /**
  62447. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62448. */
  62449. minRegionArea: number;
  62450. /**
  62451. * Any regions with a span count smaller than this value will, if possible,
  62452. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62453. */
  62454. mergeRegionArea: number;
  62455. /**
  62456. * The maximum number of vertices allowed for polygons generated during the
  62457. * contour to polygon conversion process. [Limit: >= 3]
  62458. */
  62459. maxVertsPerPoly: number;
  62460. /**
  62461. * Sets the sampling distance to use when generating the detail mesh.
  62462. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62463. */
  62464. detailSampleDist: number;
  62465. /**
  62466. * The maximum distance the detail mesh surface should deviate from heightfield
  62467. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62468. */
  62469. detailSampleMaxError: number;
  62470. }
  62471. }
  62472. declare module BABYLON {
  62473. /**
  62474. * RecastJS navigation plugin
  62475. */
  62476. export class RecastJSPlugin implements INavigationEnginePlugin {
  62477. /**
  62478. * Reference to the Recast library
  62479. */
  62480. bjsRECAST: any;
  62481. /**
  62482. * plugin name
  62483. */
  62484. name: string;
  62485. /**
  62486. * the first navmesh created. We might extend this to support multiple navmeshes
  62487. */
  62488. navMesh: any;
  62489. /**
  62490. * Initializes the recastJS plugin
  62491. * @param recastInjection can be used to inject your own recast reference
  62492. */
  62493. constructor(recastInjection?: any);
  62494. /**
  62495. * Creates a navigation mesh
  62496. * @param meshes array of all the geometry used to compute the navigatio mesh
  62497. * @param parameters bunch of parameters used to filter geometry
  62498. */
  62499. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62500. /**
  62501. * Create a navigation mesh debug mesh
  62502. * @param scene is where the mesh will be added
  62503. * @returns debug display mesh
  62504. */
  62505. createDebugNavMesh(scene: Scene): Mesh;
  62506. /**
  62507. * Get a navigation mesh constrained position, closest to the parameter position
  62508. * @param position world position
  62509. * @returns the closest point to position constrained by the navigation mesh
  62510. */
  62511. getClosestPoint(position: Vector3): Vector3;
  62512. /**
  62513. * Get a navigation mesh constrained position, closest to the parameter position
  62514. * @param position world position
  62515. * @param result output the closest point to position constrained by the navigation mesh
  62516. */
  62517. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62518. /**
  62519. * Get a navigation mesh constrained position, within a particular radius
  62520. * @param position world position
  62521. * @param maxRadius the maximum distance to the constrained world position
  62522. * @returns the closest point to position constrained by the navigation mesh
  62523. */
  62524. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62525. /**
  62526. * Get a navigation mesh constrained position, within a particular radius
  62527. * @param position world position
  62528. * @param maxRadius the maximum distance to the constrained world position
  62529. * @param result output the closest point to position constrained by the navigation mesh
  62530. */
  62531. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62532. /**
  62533. * Compute the final position from a segment made of destination-position
  62534. * @param position world position
  62535. * @param destination world position
  62536. * @returns the resulting point along the navmesh
  62537. */
  62538. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62539. /**
  62540. * Compute the final position from a segment made of destination-position
  62541. * @param position world position
  62542. * @param destination world position
  62543. * @param result output the resulting point along the navmesh
  62544. */
  62545. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62546. /**
  62547. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62548. * @param start world position
  62549. * @param end world position
  62550. * @returns array containing world position composing the path
  62551. */
  62552. computePath(start: Vector3, end: Vector3): Vector3[];
  62553. /**
  62554. * Create a new Crowd so you can add agents
  62555. * @param maxAgents the maximum agent count in the crowd
  62556. * @param maxAgentRadius the maximum radius an agent can have
  62557. * @param scene to attach the crowd to
  62558. * @returns the crowd you can add agents to
  62559. */
  62560. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62561. /**
  62562. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62563. * The queries will try to find a solution within those bounds
  62564. * default is (1,1,1)
  62565. * @param extent x,y,z value that define the extent around the queries point of reference
  62566. */
  62567. setDefaultQueryExtent(extent: Vector3): void;
  62568. /**
  62569. * Get the Bounding box extent specified by setDefaultQueryExtent
  62570. * @returns the box extent values
  62571. */
  62572. getDefaultQueryExtent(): Vector3;
  62573. /**
  62574. * build the navmesh from a previously saved state using getNavmeshData
  62575. * @param data the Uint8Array returned by getNavmeshData
  62576. */
  62577. buildFromNavmeshData(data: Uint8Array): void;
  62578. /**
  62579. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62580. * @returns data the Uint8Array that can be saved and reused
  62581. */
  62582. getNavmeshData(): Uint8Array;
  62583. /**
  62584. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62585. * @param result output the box extent values
  62586. */
  62587. getDefaultQueryExtentToRef(result: Vector3): void;
  62588. /**
  62589. * Disposes
  62590. */
  62591. dispose(): void;
  62592. /**
  62593. * If this plugin is supported
  62594. * @returns true if plugin is supported
  62595. */
  62596. isSupported(): boolean;
  62597. }
  62598. /**
  62599. * Recast detour crowd implementation
  62600. */
  62601. export class RecastJSCrowd implements ICrowd {
  62602. /**
  62603. * Recast/detour plugin
  62604. */
  62605. bjsRECASTPlugin: RecastJSPlugin;
  62606. /**
  62607. * Link to the detour crowd
  62608. */
  62609. recastCrowd: any;
  62610. /**
  62611. * One transform per agent
  62612. */
  62613. transforms: TransformNode[];
  62614. /**
  62615. * All agents created
  62616. */
  62617. agents: number[];
  62618. /**
  62619. * Link to the scene is kept to unregister the crowd from the scene
  62620. */
  62621. private _scene;
  62622. /**
  62623. * Observer for crowd updates
  62624. */
  62625. private _onBeforeAnimationsObserver;
  62626. /**
  62627. * Constructor
  62628. * @param plugin recastJS plugin
  62629. * @param maxAgents the maximum agent count in the crowd
  62630. * @param maxAgentRadius the maximum radius an agent can have
  62631. * @param scene to attach the crowd to
  62632. * @returns the crowd you can add agents to
  62633. */
  62634. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62635. /**
  62636. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62637. * You can attach anything to that node. The node position is updated in the scene update tick.
  62638. * @param pos world position that will be constrained by the navigation mesh
  62639. * @param parameters agent parameters
  62640. * @param transform hooked to the agent that will be update by the scene
  62641. * @returns agent index
  62642. */
  62643. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62644. /**
  62645. * Returns the agent position in world space
  62646. * @param index agent index returned by addAgent
  62647. * @returns world space position
  62648. */
  62649. getAgentPosition(index: number): Vector3;
  62650. /**
  62651. * Returns the agent position result in world space
  62652. * @param index agent index returned by addAgent
  62653. * @param result output world space position
  62654. */
  62655. getAgentPositionToRef(index: number, result: Vector3): void;
  62656. /**
  62657. * Returns the agent velocity in world space
  62658. * @param index agent index returned by addAgent
  62659. * @returns world space velocity
  62660. */
  62661. getAgentVelocity(index: number): Vector3;
  62662. /**
  62663. * Returns the agent velocity result in world space
  62664. * @param index agent index returned by addAgent
  62665. * @param result output world space velocity
  62666. */
  62667. getAgentVelocityToRef(index: number, result: Vector3): void;
  62668. /**
  62669. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62670. * @param index agent index returned by addAgent
  62671. * @param destination targeted world position
  62672. */
  62673. agentGoto(index: number, destination: Vector3): void;
  62674. /**
  62675. * Teleport the agent to a new position
  62676. * @param index agent index returned by addAgent
  62677. * @param destination targeted world position
  62678. */
  62679. agentTeleport(index: number, destination: Vector3): void;
  62680. /**
  62681. * Update agent parameters
  62682. * @param index agent index returned by addAgent
  62683. * @param parameters agent parameters
  62684. */
  62685. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62686. /**
  62687. * remove a particular agent previously created
  62688. * @param index agent index returned by addAgent
  62689. */
  62690. removeAgent(index: number): void;
  62691. /**
  62692. * get the list of all agents attached to this crowd
  62693. * @returns list of agent indices
  62694. */
  62695. getAgents(): number[];
  62696. /**
  62697. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62698. * @param deltaTime in seconds
  62699. */
  62700. update(deltaTime: number): void;
  62701. /**
  62702. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62703. * The queries will try to find a solution within those bounds
  62704. * default is (1,1,1)
  62705. * @param extent x,y,z value that define the extent around the queries point of reference
  62706. */
  62707. setDefaultQueryExtent(extent: Vector3): void;
  62708. /**
  62709. * Get the Bounding box extent specified by setDefaultQueryExtent
  62710. * @returns the box extent values
  62711. */
  62712. getDefaultQueryExtent(): Vector3;
  62713. /**
  62714. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62715. * @param result output the box extent values
  62716. */
  62717. getDefaultQueryExtentToRef(result: Vector3): void;
  62718. /**
  62719. * Release all resources
  62720. */
  62721. dispose(): void;
  62722. }
  62723. }
  62724. declare module BABYLON {
  62725. /**
  62726. * Class used to enable access to IndexedDB
  62727. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62728. */
  62729. export class Database implements IOfflineProvider {
  62730. private _callbackManifestChecked;
  62731. private _currentSceneUrl;
  62732. private _db;
  62733. private _enableSceneOffline;
  62734. private _enableTexturesOffline;
  62735. private _manifestVersionFound;
  62736. private _mustUpdateRessources;
  62737. private _hasReachedQuota;
  62738. private _isSupported;
  62739. private _idbFactory;
  62740. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62741. private static IsUASupportingBlobStorage;
  62742. /**
  62743. * Gets a boolean indicating if Database storate is enabled (off by default)
  62744. */
  62745. static IDBStorageEnabled: boolean;
  62746. /**
  62747. * Gets a boolean indicating if scene must be saved in the database
  62748. */
  62749. get enableSceneOffline(): boolean;
  62750. /**
  62751. * Gets a boolean indicating if textures must be saved in the database
  62752. */
  62753. get enableTexturesOffline(): boolean;
  62754. /**
  62755. * Creates a new Database
  62756. * @param urlToScene defines the url to load the scene
  62757. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62758. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62759. */
  62760. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62761. private static _ParseURL;
  62762. private static _ReturnFullUrlLocation;
  62763. private _checkManifestFile;
  62764. /**
  62765. * Open the database and make it available
  62766. * @param successCallback defines the callback to call on success
  62767. * @param errorCallback defines the callback to call on error
  62768. */
  62769. open(successCallback: () => void, errorCallback: () => void): void;
  62770. /**
  62771. * Loads an image from the database
  62772. * @param url defines the url to load from
  62773. * @param image defines the target DOM image
  62774. */
  62775. loadImage(url: string, image: HTMLImageElement): void;
  62776. private _loadImageFromDBAsync;
  62777. private _saveImageIntoDBAsync;
  62778. private _checkVersionFromDB;
  62779. private _loadVersionFromDBAsync;
  62780. private _saveVersionIntoDBAsync;
  62781. /**
  62782. * Loads a file from database
  62783. * @param url defines the URL to load from
  62784. * @param sceneLoaded defines a callback to call on success
  62785. * @param progressCallBack defines a callback to call when progress changed
  62786. * @param errorCallback defines a callback to call on error
  62787. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62788. */
  62789. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62790. private _loadFileAsync;
  62791. private _saveFileAsync;
  62792. /**
  62793. * Validates if xhr data is correct
  62794. * @param xhr defines the request to validate
  62795. * @param dataType defines the expected data type
  62796. * @returns true if data is correct
  62797. */
  62798. private static _ValidateXHRData;
  62799. }
  62800. }
  62801. declare module BABYLON {
  62802. /** @hidden */
  62803. export var gpuUpdateParticlesPixelShader: {
  62804. name: string;
  62805. shader: string;
  62806. };
  62807. }
  62808. declare module BABYLON {
  62809. /** @hidden */
  62810. export var gpuUpdateParticlesVertexShader: {
  62811. name: string;
  62812. shader: string;
  62813. };
  62814. }
  62815. declare module BABYLON {
  62816. /** @hidden */
  62817. export var clipPlaneFragmentDeclaration2: {
  62818. name: string;
  62819. shader: string;
  62820. };
  62821. }
  62822. declare module BABYLON {
  62823. /** @hidden */
  62824. export var gpuRenderParticlesPixelShader: {
  62825. name: string;
  62826. shader: string;
  62827. };
  62828. }
  62829. declare module BABYLON {
  62830. /** @hidden */
  62831. export var clipPlaneVertexDeclaration2: {
  62832. name: string;
  62833. shader: string;
  62834. };
  62835. }
  62836. declare module BABYLON {
  62837. /** @hidden */
  62838. export var gpuRenderParticlesVertexShader: {
  62839. name: string;
  62840. shader: string;
  62841. };
  62842. }
  62843. declare module BABYLON {
  62844. /**
  62845. * This represents a GPU particle system in Babylon
  62846. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62847. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62848. */
  62849. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62850. /**
  62851. * The layer mask we are rendering the particles through.
  62852. */
  62853. layerMask: number;
  62854. private _capacity;
  62855. private _activeCount;
  62856. private _currentActiveCount;
  62857. private _accumulatedCount;
  62858. private _renderEffect;
  62859. private _updateEffect;
  62860. private _buffer0;
  62861. private _buffer1;
  62862. private _spriteBuffer;
  62863. private _updateVAO;
  62864. private _renderVAO;
  62865. private _targetIndex;
  62866. private _sourceBuffer;
  62867. private _targetBuffer;
  62868. private _engine;
  62869. private _currentRenderId;
  62870. private _started;
  62871. private _stopped;
  62872. private _timeDelta;
  62873. private _randomTexture;
  62874. private _randomTexture2;
  62875. private _attributesStrideSize;
  62876. private _updateEffectOptions;
  62877. private _randomTextureSize;
  62878. private _actualFrame;
  62879. private readonly _rawTextureWidth;
  62880. /**
  62881. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62882. */
  62883. static get IsSupported(): boolean;
  62884. /**
  62885. * An event triggered when the system is disposed.
  62886. */
  62887. onDisposeObservable: Observable<GPUParticleSystem>;
  62888. /**
  62889. * Gets the maximum number of particles active at the same time.
  62890. * @returns The max number of active particles.
  62891. */
  62892. getCapacity(): number;
  62893. /**
  62894. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62895. * to override the particles.
  62896. */
  62897. forceDepthWrite: boolean;
  62898. /**
  62899. * Gets or set the number of active particles
  62900. */
  62901. get activeParticleCount(): number;
  62902. set activeParticleCount(value: number);
  62903. private _preWarmDone;
  62904. /**
  62905. * Specifies if the particles are updated in emitter local space or world space.
  62906. * This is always false for GPU particles
  62907. */
  62908. get isLocal(): boolean;
  62909. set isLocal(value: boolean);
  62910. /**
  62911. * Is this system ready to be used/rendered
  62912. * @return true if the system is ready
  62913. */
  62914. isReady(): boolean;
  62915. /**
  62916. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62917. * @returns True if it has been started, otherwise false.
  62918. */
  62919. isStarted(): boolean;
  62920. /**
  62921. * Starts the particle system and begins to emit
  62922. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62923. */
  62924. start(delay?: number): void;
  62925. /**
  62926. * Stops the particle system.
  62927. */
  62928. stop(): void;
  62929. /**
  62930. * Remove all active particles
  62931. */
  62932. reset(): void;
  62933. /**
  62934. * Returns the string "GPUParticleSystem"
  62935. * @returns a string containing the class name
  62936. */
  62937. getClassName(): string;
  62938. private _colorGradientsTexture;
  62939. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62940. /**
  62941. * Adds a new color gradient
  62942. * @param gradient defines the gradient to use (between 0 and 1)
  62943. * @param color1 defines the color to affect to the specified gradient
  62944. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62945. * @returns the current particle system
  62946. */
  62947. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62948. /**
  62949. * Remove a specific color gradient
  62950. * @param gradient defines the gradient to remove
  62951. * @returns the current particle system
  62952. */
  62953. removeColorGradient(gradient: number): GPUParticleSystem;
  62954. private _angularSpeedGradientsTexture;
  62955. private _sizeGradientsTexture;
  62956. private _velocityGradientsTexture;
  62957. private _limitVelocityGradientsTexture;
  62958. private _dragGradientsTexture;
  62959. private _addFactorGradient;
  62960. /**
  62961. * Adds a new size gradient
  62962. * @param gradient defines the gradient to use (between 0 and 1)
  62963. * @param factor defines the size factor to affect to the specified gradient
  62964. * @returns the current particle system
  62965. */
  62966. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62967. /**
  62968. * Remove a specific size gradient
  62969. * @param gradient defines the gradient to remove
  62970. * @returns the current particle system
  62971. */
  62972. removeSizeGradient(gradient: number): GPUParticleSystem;
  62973. /**
  62974. * Adds a new angular speed gradient
  62975. * @param gradient defines the gradient to use (between 0 and 1)
  62976. * @param factor defines the angular speed to affect to the specified gradient
  62977. * @returns the current particle system
  62978. */
  62979. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62980. /**
  62981. * Remove a specific angular speed gradient
  62982. * @param gradient defines the gradient to remove
  62983. * @returns the current particle system
  62984. */
  62985. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62986. /**
  62987. * Adds a new velocity gradient
  62988. * @param gradient defines the gradient to use (between 0 and 1)
  62989. * @param factor defines the velocity to affect to the specified gradient
  62990. * @returns the current particle system
  62991. */
  62992. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62993. /**
  62994. * Remove a specific velocity gradient
  62995. * @param gradient defines the gradient to remove
  62996. * @returns the current particle system
  62997. */
  62998. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62999. /**
  63000. * Adds a new limit velocity gradient
  63001. * @param gradient defines the gradient to use (between 0 and 1)
  63002. * @param factor defines the limit velocity value to affect to the specified gradient
  63003. * @returns the current particle system
  63004. */
  63005. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63006. /**
  63007. * Remove a specific limit velocity gradient
  63008. * @param gradient defines the gradient to remove
  63009. * @returns the current particle system
  63010. */
  63011. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63012. /**
  63013. * Adds a new drag gradient
  63014. * @param gradient defines the gradient to use (between 0 and 1)
  63015. * @param factor defines the drag value to affect to the specified gradient
  63016. * @returns the current particle system
  63017. */
  63018. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63019. /**
  63020. * Remove a specific drag gradient
  63021. * @param gradient defines the gradient to remove
  63022. * @returns the current particle system
  63023. */
  63024. removeDragGradient(gradient: number): GPUParticleSystem;
  63025. /**
  63026. * Not supported by GPUParticleSystem
  63027. * @param gradient defines the gradient to use (between 0 and 1)
  63028. * @param factor defines the emit rate value to affect to the specified gradient
  63029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63030. * @returns the current particle system
  63031. */
  63032. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63033. /**
  63034. * Not supported by GPUParticleSystem
  63035. * @param gradient defines the gradient to remove
  63036. * @returns the current particle system
  63037. */
  63038. removeEmitRateGradient(gradient: number): IParticleSystem;
  63039. /**
  63040. * Not supported by GPUParticleSystem
  63041. * @param gradient defines the gradient to use (between 0 and 1)
  63042. * @param factor defines the start size value to affect to the specified gradient
  63043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63044. * @returns the current particle system
  63045. */
  63046. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63047. /**
  63048. * Not supported by GPUParticleSystem
  63049. * @param gradient defines the gradient to remove
  63050. * @returns the current particle system
  63051. */
  63052. removeStartSizeGradient(gradient: number): IParticleSystem;
  63053. /**
  63054. * Not supported by GPUParticleSystem
  63055. * @param gradient defines the gradient to use (between 0 and 1)
  63056. * @param min defines the color remap minimal range
  63057. * @param max defines the color remap maximal range
  63058. * @returns the current particle system
  63059. */
  63060. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63061. /**
  63062. * Not supported by GPUParticleSystem
  63063. * @param gradient defines the gradient to remove
  63064. * @returns the current particle system
  63065. */
  63066. removeColorRemapGradient(): IParticleSystem;
  63067. /**
  63068. * Not supported by GPUParticleSystem
  63069. * @param gradient defines the gradient to use (between 0 and 1)
  63070. * @param min defines the alpha remap minimal range
  63071. * @param max defines the alpha remap maximal range
  63072. * @returns the current particle system
  63073. */
  63074. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63075. /**
  63076. * Not supported by GPUParticleSystem
  63077. * @param gradient defines the gradient to remove
  63078. * @returns the current particle system
  63079. */
  63080. removeAlphaRemapGradient(): IParticleSystem;
  63081. /**
  63082. * Not supported by GPUParticleSystem
  63083. * @param gradient defines the gradient to use (between 0 and 1)
  63084. * @param color defines the color to affect to the specified gradient
  63085. * @returns the current particle system
  63086. */
  63087. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63088. /**
  63089. * Not supported by GPUParticleSystem
  63090. * @param gradient defines the gradient to remove
  63091. * @returns the current particle system
  63092. */
  63093. removeRampGradient(): IParticleSystem;
  63094. /**
  63095. * Not supported by GPUParticleSystem
  63096. * @returns the list of ramp gradients
  63097. */
  63098. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63099. /**
  63100. * Not supported by GPUParticleSystem
  63101. * Gets or sets a boolean indicating that ramp gradients must be used
  63102. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63103. */
  63104. get useRampGradients(): boolean;
  63105. set useRampGradients(value: boolean);
  63106. /**
  63107. * Not supported by GPUParticleSystem
  63108. * @param gradient defines the gradient to use (between 0 and 1)
  63109. * @param factor defines the life time factor to affect to the specified gradient
  63110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63111. * @returns the current particle system
  63112. */
  63113. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63114. /**
  63115. * Not supported by GPUParticleSystem
  63116. * @param gradient defines the gradient to remove
  63117. * @returns the current particle system
  63118. */
  63119. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63120. /**
  63121. * Instantiates a GPU particle system.
  63122. * 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.
  63123. * @param name The name of the particle system
  63124. * @param options The options used to create the system
  63125. * @param scene The scene the particle system belongs to
  63126. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63127. */
  63128. constructor(name: string, options: Partial<{
  63129. capacity: number;
  63130. randomTextureSize: number;
  63131. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63132. protected _reset(): void;
  63133. private _createUpdateVAO;
  63134. private _createRenderVAO;
  63135. private _initialize;
  63136. /** @hidden */
  63137. _recreateUpdateEffect(): void;
  63138. /** @hidden */
  63139. _recreateRenderEffect(): void;
  63140. /**
  63141. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63142. * @param preWarm defines if we are in the pre-warmimg phase
  63143. */
  63144. animate(preWarm?: boolean): void;
  63145. private _createFactorGradientTexture;
  63146. private _createSizeGradientTexture;
  63147. private _createAngularSpeedGradientTexture;
  63148. private _createVelocityGradientTexture;
  63149. private _createLimitVelocityGradientTexture;
  63150. private _createDragGradientTexture;
  63151. private _createColorGradientTexture;
  63152. /**
  63153. * Renders the particle system in its current state
  63154. * @param preWarm defines if the system should only update the particles but not render them
  63155. * @returns the current number of particles
  63156. */
  63157. render(preWarm?: boolean): number;
  63158. /**
  63159. * Rebuilds the particle system
  63160. */
  63161. rebuild(): void;
  63162. private _releaseBuffers;
  63163. private _releaseVAOs;
  63164. /**
  63165. * Disposes the particle system and free the associated resources
  63166. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63167. */
  63168. dispose(disposeTexture?: boolean): void;
  63169. /**
  63170. * Clones the particle system.
  63171. * @param name The name of the cloned object
  63172. * @param newEmitter The new emitter to use
  63173. * @returns the cloned particle system
  63174. */
  63175. clone(name: string, newEmitter: any): GPUParticleSystem;
  63176. /**
  63177. * Serializes the particle system to a JSON object.
  63178. * @returns the JSON object
  63179. */
  63180. serialize(): any;
  63181. /**
  63182. * Parses a JSON object to create a GPU particle system.
  63183. * @param parsedParticleSystem The JSON object to parse
  63184. * @param scene The scene to create the particle system in
  63185. * @param rootUrl The root url to use to load external dependencies like texture
  63186. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63187. * @returns the parsed GPU particle system
  63188. */
  63189. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63190. }
  63191. }
  63192. declare module BABYLON {
  63193. /**
  63194. * Represents a set of particle systems working together to create a specific effect
  63195. */
  63196. export class ParticleSystemSet implements IDisposable {
  63197. /**
  63198. * Gets or sets base Assets URL
  63199. */
  63200. static BaseAssetsUrl: string;
  63201. private _emitterCreationOptions;
  63202. private _emitterNode;
  63203. /**
  63204. * Gets the particle system list
  63205. */
  63206. systems: IParticleSystem[];
  63207. /**
  63208. * Gets the emitter node used with this set
  63209. */
  63210. get emitterNode(): Nullable<TransformNode>;
  63211. /**
  63212. * Creates a new emitter mesh as a sphere
  63213. * @param options defines the options used to create the sphere
  63214. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63215. * @param scene defines the hosting scene
  63216. */
  63217. setEmitterAsSphere(options: {
  63218. diameter: number;
  63219. segments: number;
  63220. color: Color3;
  63221. }, renderingGroupId: number, scene: Scene): void;
  63222. /**
  63223. * Starts all particle systems of the set
  63224. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63225. */
  63226. start(emitter?: AbstractMesh): void;
  63227. /**
  63228. * Release all associated resources
  63229. */
  63230. dispose(): void;
  63231. /**
  63232. * Serialize the set into a JSON compatible object
  63233. * @returns a JSON compatible representation of the set
  63234. */
  63235. serialize(): any;
  63236. /**
  63237. * Parse a new ParticleSystemSet from a serialized source
  63238. * @param data defines a JSON compatible representation of the set
  63239. * @param scene defines the hosting scene
  63240. * @param gpu defines if we want GPU particles or CPU particles
  63241. * @returns a new ParticleSystemSet
  63242. */
  63243. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63244. }
  63245. }
  63246. declare module BABYLON {
  63247. /**
  63248. * This class is made for on one-liner static method to help creating particle system set.
  63249. */
  63250. export class ParticleHelper {
  63251. /**
  63252. * Gets or sets base Assets URL
  63253. */
  63254. static BaseAssetsUrl: string;
  63255. /**
  63256. * Create a default particle system that you can tweak
  63257. * @param emitter defines the emitter to use
  63258. * @param capacity defines the system capacity (default is 500 particles)
  63259. * @param scene defines the hosting scene
  63260. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63261. * @returns the new Particle system
  63262. */
  63263. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63264. /**
  63265. * This is the main static method (one-liner) of this helper to create different particle systems
  63266. * @param type This string represents the type to the particle system to create
  63267. * @param scene The scene where the particle system should live
  63268. * @param gpu If the system will use gpu
  63269. * @returns the ParticleSystemSet created
  63270. */
  63271. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63272. /**
  63273. * Static function used to export a particle system to a ParticleSystemSet variable.
  63274. * Please note that the emitter shape is not exported
  63275. * @param systems defines the particle systems to export
  63276. * @returns the created particle system set
  63277. */
  63278. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63279. }
  63280. }
  63281. declare module BABYLON {
  63282. interface Engine {
  63283. /**
  63284. * Create an effect to use with particle systems.
  63285. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63286. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63287. * @param uniformsNames defines a list of attribute names
  63288. * @param samplers defines an array of string used to represent textures
  63289. * @param defines defines the string containing the defines to use to compile the shaders
  63290. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63291. * @param onCompiled defines a function to call when the effect creation is successful
  63292. * @param onError defines a function to call when the effect creation has failed
  63293. * @returns the new Effect
  63294. */
  63295. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63296. }
  63297. interface Mesh {
  63298. /**
  63299. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63300. * @returns an array of IParticleSystem
  63301. */
  63302. getEmittedParticleSystems(): IParticleSystem[];
  63303. /**
  63304. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63305. * @returns an array of IParticleSystem
  63306. */
  63307. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63308. }
  63309. /**
  63310. * @hidden
  63311. */
  63312. export var _IDoNeedToBeInTheBuild: number;
  63313. }
  63314. declare module BABYLON {
  63315. /** Defines the 4 color options */
  63316. export enum PointColor {
  63317. /** color value */
  63318. Color = 2,
  63319. /** uv value */
  63320. UV = 1,
  63321. /** random value */
  63322. Random = 0,
  63323. /** stated value */
  63324. Stated = 3
  63325. }
  63326. /**
  63327. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63328. * 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.
  63329. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63330. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63331. *
  63332. * Full documentation here : TO BE ENTERED
  63333. */
  63334. export class PointsCloudSystem implements IDisposable {
  63335. /**
  63336. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63337. * Example : var p = SPS.particles[i];
  63338. */
  63339. particles: CloudPoint[];
  63340. /**
  63341. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63342. */
  63343. nbParticles: number;
  63344. /**
  63345. * This a counter for your own usage. It's not set by any SPS functions.
  63346. */
  63347. counter: number;
  63348. /**
  63349. * The PCS name. This name is also given to the underlying mesh.
  63350. */
  63351. name: string;
  63352. /**
  63353. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63354. */
  63355. mesh: Mesh;
  63356. /**
  63357. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63358. * Please read :
  63359. */
  63360. vars: any;
  63361. /**
  63362. * @hidden
  63363. */
  63364. _size: number;
  63365. private _scene;
  63366. private _promises;
  63367. private _positions;
  63368. private _indices;
  63369. private _normals;
  63370. private _colors;
  63371. private _uvs;
  63372. private _indices32;
  63373. private _positions32;
  63374. private _colors32;
  63375. private _uvs32;
  63376. private _updatable;
  63377. private _isVisibilityBoxLocked;
  63378. private _alwaysVisible;
  63379. private _groups;
  63380. private _groupCounter;
  63381. private _computeParticleColor;
  63382. private _computeParticleTexture;
  63383. private _computeParticleRotation;
  63384. private _computeBoundingBox;
  63385. private _isReady;
  63386. /**
  63387. * Creates a PCS (Points Cloud System) object
  63388. * @param name (String) is the PCS name, this will be the underlying mesh name
  63389. * @param pointSize (number) is the size for each point
  63390. * @param scene (Scene) is the scene in which the PCS is added
  63391. * @param options defines the options of the PCS e.g.
  63392. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63393. */
  63394. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63395. updatable?: boolean;
  63396. });
  63397. /**
  63398. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63399. * If no points were added to the PCS, the returned mesh is just a single point.
  63400. * @returns a promise for the created mesh
  63401. */
  63402. buildMeshAsync(): Promise<Mesh>;
  63403. /**
  63404. * @hidden
  63405. */
  63406. private _buildMesh;
  63407. private _addParticle;
  63408. private _randomUnitVector;
  63409. private _getColorIndicesForCoord;
  63410. private _setPointsColorOrUV;
  63411. private _colorFromTexture;
  63412. private _calculateDensity;
  63413. /**
  63414. * Adds points to the PCS in random positions within a unit sphere
  63415. * @param nb (positive integer) the number of particles to be created from this model
  63416. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63417. * @returns the number of groups in the system
  63418. */
  63419. addPoints(nb: number, pointFunction?: any): number;
  63420. /**
  63421. * Adds points to the PCS from the surface of the model shape
  63422. * @param mesh is any Mesh object that will be used as a surface model for the points
  63423. * @param nb (positive integer) the number of particles to be created from this model
  63424. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63425. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63426. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63427. * @returns the number of groups in the system
  63428. */
  63429. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63430. /**
  63431. * Adds points to the PCS inside the model shape
  63432. * @param mesh is any Mesh object that will be used as a surface model for the points
  63433. * @param nb (positive integer) the number of particles to be created from this model
  63434. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63435. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63436. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63437. * @returns the number of groups in the system
  63438. */
  63439. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63440. /**
  63441. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63442. * This method calls `updateParticle()` for each particle of the SPS.
  63443. * For an animated SPS, it is usually called within the render loop.
  63444. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63445. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63446. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63447. * @returns the PCS.
  63448. */
  63449. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63450. /**
  63451. * Disposes the PCS.
  63452. */
  63453. dispose(): void;
  63454. /**
  63455. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63456. * doc :
  63457. * @returns the PCS.
  63458. */
  63459. refreshVisibleSize(): PointsCloudSystem;
  63460. /**
  63461. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63462. * @param size the size (float) of the visibility box
  63463. * note : this doesn't lock the PCS mesh bounding box.
  63464. * doc :
  63465. */
  63466. setVisibilityBox(size: number): void;
  63467. /**
  63468. * Gets whether the PCS is always visible or not
  63469. * doc :
  63470. */
  63471. get isAlwaysVisible(): boolean;
  63472. /**
  63473. * Sets the PCS as always visible or not
  63474. * doc :
  63475. */
  63476. set isAlwaysVisible(val: boolean);
  63477. /**
  63478. * Tells to `setParticles()` to compute the particle rotations or not
  63479. * Default value : false. The PCS is faster when it's set to false
  63480. * Note : particle rotations are only applied to parent particles
  63481. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63482. */
  63483. set computeParticleRotation(val: boolean);
  63484. /**
  63485. * Tells to `setParticles()` to compute the particle colors or not.
  63486. * Default value : true. The PCS is faster when it's set to false.
  63487. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63488. */
  63489. set computeParticleColor(val: boolean);
  63490. set computeParticleTexture(val: boolean);
  63491. /**
  63492. * Gets if `setParticles()` computes the particle colors or not.
  63493. * Default value : false. The PCS is faster when it's set to false.
  63494. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63495. */
  63496. get computeParticleColor(): boolean;
  63497. /**
  63498. * Gets if `setParticles()` computes the particle textures or not.
  63499. * Default value : false. The PCS is faster when it's set to false.
  63500. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63501. */
  63502. get computeParticleTexture(): boolean;
  63503. /**
  63504. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63505. */
  63506. set computeBoundingBox(val: boolean);
  63507. /**
  63508. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63509. */
  63510. get computeBoundingBox(): boolean;
  63511. /**
  63512. * This function does nothing. It may be overwritten to set all the particle first values.
  63513. * The PCS doesn't call this function, you may have to call it by your own.
  63514. * doc :
  63515. */
  63516. initParticles(): void;
  63517. /**
  63518. * This function does nothing. It may be overwritten to recycle a particle
  63519. * The PCS doesn't call this function, you can to call it
  63520. * doc :
  63521. * @param particle The particle to recycle
  63522. * @returns the recycled particle
  63523. */
  63524. recycleParticle(particle: CloudPoint): CloudPoint;
  63525. /**
  63526. * Updates a particle : this function should be overwritten by the user.
  63527. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63528. * doc :
  63529. * @example : just set a particle position or velocity and recycle conditions
  63530. * @param particle The particle to update
  63531. * @returns the updated particle
  63532. */
  63533. updateParticle(particle: CloudPoint): CloudPoint;
  63534. /**
  63535. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63536. * This does nothing and may be overwritten by the user.
  63537. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63538. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63539. * @param update the boolean update value actually passed to setParticles()
  63540. */
  63541. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63542. /**
  63543. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63544. * This will be passed three parameters.
  63545. * This does nothing and may be overwritten by the user.
  63546. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63547. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63548. * @param update the boolean update value actually passed to setParticles()
  63549. */
  63550. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63551. }
  63552. }
  63553. declare module BABYLON {
  63554. /**
  63555. * Represents one particle of a points cloud system.
  63556. */
  63557. export class CloudPoint {
  63558. /**
  63559. * particle global index
  63560. */
  63561. idx: number;
  63562. /**
  63563. * The color of the particle
  63564. */
  63565. color: Nullable<Color4>;
  63566. /**
  63567. * The world space position of the particle.
  63568. */
  63569. position: Vector3;
  63570. /**
  63571. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63572. */
  63573. rotation: Vector3;
  63574. /**
  63575. * The world space rotation quaternion of the particle.
  63576. */
  63577. rotationQuaternion: Nullable<Quaternion>;
  63578. /**
  63579. * The uv of the particle.
  63580. */
  63581. uv: Nullable<Vector2>;
  63582. /**
  63583. * The current speed of the particle.
  63584. */
  63585. velocity: Vector3;
  63586. /**
  63587. * The pivot point in the particle local space.
  63588. */
  63589. pivot: Vector3;
  63590. /**
  63591. * Must the particle be translated from its pivot point in its local space ?
  63592. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63593. * Default : false
  63594. */
  63595. translateFromPivot: boolean;
  63596. /**
  63597. * Index of this particle in the global "positions" array (Internal use)
  63598. * @hidden
  63599. */
  63600. _pos: number;
  63601. /**
  63602. * @hidden Index of this particle in the global "indices" array (Internal use)
  63603. */
  63604. _ind: number;
  63605. /**
  63606. * Group this particle belongs to
  63607. */
  63608. _group: PointsGroup;
  63609. /**
  63610. * Group id of this particle
  63611. */
  63612. groupId: number;
  63613. /**
  63614. * Index of the particle in its group id (Internal use)
  63615. */
  63616. idxInGroup: number;
  63617. /**
  63618. * @hidden Particle BoundingInfo object (Internal use)
  63619. */
  63620. _boundingInfo: BoundingInfo;
  63621. /**
  63622. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63623. */
  63624. _pcs: PointsCloudSystem;
  63625. /**
  63626. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63627. */
  63628. _stillInvisible: boolean;
  63629. /**
  63630. * @hidden Last computed particle rotation matrix
  63631. */
  63632. _rotationMatrix: number[];
  63633. /**
  63634. * Parent particle Id, if any.
  63635. * Default null.
  63636. */
  63637. parentId: Nullable<number>;
  63638. /**
  63639. * @hidden Internal global position in the PCS.
  63640. */
  63641. _globalPosition: Vector3;
  63642. /**
  63643. * Creates a Point Cloud object.
  63644. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63645. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63646. * @param group (PointsGroup) is the group the particle belongs to
  63647. * @param groupId (integer) is the group identifier in the PCS.
  63648. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63649. * @param pcs defines the PCS it is associated to
  63650. */
  63651. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63652. /**
  63653. * get point size
  63654. */
  63655. get size(): Vector3;
  63656. /**
  63657. * Set point size
  63658. */
  63659. set size(scale: Vector3);
  63660. /**
  63661. * Legacy support, changed quaternion to rotationQuaternion
  63662. */
  63663. get quaternion(): Nullable<Quaternion>;
  63664. /**
  63665. * Legacy support, changed quaternion to rotationQuaternion
  63666. */
  63667. set quaternion(q: Nullable<Quaternion>);
  63668. /**
  63669. * Returns a boolean. True if the particle intersects a mesh, else false
  63670. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63671. * @param target is the object (point or mesh) what the intersection is computed against
  63672. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63673. * @returns true if it intersects
  63674. */
  63675. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63676. /**
  63677. * get the rotation matrix of the particle
  63678. * @hidden
  63679. */
  63680. getRotationMatrix(m: Matrix): void;
  63681. }
  63682. /**
  63683. * Represents a group of points in a points cloud system
  63684. * * PCS internal tool, don't use it manually.
  63685. */
  63686. export class PointsGroup {
  63687. /**
  63688. * The group id
  63689. * @hidden
  63690. */
  63691. groupID: number;
  63692. /**
  63693. * image data for group (internal use)
  63694. * @hidden
  63695. */
  63696. _groupImageData: Nullable<ArrayBufferView>;
  63697. /**
  63698. * Image Width (internal use)
  63699. * @hidden
  63700. */
  63701. _groupImgWidth: number;
  63702. /**
  63703. * Image Height (internal use)
  63704. * @hidden
  63705. */
  63706. _groupImgHeight: number;
  63707. /**
  63708. * Custom position function (internal use)
  63709. * @hidden
  63710. */
  63711. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63712. /**
  63713. * density per facet for surface points
  63714. * @hidden
  63715. */
  63716. _groupDensity: number[];
  63717. /**
  63718. * Only when points are colored by texture carries pointer to texture list array
  63719. * @hidden
  63720. */
  63721. _textureNb: number;
  63722. /**
  63723. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63724. * PCS internal tool, don't use it manually.
  63725. * @hidden
  63726. */
  63727. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63728. }
  63729. }
  63730. declare module BABYLON {
  63731. interface Scene {
  63732. /** @hidden (Backing field) */
  63733. _physicsEngine: Nullable<IPhysicsEngine>;
  63734. /** @hidden */
  63735. _physicsTimeAccumulator: number;
  63736. /**
  63737. * Gets the current physics engine
  63738. * @returns a IPhysicsEngine or null if none attached
  63739. */
  63740. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63741. /**
  63742. * Enables physics to the current scene
  63743. * @param gravity defines the scene's gravity for the physics engine
  63744. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63745. * @return a boolean indicating if the physics engine was initialized
  63746. */
  63747. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63748. /**
  63749. * Disables and disposes the physics engine associated with the scene
  63750. */
  63751. disablePhysicsEngine(): void;
  63752. /**
  63753. * Gets a boolean indicating if there is an active physics engine
  63754. * @returns a boolean indicating if there is an active physics engine
  63755. */
  63756. isPhysicsEnabled(): boolean;
  63757. /**
  63758. * Deletes a physics compound impostor
  63759. * @param compound defines the compound to delete
  63760. */
  63761. deleteCompoundImpostor(compound: any): void;
  63762. /**
  63763. * An event triggered when physic simulation is about to be run
  63764. */
  63765. onBeforePhysicsObservable: Observable<Scene>;
  63766. /**
  63767. * An event triggered when physic simulation has been done
  63768. */
  63769. onAfterPhysicsObservable: Observable<Scene>;
  63770. }
  63771. interface AbstractMesh {
  63772. /** @hidden */
  63773. _physicsImpostor: Nullable<PhysicsImpostor>;
  63774. /**
  63775. * Gets or sets impostor used for physic simulation
  63776. * @see http://doc.babylonjs.com/features/physics_engine
  63777. */
  63778. physicsImpostor: Nullable<PhysicsImpostor>;
  63779. /**
  63780. * Gets the current physics impostor
  63781. * @see http://doc.babylonjs.com/features/physics_engine
  63782. * @returns a physics impostor or null
  63783. */
  63784. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63785. /** Apply a physic impulse to the mesh
  63786. * @param force defines the force to apply
  63787. * @param contactPoint defines where to apply the force
  63788. * @returns the current mesh
  63789. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63790. */
  63791. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63792. /**
  63793. * Creates a physic joint between two meshes
  63794. * @param otherMesh defines the other mesh to use
  63795. * @param pivot1 defines the pivot to use on this mesh
  63796. * @param pivot2 defines the pivot to use on the other mesh
  63797. * @param options defines additional options (can be plugin dependent)
  63798. * @returns the current mesh
  63799. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63800. */
  63801. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63802. /** @hidden */
  63803. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63804. }
  63805. /**
  63806. * Defines the physics engine scene component responsible to manage a physics engine
  63807. */
  63808. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63809. /**
  63810. * The component name helpful to identify the component in the list of scene components.
  63811. */
  63812. readonly name: string;
  63813. /**
  63814. * The scene the component belongs to.
  63815. */
  63816. scene: Scene;
  63817. /**
  63818. * Creates a new instance of the component for the given scene
  63819. * @param scene Defines the scene to register the component in
  63820. */
  63821. constructor(scene: Scene);
  63822. /**
  63823. * Registers the component in a given scene
  63824. */
  63825. register(): void;
  63826. /**
  63827. * Rebuilds the elements related to this component in case of
  63828. * context lost for instance.
  63829. */
  63830. rebuild(): void;
  63831. /**
  63832. * Disposes the component and the associated ressources
  63833. */
  63834. dispose(): void;
  63835. }
  63836. }
  63837. declare module BABYLON {
  63838. /**
  63839. * A helper for physics simulations
  63840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63841. */
  63842. export class PhysicsHelper {
  63843. private _scene;
  63844. private _physicsEngine;
  63845. /**
  63846. * Initializes the Physics helper
  63847. * @param scene Babylon.js scene
  63848. */
  63849. constructor(scene: Scene);
  63850. /**
  63851. * Applies a radial explosion impulse
  63852. * @param origin the origin of the explosion
  63853. * @param radiusOrEventOptions the radius or the options of radial explosion
  63854. * @param strength the explosion strength
  63855. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63856. * @returns A physics radial explosion event, or null
  63857. */
  63858. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63859. /**
  63860. * Applies a radial explosion force
  63861. * @param origin the origin of the explosion
  63862. * @param radiusOrEventOptions the radius or the options of radial explosion
  63863. * @param strength the explosion strength
  63864. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63865. * @returns A physics radial explosion event, or null
  63866. */
  63867. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63868. /**
  63869. * Creates a gravitational field
  63870. * @param origin the origin of the explosion
  63871. * @param radiusOrEventOptions the radius or the options of radial explosion
  63872. * @param strength the explosion strength
  63873. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63874. * @returns A physics gravitational field event, or null
  63875. */
  63876. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63877. /**
  63878. * Creates a physics updraft event
  63879. * @param origin the origin of the updraft
  63880. * @param radiusOrEventOptions the radius or the options of the updraft
  63881. * @param strength the strength of the updraft
  63882. * @param height the height of the updraft
  63883. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63884. * @returns A physics updraft event, or null
  63885. */
  63886. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63887. /**
  63888. * Creates a physics vortex event
  63889. * @param origin the of the vortex
  63890. * @param radiusOrEventOptions the radius or the options of the vortex
  63891. * @param strength the strength of the vortex
  63892. * @param height the height of the vortex
  63893. * @returns a Physics vortex event, or null
  63894. * A physics vortex event or null
  63895. */
  63896. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63897. }
  63898. /**
  63899. * Represents a physics radial explosion event
  63900. */
  63901. class PhysicsRadialExplosionEvent {
  63902. private _scene;
  63903. private _options;
  63904. private _sphere;
  63905. private _dataFetched;
  63906. /**
  63907. * Initializes a radial explosioin event
  63908. * @param _scene BabylonJS scene
  63909. * @param _options The options for the vortex event
  63910. */
  63911. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63912. /**
  63913. * Returns the data related to the radial explosion event (sphere).
  63914. * @returns The radial explosion event data
  63915. */
  63916. getData(): PhysicsRadialExplosionEventData;
  63917. /**
  63918. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63919. * @param impostor A physics imposter
  63920. * @param origin the origin of the explosion
  63921. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63922. */
  63923. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63924. /**
  63925. * Triggers affecterd impostors callbacks
  63926. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63927. */
  63928. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63929. /**
  63930. * Disposes the sphere.
  63931. * @param force Specifies if the sphere should be disposed by force
  63932. */
  63933. dispose(force?: boolean): void;
  63934. /*** Helpers ***/
  63935. private _prepareSphere;
  63936. private _intersectsWithSphere;
  63937. }
  63938. /**
  63939. * Represents a gravitational field event
  63940. */
  63941. class PhysicsGravitationalFieldEvent {
  63942. private _physicsHelper;
  63943. private _scene;
  63944. private _origin;
  63945. private _options;
  63946. private _tickCallback;
  63947. private _sphere;
  63948. private _dataFetched;
  63949. /**
  63950. * Initializes the physics gravitational field event
  63951. * @param _physicsHelper A physics helper
  63952. * @param _scene BabylonJS scene
  63953. * @param _origin The origin position of the gravitational field event
  63954. * @param _options The options for the vortex event
  63955. */
  63956. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63957. /**
  63958. * Returns the data related to the gravitational field event (sphere).
  63959. * @returns A gravitational field event
  63960. */
  63961. getData(): PhysicsGravitationalFieldEventData;
  63962. /**
  63963. * Enables the gravitational field.
  63964. */
  63965. enable(): void;
  63966. /**
  63967. * Disables the gravitational field.
  63968. */
  63969. disable(): void;
  63970. /**
  63971. * Disposes the sphere.
  63972. * @param force The force to dispose from the gravitational field event
  63973. */
  63974. dispose(force?: boolean): void;
  63975. private _tick;
  63976. }
  63977. /**
  63978. * Represents a physics updraft event
  63979. */
  63980. class PhysicsUpdraftEvent {
  63981. private _scene;
  63982. private _origin;
  63983. private _options;
  63984. private _physicsEngine;
  63985. private _originTop;
  63986. private _originDirection;
  63987. private _tickCallback;
  63988. private _cylinder;
  63989. private _cylinderPosition;
  63990. private _dataFetched;
  63991. /**
  63992. * Initializes the physics updraft event
  63993. * @param _scene BabylonJS scene
  63994. * @param _origin The origin position of the updraft
  63995. * @param _options The options for the updraft event
  63996. */
  63997. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63998. /**
  63999. * Returns the data related to the updraft event (cylinder).
  64000. * @returns A physics updraft event
  64001. */
  64002. getData(): PhysicsUpdraftEventData;
  64003. /**
  64004. * Enables the updraft.
  64005. */
  64006. enable(): void;
  64007. /**
  64008. * Disables the updraft.
  64009. */
  64010. disable(): void;
  64011. /**
  64012. * Disposes the cylinder.
  64013. * @param force Specifies if the updraft should be disposed by force
  64014. */
  64015. dispose(force?: boolean): void;
  64016. private getImpostorHitData;
  64017. private _tick;
  64018. /*** Helpers ***/
  64019. private _prepareCylinder;
  64020. private _intersectsWithCylinder;
  64021. }
  64022. /**
  64023. * Represents a physics vortex event
  64024. */
  64025. class PhysicsVortexEvent {
  64026. private _scene;
  64027. private _origin;
  64028. private _options;
  64029. private _physicsEngine;
  64030. private _originTop;
  64031. private _tickCallback;
  64032. private _cylinder;
  64033. private _cylinderPosition;
  64034. private _dataFetched;
  64035. /**
  64036. * Initializes the physics vortex event
  64037. * @param _scene The BabylonJS scene
  64038. * @param _origin The origin position of the vortex
  64039. * @param _options The options for the vortex event
  64040. */
  64041. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64042. /**
  64043. * Returns the data related to the vortex event (cylinder).
  64044. * @returns The physics vortex event data
  64045. */
  64046. getData(): PhysicsVortexEventData;
  64047. /**
  64048. * Enables the vortex.
  64049. */
  64050. enable(): void;
  64051. /**
  64052. * Disables the cortex.
  64053. */
  64054. disable(): void;
  64055. /**
  64056. * Disposes the sphere.
  64057. * @param force
  64058. */
  64059. dispose(force?: boolean): void;
  64060. private getImpostorHitData;
  64061. private _tick;
  64062. /*** Helpers ***/
  64063. private _prepareCylinder;
  64064. private _intersectsWithCylinder;
  64065. }
  64066. /**
  64067. * Options fot the radial explosion event
  64068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64069. */
  64070. export class PhysicsRadialExplosionEventOptions {
  64071. /**
  64072. * The radius of the sphere for the radial explosion.
  64073. */
  64074. radius: number;
  64075. /**
  64076. * The strenth of the explosion.
  64077. */
  64078. strength: number;
  64079. /**
  64080. * The strenght of the force in correspondence to the distance of the affected object
  64081. */
  64082. falloff: PhysicsRadialImpulseFalloff;
  64083. /**
  64084. * Sphere options for the radial explosion.
  64085. */
  64086. sphere: {
  64087. segments: number;
  64088. diameter: number;
  64089. };
  64090. /**
  64091. * Sphere options for the radial explosion.
  64092. */
  64093. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64094. }
  64095. /**
  64096. * Options fot the updraft event
  64097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64098. */
  64099. export class PhysicsUpdraftEventOptions {
  64100. /**
  64101. * The radius of the cylinder for the vortex
  64102. */
  64103. radius: number;
  64104. /**
  64105. * The strenth of the updraft.
  64106. */
  64107. strength: number;
  64108. /**
  64109. * The height of the cylinder for the updraft.
  64110. */
  64111. height: number;
  64112. /**
  64113. * The mode for the the updraft.
  64114. */
  64115. updraftMode: PhysicsUpdraftMode;
  64116. }
  64117. /**
  64118. * Options fot the vortex event
  64119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64120. */
  64121. export class PhysicsVortexEventOptions {
  64122. /**
  64123. * The radius of the cylinder for the vortex
  64124. */
  64125. radius: number;
  64126. /**
  64127. * The strenth of the vortex.
  64128. */
  64129. strength: number;
  64130. /**
  64131. * The height of the cylinder for the vortex.
  64132. */
  64133. height: number;
  64134. /**
  64135. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64136. */
  64137. centripetalForceThreshold: number;
  64138. /**
  64139. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64140. */
  64141. centripetalForceMultiplier: number;
  64142. /**
  64143. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64144. */
  64145. centrifugalForceMultiplier: number;
  64146. /**
  64147. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64148. */
  64149. updraftForceMultiplier: number;
  64150. }
  64151. /**
  64152. * The strenght of the force in correspondence to the distance of the affected object
  64153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64154. */
  64155. export enum PhysicsRadialImpulseFalloff {
  64156. /** Defines that impulse is constant in strength across it's whole radius */
  64157. Constant = 0,
  64158. /** Defines that impulse gets weaker if it's further from the origin */
  64159. Linear = 1
  64160. }
  64161. /**
  64162. * The strength of the force in correspondence to the distance of the affected object
  64163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64164. */
  64165. export enum PhysicsUpdraftMode {
  64166. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64167. Center = 0,
  64168. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64169. Perpendicular = 1
  64170. }
  64171. /**
  64172. * Interface for a physics hit data
  64173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64174. */
  64175. export interface PhysicsHitData {
  64176. /**
  64177. * The force applied at the contact point
  64178. */
  64179. force: Vector3;
  64180. /**
  64181. * The contact point
  64182. */
  64183. contactPoint: Vector3;
  64184. /**
  64185. * The distance from the origin to the contact point
  64186. */
  64187. distanceFromOrigin: number;
  64188. }
  64189. /**
  64190. * Interface for radial explosion event data
  64191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64192. */
  64193. export interface PhysicsRadialExplosionEventData {
  64194. /**
  64195. * A sphere used for the radial explosion event
  64196. */
  64197. sphere: Mesh;
  64198. }
  64199. /**
  64200. * Interface for gravitational field event data
  64201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64202. */
  64203. export interface PhysicsGravitationalFieldEventData {
  64204. /**
  64205. * A sphere mesh used for the gravitational field event
  64206. */
  64207. sphere: Mesh;
  64208. }
  64209. /**
  64210. * Interface for updraft event data
  64211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64212. */
  64213. export interface PhysicsUpdraftEventData {
  64214. /**
  64215. * A cylinder used for the updraft event
  64216. */
  64217. cylinder: Mesh;
  64218. }
  64219. /**
  64220. * Interface for vortex event data
  64221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64222. */
  64223. export interface PhysicsVortexEventData {
  64224. /**
  64225. * A cylinder used for the vortex event
  64226. */
  64227. cylinder: Mesh;
  64228. }
  64229. /**
  64230. * Interface for an affected physics impostor
  64231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64232. */
  64233. export interface PhysicsAffectedImpostorWithData {
  64234. /**
  64235. * The impostor affected by the effect
  64236. */
  64237. impostor: PhysicsImpostor;
  64238. /**
  64239. * The data about the hit/horce from the explosion
  64240. */
  64241. hitData: PhysicsHitData;
  64242. }
  64243. }
  64244. declare module BABYLON {
  64245. /** @hidden */
  64246. export var blackAndWhitePixelShader: {
  64247. name: string;
  64248. shader: string;
  64249. };
  64250. }
  64251. declare module BABYLON {
  64252. /**
  64253. * Post process used to render in black and white
  64254. */
  64255. export class BlackAndWhitePostProcess extends PostProcess {
  64256. /**
  64257. * Linear about to convert he result to black and white (default: 1)
  64258. */
  64259. degree: number;
  64260. /**
  64261. * Creates a black and white post process
  64262. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64263. * @param name The name of the effect.
  64264. * @param options The required width/height ratio to downsize to before computing the render pass.
  64265. * @param camera The camera to apply the render pass to.
  64266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64267. * @param engine The engine which the post process will be applied. (default: current engine)
  64268. * @param reusable If the post process can be reused on the same frame. (default: false)
  64269. */
  64270. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64271. }
  64272. }
  64273. declare module BABYLON {
  64274. /**
  64275. * This represents a set of one or more post processes in Babylon.
  64276. * A post process can be used to apply a shader to a texture after it is rendered.
  64277. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64278. */
  64279. export class PostProcessRenderEffect {
  64280. private _postProcesses;
  64281. private _getPostProcesses;
  64282. private _singleInstance;
  64283. private _cameras;
  64284. private _indicesForCamera;
  64285. /**
  64286. * Name of the effect
  64287. * @hidden
  64288. */
  64289. _name: string;
  64290. /**
  64291. * Instantiates a post process render effect.
  64292. * A post process can be used to apply a shader to a texture after it is rendered.
  64293. * @param engine The engine the effect is tied to
  64294. * @param name The name of the effect
  64295. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64296. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64297. */
  64298. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64299. /**
  64300. * Checks if all the post processes in the effect are supported.
  64301. */
  64302. get isSupported(): boolean;
  64303. /**
  64304. * Updates the current state of the effect
  64305. * @hidden
  64306. */
  64307. _update(): void;
  64308. /**
  64309. * Attaches the effect on cameras
  64310. * @param cameras The camera to attach to.
  64311. * @hidden
  64312. */
  64313. _attachCameras(cameras: Camera): void;
  64314. /**
  64315. * Attaches the effect on cameras
  64316. * @param cameras The camera to attach to.
  64317. * @hidden
  64318. */
  64319. _attachCameras(cameras: Camera[]): void;
  64320. /**
  64321. * Detaches the effect on cameras
  64322. * @param cameras The camera to detatch from.
  64323. * @hidden
  64324. */
  64325. _detachCameras(cameras: Camera): void;
  64326. /**
  64327. * Detatches the effect on cameras
  64328. * @param cameras The camera to detatch from.
  64329. * @hidden
  64330. */
  64331. _detachCameras(cameras: Camera[]): void;
  64332. /**
  64333. * Enables the effect on given cameras
  64334. * @param cameras The camera to enable.
  64335. * @hidden
  64336. */
  64337. _enable(cameras: Camera): void;
  64338. /**
  64339. * Enables the effect on given cameras
  64340. * @param cameras The camera to enable.
  64341. * @hidden
  64342. */
  64343. _enable(cameras: Nullable<Camera[]>): void;
  64344. /**
  64345. * Disables the effect on the given cameras
  64346. * @param cameras The camera to disable.
  64347. * @hidden
  64348. */
  64349. _disable(cameras: Camera): void;
  64350. /**
  64351. * Disables the effect on the given cameras
  64352. * @param cameras The camera to disable.
  64353. * @hidden
  64354. */
  64355. _disable(cameras: Nullable<Camera[]>): void;
  64356. /**
  64357. * Gets a list of the post processes contained in the effect.
  64358. * @param camera The camera to get the post processes on.
  64359. * @returns The list of the post processes in the effect.
  64360. */
  64361. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64362. }
  64363. }
  64364. declare module BABYLON {
  64365. /** @hidden */
  64366. export var extractHighlightsPixelShader: {
  64367. name: string;
  64368. shader: string;
  64369. };
  64370. }
  64371. declare module BABYLON {
  64372. /**
  64373. * 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.
  64374. */
  64375. export class ExtractHighlightsPostProcess extends PostProcess {
  64376. /**
  64377. * The luminance threshold, pixels below this value will be set to black.
  64378. */
  64379. threshold: number;
  64380. /** @hidden */
  64381. _exposure: number;
  64382. /**
  64383. * Post process which has the input texture to be used when performing highlight extraction
  64384. * @hidden
  64385. */
  64386. _inputPostProcess: Nullable<PostProcess>;
  64387. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64388. }
  64389. }
  64390. declare module BABYLON {
  64391. /** @hidden */
  64392. export var bloomMergePixelShader: {
  64393. name: string;
  64394. shader: string;
  64395. };
  64396. }
  64397. declare module BABYLON {
  64398. /**
  64399. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64400. */
  64401. export class BloomMergePostProcess extends PostProcess {
  64402. /** Weight of the bloom to be added to the original input. */
  64403. weight: number;
  64404. /**
  64405. * Creates a new instance of @see BloomMergePostProcess
  64406. * @param name The name of the effect.
  64407. * @param originalFromInput Post process which's input will be used for the merge.
  64408. * @param blurred Blurred highlights post process which's output will be used.
  64409. * @param weight Weight of the bloom to be added to the original input.
  64410. * @param options The required width/height ratio to downsize to before computing the render pass.
  64411. * @param camera The camera to apply the render pass to.
  64412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64413. * @param engine The engine which the post process will be applied. (default: current engine)
  64414. * @param reusable If the post process can be reused on the same frame. (default: false)
  64415. * @param textureType Type of textures used when performing the post process. (default: 0)
  64416. * @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)
  64417. */
  64418. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64419. /** Weight of the bloom to be added to the original input. */
  64420. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64421. }
  64422. }
  64423. declare module BABYLON {
  64424. /**
  64425. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64426. */
  64427. export class BloomEffect extends PostProcessRenderEffect {
  64428. private bloomScale;
  64429. /**
  64430. * @hidden Internal
  64431. */
  64432. _effects: Array<PostProcess>;
  64433. /**
  64434. * @hidden Internal
  64435. */
  64436. _downscale: ExtractHighlightsPostProcess;
  64437. private _blurX;
  64438. private _blurY;
  64439. private _merge;
  64440. /**
  64441. * The luminance threshold to find bright areas of the image to bloom.
  64442. */
  64443. get threshold(): number;
  64444. set threshold(value: number);
  64445. /**
  64446. * The strength of the bloom.
  64447. */
  64448. get weight(): number;
  64449. set weight(value: number);
  64450. /**
  64451. * Specifies the size of the bloom blur kernel, relative to the final output size
  64452. */
  64453. get kernel(): number;
  64454. set kernel(value: number);
  64455. /**
  64456. * Creates a new instance of @see BloomEffect
  64457. * @param scene The scene the effect belongs to.
  64458. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64459. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64460. * @param bloomWeight The the strength of bloom.
  64461. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64462. * @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)
  64463. */
  64464. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64465. /**
  64466. * Disposes each of the internal effects for a given camera.
  64467. * @param camera The camera to dispose the effect on.
  64468. */
  64469. disposeEffects(camera: Camera): void;
  64470. /**
  64471. * @hidden Internal
  64472. */
  64473. _updateEffects(): void;
  64474. /**
  64475. * Internal
  64476. * @returns if all the contained post processes are ready.
  64477. * @hidden
  64478. */
  64479. _isReady(): boolean;
  64480. }
  64481. }
  64482. declare module BABYLON {
  64483. /** @hidden */
  64484. export var chromaticAberrationPixelShader: {
  64485. name: string;
  64486. shader: string;
  64487. };
  64488. }
  64489. declare module BABYLON {
  64490. /**
  64491. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64492. */
  64493. export class ChromaticAberrationPostProcess extends PostProcess {
  64494. /**
  64495. * The amount of seperation of rgb channels (default: 30)
  64496. */
  64497. aberrationAmount: number;
  64498. /**
  64499. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64500. */
  64501. radialIntensity: number;
  64502. /**
  64503. * 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))
  64504. */
  64505. direction: Vector2;
  64506. /**
  64507. * 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))
  64508. */
  64509. centerPosition: Vector2;
  64510. /**
  64511. * Creates a new instance ChromaticAberrationPostProcess
  64512. * @param name The name of the effect.
  64513. * @param screenWidth The width of the screen to apply the effect on.
  64514. * @param screenHeight The height of the screen to apply the effect on.
  64515. * @param options The required width/height ratio to downsize to before computing the render pass.
  64516. * @param camera The camera to apply the render pass to.
  64517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64518. * @param engine The engine which the post process will be applied. (default: current engine)
  64519. * @param reusable If the post process can be reused on the same frame. (default: false)
  64520. * @param textureType Type of textures used when performing the post process. (default: 0)
  64521. * @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)
  64522. */
  64523. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64524. }
  64525. }
  64526. declare module BABYLON {
  64527. /** @hidden */
  64528. export var circleOfConfusionPixelShader: {
  64529. name: string;
  64530. shader: string;
  64531. };
  64532. }
  64533. declare module BABYLON {
  64534. /**
  64535. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64536. */
  64537. export class CircleOfConfusionPostProcess extends PostProcess {
  64538. /**
  64539. * 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.
  64540. */
  64541. lensSize: number;
  64542. /**
  64543. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64544. */
  64545. fStop: number;
  64546. /**
  64547. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64548. */
  64549. focusDistance: number;
  64550. /**
  64551. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64552. */
  64553. focalLength: number;
  64554. private _depthTexture;
  64555. /**
  64556. * Creates a new instance CircleOfConfusionPostProcess
  64557. * @param name The name of the effect.
  64558. * @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.
  64559. * @param options The required width/height ratio to downsize to before computing the render pass.
  64560. * @param camera The camera to apply the render pass to.
  64561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64562. * @param engine The engine which the post process will be applied. (default: current engine)
  64563. * @param reusable If the post process can be reused on the same frame. (default: false)
  64564. * @param textureType Type of textures used when performing the post process. (default: 0)
  64565. * @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)
  64566. */
  64567. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64568. /**
  64569. * 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.
  64570. */
  64571. set depthTexture(value: RenderTargetTexture);
  64572. }
  64573. }
  64574. declare module BABYLON {
  64575. /** @hidden */
  64576. export var colorCorrectionPixelShader: {
  64577. name: string;
  64578. shader: string;
  64579. };
  64580. }
  64581. declare module BABYLON {
  64582. /**
  64583. *
  64584. * This post-process allows the modification of rendered colors by using
  64585. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64586. *
  64587. * The object needs to be provided an url to a texture containing the color
  64588. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64589. * Use an image editing software to tweak the LUT to match your needs.
  64590. *
  64591. * For an example of a color LUT, see here:
  64592. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64593. * For explanations on color grading, see here:
  64594. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64595. *
  64596. */
  64597. export class ColorCorrectionPostProcess extends PostProcess {
  64598. private _colorTableTexture;
  64599. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64600. }
  64601. }
  64602. declare module BABYLON {
  64603. /** @hidden */
  64604. export var convolutionPixelShader: {
  64605. name: string;
  64606. shader: string;
  64607. };
  64608. }
  64609. declare module BABYLON {
  64610. /**
  64611. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64612. * input texture to perform effects such as edge detection or sharpening
  64613. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64614. */
  64615. export class ConvolutionPostProcess extends PostProcess {
  64616. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64617. kernel: number[];
  64618. /**
  64619. * Creates a new instance ConvolutionPostProcess
  64620. * @param name The name of the effect.
  64621. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64622. * @param options The required width/height ratio to downsize to before computing the render pass.
  64623. * @param camera The camera to apply the render pass to.
  64624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64625. * @param engine The engine which the post process will be applied. (default: current engine)
  64626. * @param reusable If the post process can be reused on the same frame. (default: false)
  64627. * @param textureType Type of textures used when performing the post process. (default: 0)
  64628. */
  64629. constructor(name: string,
  64630. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64631. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64632. /**
  64633. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64634. */
  64635. static EdgeDetect0Kernel: number[];
  64636. /**
  64637. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64638. */
  64639. static EdgeDetect1Kernel: number[];
  64640. /**
  64641. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64642. */
  64643. static EdgeDetect2Kernel: number[];
  64644. /**
  64645. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64646. */
  64647. static SharpenKernel: number[];
  64648. /**
  64649. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64650. */
  64651. static EmbossKernel: number[];
  64652. /**
  64653. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64654. */
  64655. static GaussianKernel: number[];
  64656. }
  64657. }
  64658. declare module BABYLON {
  64659. /**
  64660. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64661. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64662. * based on samples that have a large difference in distance than the center pixel.
  64663. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64664. */
  64665. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64666. direction: Vector2;
  64667. /**
  64668. * Creates a new instance CircleOfConfusionPostProcess
  64669. * @param name The name of the effect.
  64670. * @param scene The scene the effect belongs to.
  64671. * @param direction The direction the blur should be applied.
  64672. * @param kernel The size of the kernel used to blur.
  64673. * @param options The required width/height ratio to downsize to before computing the render pass.
  64674. * @param camera The camera to apply the render pass to.
  64675. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64676. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64678. * @param engine The engine which the post process will be applied. (default: current engine)
  64679. * @param reusable If the post process can be reused on the same frame. (default: false)
  64680. * @param textureType Type of textures used when performing the post process. (default: 0)
  64681. * @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)
  64682. */
  64683. 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);
  64684. }
  64685. }
  64686. declare module BABYLON {
  64687. /** @hidden */
  64688. export var depthOfFieldMergePixelShader: {
  64689. name: string;
  64690. shader: string;
  64691. };
  64692. }
  64693. declare module BABYLON {
  64694. /**
  64695. * Options to be set when merging outputs from the default pipeline.
  64696. */
  64697. export class DepthOfFieldMergePostProcessOptions {
  64698. /**
  64699. * The original image to merge on top of
  64700. */
  64701. originalFromInput: PostProcess;
  64702. /**
  64703. * Parameters to perform the merge of the depth of field effect
  64704. */
  64705. depthOfField?: {
  64706. circleOfConfusion: PostProcess;
  64707. blurSteps: Array<PostProcess>;
  64708. };
  64709. /**
  64710. * Parameters to perform the merge of bloom effect
  64711. */
  64712. bloom?: {
  64713. blurred: PostProcess;
  64714. weight: number;
  64715. };
  64716. }
  64717. /**
  64718. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64719. */
  64720. export class DepthOfFieldMergePostProcess extends PostProcess {
  64721. private blurSteps;
  64722. /**
  64723. * Creates a new instance of DepthOfFieldMergePostProcess
  64724. * @param name The name of the effect.
  64725. * @param originalFromInput Post process which's input will be used for the merge.
  64726. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64727. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64728. * @param options The required width/height ratio to downsize to before computing the render pass.
  64729. * @param camera The camera to apply the render pass to.
  64730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64731. * @param engine The engine which the post process will be applied. (default: current engine)
  64732. * @param reusable If the post process can be reused on the same frame. (default: false)
  64733. * @param textureType Type of textures used when performing the post process. (default: 0)
  64734. * @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)
  64735. */
  64736. 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);
  64737. /**
  64738. * Updates the effect with the current post process compile time values and recompiles the shader.
  64739. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64740. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64741. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64742. * @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
  64743. * @param onCompiled Called when the shader has been compiled.
  64744. * @param onError Called if there is an error when compiling a shader.
  64745. */
  64746. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64747. }
  64748. }
  64749. declare module BABYLON {
  64750. /**
  64751. * Specifies the level of max blur that should be applied when using the depth of field effect
  64752. */
  64753. export enum DepthOfFieldEffectBlurLevel {
  64754. /**
  64755. * Subtle blur
  64756. */
  64757. Low = 0,
  64758. /**
  64759. * Medium blur
  64760. */
  64761. Medium = 1,
  64762. /**
  64763. * Large blur
  64764. */
  64765. High = 2
  64766. }
  64767. /**
  64768. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64769. */
  64770. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64771. private _circleOfConfusion;
  64772. /**
  64773. * @hidden Internal, blurs from high to low
  64774. */
  64775. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64776. private _depthOfFieldBlurY;
  64777. private _dofMerge;
  64778. /**
  64779. * @hidden Internal post processes in depth of field effect
  64780. */
  64781. _effects: Array<PostProcess>;
  64782. /**
  64783. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64784. */
  64785. set focalLength(value: number);
  64786. get focalLength(): number;
  64787. /**
  64788. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64789. */
  64790. set fStop(value: number);
  64791. get fStop(): number;
  64792. /**
  64793. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64794. */
  64795. set focusDistance(value: number);
  64796. get focusDistance(): number;
  64797. /**
  64798. * 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.
  64799. */
  64800. set lensSize(value: number);
  64801. get lensSize(): number;
  64802. /**
  64803. * Creates a new instance DepthOfFieldEffect
  64804. * @param scene The scene the effect belongs to.
  64805. * @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.
  64806. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64807. * @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)
  64808. */
  64809. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64810. /**
  64811. * Get the current class name of the current effet
  64812. * @returns "DepthOfFieldEffect"
  64813. */
  64814. getClassName(): string;
  64815. /**
  64816. * 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.
  64817. */
  64818. set depthTexture(value: RenderTargetTexture);
  64819. /**
  64820. * Disposes each of the internal effects for a given camera.
  64821. * @param camera The camera to dispose the effect on.
  64822. */
  64823. disposeEffects(camera: Camera): void;
  64824. /**
  64825. * @hidden Internal
  64826. */
  64827. _updateEffects(): void;
  64828. /**
  64829. * Internal
  64830. * @returns if all the contained post processes are ready.
  64831. * @hidden
  64832. */
  64833. _isReady(): boolean;
  64834. }
  64835. }
  64836. declare module BABYLON {
  64837. /** @hidden */
  64838. export var displayPassPixelShader: {
  64839. name: string;
  64840. shader: string;
  64841. };
  64842. }
  64843. declare module BABYLON {
  64844. /**
  64845. * DisplayPassPostProcess which produces an output the same as it's input
  64846. */
  64847. export class DisplayPassPostProcess extends PostProcess {
  64848. /**
  64849. * Creates the DisplayPassPostProcess
  64850. * @param name The name of the effect.
  64851. * @param options The required width/height ratio to downsize to before computing the render pass.
  64852. * @param camera The camera to apply the render pass to.
  64853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64854. * @param engine The engine which the post process will be applied. (default: current engine)
  64855. * @param reusable If the post process can be reused on the same frame. (default: false)
  64856. */
  64857. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64858. }
  64859. }
  64860. declare module BABYLON {
  64861. /** @hidden */
  64862. export var filterPixelShader: {
  64863. name: string;
  64864. shader: string;
  64865. };
  64866. }
  64867. declare module BABYLON {
  64868. /**
  64869. * Applies a kernel filter to the image
  64870. */
  64871. export class FilterPostProcess extends PostProcess {
  64872. /** The matrix to be applied to the image */
  64873. kernelMatrix: Matrix;
  64874. /**
  64875. *
  64876. * @param name The name of the effect.
  64877. * @param kernelMatrix The matrix to be applied to the image
  64878. * @param options The required width/height ratio to downsize to before computing the render pass.
  64879. * @param camera The camera to apply the render pass to.
  64880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64881. * @param engine The engine which the post process will be applied. (default: current engine)
  64882. * @param reusable If the post process can be reused on the same frame. (default: false)
  64883. */
  64884. constructor(name: string,
  64885. /** The matrix to be applied to the image */
  64886. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64887. }
  64888. }
  64889. declare module BABYLON {
  64890. /** @hidden */
  64891. export var fxaaPixelShader: {
  64892. name: string;
  64893. shader: string;
  64894. };
  64895. }
  64896. declare module BABYLON {
  64897. /** @hidden */
  64898. export var fxaaVertexShader: {
  64899. name: string;
  64900. shader: string;
  64901. };
  64902. }
  64903. declare module BABYLON {
  64904. /**
  64905. * Fxaa post process
  64906. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64907. */
  64908. export class FxaaPostProcess extends PostProcess {
  64909. /** @hidden */
  64910. texelWidth: number;
  64911. /** @hidden */
  64912. texelHeight: number;
  64913. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64914. private _getDefines;
  64915. }
  64916. }
  64917. declare module BABYLON {
  64918. /** @hidden */
  64919. export var grainPixelShader: {
  64920. name: string;
  64921. shader: string;
  64922. };
  64923. }
  64924. declare module BABYLON {
  64925. /**
  64926. * The GrainPostProcess adds noise to the image at mid luminance levels
  64927. */
  64928. export class GrainPostProcess extends PostProcess {
  64929. /**
  64930. * The intensity of the grain added (default: 30)
  64931. */
  64932. intensity: number;
  64933. /**
  64934. * If the grain should be randomized on every frame
  64935. */
  64936. animated: boolean;
  64937. /**
  64938. * Creates a new instance of @see GrainPostProcess
  64939. * @param name The name of the effect.
  64940. * @param options The required width/height ratio to downsize to before computing the render pass.
  64941. * @param camera The camera to apply the render pass to.
  64942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64943. * @param engine The engine which the post process will be applied. (default: current engine)
  64944. * @param reusable If the post process can be reused on the same frame. (default: false)
  64945. * @param textureType Type of textures used when performing the post process. (default: 0)
  64946. * @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)
  64947. */
  64948. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64949. }
  64950. }
  64951. declare module BABYLON {
  64952. /** @hidden */
  64953. export var highlightsPixelShader: {
  64954. name: string;
  64955. shader: string;
  64956. };
  64957. }
  64958. declare module BABYLON {
  64959. /**
  64960. * Extracts highlights from the image
  64961. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64962. */
  64963. export class HighlightsPostProcess extends PostProcess {
  64964. /**
  64965. * Extracts highlights from the image
  64966. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  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 texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64974. */
  64975. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64976. }
  64977. }
  64978. declare module BABYLON {
  64979. /** @hidden */
  64980. export var mrtFragmentDeclaration: {
  64981. name: string;
  64982. shader: string;
  64983. };
  64984. }
  64985. declare module BABYLON {
  64986. /** @hidden */
  64987. export var geometryPixelShader: {
  64988. name: string;
  64989. shader: string;
  64990. };
  64991. }
  64992. declare module BABYLON {
  64993. /** @hidden */
  64994. export var geometryVertexShader: {
  64995. name: string;
  64996. shader: string;
  64997. };
  64998. }
  64999. declare module BABYLON {
  65000. /** @hidden */
  65001. interface ISavedTransformationMatrix {
  65002. world: Matrix;
  65003. viewProjection: Matrix;
  65004. }
  65005. /**
  65006. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65007. */
  65008. export class GeometryBufferRenderer {
  65009. /**
  65010. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65011. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65012. */
  65013. static readonly POSITION_TEXTURE_TYPE: number;
  65014. /**
  65015. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65016. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65017. */
  65018. static readonly VELOCITY_TEXTURE_TYPE: number;
  65019. /**
  65020. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65021. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65022. */
  65023. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65024. /**
  65025. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65026. * in order to compute objects velocities when enableVelocity is set to "true"
  65027. * @hidden
  65028. */
  65029. _previousTransformationMatrices: {
  65030. [index: number]: ISavedTransformationMatrix;
  65031. };
  65032. /**
  65033. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65034. * in order to compute objects velocities when enableVelocity is set to "true"
  65035. * @hidden
  65036. */
  65037. _previousBonesTransformationMatrices: {
  65038. [index: number]: Float32Array;
  65039. };
  65040. /**
  65041. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65042. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65043. */
  65044. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65045. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65046. renderTransparentMeshes: boolean;
  65047. private _scene;
  65048. private _multiRenderTarget;
  65049. private _ratio;
  65050. private _enablePosition;
  65051. private _enableVelocity;
  65052. private _enableReflectivity;
  65053. private _positionIndex;
  65054. private _velocityIndex;
  65055. private _reflectivityIndex;
  65056. protected _effect: Effect;
  65057. protected _cachedDefines: string;
  65058. /**
  65059. * Set the render list (meshes to be rendered) used in the G buffer.
  65060. */
  65061. set renderList(meshes: Mesh[]);
  65062. /**
  65063. * Gets wether or not G buffer are supported by the running hardware.
  65064. * This requires draw buffer supports
  65065. */
  65066. get isSupported(): boolean;
  65067. /**
  65068. * Returns the index of the given texture type in the G-Buffer textures array
  65069. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65070. * @returns the index of the given texture type in the G-Buffer textures array
  65071. */
  65072. getTextureIndex(textureType: number): number;
  65073. /**
  65074. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65075. */
  65076. get enablePosition(): boolean;
  65077. /**
  65078. * Sets whether or not objects positions are enabled for the G buffer.
  65079. */
  65080. set enablePosition(enable: boolean);
  65081. /**
  65082. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65083. */
  65084. get enableVelocity(): boolean;
  65085. /**
  65086. * Sets wether or not objects velocities are enabled for the G buffer.
  65087. */
  65088. set enableVelocity(enable: boolean);
  65089. /**
  65090. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65091. */
  65092. get enableReflectivity(): boolean;
  65093. /**
  65094. * Sets wether or not objects roughness are enabled for the G buffer.
  65095. */
  65096. set enableReflectivity(enable: boolean);
  65097. /**
  65098. * Gets the scene associated with the buffer.
  65099. */
  65100. get scene(): Scene;
  65101. /**
  65102. * Gets the ratio used by the buffer during its creation.
  65103. * How big is the buffer related to the main canvas.
  65104. */
  65105. get ratio(): number;
  65106. /** @hidden */
  65107. static _SceneComponentInitialization: (scene: Scene) => void;
  65108. /**
  65109. * Creates a new G Buffer for the scene
  65110. * @param scene The scene the buffer belongs to
  65111. * @param ratio How big is the buffer related to the main canvas.
  65112. */
  65113. constructor(scene: Scene, ratio?: number);
  65114. /**
  65115. * Checks wether everything is ready to render a submesh to the G buffer.
  65116. * @param subMesh the submesh to check readiness for
  65117. * @param useInstances is the mesh drawn using instance or not
  65118. * @returns true if ready otherwise false
  65119. */
  65120. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65121. /**
  65122. * Gets the current underlying G Buffer.
  65123. * @returns the buffer
  65124. */
  65125. getGBuffer(): MultiRenderTarget;
  65126. /**
  65127. * Gets the number of samples used to render the buffer (anti aliasing).
  65128. */
  65129. get samples(): number;
  65130. /**
  65131. * Sets the number of samples used to render the buffer (anti aliasing).
  65132. */
  65133. set samples(value: number);
  65134. /**
  65135. * Disposes the renderer and frees up associated resources.
  65136. */
  65137. dispose(): void;
  65138. protected _createRenderTargets(): void;
  65139. private _copyBonesTransformationMatrices;
  65140. }
  65141. }
  65142. declare module BABYLON {
  65143. interface Scene {
  65144. /** @hidden (Backing field) */
  65145. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65146. /**
  65147. * Gets or Sets the current geometry buffer associated to the scene.
  65148. */
  65149. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65150. /**
  65151. * Enables a GeometryBufferRender and associates it with the scene
  65152. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65153. * @returns the GeometryBufferRenderer
  65154. */
  65155. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65156. /**
  65157. * Disables the GeometryBufferRender associated with the scene
  65158. */
  65159. disableGeometryBufferRenderer(): void;
  65160. }
  65161. /**
  65162. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65163. * in several rendering techniques.
  65164. */
  65165. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65166. /**
  65167. * The component name helpful to identify the component in the list of scene components.
  65168. */
  65169. readonly name: string;
  65170. /**
  65171. * The scene the component belongs to.
  65172. */
  65173. scene: Scene;
  65174. /**
  65175. * Creates a new instance of the component for the given scene
  65176. * @param scene Defines the scene to register the component in
  65177. */
  65178. constructor(scene: Scene);
  65179. /**
  65180. * Registers the component in a given scene
  65181. */
  65182. register(): void;
  65183. /**
  65184. * Rebuilds the elements related to this component in case of
  65185. * context lost for instance.
  65186. */
  65187. rebuild(): void;
  65188. /**
  65189. * Disposes the component and the associated ressources
  65190. */
  65191. dispose(): void;
  65192. private _gatherRenderTargets;
  65193. }
  65194. }
  65195. declare module BABYLON {
  65196. /** @hidden */
  65197. export var motionBlurPixelShader: {
  65198. name: string;
  65199. shader: string;
  65200. };
  65201. }
  65202. declare module BABYLON {
  65203. /**
  65204. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65205. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65206. * As an example, all you have to do is to create the post-process:
  65207. * var mb = new BABYLON.MotionBlurPostProcess(
  65208. * 'mb', // The name of the effect.
  65209. * scene, // The scene containing the objects to blur according to their velocity.
  65210. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65211. * camera // The camera to apply the render pass to.
  65212. * );
  65213. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65214. */
  65215. export class MotionBlurPostProcess extends PostProcess {
  65216. /**
  65217. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65218. */
  65219. motionStrength: number;
  65220. /**
  65221. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65222. */
  65223. get motionBlurSamples(): number;
  65224. /**
  65225. * Sets the number of iterations to be used for motion blur quality
  65226. */
  65227. set motionBlurSamples(samples: number);
  65228. private _motionBlurSamples;
  65229. private _geometryBufferRenderer;
  65230. /**
  65231. * Creates a new instance MotionBlurPostProcess
  65232. * @param name The name of the effect.
  65233. * @param scene The scene containing the objects to blur according to their velocity.
  65234. * @param options The required width/height ratio to downsize to before computing the render pass.
  65235. * @param camera The camera to apply the render pass to.
  65236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65237. * @param engine The engine which the post process will be applied. (default: current engine)
  65238. * @param reusable If the post process can be reused on the same frame. (default: false)
  65239. * @param textureType Type of textures used when performing the post process. (default: 0)
  65240. * @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)
  65241. */
  65242. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65243. /**
  65244. * Excludes the given skinned mesh from computing bones velocities.
  65245. * 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.
  65246. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65247. */
  65248. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65249. /**
  65250. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65251. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65252. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65253. */
  65254. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65255. /**
  65256. * Disposes the post process.
  65257. * @param camera The camera to dispose the post process on.
  65258. */
  65259. dispose(camera?: Camera): void;
  65260. }
  65261. }
  65262. declare module BABYLON {
  65263. /** @hidden */
  65264. export var refractionPixelShader: {
  65265. name: string;
  65266. shader: string;
  65267. };
  65268. }
  65269. declare module BABYLON {
  65270. /**
  65271. * Post process which applies a refractin texture
  65272. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65273. */
  65274. export class RefractionPostProcess extends PostProcess {
  65275. /** the base color of the refraction (used to taint the rendering) */
  65276. color: Color3;
  65277. /** simulated refraction depth */
  65278. depth: number;
  65279. /** the coefficient of the base color (0 to remove base color tainting) */
  65280. colorLevel: number;
  65281. private _refTexture;
  65282. private _ownRefractionTexture;
  65283. /**
  65284. * Gets or sets the refraction texture
  65285. * Please note that you are responsible for disposing the texture if you set it manually
  65286. */
  65287. get refractionTexture(): Texture;
  65288. set refractionTexture(value: Texture);
  65289. /**
  65290. * Initializes the RefractionPostProcess
  65291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65292. * @param name The name of the effect.
  65293. * @param refractionTextureUrl Url of the refraction texture to use
  65294. * @param color the base color of the refraction (used to taint the rendering)
  65295. * @param depth simulated refraction depth
  65296. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65297. * @param camera The camera to apply the render pass to.
  65298. * @param options The required width/height ratio to downsize to before computing the render pass.
  65299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65300. * @param engine The engine which the post process will be applied. (default: current engine)
  65301. * @param reusable If the post process can be reused on the same frame. (default: false)
  65302. */
  65303. constructor(name: string, refractionTextureUrl: string,
  65304. /** the base color of the refraction (used to taint the rendering) */
  65305. color: Color3,
  65306. /** simulated refraction depth */
  65307. depth: number,
  65308. /** the coefficient of the base color (0 to remove base color tainting) */
  65309. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65310. /**
  65311. * Disposes of the post process
  65312. * @param camera Camera to dispose post process on
  65313. */
  65314. dispose(camera: Camera): void;
  65315. }
  65316. }
  65317. declare module BABYLON {
  65318. /** @hidden */
  65319. export var sharpenPixelShader: {
  65320. name: string;
  65321. shader: string;
  65322. };
  65323. }
  65324. declare module BABYLON {
  65325. /**
  65326. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65327. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65328. */
  65329. export class SharpenPostProcess extends PostProcess {
  65330. /**
  65331. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65332. */
  65333. colorAmount: number;
  65334. /**
  65335. * How much sharpness should be applied (default: 0.3)
  65336. */
  65337. edgeAmount: number;
  65338. /**
  65339. * Creates a new instance ConvolutionPostProcess
  65340. * @param name The name of the effect.
  65341. * @param options The required width/height ratio to downsize to before computing the render pass.
  65342. * @param camera The camera to apply the render pass to.
  65343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65344. * @param engine The engine which the post process will be applied. (default: current engine)
  65345. * @param reusable If the post process can be reused on the same frame. (default: false)
  65346. * @param textureType Type of textures used when performing the post process. (default: 0)
  65347. * @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)
  65348. */
  65349. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65350. }
  65351. }
  65352. declare module BABYLON {
  65353. /**
  65354. * PostProcessRenderPipeline
  65355. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65356. */
  65357. export class PostProcessRenderPipeline {
  65358. private engine;
  65359. private _renderEffects;
  65360. private _renderEffectsForIsolatedPass;
  65361. /**
  65362. * List of inspectable custom properties (used by the Inspector)
  65363. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65364. */
  65365. inspectableCustomProperties: IInspectable[];
  65366. /**
  65367. * @hidden
  65368. */
  65369. protected _cameras: Camera[];
  65370. /** @hidden */
  65371. _name: string;
  65372. /**
  65373. * Gets pipeline name
  65374. */
  65375. get name(): string;
  65376. /** Gets the list of attached cameras */
  65377. get cameras(): Camera[];
  65378. /**
  65379. * Initializes a PostProcessRenderPipeline
  65380. * @param engine engine to add the pipeline to
  65381. * @param name name of the pipeline
  65382. */
  65383. constructor(engine: Engine, name: string);
  65384. /**
  65385. * Gets the class name
  65386. * @returns "PostProcessRenderPipeline"
  65387. */
  65388. getClassName(): string;
  65389. /**
  65390. * If all the render effects in the pipeline are supported
  65391. */
  65392. get isSupported(): boolean;
  65393. /**
  65394. * Adds an effect to the pipeline
  65395. * @param renderEffect the effect to add
  65396. */
  65397. addEffect(renderEffect: PostProcessRenderEffect): void;
  65398. /** @hidden */
  65399. _rebuild(): void;
  65400. /** @hidden */
  65401. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65402. /** @hidden */
  65403. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65404. /** @hidden */
  65405. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65406. /** @hidden */
  65407. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65408. /** @hidden */
  65409. _attachCameras(cameras: Camera, unique: boolean): void;
  65410. /** @hidden */
  65411. _attachCameras(cameras: Camera[], unique: boolean): void;
  65412. /** @hidden */
  65413. _detachCameras(cameras: Camera): void;
  65414. /** @hidden */
  65415. _detachCameras(cameras: Nullable<Camera[]>): void;
  65416. /** @hidden */
  65417. _update(): void;
  65418. /** @hidden */
  65419. _reset(): void;
  65420. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65421. /**
  65422. * Disposes of the pipeline
  65423. */
  65424. dispose(): void;
  65425. }
  65426. }
  65427. declare module BABYLON {
  65428. /**
  65429. * PostProcessRenderPipelineManager class
  65430. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65431. */
  65432. export class PostProcessRenderPipelineManager {
  65433. private _renderPipelines;
  65434. /**
  65435. * Initializes a PostProcessRenderPipelineManager
  65436. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65437. */
  65438. constructor();
  65439. /**
  65440. * Gets the list of supported render pipelines
  65441. */
  65442. get supportedPipelines(): PostProcessRenderPipeline[];
  65443. /**
  65444. * Adds a pipeline to the manager
  65445. * @param renderPipeline The pipeline to add
  65446. */
  65447. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65448. /**
  65449. * Attaches a camera to the pipeline
  65450. * @param renderPipelineName The name of the pipeline to attach to
  65451. * @param cameras the camera to attach
  65452. * @param unique if the camera can be attached multiple times to the pipeline
  65453. */
  65454. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65455. /**
  65456. * Detaches a camera from the pipeline
  65457. * @param renderPipelineName The name of the pipeline to detach from
  65458. * @param cameras the camera to detach
  65459. */
  65460. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65461. /**
  65462. * Enables an effect by name on a pipeline
  65463. * @param renderPipelineName the name of the pipeline to enable the effect in
  65464. * @param renderEffectName the name of the effect to enable
  65465. * @param cameras the cameras that the effect should be enabled on
  65466. */
  65467. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65468. /**
  65469. * Disables an effect by name on a pipeline
  65470. * @param renderPipelineName the name of the pipeline to disable the effect in
  65471. * @param renderEffectName the name of the effect to disable
  65472. * @param cameras the cameras that the effect should be disabled on
  65473. */
  65474. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65475. /**
  65476. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65477. */
  65478. update(): void;
  65479. /** @hidden */
  65480. _rebuild(): void;
  65481. /**
  65482. * Disposes of the manager and pipelines
  65483. */
  65484. dispose(): void;
  65485. }
  65486. }
  65487. declare module BABYLON {
  65488. interface Scene {
  65489. /** @hidden (Backing field) */
  65490. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65491. /**
  65492. * Gets the postprocess render pipeline manager
  65493. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65494. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65495. */
  65496. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65497. }
  65498. /**
  65499. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65500. */
  65501. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65502. /**
  65503. * The component name helpfull to identify the component in the list of scene components.
  65504. */
  65505. readonly name: string;
  65506. /**
  65507. * The scene the component belongs to.
  65508. */
  65509. scene: Scene;
  65510. /**
  65511. * Creates a new instance of the component for the given scene
  65512. * @param scene Defines the scene to register the component in
  65513. */
  65514. constructor(scene: Scene);
  65515. /**
  65516. * Registers the component in a given scene
  65517. */
  65518. register(): void;
  65519. /**
  65520. * Rebuilds the elements related to this component in case of
  65521. * context lost for instance.
  65522. */
  65523. rebuild(): void;
  65524. /**
  65525. * Disposes the component and the associated ressources
  65526. */
  65527. dispose(): void;
  65528. private _gatherRenderTargets;
  65529. }
  65530. }
  65531. declare module BABYLON {
  65532. /**
  65533. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65534. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65535. */
  65536. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65537. private _scene;
  65538. private _camerasToBeAttached;
  65539. /**
  65540. * ID of the sharpen post process,
  65541. */
  65542. private readonly SharpenPostProcessId;
  65543. /**
  65544. * @ignore
  65545. * ID of the image processing post process;
  65546. */
  65547. readonly ImageProcessingPostProcessId: string;
  65548. /**
  65549. * @ignore
  65550. * ID of the Fast Approximate Anti-Aliasing post process;
  65551. */
  65552. readonly FxaaPostProcessId: string;
  65553. /**
  65554. * ID of the chromatic aberration post process,
  65555. */
  65556. private readonly ChromaticAberrationPostProcessId;
  65557. /**
  65558. * ID of the grain post process
  65559. */
  65560. private readonly GrainPostProcessId;
  65561. /**
  65562. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65563. */
  65564. sharpen: SharpenPostProcess;
  65565. private _sharpenEffect;
  65566. private bloom;
  65567. /**
  65568. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65569. */
  65570. depthOfField: DepthOfFieldEffect;
  65571. /**
  65572. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65573. */
  65574. fxaa: FxaaPostProcess;
  65575. /**
  65576. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65577. */
  65578. imageProcessing: ImageProcessingPostProcess;
  65579. /**
  65580. * Chromatic aberration post process which will shift rgb colors in the image
  65581. */
  65582. chromaticAberration: ChromaticAberrationPostProcess;
  65583. private _chromaticAberrationEffect;
  65584. /**
  65585. * Grain post process which add noise to the image
  65586. */
  65587. grain: GrainPostProcess;
  65588. private _grainEffect;
  65589. /**
  65590. * Glow post process which adds a glow to emissive areas of the image
  65591. */
  65592. private _glowLayer;
  65593. /**
  65594. * Animations which can be used to tweak settings over a period of time
  65595. */
  65596. animations: Animation[];
  65597. private _imageProcessingConfigurationObserver;
  65598. private _sharpenEnabled;
  65599. private _bloomEnabled;
  65600. private _depthOfFieldEnabled;
  65601. private _depthOfFieldBlurLevel;
  65602. private _fxaaEnabled;
  65603. private _imageProcessingEnabled;
  65604. private _defaultPipelineTextureType;
  65605. private _bloomScale;
  65606. private _chromaticAberrationEnabled;
  65607. private _grainEnabled;
  65608. private _buildAllowed;
  65609. /**
  65610. * Gets active scene
  65611. */
  65612. get scene(): Scene;
  65613. /**
  65614. * Enable or disable the sharpen process from the pipeline
  65615. */
  65616. set sharpenEnabled(enabled: boolean);
  65617. get sharpenEnabled(): boolean;
  65618. private _resizeObserver;
  65619. private _hardwareScaleLevel;
  65620. private _bloomKernel;
  65621. /**
  65622. * Specifies the size of the bloom blur kernel, relative to the final output size
  65623. */
  65624. get bloomKernel(): number;
  65625. set bloomKernel(value: number);
  65626. /**
  65627. * Specifies the weight of the bloom in the final rendering
  65628. */
  65629. private _bloomWeight;
  65630. /**
  65631. * Specifies the luma threshold for the area that will be blurred by the bloom
  65632. */
  65633. private _bloomThreshold;
  65634. private _hdr;
  65635. /**
  65636. * The strength of the bloom.
  65637. */
  65638. set bloomWeight(value: number);
  65639. get bloomWeight(): number;
  65640. /**
  65641. * The strength of the bloom.
  65642. */
  65643. set bloomThreshold(value: number);
  65644. get bloomThreshold(): number;
  65645. /**
  65646. * The scale of the bloom, lower value will provide better performance.
  65647. */
  65648. set bloomScale(value: number);
  65649. get bloomScale(): number;
  65650. /**
  65651. * Enable or disable the bloom from the pipeline
  65652. */
  65653. set bloomEnabled(enabled: boolean);
  65654. get bloomEnabled(): boolean;
  65655. private _rebuildBloom;
  65656. /**
  65657. * If the depth of field is enabled.
  65658. */
  65659. get depthOfFieldEnabled(): boolean;
  65660. set depthOfFieldEnabled(enabled: boolean);
  65661. /**
  65662. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65663. */
  65664. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65665. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65666. /**
  65667. * If the anti aliasing is enabled.
  65668. */
  65669. set fxaaEnabled(enabled: boolean);
  65670. get fxaaEnabled(): boolean;
  65671. private _samples;
  65672. /**
  65673. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65674. */
  65675. set samples(sampleCount: number);
  65676. get samples(): number;
  65677. /**
  65678. * If image processing is enabled.
  65679. */
  65680. set imageProcessingEnabled(enabled: boolean);
  65681. get imageProcessingEnabled(): boolean;
  65682. /**
  65683. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65684. */
  65685. set glowLayerEnabled(enabled: boolean);
  65686. get glowLayerEnabled(): boolean;
  65687. /**
  65688. * Gets the glow layer (or null if not defined)
  65689. */
  65690. get glowLayer(): Nullable<GlowLayer>;
  65691. /**
  65692. * Enable or disable the chromaticAberration process from the pipeline
  65693. */
  65694. set chromaticAberrationEnabled(enabled: boolean);
  65695. get chromaticAberrationEnabled(): boolean;
  65696. /**
  65697. * Enable or disable the grain process from the pipeline
  65698. */
  65699. set grainEnabled(enabled: boolean);
  65700. get grainEnabled(): boolean;
  65701. /**
  65702. * @constructor
  65703. * @param name - The rendering pipeline name (default: "")
  65704. * @param hdr - If high dynamic range textures should be used (default: true)
  65705. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65706. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65707. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65708. */
  65709. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65710. /**
  65711. * Get the class name
  65712. * @returns "DefaultRenderingPipeline"
  65713. */
  65714. getClassName(): string;
  65715. /**
  65716. * Force the compilation of the entire pipeline.
  65717. */
  65718. prepare(): void;
  65719. private _hasCleared;
  65720. private _prevPostProcess;
  65721. private _prevPrevPostProcess;
  65722. private _setAutoClearAndTextureSharing;
  65723. private _depthOfFieldSceneObserver;
  65724. private _buildPipeline;
  65725. private _disposePostProcesses;
  65726. /**
  65727. * Adds a camera to the pipeline
  65728. * @param camera the camera to be added
  65729. */
  65730. addCamera(camera: Camera): void;
  65731. /**
  65732. * Removes a camera from the pipeline
  65733. * @param camera the camera to remove
  65734. */
  65735. removeCamera(camera: Camera): void;
  65736. /**
  65737. * Dispose of the pipeline and stop all post processes
  65738. */
  65739. dispose(): void;
  65740. /**
  65741. * Serialize the rendering pipeline (Used when exporting)
  65742. * @returns the serialized object
  65743. */
  65744. serialize(): any;
  65745. /**
  65746. * Parse the serialized pipeline
  65747. * @param source Source pipeline.
  65748. * @param scene The scene to load the pipeline to.
  65749. * @param rootUrl The URL of the serialized pipeline.
  65750. * @returns An instantiated pipeline from the serialized object.
  65751. */
  65752. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65753. }
  65754. }
  65755. declare module BABYLON {
  65756. /** @hidden */
  65757. export var lensHighlightsPixelShader: {
  65758. name: string;
  65759. shader: string;
  65760. };
  65761. }
  65762. declare module BABYLON {
  65763. /** @hidden */
  65764. export var depthOfFieldPixelShader: {
  65765. name: string;
  65766. shader: string;
  65767. };
  65768. }
  65769. declare module BABYLON {
  65770. /**
  65771. * BABYLON.JS Chromatic Aberration GLSL Shader
  65772. * Author: Olivier Guyot
  65773. * Separates very slightly R, G and B colors on the edges of the screen
  65774. * Inspired by Francois Tarlier & Martins Upitis
  65775. */
  65776. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65777. /**
  65778. * @ignore
  65779. * The chromatic aberration PostProcess id in the pipeline
  65780. */
  65781. LensChromaticAberrationEffect: string;
  65782. /**
  65783. * @ignore
  65784. * The highlights enhancing PostProcess id in the pipeline
  65785. */
  65786. HighlightsEnhancingEffect: string;
  65787. /**
  65788. * @ignore
  65789. * The depth-of-field PostProcess id in the pipeline
  65790. */
  65791. LensDepthOfFieldEffect: string;
  65792. private _scene;
  65793. private _depthTexture;
  65794. private _grainTexture;
  65795. private _chromaticAberrationPostProcess;
  65796. private _highlightsPostProcess;
  65797. private _depthOfFieldPostProcess;
  65798. private _edgeBlur;
  65799. private _grainAmount;
  65800. private _chromaticAberration;
  65801. private _distortion;
  65802. private _highlightsGain;
  65803. private _highlightsThreshold;
  65804. private _dofDistance;
  65805. private _dofAperture;
  65806. private _dofDarken;
  65807. private _dofPentagon;
  65808. private _blurNoise;
  65809. /**
  65810. * @constructor
  65811. *
  65812. * Effect parameters are as follow:
  65813. * {
  65814. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65815. * edge_blur: number; // from 0 to x (1 for realism)
  65816. * distortion: number; // from 0 to x (1 for realism)
  65817. * grain_amount: number; // from 0 to 1
  65818. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65819. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65820. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65821. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65822. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65823. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65824. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65825. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65826. * }
  65827. * Note: if an effect parameter is unset, effect is disabled
  65828. *
  65829. * @param name The rendering pipeline name
  65830. * @param parameters - An object containing all parameters (see above)
  65831. * @param scene The scene linked to this pipeline
  65832. * @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)
  65833. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65834. */
  65835. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65836. /**
  65837. * Get the class name
  65838. * @returns "LensRenderingPipeline"
  65839. */
  65840. getClassName(): string;
  65841. /**
  65842. * Gets associated scene
  65843. */
  65844. get scene(): Scene;
  65845. /**
  65846. * Gets or sets the edge blur
  65847. */
  65848. get edgeBlur(): number;
  65849. set edgeBlur(value: number);
  65850. /**
  65851. * Gets or sets the grain amount
  65852. */
  65853. get grainAmount(): number;
  65854. set grainAmount(value: number);
  65855. /**
  65856. * Gets or sets the chromatic aberration amount
  65857. */
  65858. get chromaticAberration(): number;
  65859. set chromaticAberration(value: number);
  65860. /**
  65861. * Gets or sets the depth of field aperture
  65862. */
  65863. get dofAperture(): number;
  65864. set dofAperture(value: number);
  65865. /**
  65866. * Gets or sets the edge distortion
  65867. */
  65868. get edgeDistortion(): number;
  65869. set edgeDistortion(value: number);
  65870. /**
  65871. * Gets or sets the depth of field distortion
  65872. */
  65873. get dofDistortion(): number;
  65874. set dofDistortion(value: number);
  65875. /**
  65876. * Gets or sets the darken out of focus amount
  65877. */
  65878. get darkenOutOfFocus(): number;
  65879. set darkenOutOfFocus(value: number);
  65880. /**
  65881. * Gets or sets a boolean indicating if blur noise is enabled
  65882. */
  65883. get blurNoise(): boolean;
  65884. set blurNoise(value: boolean);
  65885. /**
  65886. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65887. */
  65888. get pentagonBokeh(): boolean;
  65889. set pentagonBokeh(value: boolean);
  65890. /**
  65891. * Gets or sets the highlight grain amount
  65892. */
  65893. get highlightsGain(): number;
  65894. set highlightsGain(value: number);
  65895. /**
  65896. * Gets or sets the highlight threshold
  65897. */
  65898. get highlightsThreshold(): number;
  65899. set highlightsThreshold(value: number);
  65900. /**
  65901. * Sets the amount of blur at the edges
  65902. * @param amount blur amount
  65903. */
  65904. setEdgeBlur(amount: number): void;
  65905. /**
  65906. * Sets edge blur to 0
  65907. */
  65908. disableEdgeBlur(): void;
  65909. /**
  65910. * Sets the amout of grain
  65911. * @param amount Amount of grain
  65912. */
  65913. setGrainAmount(amount: number): void;
  65914. /**
  65915. * Set grain amount to 0
  65916. */
  65917. disableGrain(): void;
  65918. /**
  65919. * Sets the chromatic aberration amount
  65920. * @param amount amount of chromatic aberration
  65921. */
  65922. setChromaticAberration(amount: number): void;
  65923. /**
  65924. * Sets chromatic aberration amount to 0
  65925. */
  65926. disableChromaticAberration(): void;
  65927. /**
  65928. * Sets the EdgeDistortion amount
  65929. * @param amount amount of EdgeDistortion
  65930. */
  65931. setEdgeDistortion(amount: number): void;
  65932. /**
  65933. * Sets edge distortion to 0
  65934. */
  65935. disableEdgeDistortion(): void;
  65936. /**
  65937. * Sets the FocusDistance amount
  65938. * @param amount amount of FocusDistance
  65939. */
  65940. setFocusDistance(amount: number): void;
  65941. /**
  65942. * Disables depth of field
  65943. */
  65944. disableDepthOfField(): void;
  65945. /**
  65946. * Sets the Aperture amount
  65947. * @param amount amount of Aperture
  65948. */
  65949. setAperture(amount: number): void;
  65950. /**
  65951. * Sets the DarkenOutOfFocus amount
  65952. * @param amount amount of DarkenOutOfFocus
  65953. */
  65954. setDarkenOutOfFocus(amount: number): void;
  65955. private _pentagonBokehIsEnabled;
  65956. /**
  65957. * Creates a pentagon bokeh effect
  65958. */
  65959. enablePentagonBokeh(): void;
  65960. /**
  65961. * Disables the pentagon bokeh effect
  65962. */
  65963. disablePentagonBokeh(): void;
  65964. /**
  65965. * Enables noise blur
  65966. */
  65967. enableNoiseBlur(): void;
  65968. /**
  65969. * Disables noise blur
  65970. */
  65971. disableNoiseBlur(): void;
  65972. /**
  65973. * Sets the HighlightsGain amount
  65974. * @param amount amount of HighlightsGain
  65975. */
  65976. setHighlightsGain(amount: number): void;
  65977. /**
  65978. * Sets the HighlightsThreshold amount
  65979. * @param amount amount of HighlightsThreshold
  65980. */
  65981. setHighlightsThreshold(amount: number): void;
  65982. /**
  65983. * Disables highlights
  65984. */
  65985. disableHighlights(): void;
  65986. /**
  65987. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65988. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65989. */
  65990. dispose(disableDepthRender?: boolean): void;
  65991. private _createChromaticAberrationPostProcess;
  65992. private _createHighlightsPostProcess;
  65993. private _createDepthOfFieldPostProcess;
  65994. private _createGrainTexture;
  65995. }
  65996. }
  65997. declare module BABYLON {
  65998. /** @hidden */
  65999. export var ssao2PixelShader: {
  66000. name: string;
  66001. shader: string;
  66002. };
  66003. }
  66004. declare module BABYLON {
  66005. /** @hidden */
  66006. export var ssaoCombinePixelShader: {
  66007. name: string;
  66008. shader: string;
  66009. };
  66010. }
  66011. declare module BABYLON {
  66012. /**
  66013. * Render pipeline to produce ssao effect
  66014. */
  66015. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66016. /**
  66017. * @ignore
  66018. * The PassPostProcess id in the pipeline that contains the original scene color
  66019. */
  66020. SSAOOriginalSceneColorEffect: string;
  66021. /**
  66022. * @ignore
  66023. * The SSAO PostProcess id in the pipeline
  66024. */
  66025. SSAORenderEffect: string;
  66026. /**
  66027. * @ignore
  66028. * The horizontal blur PostProcess id in the pipeline
  66029. */
  66030. SSAOBlurHRenderEffect: string;
  66031. /**
  66032. * @ignore
  66033. * The vertical blur PostProcess id in the pipeline
  66034. */
  66035. SSAOBlurVRenderEffect: string;
  66036. /**
  66037. * @ignore
  66038. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66039. */
  66040. SSAOCombineRenderEffect: string;
  66041. /**
  66042. * The output strength of the SSAO post-process. Default value is 1.0.
  66043. */
  66044. totalStrength: number;
  66045. /**
  66046. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66047. */
  66048. maxZ: number;
  66049. /**
  66050. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66051. */
  66052. minZAspect: number;
  66053. private _samples;
  66054. /**
  66055. * Number of samples used for the SSAO calculations. Default value is 8
  66056. */
  66057. set samples(n: number);
  66058. get samples(): number;
  66059. private _textureSamples;
  66060. /**
  66061. * Number of samples to use for antialiasing
  66062. */
  66063. set textureSamples(n: number);
  66064. get textureSamples(): number;
  66065. /**
  66066. * Ratio object used for SSAO ratio and blur ratio
  66067. */
  66068. private _ratio;
  66069. /**
  66070. * Dynamically generated sphere sampler.
  66071. */
  66072. private _sampleSphere;
  66073. /**
  66074. * Blur filter offsets
  66075. */
  66076. private _samplerOffsets;
  66077. private _expensiveBlur;
  66078. /**
  66079. * If bilateral blur should be used
  66080. */
  66081. set expensiveBlur(b: boolean);
  66082. get expensiveBlur(): boolean;
  66083. /**
  66084. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66085. */
  66086. radius: number;
  66087. /**
  66088. * The base color of the SSAO post-process
  66089. * The final result is "base + ssao" between [0, 1]
  66090. */
  66091. base: number;
  66092. /**
  66093. * Support test.
  66094. */
  66095. static get IsSupported(): boolean;
  66096. private _scene;
  66097. private _depthTexture;
  66098. private _normalTexture;
  66099. private _randomTexture;
  66100. private _originalColorPostProcess;
  66101. private _ssaoPostProcess;
  66102. private _blurHPostProcess;
  66103. private _blurVPostProcess;
  66104. private _ssaoCombinePostProcess;
  66105. /**
  66106. * Gets active scene
  66107. */
  66108. get scene(): Scene;
  66109. /**
  66110. * @constructor
  66111. * @param name The rendering pipeline name
  66112. * @param scene The scene linked to this pipeline
  66113. * @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 }
  66114. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66115. */
  66116. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66117. /**
  66118. * Get the class name
  66119. * @returns "SSAO2RenderingPipeline"
  66120. */
  66121. getClassName(): string;
  66122. /**
  66123. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66124. */
  66125. dispose(disableGeometryBufferRenderer?: boolean): void;
  66126. private _createBlurPostProcess;
  66127. /** @hidden */
  66128. _rebuild(): void;
  66129. private _bits;
  66130. private _radicalInverse_VdC;
  66131. private _hammersley;
  66132. private _hemisphereSample_uniform;
  66133. private _generateHemisphere;
  66134. private _createSSAOPostProcess;
  66135. private _createSSAOCombinePostProcess;
  66136. private _createRandomTexture;
  66137. /**
  66138. * Serialize the rendering pipeline (Used when exporting)
  66139. * @returns the serialized object
  66140. */
  66141. serialize(): any;
  66142. /**
  66143. * Parse the serialized pipeline
  66144. * @param source Source pipeline.
  66145. * @param scene The scene to load the pipeline to.
  66146. * @param rootUrl The URL of the serialized pipeline.
  66147. * @returns An instantiated pipeline from the serialized object.
  66148. */
  66149. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66150. }
  66151. }
  66152. declare module BABYLON {
  66153. /** @hidden */
  66154. export var ssaoPixelShader: {
  66155. name: string;
  66156. shader: string;
  66157. };
  66158. }
  66159. declare module BABYLON {
  66160. /**
  66161. * Render pipeline to produce ssao effect
  66162. */
  66163. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66164. /**
  66165. * @ignore
  66166. * The PassPostProcess id in the pipeline that contains the original scene color
  66167. */
  66168. SSAOOriginalSceneColorEffect: string;
  66169. /**
  66170. * @ignore
  66171. * The SSAO PostProcess id in the pipeline
  66172. */
  66173. SSAORenderEffect: string;
  66174. /**
  66175. * @ignore
  66176. * The horizontal blur PostProcess id in the pipeline
  66177. */
  66178. SSAOBlurHRenderEffect: string;
  66179. /**
  66180. * @ignore
  66181. * The vertical blur PostProcess id in the pipeline
  66182. */
  66183. SSAOBlurVRenderEffect: string;
  66184. /**
  66185. * @ignore
  66186. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66187. */
  66188. SSAOCombineRenderEffect: string;
  66189. /**
  66190. * The output strength of the SSAO post-process. Default value is 1.0.
  66191. */
  66192. totalStrength: number;
  66193. /**
  66194. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66195. */
  66196. radius: number;
  66197. /**
  66198. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66199. * Must not be equal to fallOff and superior to fallOff.
  66200. * Default value is 0.0075
  66201. */
  66202. area: number;
  66203. /**
  66204. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66205. * Must not be equal to area and inferior to area.
  66206. * Default value is 0.000001
  66207. */
  66208. fallOff: number;
  66209. /**
  66210. * The base color of the SSAO post-process
  66211. * The final result is "base + ssao" between [0, 1]
  66212. */
  66213. base: number;
  66214. private _scene;
  66215. private _depthTexture;
  66216. private _randomTexture;
  66217. private _originalColorPostProcess;
  66218. private _ssaoPostProcess;
  66219. private _blurHPostProcess;
  66220. private _blurVPostProcess;
  66221. private _ssaoCombinePostProcess;
  66222. private _firstUpdate;
  66223. /**
  66224. * Gets active scene
  66225. */
  66226. get scene(): Scene;
  66227. /**
  66228. * @constructor
  66229. * @param name - The rendering pipeline name
  66230. * @param scene - The scene linked to this pipeline
  66231. * @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 }
  66232. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66233. */
  66234. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66235. /**
  66236. * Get the class name
  66237. * @returns "SSAORenderingPipeline"
  66238. */
  66239. getClassName(): string;
  66240. /**
  66241. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66242. */
  66243. dispose(disableDepthRender?: boolean): void;
  66244. private _createBlurPostProcess;
  66245. /** @hidden */
  66246. _rebuild(): void;
  66247. private _createSSAOPostProcess;
  66248. private _createSSAOCombinePostProcess;
  66249. private _createRandomTexture;
  66250. }
  66251. }
  66252. declare module BABYLON {
  66253. /** @hidden */
  66254. export var screenSpaceReflectionPixelShader: {
  66255. name: string;
  66256. shader: string;
  66257. };
  66258. }
  66259. declare module BABYLON {
  66260. /**
  66261. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66262. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66263. */
  66264. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66265. /**
  66266. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66267. */
  66268. threshold: number;
  66269. /**
  66270. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66271. */
  66272. strength: number;
  66273. /**
  66274. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66275. */
  66276. reflectionSpecularFalloffExponent: number;
  66277. /**
  66278. * 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]
  66279. */
  66280. step: number;
  66281. /**
  66282. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66283. */
  66284. roughnessFactor: number;
  66285. private _geometryBufferRenderer;
  66286. private _enableSmoothReflections;
  66287. private _reflectionSamples;
  66288. private _smoothSteps;
  66289. /**
  66290. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66291. * @param name The name of the effect.
  66292. * @param scene The scene containing the objects to calculate reflections.
  66293. * @param options The required width/height ratio to downsize to before computing the render pass.
  66294. * @param camera The camera to apply the render pass to.
  66295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66296. * @param engine The engine which the post process will be applied. (default: current engine)
  66297. * @param reusable If the post process can be reused on the same frame. (default: false)
  66298. * @param textureType Type of textures used when performing the post process. (default: 0)
  66299. * @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)
  66300. */
  66301. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66302. /**
  66303. * Gets wether or not smoothing reflections is enabled.
  66304. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66305. */
  66306. get enableSmoothReflections(): boolean;
  66307. /**
  66308. * Sets wether or not smoothing reflections is enabled.
  66309. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66310. */
  66311. set enableSmoothReflections(enabled: boolean);
  66312. /**
  66313. * Gets the number of samples taken while computing reflections. More samples count is high,
  66314. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66315. */
  66316. get reflectionSamples(): number;
  66317. /**
  66318. * Sets the number of samples taken while computing reflections. More samples count is high,
  66319. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66320. */
  66321. set reflectionSamples(samples: number);
  66322. /**
  66323. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66324. * more the post-process will require GPU power and can generate a drop in FPS.
  66325. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66326. */
  66327. get smoothSteps(): number;
  66328. set smoothSteps(steps: number);
  66329. private _updateEffectDefines;
  66330. }
  66331. }
  66332. declare module BABYLON {
  66333. /** @hidden */
  66334. export var standardPixelShader: {
  66335. name: string;
  66336. shader: string;
  66337. };
  66338. }
  66339. declare module BABYLON {
  66340. /**
  66341. * Standard rendering pipeline
  66342. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66343. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66344. */
  66345. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66346. /**
  66347. * Public members
  66348. */
  66349. /**
  66350. * Post-process which contains the original scene color before the pipeline applies all the effects
  66351. */
  66352. originalPostProcess: Nullable<PostProcess>;
  66353. /**
  66354. * Post-process used to down scale an image x4
  66355. */
  66356. downSampleX4PostProcess: Nullable<PostProcess>;
  66357. /**
  66358. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66359. */
  66360. brightPassPostProcess: Nullable<PostProcess>;
  66361. /**
  66362. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66363. */
  66364. blurHPostProcesses: PostProcess[];
  66365. /**
  66366. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66367. */
  66368. blurVPostProcesses: PostProcess[];
  66369. /**
  66370. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66371. */
  66372. textureAdderPostProcess: Nullable<PostProcess>;
  66373. /**
  66374. * Post-process used to create volumetric lighting effect
  66375. */
  66376. volumetricLightPostProcess: Nullable<PostProcess>;
  66377. /**
  66378. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66379. */
  66380. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66381. /**
  66382. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66383. */
  66384. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66385. /**
  66386. * Post-process used to merge the volumetric light effect and the real scene color
  66387. */
  66388. volumetricLightMergePostProces: Nullable<PostProcess>;
  66389. /**
  66390. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66391. */
  66392. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66393. /**
  66394. * Base post-process used to calculate the average luminance of the final image for HDR
  66395. */
  66396. luminancePostProcess: Nullable<PostProcess>;
  66397. /**
  66398. * Post-processes used to create down sample post-processes in order to get
  66399. * the average luminance of the final image for HDR
  66400. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66401. */
  66402. luminanceDownSamplePostProcesses: PostProcess[];
  66403. /**
  66404. * Post-process used to create a HDR effect (light adaptation)
  66405. */
  66406. hdrPostProcess: Nullable<PostProcess>;
  66407. /**
  66408. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66409. */
  66410. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66411. /**
  66412. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66413. */
  66414. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66415. /**
  66416. * Post-process used to merge the final HDR post-process and the real scene color
  66417. */
  66418. hdrFinalPostProcess: Nullable<PostProcess>;
  66419. /**
  66420. * Post-process used to create a lens flare effect
  66421. */
  66422. lensFlarePostProcess: Nullable<PostProcess>;
  66423. /**
  66424. * Post-process that merges the result of the lens flare post-process and the real scene color
  66425. */
  66426. lensFlareComposePostProcess: Nullable<PostProcess>;
  66427. /**
  66428. * Post-process used to create a motion blur effect
  66429. */
  66430. motionBlurPostProcess: Nullable<PostProcess>;
  66431. /**
  66432. * Post-process used to create a depth of field effect
  66433. */
  66434. depthOfFieldPostProcess: Nullable<PostProcess>;
  66435. /**
  66436. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66437. */
  66438. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66439. /**
  66440. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66441. */
  66442. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66443. /**
  66444. * Represents the brightness threshold in order to configure the illuminated surfaces
  66445. */
  66446. brightThreshold: number;
  66447. /**
  66448. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66449. */
  66450. blurWidth: number;
  66451. /**
  66452. * Sets if the blur for highlighted surfaces must be only horizontal
  66453. */
  66454. horizontalBlur: boolean;
  66455. /**
  66456. * Gets the overall exposure used by the pipeline
  66457. */
  66458. get exposure(): number;
  66459. /**
  66460. * Sets the overall exposure used by the pipeline
  66461. */
  66462. set exposure(value: number);
  66463. /**
  66464. * Texture used typically to simulate "dirty" on camera lens
  66465. */
  66466. lensTexture: Nullable<Texture>;
  66467. /**
  66468. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66469. */
  66470. volumetricLightCoefficient: number;
  66471. /**
  66472. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66473. */
  66474. volumetricLightPower: number;
  66475. /**
  66476. * Used the set the blur intensity to smooth the volumetric lights
  66477. */
  66478. volumetricLightBlurScale: number;
  66479. /**
  66480. * Light (spot or directional) used to generate the volumetric lights rays
  66481. * The source light must have a shadow generate so the pipeline can get its
  66482. * depth map
  66483. */
  66484. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66485. /**
  66486. * For eye adaptation, represents the minimum luminance the eye can see
  66487. */
  66488. hdrMinimumLuminance: number;
  66489. /**
  66490. * For eye adaptation, represents the decrease luminance speed
  66491. */
  66492. hdrDecreaseRate: number;
  66493. /**
  66494. * For eye adaptation, represents the increase luminance speed
  66495. */
  66496. hdrIncreaseRate: number;
  66497. /**
  66498. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66499. */
  66500. get hdrAutoExposure(): boolean;
  66501. /**
  66502. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66503. */
  66504. set hdrAutoExposure(value: boolean);
  66505. /**
  66506. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66507. */
  66508. lensColorTexture: Nullable<Texture>;
  66509. /**
  66510. * The overall strengh for the lens flare effect
  66511. */
  66512. lensFlareStrength: number;
  66513. /**
  66514. * Dispersion coefficient for lens flare ghosts
  66515. */
  66516. lensFlareGhostDispersal: number;
  66517. /**
  66518. * Main lens flare halo width
  66519. */
  66520. lensFlareHaloWidth: number;
  66521. /**
  66522. * Based on the lens distortion effect, defines how much the lens flare result
  66523. * is distorted
  66524. */
  66525. lensFlareDistortionStrength: number;
  66526. /**
  66527. * Configures the blur intensity used for for lens flare (halo)
  66528. */
  66529. lensFlareBlurWidth: number;
  66530. /**
  66531. * Lens star texture must be used to simulate rays on the flares and is available
  66532. * in the documentation
  66533. */
  66534. lensStarTexture: Nullable<Texture>;
  66535. /**
  66536. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66537. * flare effect by taking account of the dirt texture
  66538. */
  66539. lensFlareDirtTexture: Nullable<Texture>;
  66540. /**
  66541. * Represents the focal length for the depth of field effect
  66542. */
  66543. depthOfFieldDistance: number;
  66544. /**
  66545. * Represents the blur intensity for the blurred part of the depth of field effect
  66546. */
  66547. depthOfFieldBlurWidth: number;
  66548. /**
  66549. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66550. */
  66551. get motionStrength(): number;
  66552. /**
  66553. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66554. */
  66555. set motionStrength(strength: number);
  66556. /**
  66557. * Gets wether or not the motion blur post-process is object based or screen based.
  66558. */
  66559. get objectBasedMotionBlur(): boolean;
  66560. /**
  66561. * Sets wether or not the motion blur post-process should be object based or screen based
  66562. */
  66563. set objectBasedMotionBlur(value: boolean);
  66564. /**
  66565. * List of animations for the pipeline (IAnimatable implementation)
  66566. */
  66567. animations: Animation[];
  66568. /**
  66569. * Private members
  66570. */
  66571. private _scene;
  66572. private _currentDepthOfFieldSource;
  66573. private _basePostProcess;
  66574. private _fixedExposure;
  66575. private _currentExposure;
  66576. private _hdrAutoExposure;
  66577. private _hdrCurrentLuminance;
  66578. private _motionStrength;
  66579. private _isObjectBasedMotionBlur;
  66580. private _floatTextureType;
  66581. private _camerasToBeAttached;
  66582. private _ratio;
  66583. private _bloomEnabled;
  66584. private _depthOfFieldEnabled;
  66585. private _vlsEnabled;
  66586. private _lensFlareEnabled;
  66587. private _hdrEnabled;
  66588. private _motionBlurEnabled;
  66589. private _fxaaEnabled;
  66590. private _screenSpaceReflectionsEnabled;
  66591. private _motionBlurSamples;
  66592. private _volumetricLightStepsCount;
  66593. private _samples;
  66594. /**
  66595. * @ignore
  66596. * Specifies if the bloom pipeline is enabled
  66597. */
  66598. get BloomEnabled(): boolean;
  66599. set BloomEnabled(enabled: boolean);
  66600. /**
  66601. * @ignore
  66602. * Specifies if the depth of field pipeline is enabed
  66603. */
  66604. get DepthOfFieldEnabled(): boolean;
  66605. set DepthOfFieldEnabled(enabled: boolean);
  66606. /**
  66607. * @ignore
  66608. * Specifies if the lens flare pipeline is enabed
  66609. */
  66610. get LensFlareEnabled(): boolean;
  66611. set LensFlareEnabled(enabled: boolean);
  66612. /**
  66613. * @ignore
  66614. * Specifies if the HDR pipeline is enabled
  66615. */
  66616. get HDREnabled(): boolean;
  66617. set HDREnabled(enabled: boolean);
  66618. /**
  66619. * @ignore
  66620. * Specifies if the volumetric lights scattering effect is enabled
  66621. */
  66622. get VLSEnabled(): boolean;
  66623. set VLSEnabled(enabled: boolean);
  66624. /**
  66625. * @ignore
  66626. * Specifies if the motion blur effect is enabled
  66627. */
  66628. get MotionBlurEnabled(): boolean;
  66629. set MotionBlurEnabled(enabled: boolean);
  66630. /**
  66631. * Specifies if anti-aliasing is enabled
  66632. */
  66633. get fxaaEnabled(): boolean;
  66634. set fxaaEnabled(enabled: boolean);
  66635. /**
  66636. * Specifies if screen space reflections are enabled.
  66637. */
  66638. get screenSpaceReflectionsEnabled(): boolean;
  66639. set screenSpaceReflectionsEnabled(enabled: boolean);
  66640. /**
  66641. * Specifies the number of steps used to calculate the volumetric lights
  66642. * Typically in interval [50, 200]
  66643. */
  66644. get volumetricLightStepsCount(): number;
  66645. set volumetricLightStepsCount(count: number);
  66646. /**
  66647. * Specifies the number of samples used for the motion blur effect
  66648. * Typically in interval [16, 64]
  66649. */
  66650. get motionBlurSamples(): number;
  66651. set motionBlurSamples(samples: number);
  66652. /**
  66653. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66654. */
  66655. get samples(): number;
  66656. set samples(sampleCount: number);
  66657. /**
  66658. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66659. * @constructor
  66660. * @param name The rendering pipeline name
  66661. * @param scene The scene linked to this pipeline
  66662. * @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)
  66663. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66664. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66665. */
  66666. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66667. private _buildPipeline;
  66668. private _createDownSampleX4PostProcess;
  66669. private _createBrightPassPostProcess;
  66670. private _createBlurPostProcesses;
  66671. private _createTextureAdderPostProcess;
  66672. private _createVolumetricLightPostProcess;
  66673. private _createLuminancePostProcesses;
  66674. private _createHdrPostProcess;
  66675. private _createLensFlarePostProcess;
  66676. private _createDepthOfFieldPostProcess;
  66677. private _createMotionBlurPostProcess;
  66678. private _getDepthTexture;
  66679. private _disposePostProcesses;
  66680. /**
  66681. * Dispose of the pipeline and stop all post processes
  66682. */
  66683. dispose(): void;
  66684. /**
  66685. * Serialize the rendering pipeline (Used when exporting)
  66686. * @returns the serialized object
  66687. */
  66688. serialize(): any;
  66689. /**
  66690. * Parse the serialized pipeline
  66691. * @param source Source pipeline.
  66692. * @param scene The scene to load the pipeline to.
  66693. * @param rootUrl The URL of the serialized pipeline.
  66694. * @returns An instantiated pipeline from the serialized object.
  66695. */
  66696. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66697. /**
  66698. * Luminance steps
  66699. */
  66700. static LuminanceSteps: number;
  66701. }
  66702. }
  66703. declare module BABYLON {
  66704. /** @hidden */
  66705. export var tonemapPixelShader: {
  66706. name: string;
  66707. shader: string;
  66708. };
  66709. }
  66710. declare module BABYLON {
  66711. /** Defines operator used for tonemapping */
  66712. export enum TonemappingOperator {
  66713. /** Hable */
  66714. Hable = 0,
  66715. /** Reinhard */
  66716. Reinhard = 1,
  66717. /** HejiDawson */
  66718. HejiDawson = 2,
  66719. /** Photographic */
  66720. Photographic = 3
  66721. }
  66722. /**
  66723. * Defines a post process to apply tone mapping
  66724. */
  66725. export class TonemapPostProcess extends PostProcess {
  66726. private _operator;
  66727. /** Defines the required exposure adjustement */
  66728. exposureAdjustment: number;
  66729. /**
  66730. * Creates a new TonemapPostProcess
  66731. * @param name defines the name of the postprocess
  66732. * @param _operator defines the operator to use
  66733. * @param exposureAdjustment defines the required exposure adjustement
  66734. * @param camera defines the camera to use (can be null)
  66735. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66736. * @param engine defines the hosting engine (can be ignore if camera is set)
  66737. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66738. */
  66739. constructor(name: string, _operator: TonemappingOperator,
  66740. /** Defines the required exposure adjustement */
  66741. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66742. }
  66743. }
  66744. declare module BABYLON {
  66745. /** @hidden */
  66746. export var volumetricLightScatteringPixelShader: {
  66747. name: string;
  66748. shader: string;
  66749. };
  66750. }
  66751. declare module BABYLON {
  66752. /** @hidden */
  66753. export var volumetricLightScatteringPassVertexShader: {
  66754. name: string;
  66755. shader: string;
  66756. };
  66757. }
  66758. declare module BABYLON {
  66759. /** @hidden */
  66760. export var volumetricLightScatteringPassPixelShader: {
  66761. name: string;
  66762. shader: string;
  66763. };
  66764. }
  66765. declare module BABYLON {
  66766. /**
  66767. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66768. */
  66769. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66770. private _volumetricLightScatteringPass;
  66771. private _volumetricLightScatteringRTT;
  66772. private _viewPort;
  66773. private _screenCoordinates;
  66774. private _cachedDefines;
  66775. /**
  66776. * If not undefined, the mesh position is computed from the attached node position
  66777. */
  66778. attachedNode: {
  66779. position: Vector3;
  66780. };
  66781. /**
  66782. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66783. */
  66784. customMeshPosition: Vector3;
  66785. /**
  66786. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66787. */
  66788. useCustomMeshPosition: boolean;
  66789. /**
  66790. * If the post-process should inverse the light scattering direction
  66791. */
  66792. invert: boolean;
  66793. /**
  66794. * The internal mesh used by the post-process
  66795. */
  66796. mesh: Mesh;
  66797. /**
  66798. * @hidden
  66799. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66800. */
  66801. get useDiffuseColor(): boolean;
  66802. set useDiffuseColor(useDiffuseColor: boolean);
  66803. /**
  66804. * Array containing the excluded meshes not rendered in the internal pass
  66805. */
  66806. excludedMeshes: AbstractMesh[];
  66807. /**
  66808. * Controls the overall intensity of the post-process
  66809. */
  66810. exposure: number;
  66811. /**
  66812. * Dissipates each sample's contribution in range [0, 1]
  66813. */
  66814. decay: number;
  66815. /**
  66816. * Controls the overall intensity of each sample
  66817. */
  66818. weight: number;
  66819. /**
  66820. * Controls the density of each sample
  66821. */
  66822. density: number;
  66823. /**
  66824. * @constructor
  66825. * @param name The post-process name
  66826. * @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)
  66827. * @param camera The camera that the post-process will be attached to
  66828. * @param mesh The mesh used to create the light scattering
  66829. * @param samples The post-process quality, default 100
  66830. * @param samplingModeThe post-process filtering mode
  66831. * @param engine The babylon engine
  66832. * @param reusable If the post-process is reusable
  66833. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66834. */
  66835. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66836. /**
  66837. * Returns the string "VolumetricLightScatteringPostProcess"
  66838. * @returns "VolumetricLightScatteringPostProcess"
  66839. */
  66840. getClassName(): string;
  66841. private _isReady;
  66842. /**
  66843. * Sets the new light position for light scattering effect
  66844. * @param position The new custom light position
  66845. */
  66846. setCustomMeshPosition(position: Vector3): void;
  66847. /**
  66848. * Returns the light position for light scattering effect
  66849. * @return Vector3 The custom light position
  66850. */
  66851. getCustomMeshPosition(): Vector3;
  66852. /**
  66853. * Disposes the internal assets and detaches the post-process from the camera
  66854. */
  66855. dispose(camera: Camera): void;
  66856. /**
  66857. * Returns the render target texture used by the post-process
  66858. * @return the render target texture used by the post-process
  66859. */
  66860. getPass(): RenderTargetTexture;
  66861. private _meshExcluded;
  66862. private _createPass;
  66863. private _updateMeshScreenCoordinates;
  66864. /**
  66865. * Creates a default mesh for the Volumeric Light Scattering post-process
  66866. * @param name The mesh name
  66867. * @param scene The scene where to create the mesh
  66868. * @return the default mesh
  66869. */
  66870. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66871. }
  66872. }
  66873. declare module BABYLON {
  66874. interface Scene {
  66875. /** @hidden (Backing field) */
  66876. _boundingBoxRenderer: BoundingBoxRenderer;
  66877. /** @hidden (Backing field) */
  66878. _forceShowBoundingBoxes: boolean;
  66879. /**
  66880. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66881. */
  66882. forceShowBoundingBoxes: boolean;
  66883. /**
  66884. * Gets the bounding box renderer associated with the scene
  66885. * @returns a BoundingBoxRenderer
  66886. */
  66887. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66888. }
  66889. interface AbstractMesh {
  66890. /** @hidden (Backing field) */
  66891. _showBoundingBox: boolean;
  66892. /**
  66893. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66894. */
  66895. showBoundingBox: boolean;
  66896. }
  66897. /**
  66898. * Component responsible of rendering the bounding box of the meshes in a scene.
  66899. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66900. */
  66901. export class BoundingBoxRenderer implements ISceneComponent {
  66902. /**
  66903. * The component name helpfull to identify the component in the list of scene components.
  66904. */
  66905. readonly name: string;
  66906. /**
  66907. * The scene the component belongs to.
  66908. */
  66909. scene: Scene;
  66910. /**
  66911. * Color of the bounding box lines placed in front of an object
  66912. */
  66913. frontColor: Color3;
  66914. /**
  66915. * Color of the bounding box lines placed behind an object
  66916. */
  66917. backColor: Color3;
  66918. /**
  66919. * Defines if the renderer should show the back lines or not
  66920. */
  66921. showBackLines: boolean;
  66922. /**
  66923. * @hidden
  66924. */
  66925. renderList: SmartArray<BoundingBox>;
  66926. private _colorShader;
  66927. private _vertexBuffers;
  66928. private _indexBuffer;
  66929. private _fillIndexBuffer;
  66930. private _fillIndexData;
  66931. /**
  66932. * Instantiates a new bounding box renderer in a scene.
  66933. * @param scene the scene the renderer renders in
  66934. */
  66935. constructor(scene: Scene);
  66936. /**
  66937. * Registers the component in a given scene
  66938. */
  66939. register(): void;
  66940. private _evaluateSubMesh;
  66941. private _activeMesh;
  66942. private _prepareRessources;
  66943. private _createIndexBuffer;
  66944. /**
  66945. * Rebuilds the elements related to this component in case of
  66946. * context lost for instance.
  66947. */
  66948. rebuild(): void;
  66949. /**
  66950. * @hidden
  66951. */
  66952. reset(): void;
  66953. /**
  66954. * Render the bounding boxes of a specific rendering group
  66955. * @param renderingGroupId defines the rendering group to render
  66956. */
  66957. render(renderingGroupId: number): void;
  66958. /**
  66959. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66960. * @param mesh Define the mesh to render the occlusion bounding box for
  66961. */
  66962. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66963. /**
  66964. * Dispose and release the resources attached to this renderer.
  66965. */
  66966. dispose(): void;
  66967. }
  66968. }
  66969. declare module BABYLON {
  66970. interface Scene {
  66971. /** @hidden (Backing field) */
  66972. _depthRenderer: {
  66973. [id: string]: DepthRenderer;
  66974. };
  66975. /**
  66976. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66977. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66978. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66979. * @returns the created depth renderer
  66980. */
  66981. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66982. /**
  66983. * Disables a depth renderer for a given camera
  66984. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66985. */
  66986. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66987. }
  66988. /**
  66989. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66990. * in several rendering techniques.
  66991. */
  66992. export class DepthRendererSceneComponent implements ISceneComponent {
  66993. /**
  66994. * The component name helpfull to identify the component in the list of scene components.
  66995. */
  66996. readonly name: string;
  66997. /**
  66998. * The scene the component belongs to.
  66999. */
  67000. scene: Scene;
  67001. /**
  67002. * Creates a new instance of the component for the given scene
  67003. * @param scene Defines the scene to register the component in
  67004. */
  67005. constructor(scene: Scene);
  67006. /**
  67007. * Registers the component in a given scene
  67008. */
  67009. register(): void;
  67010. /**
  67011. * Rebuilds the elements related to this component in case of
  67012. * context lost for instance.
  67013. */
  67014. rebuild(): void;
  67015. /**
  67016. * Disposes the component and the associated ressources
  67017. */
  67018. dispose(): void;
  67019. private _gatherRenderTargets;
  67020. private _gatherActiveCameraRenderTargets;
  67021. }
  67022. }
  67023. declare module BABYLON {
  67024. /** @hidden */
  67025. export var outlinePixelShader: {
  67026. name: string;
  67027. shader: string;
  67028. };
  67029. }
  67030. declare module BABYLON {
  67031. /** @hidden */
  67032. export var outlineVertexShader: {
  67033. name: string;
  67034. shader: string;
  67035. };
  67036. }
  67037. declare module BABYLON {
  67038. interface Scene {
  67039. /** @hidden */
  67040. _outlineRenderer: OutlineRenderer;
  67041. /**
  67042. * Gets the outline renderer associated with the scene
  67043. * @returns a OutlineRenderer
  67044. */
  67045. getOutlineRenderer(): OutlineRenderer;
  67046. }
  67047. interface AbstractMesh {
  67048. /** @hidden (Backing field) */
  67049. _renderOutline: boolean;
  67050. /**
  67051. * Gets or sets a boolean indicating if the outline must be rendered as well
  67052. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67053. */
  67054. renderOutline: boolean;
  67055. /** @hidden (Backing field) */
  67056. _renderOverlay: boolean;
  67057. /**
  67058. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67059. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67060. */
  67061. renderOverlay: boolean;
  67062. }
  67063. /**
  67064. * This class is responsible to draw bothe outline/overlay of meshes.
  67065. * It should not be used directly but through the available method on mesh.
  67066. */
  67067. export class OutlineRenderer implements ISceneComponent {
  67068. /**
  67069. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67070. */
  67071. private static _StencilReference;
  67072. /**
  67073. * The name of the component. Each component must have a unique name.
  67074. */
  67075. name: string;
  67076. /**
  67077. * The scene the component belongs to.
  67078. */
  67079. scene: Scene;
  67080. /**
  67081. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67082. */
  67083. zOffset: number;
  67084. private _engine;
  67085. private _effect;
  67086. private _cachedDefines;
  67087. private _savedDepthWrite;
  67088. /**
  67089. * Instantiates a new outline renderer. (There could be only one per scene).
  67090. * @param scene Defines the scene it belongs to
  67091. */
  67092. constructor(scene: Scene);
  67093. /**
  67094. * Register the component to one instance of a scene.
  67095. */
  67096. register(): void;
  67097. /**
  67098. * Rebuilds the elements related to this component in case of
  67099. * context lost for instance.
  67100. */
  67101. rebuild(): void;
  67102. /**
  67103. * Disposes the component and the associated ressources.
  67104. */
  67105. dispose(): void;
  67106. /**
  67107. * Renders the outline in the canvas.
  67108. * @param subMesh Defines the sumesh to render
  67109. * @param batch Defines the batch of meshes in case of instances
  67110. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67111. */
  67112. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67113. /**
  67114. * Returns whether or not the outline renderer is ready for a given submesh.
  67115. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67116. * @param subMesh Defines the submesh to check readyness for
  67117. * @param useInstances Defines wheter wee are trying to render instances or not
  67118. * @returns true if ready otherwise false
  67119. */
  67120. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67121. private _beforeRenderingMesh;
  67122. private _afterRenderingMesh;
  67123. }
  67124. }
  67125. declare module BABYLON {
  67126. /**
  67127. * Defines the basic options interface of a Sprite Frame Source Size.
  67128. */
  67129. export interface ISpriteJSONSpriteSourceSize {
  67130. /**
  67131. * number of the original width of the Frame
  67132. */
  67133. w: number;
  67134. /**
  67135. * number of the original height of the Frame
  67136. */
  67137. h: number;
  67138. }
  67139. /**
  67140. * Defines the basic options interface of a Sprite Frame Data.
  67141. */
  67142. export interface ISpriteJSONSpriteFrameData {
  67143. /**
  67144. * number of the x offset of the Frame
  67145. */
  67146. x: number;
  67147. /**
  67148. * number of the y offset of the Frame
  67149. */
  67150. y: number;
  67151. /**
  67152. * number of the width of the Frame
  67153. */
  67154. w: number;
  67155. /**
  67156. * number of the height of the Frame
  67157. */
  67158. h: number;
  67159. }
  67160. /**
  67161. * Defines the basic options interface of a JSON Sprite.
  67162. */
  67163. export interface ISpriteJSONSprite {
  67164. /**
  67165. * string name of the Frame
  67166. */
  67167. filename: string;
  67168. /**
  67169. * ISpriteJSONSpriteFrame basic object of the frame data
  67170. */
  67171. frame: ISpriteJSONSpriteFrameData;
  67172. /**
  67173. * boolean to flag is the frame was rotated.
  67174. */
  67175. rotated: boolean;
  67176. /**
  67177. * boolean to flag is the frame was trimmed.
  67178. */
  67179. trimmed: boolean;
  67180. /**
  67181. * ISpriteJSONSpriteFrame basic object of the source data
  67182. */
  67183. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67184. /**
  67185. * ISpriteJSONSpriteFrame basic object of the source data
  67186. */
  67187. sourceSize: ISpriteJSONSpriteSourceSize;
  67188. }
  67189. /**
  67190. * Defines the basic options interface of a JSON atlas.
  67191. */
  67192. export interface ISpriteJSONAtlas {
  67193. /**
  67194. * Array of objects that contain the frame data.
  67195. */
  67196. frames: Array<ISpriteJSONSprite>;
  67197. /**
  67198. * object basic object containing the sprite meta data.
  67199. */
  67200. meta?: object;
  67201. }
  67202. }
  67203. declare module BABYLON {
  67204. /** @hidden */
  67205. export var spriteMapPixelShader: {
  67206. name: string;
  67207. shader: string;
  67208. };
  67209. }
  67210. declare module BABYLON {
  67211. /** @hidden */
  67212. export var spriteMapVertexShader: {
  67213. name: string;
  67214. shader: string;
  67215. };
  67216. }
  67217. declare module BABYLON {
  67218. /**
  67219. * Defines the basic options interface of a SpriteMap
  67220. */
  67221. export interface ISpriteMapOptions {
  67222. /**
  67223. * Vector2 of the number of cells in the grid.
  67224. */
  67225. stageSize?: Vector2;
  67226. /**
  67227. * Vector2 of the size of the output plane in World Units.
  67228. */
  67229. outputSize?: Vector2;
  67230. /**
  67231. * Vector3 of the position of the output plane in World Units.
  67232. */
  67233. outputPosition?: Vector3;
  67234. /**
  67235. * Vector3 of the rotation of the output plane.
  67236. */
  67237. outputRotation?: Vector3;
  67238. /**
  67239. * number of layers that the system will reserve in resources.
  67240. */
  67241. layerCount?: number;
  67242. /**
  67243. * number of max animation frames a single cell will reserve in resources.
  67244. */
  67245. maxAnimationFrames?: number;
  67246. /**
  67247. * number cell index of the base tile when the system compiles.
  67248. */
  67249. baseTile?: number;
  67250. /**
  67251. * boolean flip the sprite after its been repositioned by the framing data.
  67252. */
  67253. flipU?: boolean;
  67254. /**
  67255. * Vector3 scalar of the global RGB values of the SpriteMap.
  67256. */
  67257. colorMultiply?: Vector3;
  67258. }
  67259. /**
  67260. * Defines the IDisposable interface in order to be cleanable from resources.
  67261. */
  67262. export interface ISpriteMap extends IDisposable {
  67263. /**
  67264. * String name of the SpriteMap.
  67265. */
  67266. name: string;
  67267. /**
  67268. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67269. */
  67270. atlasJSON: ISpriteJSONAtlas;
  67271. /**
  67272. * Texture of the SpriteMap.
  67273. */
  67274. spriteSheet: Texture;
  67275. /**
  67276. * The parameters to initialize the SpriteMap with.
  67277. */
  67278. options: ISpriteMapOptions;
  67279. }
  67280. /**
  67281. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67282. */
  67283. export class SpriteMap implements ISpriteMap {
  67284. /** The Name of the spriteMap */
  67285. name: string;
  67286. /** The JSON file with the frame and meta data */
  67287. atlasJSON: ISpriteJSONAtlas;
  67288. /** The systems Sprite Sheet Texture */
  67289. spriteSheet: Texture;
  67290. /** Arguments passed with the Constructor */
  67291. options: ISpriteMapOptions;
  67292. /** Public Sprite Storage array, parsed from atlasJSON */
  67293. sprites: Array<ISpriteJSONSprite>;
  67294. /** Returns the Number of Sprites in the System */
  67295. get spriteCount(): number;
  67296. /** Returns the Position of Output Plane*/
  67297. get position(): Vector3;
  67298. /** Returns the Position of Output Plane*/
  67299. set position(v: Vector3);
  67300. /** Returns the Rotation of Output Plane*/
  67301. get rotation(): Vector3;
  67302. /** Returns the Rotation of Output Plane*/
  67303. set rotation(v: Vector3);
  67304. /** Sets the AnimationMap*/
  67305. get animationMap(): RawTexture;
  67306. /** Sets the AnimationMap*/
  67307. set animationMap(v: RawTexture);
  67308. /** Scene that the SpriteMap was created in */
  67309. private _scene;
  67310. /** Texture Buffer of Float32 that holds tile frame data*/
  67311. private _frameMap;
  67312. /** Texture Buffers of Float32 that holds tileMap data*/
  67313. private _tileMaps;
  67314. /** Texture Buffer of Float32 that holds Animation Data*/
  67315. private _animationMap;
  67316. /** Custom ShaderMaterial Central to the System*/
  67317. private _material;
  67318. /** Custom ShaderMaterial Central to the System*/
  67319. private _output;
  67320. /** Systems Time Ticker*/
  67321. private _time;
  67322. /**
  67323. * Creates a new SpriteMap
  67324. * @param name defines the SpriteMaps Name
  67325. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67326. * @param spriteSheet is the Texture that the Sprites are on.
  67327. * @param options a basic deployment configuration
  67328. * @param scene The Scene that the map is deployed on
  67329. */
  67330. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67331. /**
  67332. * Returns tileID location
  67333. * @returns Vector2 the cell position ID
  67334. */
  67335. getTileID(): Vector2;
  67336. /**
  67337. * Gets the UV location of the mouse over the SpriteMap.
  67338. * @returns Vector2 the UV position of the mouse interaction
  67339. */
  67340. getMousePosition(): Vector2;
  67341. /**
  67342. * Creates the "frame" texture Buffer
  67343. * -------------------------------------
  67344. * Structure of frames
  67345. * "filename": "Falling-Water-2.png",
  67346. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67347. * "rotated": true,
  67348. * "trimmed": true,
  67349. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67350. * "sourceSize": {"w":32,"h":32}
  67351. * @returns RawTexture of the frameMap
  67352. */
  67353. private _createFrameBuffer;
  67354. /**
  67355. * Creates the tileMap texture Buffer
  67356. * @param buffer normally and array of numbers, or a false to generate from scratch
  67357. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67358. * @returns RawTexture of the tileMap
  67359. */
  67360. private _createTileBuffer;
  67361. /**
  67362. * Modifies the data of the tileMaps
  67363. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67364. * @param pos is the iVector2 Coordinates of the Tile
  67365. * @param tile The SpriteIndex of the new Tile
  67366. */
  67367. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67368. /**
  67369. * Creates the animationMap texture Buffer
  67370. * @param buffer normally and array of numbers, or a false to generate from scratch
  67371. * @returns RawTexture of the animationMap
  67372. */
  67373. private _createTileAnimationBuffer;
  67374. /**
  67375. * Modifies the data of the animationMap
  67376. * @param cellID is the Index of the Sprite
  67377. * @param _frame is the target Animation frame
  67378. * @param toCell is the Target Index of the next frame of the animation
  67379. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67380. * @param speed is a global scalar of the time variable on the map.
  67381. */
  67382. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67383. /**
  67384. * Exports the .tilemaps file
  67385. */
  67386. saveTileMaps(): void;
  67387. /**
  67388. * Imports the .tilemaps file
  67389. * @param url of the .tilemaps file
  67390. */
  67391. loadTileMaps(url: string): void;
  67392. /**
  67393. * Release associated resources
  67394. */
  67395. dispose(): void;
  67396. }
  67397. }
  67398. declare module BABYLON {
  67399. /**
  67400. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67401. * @see http://doc.babylonjs.com/babylon101/sprites
  67402. */
  67403. export class SpritePackedManager extends SpriteManager {
  67404. /** defines the packed manager's name */
  67405. name: string;
  67406. /**
  67407. * Creates a new sprite manager from a packed sprite sheet
  67408. * @param name defines the manager's name
  67409. * @param imgUrl defines the sprite sheet url
  67410. * @param capacity defines the maximum allowed number of sprites
  67411. * @param scene defines the hosting scene
  67412. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67413. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67414. * @param samplingMode defines the smapling mode to use with spritesheet
  67415. * @param fromPacked set to true; do not alter
  67416. */
  67417. constructor(
  67418. /** defines the packed manager's name */
  67419. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67420. }
  67421. }
  67422. declare module BABYLON {
  67423. /**
  67424. * Defines the list of states available for a task inside a AssetsManager
  67425. */
  67426. export enum AssetTaskState {
  67427. /**
  67428. * Initialization
  67429. */
  67430. INIT = 0,
  67431. /**
  67432. * Running
  67433. */
  67434. RUNNING = 1,
  67435. /**
  67436. * Done
  67437. */
  67438. DONE = 2,
  67439. /**
  67440. * Error
  67441. */
  67442. ERROR = 3
  67443. }
  67444. /**
  67445. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67446. */
  67447. export abstract class AbstractAssetTask {
  67448. /**
  67449. * Task name
  67450. */ name: string;
  67451. /**
  67452. * Callback called when the task is successful
  67453. */
  67454. onSuccess: (task: any) => void;
  67455. /**
  67456. * Callback called when the task is not successful
  67457. */
  67458. onError: (task: any, message?: string, exception?: any) => void;
  67459. /**
  67460. * Creates a new AssetsManager
  67461. * @param name defines the name of the task
  67462. */
  67463. constructor(
  67464. /**
  67465. * Task name
  67466. */ name: string);
  67467. private _isCompleted;
  67468. private _taskState;
  67469. private _errorObject;
  67470. /**
  67471. * Get if the task is completed
  67472. */
  67473. get isCompleted(): boolean;
  67474. /**
  67475. * Gets the current state of the task
  67476. */
  67477. get taskState(): AssetTaskState;
  67478. /**
  67479. * Gets the current error object (if task is in error)
  67480. */
  67481. get errorObject(): {
  67482. message?: string;
  67483. exception?: any;
  67484. };
  67485. /**
  67486. * Internal only
  67487. * @hidden
  67488. */
  67489. _setErrorObject(message?: string, exception?: any): void;
  67490. /**
  67491. * Execute the current task
  67492. * @param scene defines the scene where you want your assets to be loaded
  67493. * @param onSuccess is a callback called when the task is successfully executed
  67494. * @param onError is a callback called if an error occurs
  67495. */
  67496. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67497. /**
  67498. * Execute the current task
  67499. * @param scene defines the scene where you want your assets to be loaded
  67500. * @param onSuccess is a callback called when the task is successfully executed
  67501. * @param onError is a callback called if an error occurs
  67502. */
  67503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67504. /**
  67505. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67506. * This can be used with failed tasks that have the reason for failure fixed.
  67507. */
  67508. reset(): void;
  67509. private onErrorCallback;
  67510. private onDoneCallback;
  67511. }
  67512. /**
  67513. * Define the interface used by progress events raised during assets loading
  67514. */
  67515. export interface IAssetsProgressEvent {
  67516. /**
  67517. * Defines the number of remaining tasks to process
  67518. */
  67519. remainingCount: number;
  67520. /**
  67521. * Defines the total number of tasks
  67522. */
  67523. totalCount: number;
  67524. /**
  67525. * Defines the task that was just processed
  67526. */
  67527. task: AbstractAssetTask;
  67528. }
  67529. /**
  67530. * Class used to share progress information about assets loading
  67531. */
  67532. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67533. /**
  67534. * Defines the number of remaining tasks to process
  67535. */
  67536. remainingCount: number;
  67537. /**
  67538. * Defines the total number of tasks
  67539. */
  67540. totalCount: number;
  67541. /**
  67542. * Defines the task that was just processed
  67543. */
  67544. task: AbstractAssetTask;
  67545. /**
  67546. * Creates a AssetsProgressEvent
  67547. * @param remainingCount defines the number of remaining tasks to process
  67548. * @param totalCount defines the total number of tasks
  67549. * @param task defines the task that was just processed
  67550. */
  67551. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67552. }
  67553. /**
  67554. * Define a task used by AssetsManager to load meshes
  67555. */
  67556. export class MeshAssetTask extends AbstractAssetTask {
  67557. /**
  67558. * Defines the name of the task
  67559. */
  67560. name: string;
  67561. /**
  67562. * Defines the list of mesh's names you want to load
  67563. */
  67564. meshesNames: any;
  67565. /**
  67566. * Defines the root url to use as a base to load your meshes and associated resources
  67567. */
  67568. rootUrl: string;
  67569. /**
  67570. * Defines the filename of the scene to load from
  67571. */
  67572. sceneFilename: string;
  67573. /**
  67574. * Gets the list of loaded meshes
  67575. */
  67576. loadedMeshes: Array<AbstractMesh>;
  67577. /**
  67578. * Gets the list of loaded particle systems
  67579. */
  67580. loadedParticleSystems: Array<IParticleSystem>;
  67581. /**
  67582. * Gets the list of loaded skeletons
  67583. */
  67584. loadedSkeletons: Array<Skeleton>;
  67585. /**
  67586. * Gets the list of loaded animation groups
  67587. */
  67588. loadedAnimationGroups: Array<AnimationGroup>;
  67589. /**
  67590. * Callback called when the task is successful
  67591. */
  67592. onSuccess: (task: MeshAssetTask) => void;
  67593. /**
  67594. * Callback called when the task is successful
  67595. */
  67596. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67597. /**
  67598. * Creates a new MeshAssetTask
  67599. * @param name defines the name of the task
  67600. * @param meshesNames defines the list of mesh's names you want to load
  67601. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67602. * @param sceneFilename defines the filename of the scene to load from
  67603. */
  67604. constructor(
  67605. /**
  67606. * Defines the name of the task
  67607. */
  67608. name: string,
  67609. /**
  67610. * Defines the list of mesh's names you want to load
  67611. */
  67612. meshesNames: any,
  67613. /**
  67614. * Defines the root url to use as a base to load your meshes and associated resources
  67615. */
  67616. rootUrl: string,
  67617. /**
  67618. * Defines the filename of the scene to load from
  67619. */
  67620. sceneFilename: string);
  67621. /**
  67622. * Execute the current task
  67623. * @param scene defines the scene where you want your assets to be loaded
  67624. * @param onSuccess is a callback called when the task is successfully executed
  67625. * @param onError is a callback called if an error occurs
  67626. */
  67627. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67628. }
  67629. /**
  67630. * Define a task used by AssetsManager to load text content
  67631. */
  67632. export class TextFileAssetTask extends AbstractAssetTask {
  67633. /**
  67634. * Defines the name of the task
  67635. */
  67636. name: string;
  67637. /**
  67638. * Defines the location of the file to load
  67639. */
  67640. url: string;
  67641. /**
  67642. * Gets the loaded text string
  67643. */
  67644. text: string;
  67645. /**
  67646. * Callback called when the task is successful
  67647. */
  67648. onSuccess: (task: TextFileAssetTask) => void;
  67649. /**
  67650. * Callback called when the task is successful
  67651. */
  67652. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67653. /**
  67654. * Creates a new TextFileAssetTask object
  67655. * @param name defines the name of the task
  67656. * @param url defines the location of the file to load
  67657. */
  67658. constructor(
  67659. /**
  67660. * Defines the name of the task
  67661. */
  67662. name: string,
  67663. /**
  67664. * Defines the location of the file to load
  67665. */
  67666. url: string);
  67667. /**
  67668. * Execute the current task
  67669. * @param scene defines the scene where you want your assets to be loaded
  67670. * @param onSuccess is a callback called when the task is successfully executed
  67671. * @param onError is a callback called if an error occurs
  67672. */
  67673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67674. }
  67675. /**
  67676. * Define a task used by AssetsManager to load binary data
  67677. */
  67678. export class BinaryFileAssetTask extends AbstractAssetTask {
  67679. /**
  67680. * Defines the name of the task
  67681. */
  67682. name: string;
  67683. /**
  67684. * Defines the location of the file to load
  67685. */
  67686. url: string;
  67687. /**
  67688. * Gets the lodaded data (as an array buffer)
  67689. */
  67690. data: ArrayBuffer;
  67691. /**
  67692. * Callback called when the task is successful
  67693. */
  67694. onSuccess: (task: BinaryFileAssetTask) => void;
  67695. /**
  67696. * Callback called when the task is successful
  67697. */
  67698. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67699. /**
  67700. * Creates a new BinaryFileAssetTask object
  67701. * @param name defines the name of the new task
  67702. * @param url defines the location of the file to load
  67703. */
  67704. constructor(
  67705. /**
  67706. * Defines the name of the task
  67707. */
  67708. name: string,
  67709. /**
  67710. * Defines the location of the file to load
  67711. */
  67712. url: string);
  67713. /**
  67714. * Execute the current task
  67715. * @param scene defines the scene where you want your assets to be loaded
  67716. * @param onSuccess is a callback called when the task is successfully executed
  67717. * @param onError is a callback called if an error occurs
  67718. */
  67719. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67720. }
  67721. /**
  67722. * Define a task used by AssetsManager to load images
  67723. */
  67724. export class ImageAssetTask extends AbstractAssetTask {
  67725. /**
  67726. * Defines the name of the task
  67727. */
  67728. name: string;
  67729. /**
  67730. * Defines the location of the image to load
  67731. */
  67732. url: string;
  67733. /**
  67734. * Gets the loaded images
  67735. */
  67736. image: HTMLImageElement;
  67737. /**
  67738. * Callback called when the task is successful
  67739. */
  67740. onSuccess: (task: ImageAssetTask) => void;
  67741. /**
  67742. * Callback called when the task is successful
  67743. */
  67744. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67745. /**
  67746. * Creates a new ImageAssetTask
  67747. * @param name defines the name of the task
  67748. * @param url defines the location of the image to load
  67749. */
  67750. constructor(
  67751. /**
  67752. * Defines the name of the task
  67753. */
  67754. name: string,
  67755. /**
  67756. * Defines the location of the image to load
  67757. */
  67758. url: string);
  67759. /**
  67760. * Execute the current task
  67761. * @param scene defines the scene where you want your assets to be loaded
  67762. * @param onSuccess is a callback called when the task is successfully executed
  67763. * @param onError is a callback called if an error occurs
  67764. */
  67765. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67766. }
  67767. /**
  67768. * Defines the interface used by texture loading tasks
  67769. */
  67770. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67771. /**
  67772. * Gets the loaded texture
  67773. */
  67774. texture: TEX;
  67775. }
  67776. /**
  67777. * Define a task used by AssetsManager to load 2D textures
  67778. */
  67779. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67780. /**
  67781. * Defines the name of the task
  67782. */
  67783. name: string;
  67784. /**
  67785. * Defines the location of the file to load
  67786. */
  67787. url: string;
  67788. /**
  67789. * Defines if mipmap should not be generated (default is false)
  67790. */
  67791. noMipmap?: boolean | undefined;
  67792. /**
  67793. * Defines if texture must be inverted on Y axis (default is false)
  67794. */
  67795. invertY?: boolean | undefined;
  67796. /**
  67797. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67798. */
  67799. samplingMode: number;
  67800. /**
  67801. * Gets the loaded texture
  67802. */
  67803. texture: Texture;
  67804. /**
  67805. * Callback called when the task is successful
  67806. */
  67807. onSuccess: (task: TextureAssetTask) => void;
  67808. /**
  67809. * Callback called when the task is successful
  67810. */
  67811. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67812. /**
  67813. * Creates a new TextureAssetTask object
  67814. * @param name defines the name of the task
  67815. * @param url defines the location of the file to load
  67816. * @param noMipmap defines if mipmap should not be generated (default is false)
  67817. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67818. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67819. */
  67820. constructor(
  67821. /**
  67822. * Defines the name of the task
  67823. */
  67824. name: string,
  67825. /**
  67826. * Defines the location of the file to load
  67827. */
  67828. url: string,
  67829. /**
  67830. * Defines if mipmap should not be generated (default is false)
  67831. */
  67832. noMipmap?: boolean | undefined,
  67833. /**
  67834. * Defines if texture must be inverted on Y axis (default is false)
  67835. */
  67836. invertY?: boolean | undefined,
  67837. /**
  67838. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67839. */
  67840. samplingMode?: number);
  67841. /**
  67842. * Execute the current task
  67843. * @param scene defines the scene where you want your assets to be loaded
  67844. * @param onSuccess is a callback called when the task is successfully executed
  67845. * @param onError is a callback called if an error occurs
  67846. */
  67847. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67848. }
  67849. /**
  67850. * Define a task used by AssetsManager to load cube textures
  67851. */
  67852. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67853. /**
  67854. * Defines the name of the task
  67855. */
  67856. name: string;
  67857. /**
  67858. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67859. */
  67860. url: string;
  67861. /**
  67862. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67863. */
  67864. extensions?: string[] | undefined;
  67865. /**
  67866. * Defines if mipmaps should not be generated (default is false)
  67867. */
  67868. noMipmap?: boolean | undefined;
  67869. /**
  67870. * Defines the explicit list of files (undefined by default)
  67871. */
  67872. files?: string[] | undefined;
  67873. /**
  67874. * Gets the loaded texture
  67875. */
  67876. texture: CubeTexture;
  67877. /**
  67878. * Callback called when the task is successful
  67879. */
  67880. onSuccess: (task: CubeTextureAssetTask) => void;
  67881. /**
  67882. * Callback called when the task is successful
  67883. */
  67884. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67885. /**
  67886. * Creates a new CubeTextureAssetTask
  67887. * @param name defines the name of the task
  67888. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67889. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67890. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67891. * @param files defines the explicit list of files (undefined by default)
  67892. */
  67893. constructor(
  67894. /**
  67895. * Defines the name of the task
  67896. */
  67897. name: string,
  67898. /**
  67899. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67900. */
  67901. url: string,
  67902. /**
  67903. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67904. */
  67905. extensions?: string[] | undefined,
  67906. /**
  67907. * Defines if mipmaps should not be generated (default is false)
  67908. */
  67909. noMipmap?: boolean | undefined,
  67910. /**
  67911. * Defines the explicit list of files (undefined by default)
  67912. */
  67913. files?: string[] | undefined);
  67914. /**
  67915. * Execute the current task
  67916. * @param scene defines the scene where you want your assets to be loaded
  67917. * @param onSuccess is a callback called when the task is successfully executed
  67918. * @param onError is a callback called if an error occurs
  67919. */
  67920. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67921. }
  67922. /**
  67923. * Define a task used by AssetsManager to load HDR cube textures
  67924. */
  67925. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67926. /**
  67927. * Defines the name of the task
  67928. */
  67929. name: string;
  67930. /**
  67931. * Defines the location of the file to load
  67932. */
  67933. url: string;
  67934. /**
  67935. * Defines the desired size (the more it increases the longer the generation will be)
  67936. */
  67937. size: number;
  67938. /**
  67939. * Defines if mipmaps should not be generated (default is false)
  67940. */
  67941. noMipmap: boolean;
  67942. /**
  67943. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67944. */
  67945. generateHarmonics: boolean;
  67946. /**
  67947. * 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)
  67948. */
  67949. gammaSpace: boolean;
  67950. /**
  67951. * Internal Use Only
  67952. */
  67953. reserved: boolean;
  67954. /**
  67955. * Gets the loaded texture
  67956. */
  67957. texture: HDRCubeTexture;
  67958. /**
  67959. * Callback called when the task is successful
  67960. */
  67961. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67962. /**
  67963. * Callback called when the task is successful
  67964. */
  67965. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67966. /**
  67967. * Creates a new HDRCubeTextureAssetTask object
  67968. * @param name defines the name of the task
  67969. * @param url defines the location of the file to load
  67970. * @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.
  67971. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67972. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67973. * @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)
  67974. * @param reserved Internal use only
  67975. */
  67976. constructor(
  67977. /**
  67978. * Defines the name of the task
  67979. */
  67980. name: string,
  67981. /**
  67982. * Defines the location of the file to load
  67983. */
  67984. url: string,
  67985. /**
  67986. * Defines the desired size (the more it increases the longer the generation will be)
  67987. */
  67988. size: number,
  67989. /**
  67990. * Defines if mipmaps should not be generated (default is false)
  67991. */
  67992. noMipmap?: boolean,
  67993. /**
  67994. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67995. */
  67996. generateHarmonics?: boolean,
  67997. /**
  67998. * 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)
  67999. */
  68000. gammaSpace?: boolean,
  68001. /**
  68002. * Internal Use Only
  68003. */
  68004. reserved?: boolean);
  68005. /**
  68006. * Execute the current task
  68007. * @param scene defines the scene where you want your assets to be loaded
  68008. * @param onSuccess is a callback called when the task is successfully executed
  68009. * @param onError is a callback called if an error occurs
  68010. */
  68011. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68012. }
  68013. /**
  68014. * Define a task used by AssetsManager to load Equirectangular cube textures
  68015. */
  68016. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68017. /**
  68018. * Defines the name of the task
  68019. */
  68020. name: string;
  68021. /**
  68022. * Defines the location of the file to load
  68023. */
  68024. url: string;
  68025. /**
  68026. * Defines the desired size (the more it increases the longer the generation will be)
  68027. */
  68028. size: number;
  68029. /**
  68030. * Defines if mipmaps should not be generated (default is false)
  68031. */
  68032. noMipmap: boolean;
  68033. /**
  68034. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68035. * but the standard material would require them in Gamma space) (default is true)
  68036. */
  68037. gammaSpace: boolean;
  68038. /**
  68039. * Gets the loaded texture
  68040. */
  68041. texture: EquiRectangularCubeTexture;
  68042. /**
  68043. * Callback called when the task is successful
  68044. */
  68045. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68046. /**
  68047. * Callback called when the task is successful
  68048. */
  68049. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68050. /**
  68051. * Creates a new EquiRectangularCubeTextureAssetTask object
  68052. * @param name defines the name of the task
  68053. * @param url defines the location of the file to load
  68054. * @param size defines the desired size (the more it increases the longer the generation will be)
  68055. * If the size is omitted this implies you are using a preprocessed cubemap.
  68056. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68057. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68058. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68059. * (default is true)
  68060. */
  68061. constructor(
  68062. /**
  68063. * Defines the name of the task
  68064. */
  68065. name: string,
  68066. /**
  68067. * Defines the location of the file to load
  68068. */
  68069. url: string,
  68070. /**
  68071. * Defines the desired size (the more it increases the longer the generation will be)
  68072. */
  68073. size: number,
  68074. /**
  68075. * Defines if mipmaps should not be generated (default is false)
  68076. */
  68077. noMipmap?: boolean,
  68078. /**
  68079. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68080. * but the standard material would require them in Gamma space) (default is true)
  68081. */
  68082. gammaSpace?: boolean);
  68083. /**
  68084. * Execute the current task
  68085. * @param scene defines the scene where you want your assets to be loaded
  68086. * @param onSuccess is a callback called when the task is successfully executed
  68087. * @param onError is a callback called if an error occurs
  68088. */
  68089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68090. }
  68091. /**
  68092. * This class can be used to easily import assets into a scene
  68093. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68094. */
  68095. export class AssetsManager {
  68096. private _scene;
  68097. private _isLoading;
  68098. protected _tasks: AbstractAssetTask[];
  68099. protected _waitingTasksCount: number;
  68100. protected _totalTasksCount: number;
  68101. /**
  68102. * Callback called when all tasks are processed
  68103. */
  68104. onFinish: (tasks: AbstractAssetTask[]) => void;
  68105. /**
  68106. * Callback called when a task is successful
  68107. */
  68108. onTaskSuccess: (task: AbstractAssetTask) => void;
  68109. /**
  68110. * Callback called when a task had an error
  68111. */
  68112. onTaskError: (task: AbstractAssetTask) => void;
  68113. /**
  68114. * Callback called when a task is done (whatever the result is)
  68115. */
  68116. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68117. /**
  68118. * Observable called when all tasks are processed
  68119. */
  68120. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68121. /**
  68122. * Observable called when a task had an error
  68123. */
  68124. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68125. /**
  68126. * Observable called when all tasks were executed
  68127. */
  68128. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68129. /**
  68130. * Observable called when a task is done (whatever the result is)
  68131. */
  68132. onProgressObservable: Observable<IAssetsProgressEvent>;
  68133. /**
  68134. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68135. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68136. */
  68137. useDefaultLoadingScreen: boolean;
  68138. /**
  68139. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68140. * when all assets have been downloaded.
  68141. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68142. */
  68143. autoHideLoadingUI: boolean;
  68144. /**
  68145. * Creates a new AssetsManager
  68146. * @param scene defines the scene to work on
  68147. */
  68148. constructor(scene: Scene);
  68149. /**
  68150. * Add a MeshAssetTask to the list of active tasks
  68151. * @param taskName defines the name of the new task
  68152. * @param meshesNames defines the name of meshes to load
  68153. * @param rootUrl defines the root url to use to locate files
  68154. * @param sceneFilename defines the filename of the scene file
  68155. * @returns a new MeshAssetTask object
  68156. */
  68157. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68158. /**
  68159. * Add a TextFileAssetTask to the list of active tasks
  68160. * @param taskName defines the name of the new task
  68161. * @param url defines the url of the file to load
  68162. * @returns a new TextFileAssetTask object
  68163. */
  68164. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68165. /**
  68166. * Add a BinaryFileAssetTask to the list of active tasks
  68167. * @param taskName defines the name of the new task
  68168. * @param url defines the url of the file to load
  68169. * @returns a new BinaryFileAssetTask object
  68170. */
  68171. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68172. /**
  68173. * Add a ImageAssetTask to the list of active tasks
  68174. * @param taskName defines the name of the new task
  68175. * @param url defines the url of the file to load
  68176. * @returns a new ImageAssetTask object
  68177. */
  68178. addImageTask(taskName: string, url: string): ImageAssetTask;
  68179. /**
  68180. * Add a TextureAssetTask to the list of active tasks
  68181. * @param taskName defines the name of the new task
  68182. * @param url defines the url of the file to load
  68183. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68184. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68185. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68186. * @returns a new TextureAssetTask object
  68187. */
  68188. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68189. /**
  68190. * Add a CubeTextureAssetTask to the list of active tasks
  68191. * @param taskName defines the name of the new task
  68192. * @param url defines the url of the file to load
  68193. * @param extensions defines the extension to use to load the cube map (can be null)
  68194. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68195. * @param files defines the list of files to load (can be null)
  68196. * @returns a new CubeTextureAssetTask object
  68197. */
  68198. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68199. /**
  68200. *
  68201. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68202. * @param taskName defines the name of the new task
  68203. * @param url defines the url of the file to load
  68204. * @param size defines the size you want for the cubemap (can be null)
  68205. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68206. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68207. * @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)
  68208. * @param reserved Internal use only
  68209. * @returns a new HDRCubeTextureAssetTask object
  68210. */
  68211. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68212. /**
  68213. *
  68214. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68215. * @param taskName defines the name of the new task
  68216. * @param url defines the url of the file to load
  68217. * @param size defines the size you want for the cubemap (can be null)
  68218. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68219. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68220. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68221. * @returns a new EquiRectangularCubeTextureAssetTask object
  68222. */
  68223. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68224. /**
  68225. * Remove a task from the assets manager.
  68226. * @param task the task to remove
  68227. */
  68228. removeTask(task: AbstractAssetTask): void;
  68229. private _decreaseWaitingTasksCount;
  68230. private _runTask;
  68231. /**
  68232. * Reset the AssetsManager and remove all tasks
  68233. * @return the current instance of the AssetsManager
  68234. */
  68235. reset(): AssetsManager;
  68236. /**
  68237. * Start the loading process
  68238. * @return the current instance of the AssetsManager
  68239. */
  68240. load(): AssetsManager;
  68241. /**
  68242. * Start the loading process as an async operation
  68243. * @return a promise returning the list of failed tasks
  68244. */
  68245. loadAsync(): Promise<void>;
  68246. }
  68247. }
  68248. declare module BABYLON {
  68249. /**
  68250. * Wrapper class for promise with external resolve and reject.
  68251. */
  68252. export class Deferred<T> {
  68253. /**
  68254. * The promise associated with this deferred object.
  68255. */
  68256. readonly promise: Promise<T>;
  68257. private _resolve;
  68258. private _reject;
  68259. /**
  68260. * The resolve method of the promise associated with this deferred object.
  68261. */
  68262. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68263. /**
  68264. * The reject method of the promise associated with this deferred object.
  68265. */
  68266. get reject(): (reason?: any) => void;
  68267. /**
  68268. * Constructor for this deferred object.
  68269. */
  68270. constructor();
  68271. }
  68272. }
  68273. declare module BABYLON {
  68274. /**
  68275. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68276. */
  68277. export class MeshExploder {
  68278. private _centerMesh;
  68279. private _meshes;
  68280. private _meshesOrigins;
  68281. private _toCenterVectors;
  68282. private _scaledDirection;
  68283. private _newPosition;
  68284. private _centerPosition;
  68285. /**
  68286. * Explodes meshes from a center mesh.
  68287. * @param meshes The meshes to explode.
  68288. * @param centerMesh The mesh to be center of explosion.
  68289. */
  68290. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68291. private _setCenterMesh;
  68292. /**
  68293. * Get class name
  68294. * @returns "MeshExploder"
  68295. */
  68296. getClassName(): string;
  68297. /**
  68298. * "Exploded meshes"
  68299. * @returns Array of meshes with the centerMesh at index 0.
  68300. */
  68301. getMeshes(): Array<Mesh>;
  68302. /**
  68303. * Explodes meshes giving a specific direction
  68304. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68305. */
  68306. explode(direction?: number): void;
  68307. }
  68308. }
  68309. declare module BABYLON {
  68310. /**
  68311. * Class used to help managing file picking and drag'n'drop
  68312. */
  68313. export class FilesInput {
  68314. /**
  68315. * List of files ready to be loaded
  68316. */
  68317. static get FilesToLoad(): {
  68318. [key: string]: File;
  68319. };
  68320. /**
  68321. * Callback called when a file is processed
  68322. */
  68323. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68324. private _engine;
  68325. private _currentScene;
  68326. private _sceneLoadedCallback;
  68327. private _progressCallback;
  68328. private _additionalRenderLoopLogicCallback;
  68329. private _textureLoadingCallback;
  68330. private _startingProcessingFilesCallback;
  68331. private _onReloadCallback;
  68332. private _errorCallback;
  68333. private _elementToMonitor;
  68334. private _sceneFileToLoad;
  68335. private _filesToLoad;
  68336. /**
  68337. * Creates a new FilesInput
  68338. * @param engine defines the rendering engine
  68339. * @param scene defines the hosting scene
  68340. * @param sceneLoadedCallback callback called when scene is loaded
  68341. * @param progressCallback callback called to track progress
  68342. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68343. * @param textureLoadingCallback callback called when a texture is loading
  68344. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68345. * @param onReloadCallback callback called when a reload is requested
  68346. * @param errorCallback callback call if an error occurs
  68347. */
  68348. 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);
  68349. private _dragEnterHandler;
  68350. private _dragOverHandler;
  68351. private _dropHandler;
  68352. /**
  68353. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68354. * @param elementToMonitor defines the DOM element to track
  68355. */
  68356. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68357. /**
  68358. * Release all associated resources
  68359. */
  68360. dispose(): void;
  68361. private renderFunction;
  68362. private drag;
  68363. private drop;
  68364. private _traverseFolder;
  68365. private _processFiles;
  68366. /**
  68367. * Load files from a drop event
  68368. * @param event defines the drop event to use as source
  68369. */
  68370. loadFiles(event: any): void;
  68371. private _processReload;
  68372. /**
  68373. * Reload the current scene from the loaded files
  68374. */
  68375. reload(): void;
  68376. }
  68377. }
  68378. declare module BABYLON {
  68379. /**
  68380. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68382. */
  68383. export class SceneOptimization {
  68384. /**
  68385. * Defines the priority of this optimization (0 by default which means first in the list)
  68386. */
  68387. priority: number;
  68388. /**
  68389. * Gets a string describing the action executed by the current optimization
  68390. * @returns description string
  68391. */
  68392. getDescription(): string;
  68393. /**
  68394. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68395. * @param scene defines the current scene where to apply this optimization
  68396. * @param optimizer defines the current optimizer
  68397. * @returns true if everything that can be done was applied
  68398. */
  68399. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68400. /**
  68401. * Creates the SceneOptimization object
  68402. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68403. * @param desc defines the description associated with the optimization
  68404. */
  68405. constructor(
  68406. /**
  68407. * Defines the priority of this optimization (0 by default which means first in the list)
  68408. */
  68409. priority?: number);
  68410. }
  68411. /**
  68412. * Defines an optimization used to reduce the size of render target textures
  68413. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68414. */
  68415. export class TextureOptimization extends SceneOptimization {
  68416. /**
  68417. * Defines the priority of this optimization (0 by default which means first in the list)
  68418. */
  68419. priority: number;
  68420. /**
  68421. * 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
  68422. */
  68423. maximumSize: number;
  68424. /**
  68425. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68426. */
  68427. step: number;
  68428. /**
  68429. * Gets a string describing the action executed by the current optimization
  68430. * @returns description string
  68431. */
  68432. getDescription(): string;
  68433. /**
  68434. * Creates the TextureOptimization object
  68435. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68436. * @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
  68437. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68438. */
  68439. constructor(
  68440. /**
  68441. * Defines the priority of this optimization (0 by default which means first in the list)
  68442. */
  68443. priority?: number,
  68444. /**
  68445. * 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
  68446. */
  68447. maximumSize?: number,
  68448. /**
  68449. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68450. */
  68451. step?: number);
  68452. /**
  68453. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68454. * @param scene defines the current scene where to apply this optimization
  68455. * @param optimizer defines the current optimizer
  68456. * @returns true if everything that can be done was applied
  68457. */
  68458. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68459. }
  68460. /**
  68461. * Defines an optimization used to increase or decrease the rendering resolution
  68462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68463. */
  68464. export class HardwareScalingOptimization extends SceneOptimization {
  68465. /**
  68466. * Defines the priority of this optimization (0 by default which means first in the list)
  68467. */
  68468. priority: number;
  68469. /**
  68470. * Defines the maximum scale to use (2 by default)
  68471. */
  68472. maximumScale: number;
  68473. /**
  68474. * Defines the step to use between two passes (0.5 by default)
  68475. */
  68476. step: number;
  68477. private _currentScale;
  68478. private _directionOffset;
  68479. /**
  68480. * Gets a string describing the action executed by the current optimization
  68481. * @return description string
  68482. */
  68483. getDescription(): string;
  68484. /**
  68485. * Creates the HardwareScalingOptimization object
  68486. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68487. * @param maximumScale defines the maximum scale to use (2 by default)
  68488. * @param step defines the step to use between two passes (0.5 by default)
  68489. */
  68490. constructor(
  68491. /**
  68492. * Defines the priority of this optimization (0 by default which means first in the list)
  68493. */
  68494. priority?: number,
  68495. /**
  68496. * Defines the maximum scale to use (2 by default)
  68497. */
  68498. maximumScale?: number,
  68499. /**
  68500. * Defines the step to use between two passes (0.5 by default)
  68501. */
  68502. step?: number);
  68503. /**
  68504. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68505. * @param scene defines the current scene where to apply this optimization
  68506. * @param optimizer defines the current optimizer
  68507. * @returns true if everything that can be done was applied
  68508. */
  68509. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68510. }
  68511. /**
  68512. * Defines an optimization used to remove shadows
  68513. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68514. */
  68515. export class ShadowsOptimization extends SceneOptimization {
  68516. /**
  68517. * Gets a string describing the action executed by the current optimization
  68518. * @return description string
  68519. */
  68520. getDescription(): string;
  68521. /**
  68522. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68523. * @param scene defines the current scene where to apply this optimization
  68524. * @param optimizer defines the current optimizer
  68525. * @returns true if everything that can be done was applied
  68526. */
  68527. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68528. }
  68529. /**
  68530. * Defines an optimization used to turn post-processes off
  68531. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68532. */
  68533. export class PostProcessesOptimization extends SceneOptimization {
  68534. /**
  68535. * Gets a string describing the action executed by the current optimization
  68536. * @return description string
  68537. */
  68538. getDescription(): string;
  68539. /**
  68540. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68541. * @param scene defines the current scene where to apply this optimization
  68542. * @param optimizer defines the current optimizer
  68543. * @returns true if everything that can be done was applied
  68544. */
  68545. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68546. }
  68547. /**
  68548. * Defines an optimization used to turn lens flares off
  68549. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68550. */
  68551. export class LensFlaresOptimization extends SceneOptimization {
  68552. /**
  68553. * Gets a string describing the action executed by the current optimization
  68554. * @return description string
  68555. */
  68556. getDescription(): string;
  68557. /**
  68558. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68559. * @param scene defines the current scene where to apply this optimization
  68560. * @param optimizer defines the current optimizer
  68561. * @returns true if everything that can be done was applied
  68562. */
  68563. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68564. }
  68565. /**
  68566. * Defines an optimization based on user defined callback.
  68567. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68568. */
  68569. export class CustomOptimization extends SceneOptimization {
  68570. /**
  68571. * Callback called to apply the custom optimization.
  68572. */
  68573. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68574. /**
  68575. * Callback called to get custom description
  68576. */
  68577. onGetDescription: () => string;
  68578. /**
  68579. * Gets a string describing the action executed by the current optimization
  68580. * @returns description string
  68581. */
  68582. getDescription(): string;
  68583. /**
  68584. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68585. * @param scene defines the current scene where to apply this optimization
  68586. * @param optimizer defines the current optimizer
  68587. * @returns true if everything that can be done was applied
  68588. */
  68589. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68590. }
  68591. /**
  68592. * Defines an optimization used to turn particles off
  68593. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68594. */
  68595. export class ParticlesOptimization extends SceneOptimization {
  68596. /**
  68597. * Gets a string describing the action executed by the current optimization
  68598. * @return description string
  68599. */
  68600. getDescription(): string;
  68601. /**
  68602. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68603. * @param scene defines the current scene where to apply this optimization
  68604. * @param optimizer defines the current optimizer
  68605. * @returns true if everything that can be done was applied
  68606. */
  68607. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68608. }
  68609. /**
  68610. * Defines an optimization used to turn render targets off
  68611. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68612. */
  68613. export class RenderTargetsOptimization extends SceneOptimization {
  68614. /**
  68615. * Gets a string describing the action executed by the current optimization
  68616. * @return description string
  68617. */
  68618. getDescription(): string;
  68619. /**
  68620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68621. * @param scene defines the current scene where to apply this optimization
  68622. * @param optimizer defines the current optimizer
  68623. * @returns true if everything that can be done was applied
  68624. */
  68625. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68626. }
  68627. /**
  68628. * Defines an optimization used to merge meshes with compatible materials
  68629. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68630. */
  68631. export class MergeMeshesOptimization extends SceneOptimization {
  68632. private static _UpdateSelectionTree;
  68633. /**
  68634. * Gets or sets a boolean which defines if optimization octree has to be updated
  68635. */
  68636. static get UpdateSelectionTree(): boolean;
  68637. /**
  68638. * Gets or sets a boolean which defines if optimization octree has to be updated
  68639. */
  68640. static set UpdateSelectionTree(value: boolean);
  68641. /**
  68642. * Gets a string describing the action executed by the current optimization
  68643. * @return description string
  68644. */
  68645. getDescription(): string;
  68646. private _canBeMerged;
  68647. /**
  68648. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68649. * @param scene defines the current scene where to apply this optimization
  68650. * @param optimizer defines the current optimizer
  68651. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68652. * @returns true if everything that can be done was applied
  68653. */
  68654. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68655. }
  68656. /**
  68657. * Defines a list of options used by SceneOptimizer
  68658. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68659. */
  68660. export class SceneOptimizerOptions {
  68661. /**
  68662. * Defines the target frame rate to reach (60 by default)
  68663. */
  68664. targetFrameRate: number;
  68665. /**
  68666. * Defines the interval between two checkes (2000ms by default)
  68667. */
  68668. trackerDuration: number;
  68669. /**
  68670. * Gets the list of optimizations to apply
  68671. */
  68672. optimizations: SceneOptimization[];
  68673. /**
  68674. * Creates a new list of options used by SceneOptimizer
  68675. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68676. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68677. */
  68678. constructor(
  68679. /**
  68680. * Defines the target frame rate to reach (60 by default)
  68681. */
  68682. targetFrameRate?: number,
  68683. /**
  68684. * Defines the interval between two checkes (2000ms by default)
  68685. */
  68686. trackerDuration?: number);
  68687. /**
  68688. * Add a new optimization
  68689. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68690. * @returns the current SceneOptimizerOptions
  68691. */
  68692. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68693. /**
  68694. * Add a new custom optimization
  68695. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68696. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68697. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68698. * @returns the current SceneOptimizerOptions
  68699. */
  68700. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68701. /**
  68702. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68703. * @param targetFrameRate defines the target frame rate (60 by default)
  68704. * @returns a SceneOptimizerOptions object
  68705. */
  68706. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68707. /**
  68708. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68709. * @param targetFrameRate defines the target frame rate (60 by default)
  68710. * @returns a SceneOptimizerOptions object
  68711. */
  68712. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68713. /**
  68714. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68715. * @param targetFrameRate defines the target frame rate (60 by default)
  68716. * @returns a SceneOptimizerOptions object
  68717. */
  68718. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68719. }
  68720. /**
  68721. * Class used to run optimizations in order to reach a target frame rate
  68722. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68723. */
  68724. export class SceneOptimizer implements IDisposable {
  68725. private _isRunning;
  68726. private _options;
  68727. private _scene;
  68728. private _currentPriorityLevel;
  68729. private _targetFrameRate;
  68730. private _trackerDuration;
  68731. private _currentFrameRate;
  68732. private _sceneDisposeObserver;
  68733. private _improvementMode;
  68734. /**
  68735. * Defines an observable called when the optimizer reaches the target frame rate
  68736. */
  68737. onSuccessObservable: Observable<SceneOptimizer>;
  68738. /**
  68739. * Defines an observable called when the optimizer enables an optimization
  68740. */
  68741. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68742. /**
  68743. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68744. */
  68745. onFailureObservable: Observable<SceneOptimizer>;
  68746. /**
  68747. * Gets a boolean indicating if the optimizer is in improvement mode
  68748. */
  68749. get isInImprovementMode(): boolean;
  68750. /**
  68751. * Gets the current priority level (0 at start)
  68752. */
  68753. get currentPriorityLevel(): number;
  68754. /**
  68755. * Gets the current frame rate checked by the SceneOptimizer
  68756. */
  68757. get currentFrameRate(): number;
  68758. /**
  68759. * Gets or sets the current target frame rate (60 by default)
  68760. */
  68761. get targetFrameRate(): number;
  68762. /**
  68763. * Gets or sets the current target frame rate (60 by default)
  68764. */
  68765. set targetFrameRate(value: number);
  68766. /**
  68767. * Gets or sets the current interval between two checks (every 2000ms by default)
  68768. */
  68769. get trackerDuration(): number;
  68770. /**
  68771. * Gets or sets the current interval between two checks (every 2000ms by default)
  68772. */
  68773. set trackerDuration(value: number);
  68774. /**
  68775. * Gets the list of active optimizations
  68776. */
  68777. get optimizations(): SceneOptimization[];
  68778. /**
  68779. * Creates a new SceneOptimizer
  68780. * @param scene defines the scene to work on
  68781. * @param options defines the options to use with the SceneOptimizer
  68782. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68783. * @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)
  68784. */
  68785. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68786. /**
  68787. * Stops the current optimizer
  68788. */
  68789. stop(): void;
  68790. /**
  68791. * Reset the optimizer to initial step (current priority level = 0)
  68792. */
  68793. reset(): void;
  68794. /**
  68795. * Start the optimizer. By default it will try to reach a specific framerate
  68796. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68797. */
  68798. start(): void;
  68799. private _checkCurrentState;
  68800. /**
  68801. * Release all resources
  68802. */
  68803. dispose(): void;
  68804. /**
  68805. * Helper function to create a SceneOptimizer with one single line of code
  68806. * @param scene defines the scene to work on
  68807. * @param options defines the options to use with the SceneOptimizer
  68808. * @param onSuccess defines a callback to call on success
  68809. * @param onFailure defines a callback to call on failure
  68810. * @returns the new SceneOptimizer object
  68811. */
  68812. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68813. }
  68814. }
  68815. declare module BABYLON {
  68816. /**
  68817. * Class used to serialize a scene into a string
  68818. */
  68819. export class SceneSerializer {
  68820. /**
  68821. * Clear cache used by a previous serialization
  68822. */
  68823. static ClearCache(): void;
  68824. /**
  68825. * Serialize a scene into a JSON compatible object
  68826. * @param scene defines the scene to serialize
  68827. * @returns a JSON compatible object
  68828. */
  68829. static Serialize(scene: Scene): any;
  68830. /**
  68831. * Serialize a mesh into a JSON compatible object
  68832. * @param toSerialize defines the mesh to serialize
  68833. * @param withParents defines if parents must be serialized as well
  68834. * @param withChildren defines if children must be serialized as well
  68835. * @returns a JSON compatible object
  68836. */
  68837. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68838. }
  68839. }
  68840. declare module BABYLON {
  68841. /**
  68842. * Class used to host texture specific utilities
  68843. */
  68844. export class TextureTools {
  68845. /**
  68846. * Uses the GPU to create a copy texture rescaled at a given size
  68847. * @param texture Texture to copy from
  68848. * @param width defines the desired width
  68849. * @param height defines the desired height
  68850. * @param useBilinearMode defines if bilinear mode has to be used
  68851. * @return the generated texture
  68852. */
  68853. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68854. }
  68855. }
  68856. declare module BABYLON {
  68857. /**
  68858. * This represents the different options available for the video capture.
  68859. */
  68860. export interface VideoRecorderOptions {
  68861. /** Defines the mime type of the video. */
  68862. mimeType: string;
  68863. /** Defines the FPS the video should be recorded at. */
  68864. fps: number;
  68865. /** Defines the chunk size for the recording data. */
  68866. recordChunckSize: number;
  68867. /** The audio tracks to attach to the recording. */
  68868. audioTracks?: MediaStreamTrack[];
  68869. }
  68870. /**
  68871. * This can help with recording videos from BabylonJS.
  68872. * This is based on the available WebRTC functionalities of the browser.
  68873. *
  68874. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68875. */
  68876. export class VideoRecorder {
  68877. private static readonly _defaultOptions;
  68878. /**
  68879. * Returns whether or not the VideoRecorder is available in your browser.
  68880. * @param engine Defines the Babylon Engine.
  68881. * @returns true if supported otherwise false.
  68882. */
  68883. static IsSupported(engine: Engine): boolean;
  68884. private readonly _options;
  68885. private _canvas;
  68886. private _mediaRecorder;
  68887. private _recordedChunks;
  68888. private _fileName;
  68889. private _resolve;
  68890. private _reject;
  68891. /**
  68892. * True when a recording is already in progress.
  68893. */
  68894. get isRecording(): boolean;
  68895. /**
  68896. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68897. * @param engine Defines the BabylonJS Engine you wish to record.
  68898. * @param options Defines options that can be used to customize the capture.
  68899. */
  68900. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68901. /**
  68902. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68903. */
  68904. stopRecording(): void;
  68905. /**
  68906. * Starts recording the canvas for a max duration specified in parameters.
  68907. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68908. * If null no automatic download will start and you can rely on the promise to get the data back.
  68909. * @param maxDuration Defines the maximum recording time in seconds.
  68910. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68911. * @return A promise callback at the end of the recording with the video data in Blob.
  68912. */
  68913. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68914. /**
  68915. * Releases internal resources used during the recording.
  68916. */
  68917. dispose(): void;
  68918. private _handleDataAvailable;
  68919. private _handleError;
  68920. private _handleStop;
  68921. }
  68922. }
  68923. declare module BABYLON {
  68924. /**
  68925. * Class containing a set of static utilities functions for screenshots
  68926. */
  68927. export class ScreenshotTools {
  68928. /**
  68929. * Captures a screenshot of the current rendering
  68930. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68931. * @param engine defines the rendering engine
  68932. * @param camera defines the source camera
  68933. * @param size This parameter can be set to a single number or to an object with the
  68934. * following (optional) properties: precision, width, height. If a single number is passed,
  68935. * it will be used for both width and height. If an object is passed, the screenshot size
  68936. * will be derived from the parameters. The precision property is a multiplier allowing
  68937. * rendering at a higher or lower resolution
  68938. * @param successCallback defines the callback receives a single parameter which contains the
  68939. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68940. * src parameter of an <img> to display it
  68941. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68942. * Check your browser for supported MIME types
  68943. */
  68944. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68945. /**
  68946. * Captures a screenshot of the current rendering
  68947. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68948. * @param engine defines the rendering engine
  68949. * @param camera defines the source camera
  68950. * @param size This parameter can be set to a single number or to an object with the
  68951. * following (optional) properties: precision, width, height. If a single number is passed,
  68952. * it will be used for both width and height. If an object is passed, the screenshot size
  68953. * will be derived from the parameters. The precision property is a multiplier allowing
  68954. * rendering at a higher or lower resolution
  68955. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68956. * Check your browser for supported MIME types
  68957. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68958. * to the src parameter of an <img> to display it
  68959. */
  68960. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68961. /**
  68962. * Generates an image screenshot from the specified camera.
  68963. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68964. * @param engine The engine to use for rendering
  68965. * @param camera The camera to use for rendering
  68966. * @param size This parameter can be set to a single number or to an object with the
  68967. * following (optional) properties: precision, width, height. If a single number is passed,
  68968. * it will be used for both width and height. If an object is passed, the screenshot size
  68969. * will be derived from the parameters. The precision property is a multiplier allowing
  68970. * rendering at a higher or lower resolution
  68971. * @param successCallback The callback receives a single parameter which contains the
  68972. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68973. * src parameter of an <img> to display it
  68974. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68975. * Check your browser for supported MIME types
  68976. * @param samples Texture samples (default: 1)
  68977. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68978. * @param fileName A name for for the downloaded file.
  68979. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68980. */
  68981. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  68982. /**
  68983. * Generates an image screenshot from the specified camera.
  68984. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68985. * @param engine The engine to use for rendering
  68986. * @param camera The camera to use for rendering
  68987. * @param size This parameter can be set to a single number or to an object with the
  68988. * following (optional) properties: precision, width, height. If a single number is passed,
  68989. * it will be used for both width and height. If an object is passed, the screenshot size
  68990. * will be derived from the parameters. The precision property is a multiplier allowing
  68991. * rendering at a higher or lower resolution
  68992. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68993. * Check your browser for supported MIME types
  68994. * @param samples Texture samples (default: 1)
  68995. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68996. * @param fileName A name for for the downloaded file.
  68997. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68998. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68999. * to the src parameter of an <img> to display it
  69000. */
  69001. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69002. /**
  69003. * Gets height and width for screenshot size
  69004. * @private
  69005. */
  69006. private static _getScreenshotSize;
  69007. }
  69008. }
  69009. declare module BABYLON {
  69010. /**
  69011. * Interface for a data buffer
  69012. */
  69013. export interface IDataBuffer {
  69014. /**
  69015. * Reads bytes from the data buffer.
  69016. * @param byteOffset The byte offset to read
  69017. * @param byteLength The byte length to read
  69018. * @returns A promise that resolves when the bytes are read
  69019. */
  69020. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69021. /**
  69022. * The byte length of the buffer.
  69023. */
  69024. readonly byteLength: number;
  69025. }
  69026. /**
  69027. * Utility class for reading from a data buffer
  69028. */
  69029. export class DataReader {
  69030. /**
  69031. * The data buffer associated with this data reader.
  69032. */
  69033. readonly buffer: IDataBuffer;
  69034. /**
  69035. * The current byte offset from the beginning of the data buffer.
  69036. */
  69037. byteOffset: number;
  69038. private _dataView;
  69039. private _dataByteOffset;
  69040. /**
  69041. * Constructor
  69042. * @param buffer The buffer to read
  69043. */
  69044. constructor(buffer: IDataBuffer);
  69045. /**
  69046. * Loads the given byte length.
  69047. * @param byteLength The byte length to load
  69048. * @returns A promise that resolves when the load is complete
  69049. */
  69050. loadAsync(byteLength: number): Promise<void>;
  69051. /**
  69052. * Read a unsigned 32-bit integer from the currently loaded data range.
  69053. * @returns The 32-bit integer read
  69054. */
  69055. readUint32(): number;
  69056. /**
  69057. * Read a byte array from the currently loaded data range.
  69058. * @param byteLength The byte length to read
  69059. * @returns The byte array read
  69060. */
  69061. readUint8Array(byteLength: number): Uint8Array;
  69062. /**
  69063. * Read a string from the currently loaded data range.
  69064. * @param byteLength The byte length to read
  69065. * @returns The string read
  69066. */
  69067. readString(byteLength: number): string;
  69068. /**
  69069. * Skips the given byte length the currently loaded data range.
  69070. * @param byteLength The byte length to skip
  69071. */
  69072. skipBytes(byteLength: number): void;
  69073. }
  69074. }
  69075. declare module BABYLON {
  69076. /**
  69077. * Class for storing data to local storage if available or in-memory storage otherwise
  69078. */
  69079. export class DataStorage {
  69080. private static _Storage;
  69081. private static _GetStorage;
  69082. /**
  69083. * Reads a string from the data storage
  69084. * @param key The key to read
  69085. * @param defaultValue The value if the key doesn't exist
  69086. * @returns The string value
  69087. */
  69088. static ReadString(key: string, defaultValue: string): string;
  69089. /**
  69090. * Writes a string to the data storage
  69091. * @param key The key to write
  69092. * @param value The value to write
  69093. */
  69094. static WriteString(key: string, value: string): void;
  69095. /**
  69096. * Reads a boolean from the data storage
  69097. * @param key The key to read
  69098. * @param defaultValue The value if the key doesn't exist
  69099. * @returns The boolean value
  69100. */
  69101. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69102. /**
  69103. * Writes a boolean to the data storage
  69104. * @param key The key to write
  69105. * @param value The value to write
  69106. */
  69107. static WriteBoolean(key: string, value: boolean): void;
  69108. /**
  69109. * Reads a number from the data storage
  69110. * @param key The key to read
  69111. * @param defaultValue The value if the key doesn't exist
  69112. * @returns The number value
  69113. */
  69114. static ReadNumber(key: string, defaultValue: number): number;
  69115. /**
  69116. * Writes a number to the data storage
  69117. * @param key The key to write
  69118. * @param value The value to write
  69119. */
  69120. static WriteNumber(key: string, value: number): void;
  69121. }
  69122. }
  69123. declare module BABYLON {
  69124. /**
  69125. * Options used for hit testing
  69126. */
  69127. export interface IWebXRHitTestOptions {
  69128. /**
  69129. * Only test when user interacted with the scene. Default - hit test every frame
  69130. */
  69131. testOnPointerDownOnly?: boolean;
  69132. /**
  69133. * The node to use to transform the local results to world coordinates
  69134. */
  69135. worldParentNode?: TransformNode;
  69136. }
  69137. /**
  69138. * Interface defining the babylon result of raycasting/hit-test
  69139. */
  69140. export interface IWebXRHitResult {
  69141. /**
  69142. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69143. */
  69144. transformationMatrix: Matrix;
  69145. /**
  69146. * The native hit test result
  69147. */
  69148. xrHitResult: XRHitResult;
  69149. }
  69150. /**
  69151. * The currently-working hit-test module.
  69152. * Hit test (or Ray-casting) is used to interact with the real world.
  69153. * For further information read here - https://github.com/immersive-web/hit-test
  69154. */
  69155. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69156. /**
  69157. * options to use when constructing this feature
  69158. */
  69159. readonly options: IWebXRHitTestOptions;
  69160. private _direction;
  69161. private _mat;
  69162. private _onSelectEnabled;
  69163. private _origin;
  69164. /**
  69165. * The module's name
  69166. */
  69167. static readonly Name: string;
  69168. /**
  69169. * The (Babylon) version of this module.
  69170. * This is an integer representing the implementation version.
  69171. * This number does not correspond to the WebXR specs version
  69172. */
  69173. static readonly Version: number;
  69174. /**
  69175. * Populated with the last native XR Hit Results
  69176. */
  69177. lastNativeXRHitResults: XRHitResult[];
  69178. /**
  69179. * Triggered when new babylon (transformed) hit test results are available
  69180. */
  69181. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  69182. /**
  69183. * Creates a new instance of the (legacy version) hit test feature
  69184. * @param _xrSessionManager an instance of WebXRSessionManager
  69185. * @param options options to use when constructing this feature
  69186. */
  69187. constructor(_xrSessionManager: WebXRSessionManager,
  69188. /**
  69189. * options to use when constructing this feature
  69190. */
  69191. options?: IWebXRHitTestOptions);
  69192. /**
  69193. * execute a hit test with an XR Ray
  69194. *
  69195. * @param xrSession a native xrSession that will execute this hit test
  69196. * @param xrRay the ray (position and direction) to use for ray-casting
  69197. * @param referenceSpace native XR reference space to use for the hit-test
  69198. * @param filter filter function that will filter the results
  69199. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69200. */
  69201. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69202. /**
  69203. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69204. * @param event the (select) event to use to select with
  69205. * @param referenceSpace the reference space to use for this hit test
  69206. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69207. */
  69208. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69209. /**
  69210. * attach this feature
  69211. * Will usually be called by the features manager
  69212. *
  69213. * @returns true if successful.
  69214. */
  69215. attach(): boolean;
  69216. /**
  69217. * detach this feature.
  69218. * Will usually be called by the features manager
  69219. *
  69220. * @returns true if successful.
  69221. */
  69222. detach(): boolean;
  69223. /**
  69224. * Dispose this feature and all of the resources attached
  69225. */
  69226. dispose(): void;
  69227. protected _onXRFrame(frame: XRFrame): void;
  69228. private _onHitTestResults;
  69229. private _onSelect;
  69230. }
  69231. }
  69232. declare module BABYLON {
  69233. /**
  69234. * Options used in the plane detector module
  69235. */
  69236. export interface IWebXRPlaneDetectorOptions {
  69237. /**
  69238. * The node to use to transform the local results to world coordinates
  69239. */
  69240. worldParentNode?: TransformNode;
  69241. }
  69242. /**
  69243. * A babylon interface for a WebXR plane.
  69244. * A Plane is actually a polygon, built from N points in space
  69245. *
  69246. * Supported in chrome 79, not supported in canary 81 ATM
  69247. */
  69248. export interface IWebXRPlane {
  69249. /**
  69250. * a babylon-assigned ID for this polygon
  69251. */
  69252. id: number;
  69253. /**
  69254. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69255. */
  69256. polygonDefinition: Array<Vector3>;
  69257. /**
  69258. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69259. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69260. */
  69261. transformationMatrix: Matrix;
  69262. /**
  69263. * the native xr-plane object
  69264. */
  69265. xrPlane: XRPlane;
  69266. }
  69267. /**
  69268. * The plane detector is used to detect planes in the real world when in AR
  69269. * For more information see https://github.com/immersive-web/real-world-geometry/
  69270. */
  69271. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69272. private _options;
  69273. private _detectedPlanes;
  69274. private _enabled;
  69275. private _lastFrameDetected;
  69276. /**
  69277. * The module's name
  69278. */
  69279. static readonly Name: string;
  69280. /**
  69281. * The (Babylon) version of this module.
  69282. * This is an integer representing the implementation version.
  69283. * This number does not correspond to the WebXR specs version
  69284. */
  69285. static readonly Version: number;
  69286. /**
  69287. * Observers registered here will be executed when a new plane was added to the session
  69288. */
  69289. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69290. /**
  69291. * Observers registered here will be executed when a plane is no longer detected in the session
  69292. */
  69293. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69294. /**
  69295. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69296. * This can execute N times every frame
  69297. */
  69298. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69299. /**
  69300. * construct a new Plane Detector
  69301. * @param _xrSessionManager an instance of xr Session manager
  69302. * @param _options configuration to use when constructing this feature
  69303. */
  69304. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69305. /**
  69306. * Dispose this feature and all of the resources attached
  69307. */
  69308. dispose(): void;
  69309. protected _onXRFrame(frame: XRFrame): void;
  69310. private _init;
  69311. private _updatePlaneWithXRPlane;
  69312. /**
  69313. * avoiding using Array.find for global support.
  69314. * @param xrPlane the plane to find in the array
  69315. */
  69316. private findIndexInPlaneArray;
  69317. }
  69318. }
  69319. declare module BABYLON {
  69320. /**
  69321. * Configuration options of the anchor system
  69322. */
  69323. export interface IWebXRAnchorSystemOptions {
  69324. /**
  69325. * Should a new anchor be added every time a select event is triggered
  69326. */
  69327. addAnchorOnSelect?: boolean;
  69328. /**
  69329. * should the anchor system use plane detection.
  69330. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69331. */
  69332. usePlaneDetection?: boolean;
  69333. /**
  69334. * a node that will be used to convert local to world coordinates
  69335. */
  69336. worldParentNode?: TransformNode;
  69337. }
  69338. /**
  69339. * A babylon container for an XR Anchor
  69340. */
  69341. export interface IWebXRAnchor {
  69342. /**
  69343. * A babylon-assigned ID for this anchor
  69344. */
  69345. id: number;
  69346. /**
  69347. * Transformation matrix to apply to an object attached to this anchor
  69348. */
  69349. transformationMatrix: Matrix;
  69350. /**
  69351. * The native anchor object
  69352. */
  69353. xrAnchor: XRAnchor;
  69354. }
  69355. /**
  69356. * An implementation of the anchor system of WebXR.
  69357. * Note that the current documented implementation is not available in any browser. Future implementations
  69358. * will use the frame to create an anchor and not the session or a detected plane
  69359. * For further information see https://github.com/immersive-web/anchors/
  69360. */
  69361. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69362. private _options;
  69363. private _enabled;
  69364. private _hitTestModule;
  69365. private _lastFrameDetected;
  69366. private _onSelect;
  69367. private _planeDetector;
  69368. private _trackedAnchors;
  69369. /**
  69370. * The module's name
  69371. */
  69372. static readonly Name: string;
  69373. /**
  69374. * The (Babylon) version of this module.
  69375. * This is an integer representing the implementation version.
  69376. * This number does not correspond to the WebXR specs version
  69377. */
  69378. static readonly Version: number;
  69379. /**
  69380. * Observers registered here will be executed when a new anchor was added to the session
  69381. */
  69382. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69383. /**
  69384. * Observers registered here will be executed when an anchor was removed from the session
  69385. */
  69386. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69387. /**
  69388. * Observers registered here will be executed when an existing anchor updates
  69389. * This can execute N times every frame
  69390. */
  69391. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69392. /**
  69393. * constructs a new anchor system
  69394. * @param _xrSessionManager an instance of WebXRSessionManager
  69395. * @param _options configuration object for this feature
  69396. */
  69397. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69398. /**
  69399. * Add anchor at a specific XR point.
  69400. *
  69401. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69402. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69403. * @returns a promise the fulfills when the anchor was created
  69404. */
  69405. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69406. /**
  69407. * attach this feature
  69408. * Will usually be called by the features manager
  69409. *
  69410. * @returns true if successful.
  69411. */
  69412. attach(): boolean;
  69413. /**
  69414. * detach this feature.
  69415. * Will usually be called by the features manager
  69416. *
  69417. * @returns true if successful.
  69418. */
  69419. detach(): boolean;
  69420. /**
  69421. * Dispose this feature and all of the resources attached
  69422. */
  69423. dispose(): void;
  69424. /**
  69425. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69426. * @param hitTestModule the hit-test module to use.
  69427. */
  69428. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69429. /**
  69430. * set the plane detector to use in order to create anchors from frames
  69431. * @param planeDetector the plane-detector module to use
  69432. * @param enable enable plane-anchors. default is true
  69433. */
  69434. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69435. protected _onXRFrame(frame: XRFrame): void;
  69436. /**
  69437. * avoiding using Array.find for global support.
  69438. * @param xrAnchor the plane to find in the array
  69439. */
  69440. private _findIndexInAnchorArray;
  69441. private _updateAnchorWithXRFrame;
  69442. }
  69443. }
  69444. declare module BABYLON {
  69445. /**
  69446. * Options interface for the background remover plugin
  69447. */
  69448. export interface IWebXRBackgroundRemoverOptions {
  69449. /**
  69450. * Further background meshes to disable when entering AR
  69451. */
  69452. backgroundMeshes?: AbstractMesh[];
  69453. /**
  69454. * flags to configure the removal of the environment helper.
  69455. * If not set, the entire background will be removed. If set, flags should be set as well.
  69456. */
  69457. environmentHelperRemovalFlags?: {
  69458. /**
  69459. * Should the skybox be removed (default false)
  69460. */
  69461. skyBox?: boolean;
  69462. /**
  69463. * Should the ground be removed (default false)
  69464. */
  69465. ground?: boolean;
  69466. };
  69467. /**
  69468. * don't disable the environment helper
  69469. */
  69470. ignoreEnvironmentHelper?: boolean;
  69471. }
  69472. /**
  69473. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69474. */
  69475. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69476. /**
  69477. * read-only options to be used in this module
  69478. */
  69479. readonly options: IWebXRBackgroundRemoverOptions;
  69480. /**
  69481. * The module's name
  69482. */
  69483. static readonly Name: string;
  69484. /**
  69485. * The (Babylon) version of this module.
  69486. * This is an integer representing the implementation version.
  69487. * This number does not correspond to the WebXR specs version
  69488. */
  69489. static readonly Version: number;
  69490. /**
  69491. * registered observers will be triggered when the background state changes
  69492. */
  69493. onBackgroundStateChangedObservable: Observable<boolean>;
  69494. /**
  69495. * constructs a new background remover module
  69496. * @param _xrSessionManager the session manager for this module
  69497. * @param options read-only options to be used in this module
  69498. */
  69499. constructor(_xrSessionManager: WebXRSessionManager,
  69500. /**
  69501. * read-only options to be used in this module
  69502. */
  69503. options?: IWebXRBackgroundRemoverOptions);
  69504. /**
  69505. * attach this feature
  69506. * Will usually be called by the features manager
  69507. *
  69508. * @returns true if successful.
  69509. */
  69510. attach(): boolean;
  69511. /**
  69512. * detach this feature.
  69513. * Will usually be called by the features manager
  69514. *
  69515. * @returns true if successful.
  69516. */
  69517. detach(): boolean;
  69518. /**
  69519. * Dispose this feature and all of the resources attached
  69520. */
  69521. dispose(): void;
  69522. protected _onXRFrame(_xrFrame: XRFrame): void;
  69523. private _setBackgroundState;
  69524. }
  69525. }
  69526. declare module BABYLON {
  69527. /**
  69528. * Options for the controller physics feature
  69529. */
  69530. export class IWebXRControllerPhysicsOptions {
  69531. /**
  69532. * Should the headset get its own impostor
  69533. */
  69534. enableHeadsetImpostor?: boolean;
  69535. /**
  69536. * Optional parameters for the headset impostor
  69537. */
  69538. headsetImpostorParams?: {
  69539. /**
  69540. * The type of impostor to create. Default is sphere
  69541. */
  69542. impostorType: number;
  69543. /**
  69544. * the size of the impostor. Defaults to 10cm
  69545. */
  69546. impostorSize?: number | {
  69547. width: number;
  69548. height: number;
  69549. depth: number;
  69550. };
  69551. /**
  69552. * Friction definitions
  69553. */
  69554. friction?: number;
  69555. /**
  69556. * Restitution
  69557. */
  69558. restitution?: number;
  69559. };
  69560. /**
  69561. * The physics properties of the future impostors
  69562. */
  69563. physicsProperties?: {
  69564. /**
  69565. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69566. * Note that this requires a physics engine that supports mesh impostors!
  69567. */
  69568. useControllerMesh?: boolean;
  69569. /**
  69570. * The type of impostor to create. Default is sphere
  69571. */
  69572. impostorType?: number;
  69573. /**
  69574. * the size of the impostor. Defaults to 10cm
  69575. */
  69576. impostorSize?: number | {
  69577. width: number;
  69578. height: number;
  69579. depth: number;
  69580. };
  69581. /**
  69582. * Friction definitions
  69583. */
  69584. friction?: number;
  69585. /**
  69586. * Restitution
  69587. */
  69588. restitution?: number;
  69589. };
  69590. /**
  69591. * the xr input to use with this pointer selection
  69592. */
  69593. xrInput: WebXRInput;
  69594. }
  69595. /**
  69596. * Add physics impostor to your webxr controllers,
  69597. * including naive calculation of their linear and angular velocity
  69598. */
  69599. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69600. private readonly _options;
  69601. private _attachController;
  69602. private _controllers;
  69603. private _debugMode;
  69604. private _delta;
  69605. private _headsetImpostor?;
  69606. private _headsetMesh?;
  69607. private _lastTimestamp;
  69608. private _tmpQuaternion;
  69609. private _tmpVector;
  69610. /**
  69611. * The module's name
  69612. */
  69613. static readonly Name: string;
  69614. /**
  69615. * The (Babylon) version of this module.
  69616. * This is an integer representing the implementation version.
  69617. * This number does not correspond to the webxr specs version
  69618. */
  69619. static readonly Version: number;
  69620. /**
  69621. * Construct a new Controller Physics Feature
  69622. * @param _xrSessionManager the corresponding xr session manager
  69623. * @param _options options to create this feature with
  69624. */
  69625. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69626. /**
  69627. * @hidden
  69628. * enable debugging - will show console outputs and the impostor mesh
  69629. */
  69630. _enablePhysicsDebug(): void;
  69631. /**
  69632. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69633. * @param xrController the controller to add
  69634. */
  69635. addController(xrController: WebXRInputSource): void;
  69636. /**
  69637. * attach this feature
  69638. * Will usually be called by the features manager
  69639. *
  69640. * @returns true if successful.
  69641. */
  69642. attach(): boolean;
  69643. /**
  69644. * detach this feature.
  69645. * Will usually be called by the features manager
  69646. *
  69647. * @returns true if successful.
  69648. */
  69649. detach(): boolean;
  69650. /**
  69651. * Get the headset impostor, if enabled
  69652. * @returns the impostor
  69653. */
  69654. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69655. /**
  69656. * Get the physics impostor of a specific controller.
  69657. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69658. * @param controller the controller or the controller id of which to get the impostor
  69659. * @returns the impostor or null
  69660. */
  69661. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69662. /**
  69663. * Update the physics properties provided in the constructor
  69664. * @param newProperties the new properties object
  69665. */
  69666. setPhysicsProperties(newProperties: {
  69667. impostorType?: number;
  69668. impostorSize?: number | {
  69669. width: number;
  69670. height: number;
  69671. depth: number;
  69672. };
  69673. friction?: number;
  69674. restitution?: number;
  69675. }): void;
  69676. protected _onXRFrame(_xrFrame: any): void;
  69677. private _detachController;
  69678. }
  69679. }
  69680. declare module BABYLON {
  69681. /**
  69682. * The motion controller class for all microsoft mixed reality controllers
  69683. */
  69684. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69685. protected readonly _mapping: {
  69686. defaultButton: {
  69687. "valueNodeName": string;
  69688. "unpressedNodeName": string;
  69689. "pressedNodeName": string;
  69690. };
  69691. defaultAxis: {
  69692. "valueNodeName": string;
  69693. "minNodeName": string;
  69694. "maxNodeName": string;
  69695. };
  69696. buttons: {
  69697. "xr-standard-trigger": {
  69698. "rootNodeName": string;
  69699. "componentProperty": string;
  69700. "states": string[];
  69701. };
  69702. "xr-standard-squeeze": {
  69703. "rootNodeName": string;
  69704. "componentProperty": string;
  69705. "states": string[];
  69706. };
  69707. "xr-standard-touchpad": {
  69708. "rootNodeName": string;
  69709. "labelAnchorNodeName": string;
  69710. "touchPointNodeName": string;
  69711. };
  69712. "xr-standard-thumbstick": {
  69713. "rootNodeName": string;
  69714. "componentProperty": string;
  69715. "states": string[];
  69716. };
  69717. };
  69718. axes: {
  69719. "xr-standard-touchpad": {
  69720. "x-axis": {
  69721. "rootNodeName": string;
  69722. };
  69723. "y-axis": {
  69724. "rootNodeName": string;
  69725. };
  69726. };
  69727. "xr-standard-thumbstick": {
  69728. "x-axis": {
  69729. "rootNodeName": string;
  69730. };
  69731. "y-axis": {
  69732. "rootNodeName": string;
  69733. };
  69734. };
  69735. };
  69736. };
  69737. /**
  69738. * The base url used to load the left and right controller models
  69739. */
  69740. static MODEL_BASE_URL: string;
  69741. /**
  69742. * The name of the left controller model file
  69743. */
  69744. static MODEL_LEFT_FILENAME: string;
  69745. /**
  69746. * The name of the right controller model file
  69747. */
  69748. static MODEL_RIGHT_FILENAME: string;
  69749. profileId: string;
  69750. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69751. protected _getFilenameAndPath(): {
  69752. filename: string;
  69753. path: string;
  69754. };
  69755. protected _getModelLoadingConstraints(): boolean;
  69756. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69757. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69758. protected _updateModel(): void;
  69759. }
  69760. }
  69761. declare module BABYLON {
  69762. /**
  69763. * The motion controller class for oculus touch (quest, rift).
  69764. * This class supports legacy mapping as well the standard xr mapping
  69765. */
  69766. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69767. private _forceLegacyControllers;
  69768. private _modelRootNode;
  69769. /**
  69770. * The base url used to load the left and right controller models
  69771. */
  69772. static MODEL_BASE_URL: string;
  69773. /**
  69774. * The name of the left controller model file
  69775. */
  69776. static MODEL_LEFT_FILENAME: string;
  69777. /**
  69778. * The name of the right controller model file
  69779. */
  69780. static MODEL_RIGHT_FILENAME: string;
  69781. /**
  69782. * Base Url for the Quest controller model.
  69783. */
  69784. static QUEST_MODEL_BASE_URL: string;
  69785. profileId: string;
  69786. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69787. protected _getFilenameAndPath(): {
  69788. filename: string;
  69789. path: string;
  69790. };
  69791. protected _getModelLoadingConstraints(): boolean;
  69792. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69793. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69794. protected _updateModel(): void;
  69795. /**
  69796. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69797. * between the touch and touch 2.
  69798. */
  69799. private _isQuest;
  69800. }
  69801. }
  69802. declare module BABYLON {
  69803. /**
  69804. * The motion controller class for the standard HTC-Vive controllers
  69805. */
  69806. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69807. private _modelRootNode;
  69808. /**
  69809. * The base url used to load the left and right controller models
  69810. */
  69811. static MODEL_BASE_URL: string;
  69812. /**
  69813. * File name for the controller model.
  69814. */
  69815. static MODEL_FILENAME: string;
  69816. profileId: string;
  69817. /**
  69818. * Create a new Vive motion controller object
  69819. * @param scene the scene to use to create this controller
  69820. * @param gamepadObject the corresponding gamepad object
  69821. * @param handness the handness of the controller
  69822. */
  69823. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69824. protected _getFilenameAndPath(): {
  69825. filename: string;
  69826. path: string;
  69827. };
  69828. protected _getModelLoadingConstraints(): boolean;
  69829. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69830. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69831. protected _updateModel(): void;
  69832. }
  69833. }
  69834. declare module BABYLON {
  69835. /**
  69836. * A cursor which tracks a point on a path
  69837. */
  69838. export class PathCursor {
  69839. private path;
  69840. /**
  69841. * Stores path cursor callbacks for when an onchange event is triggered
  69842. */
  69843. private _onchange;
  69844. /**
  69845. * The value of the path cursor
  69846. */
  69847. value: number;
  69848. /**
  69849. * The animation array of the path cursor
  69850. */
  69851. animations: Animation[];
  69852. /**
  69853. * Initializes the path cursor
  69854. * @param path The path to track
  69855. */
  69856. constructor(path: Path2);
  69857. /**
  69858. * Gets the cursor point on the path
  69859. * @returns A point on the path cursor at the cursor location
  69860. */
  69861. getPoint(): Vector3;
  69862. /**
  69863. * Moves the cursor ahead by the step amount
  69864. * @param step The amount to move the cursor forward
  69865. * @returns This path cursor
  69866. */
  69867. moveAhead(step?: number): PathCursor;
  69868. /**
  69869. * Moves the cursor behind by the step amount
  69870. * @param step The amount to move the cursor back
  69871. * @returns This path cursor
  69872. */
  69873. moveBack(step?: number): PathCursor;
  69874. /**
  69875. * Moves the cursor by the step amount
  69876. * If the step amount is greater than one, an exception is thrown
  69877. * @param step The amount to move the cursor
  69878. * @returns This path cursor
  69879. */
  69880. move(step: number): PathCursor;
  69881. /**
  69882. * Ensures that the value is limited between zero and one
  69883. * @returns This path cursor
  69884. */
  69885. private ensureLimits;
  69886. /**
  69887. * Runs onchange callbacks on change (used by the animation engine)
  69888. * @returns This path cursor
  69889. */
  69890. private raiseOnChange;
  69891. /**
  69892. * Executes a function on change
  69893. * @param f A path cursor onchange callback
  69894. * @returns This path cursor
  69895. */
  69896. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69897. }
  69898. }
  69899. declare module BABYLON {
  69900. /** @hidden */
  69901. export var blurPixelShader: {
  69902. name: string;
  69903. shader: string;
  69904. };
  69905. }
  69906. declare module BABYLON {
  69907. /** @hidden */
  69908. export var pointCloudVertexDeclaration: {
  69909. name: string;
  69910. shader: string;
  69911. };
  69912. }
  69913. // Mixins
  69914. interface Window {
  69915. mozIndexedDB: IDBFactory;
  69916. webkitIndexedDB: IDBFactory;
  69917. msIndexedDB: IDBFactory;
  69918. webkitURL: typeof URL;
  69919. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69920. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69921. WebGLRenderingContext: WebGLRenderingContext;
  69922. MSGesture: MSGesture;
  69923. CANNON: any;
  69924. AudioContext: AudioContext;
  69925. webkitAudioContext: AudioContext;
  69926. PointerEvent: any;
  69927. Math: Math;
  69928. Uint8Array: Uint8ArrayConstructor;
  69929. Float32Array: Float32ArrayConstructor;
  69930. mozURL: typeof URL;
  69931. msURL: typeof URL;
  69932. VRFrameData: any; // WebVR, from specs 1.1
  69933. DracoDecoderModule: any;
  69934. setImmediate(handler: (...args: any[]) => void): number;
  69935. }
  69936. interface HTMLCanvasElement {
  69937. requestPointerLock(): void;
  69938. msRequestPointerLock?(): void;
  69939. mozRequestPointerLock?(): void;
  69940. webkitRequestPointerLock?(): void;
  69941. /** Track wether a record is in progress */
  69942. isRecording: boolean;
  69943. /** Capture Stream method defined by some browsers */
  69944. captureStream(fps?: number): MediaStream;
  69945. }
  69946. interface CanvasRenderingContext2D {
  69947. msImageSmoothingEnabled: boolean;
  69948. }
  69949. interface MouseEvent {
  69950. mozMovementX: number;
  69951. mozMovementY: number;
  69952. webkitMovementX: number;
  69953. webkitMovementY: number;
  69954. msMovementX: number;
  69955. msMovementY: number;
  69956. }
  69957. interface Navigator {
  69958. mozGetVRDevices: (any: any) => any;
  69959. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69960. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69961. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69962. webkitGetGamepads(): Gamepad[];
  69963. msGetGamepads(): Gamepad[];
  69964. webkitGamepads(): Gamepad[];
  69965. }
  69966. interface HTMLVideoElement {
  69967. mozSrcObject: any;
  69968. }
  69969. interface Math {
  69970. fround(x: number): number;
  69971. imul(a: number, b: number): number;
  69972. }
  69973. interface WebGLRenderingContext {
  69974. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69975. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69976. vertexAttribDivisor(index: number, divisor: number): void;
  69977. createVertexArray(): any;
  69978. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69979. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69980. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69981. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69982. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69983. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69984. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69985. // Queries
  69986. createQuery(): WebGLQuery;
  69987. deleteQuery(query: WebGLQuery): void;
  69988. beginQuery(target: number, query: WebGLQuery): void;
  69989. endQuery(target: number): void;
  69990. getQueryParameter(query: WebGLQuery, pname: number): any;
  69991. getQuery(target: number, pname: number): any;
  69992. MAX_SAMPLES: number;
  69993. RGBA8: number;
  69994. READ_FRAMEBUFFER: number;
  69995. DRAW_FRAMEBUFFER: number;
  69996. UNIFORM_BUFFER: number;
  69997. HALF_FLOAT_OES: number;
  69998. RGBA16F: number;
  69999. RGBA32F: number;
  70000. R32F: number;
  70001. RG32F: number;
  70002. RGB32F: number;
  70003. R16F: number;
  70004. RG16F: number;
  70005. RGB16F: number;
  70006. RED: number;
  70007. RG: number;
  70008. R8: number;
  70009. RG8: number;
  70010. UNSIGNED_INT_24_8: number;
  70011. DEPTH24_STENCIL8: number;
  70012. MIN: number;
  70013. MAX: number;
  70014. /* Multiple Render Targets */
  70015. drawBuffers(buffers: number[]): void;
  70016. readBuffer(src: number): void;
  70017. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70018. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70019. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70020. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70021. // Occlusion Query
  70022. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70023. ANY_SAMPLES_PASSED: number;
  70024. QUERY_RESULT_AVAILABLE: number;
  70025. QUERY_RESULT: number;
  70026. }
  70027. interface WebGLProgram {
  70028. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70029. }
  70030. interface EXT_disjoint_timer_query {
  70031. QUERY_COUNTER_BITS_EXT: number;
  70032. TIME_ELAPSED_EXT: number;
  70033. TIMESTAMP_EXT: number;
  70034. GPU_DISJOINT_EXT: number;
  70035. QUERY_RESULT_EXT: number;
  70036. QUERY_RESULT_AVAILABLE_EXT: number;
  70037. queryCounterEXT(query: WebGLQuery, target: number): void;
  70038. createQueryEXT(): WebGLQuery;
  70039. beginQueryEXT(target: number, query: WebGLQuery): void;
  70040. endQueryEXT(target: number): void;
  70041. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70042. deleteQueryEXT(query: WebGLQuery): void;
  70043. }
  70044. interface WebGLUniformLocation {
  70045. _currentState: any;
  70046. }
  70047. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70048. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70049. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70050. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70051. interface WebGLRenderingContext {
  70052. readonly RASTERIZER_DISCARD: number;
  70053. readonly DEPTH_COMPONENT24: number;
  70054. readonly TEXTURE_3D: number;
  70055. readonly TEXTURE_2D_ARRAY: number;
  70056. readonly TEXTURE_COMPARE_FUNC: number;
  70057. readonly TEXTURE_COMPARE_MODE: number;
  70058. readonly COMPARE_REF_TO_TEXTURE: number;
  70059. readonly TEXTURE_WRAP_R: number;
  70060. readonly HALF_FLOAT: number;
  70061. readonly RGB8: number;
  70062. readonly RED_INTEGER: number;
  70063. readonly RG_INTEGER: number;
  70064. readonly RGB_INTEGER: number;
  70065. readonly RGBA_INTEGER: number;
  70066. readonly R8_SNORM: number;
  70067. readonly RG8_SNORM: number;
  70068. readonly RGB8_SNORM: number;
  70069. readonly RGBA8_SNORM: number;
  70070. readonly R8I: number;
  70071. readonly RG8I: number;
  70072. readonly RGB8I: number;
  70073. readonly RGBA8I: number;
  70074. readonly R8UI: number;
  70075. readonly RG8UI: number;
  70076. readonly RGB8UI: number;
  70077. readonly RGBA8UI: number;
  70078. readonly R16I: number;
  70079. readonly RG16I: number;
  70080. readonly RGB16I: number;
  70081. readonly RGBA16I: number;
  70082. readonly R16UI: number;
  70083. readonly RG16UI: number;
  70084. readonly RGB16UI: number;
  70085. readonly RGBA16UI: number;
  70086. readonly R32I: number;
  70087. readonly RG32I: number;
  70088. readonly RGB32I: number;
  70089. readonly RGBA32I: number;
  70090. readonly R32UI: number;
  70091. readonly RG32UI: number;
  70092. readonly RGB32UI: number;
  70093. readonly RGBA32UI: number;
  70094. readonly RGB10_A2UI: number;
  70095. readonly R11F_G11F_B10F: number;
  70096. readonly RGB9_E5: number;
  70097. readonly RGB10_A2: number;
  70098. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70099. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70100. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70101. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70102. readonly DEPTH_COMPONENT32F: number;
  70103. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70104. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70105. 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;
  70106. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70107. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70108. readonly TRANSFORM_FEEDBACK: number;
  70109. readonly INTERLEAVED_ATTRIBS: number;
  70110. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70111. createTransformFeedback(): WebGLTransformFeedback;
  70112. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70113. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70114. beginTransformFeedback(primitiveMode: number): void;
  70115. endTransformFeedback(): void;
  70116. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70117. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70118. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70119. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70120. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70121. }
  70122. interface ImageBitmap {
  70123. readonly width: number;
  70124. readonly height: number;
  70125. close(): void;
  70126. }
  70127. interface WebGLQuery extends WebGLObject {
  70128. }
  70129. declare var WebGLQuery: {
  70130. prototype: WebGLQuery;
  70131. new(): WebGLQuery;
  70132. };
  70133. interface WebGLSampler extends WebGLObject {
  70134. }
  70135. declare var WebGLSampler: {
  70136. prototype: WebGLSampler;
  70137. new(): WebGLSampler;
  70138. };
  70139. interface WebGLSync extends WebGLObject {
  70140. }
  70141. declare var WebGLSync: {
  70142. prototype: WebGLSync;
  70143. new(): WebGLSync;
  70144. };
  70145. interface WebGLTransformFeedback extends WebGLObject {
  70146. }
  70147. declare var WebGLTransformFeedback: {
  70148. prototype: WebGLTransformFeedback;
  70149. new(): WebGLTransformFeedback;
  70150. };
  70151. interface WebGLVertexArrayObject extends WebGLObject {
  70152. }
  70153. declare var WebGLVertexArrayObject: {
  70154. prototype: WebGLVertexArrayObject;
  70155. new(): WebGLVertexArrayObject;
  70156. };
  70157. // Type definitions for WebVR API
  70158. // Project: https://w3c.github.io/webvr/
  70159. // Definitions by: six a <https://github.com/lostfictions>
  70160. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70161. interface VRDisplay extends EventTarget {
  70162. /**
  70163. * Dictionary of capabilities describing the VRDisplay.
  70164. */
  70165. readonly capabilities: VRDisplayCapabilities;
  70166. /**
  70167. * z-depth defining the far plane of the eye view frustum
  70168. * enables mapping of values in the render target depth
  70169. * attachment to scene coordinates. Initially set to 10000.0.
  70170. */
  70171. depthFar: number;
  70172. /**
  70173. * z-depth defining the near plane of the eye view frustum
  70174. * enables mapping of values in the render target depth
  70175. * attachment to scene coordinates. Initially set to 0.01.
  70176. */
  70177. depthNear: number;
  70178. /**
  70179. * An identifier for this distinct VRDisplay. Used as an
  70180. * association point in the Gamepad API.
  70181. */
  70182. readonly displayId: number;
  70183. /**
  70184. * A display name, a user-readable name identifying it.
  70185. */
  70186. readonly displayName: string;
  70187. readonly isConnected: boolean;
  70188. readonly isPresenting: boolean;
  70189. /**
  70190. * If this VRDisplay supports room-scale experiences, the optional
  70191. * stage attribute contains details on the room-scale parameters.
  70192. */
  70193. readonly stageParameters: VRStageParameters | null;
  70194. /**
  70195. * Passing the value returned by `requestAnimationFrame` to
  70196. * `cancelAnimationFrame` will unregister the callback.
  70197. * @param handle Define the hanle of the request to cancel
  70198. */
  70199. cancelAnimationFrame(handle: number): void;
  70200. /**
  70201. * Stops presenting to the VRDisplay.
  70202. * @returns a promise to know when it stopped
  70203. */
  70204. exitPresent(): Promise<void>;
  70205. /**
  70206. * Return the current VREyeParameters for the given eye.
  70207. * @param whichEye Define the eye we want the parameter for
  70208. * @returns the eye parameters
  70209. */
  70210. getEyeParameters(whichEye: string): VREyeParameters;
  70211. /**
  70212. * Populates the passed VRFrameData with the information required to render
  70213. * the current frame.
  70214. * @param frameData Define the data structure to populate
  70215. * @returns true if ok otherwise false
  70216. */
  70217. getFrameData(frameData: VRFrameData): boolean;
  70218. /**
  70219. * Get the layers currently being presented.
  70220. * @returns the list of VR layers
  70221. */
  70222. getLayers(): VRLayer[];
  70223. /**
  70224. * Return a VRPose containing the future predicted pose of the VRDisplay
  70225. * when the current frame will be presented. The value returned will not
  70226. * change until JavaScript has returned control to the browser.
  70227. *
  70228. * The VRPose will contain the position, orientation, velocity,
  70229. * and acceleration of each of these properties.
  70230. * @returns the pose object
  70231. */
  70232. getPose(): VRPose;
  70233. /**
  70234. * Return the current instantaneous pose of the VRDisplay, with no
  70235. * prediction applied.
  70236. * @returns the current instantaneous pose
  70237. */
  70238. getImmediatePose(): VRPose;
  70239. /**
  70240. * The callback passed to `requestAnimationFrame` will be called
  70241. * any time a new frame should be rendered. When the VRDisplay is
  70242. * presenting the callback will be called at the native refresh
  70243. * rate of the HMD. When not presenting this function acts
  70244. * identically to how window.requestAnimationFrame acts. Content should
  70245. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70246. * asynchronously from other displays and at differing refresh rates.
  70247. * @param callback Define the eaction to run next frame
  70248. * @returns the request handle it
  70249. */
  70250. requestAnimationFrame(callback: FrameRequestCallback): number;
  70251. /**
  70252. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70253. * Repeat calls while already presenting will update the VRLayers being displayed.
  70254. * @param layers Define the list of layer to present
  70255. * @returns a promise to know when the request has been fulfilled
  70256. */
  70257. requestPresent(layers: VRLayer[]): Promise<void>;
  70258. /**
  70259. * Reset the pose for this display, treating its current position and
  70260. * orientation as the "origin/zero" values. VRPose.position,
  70261. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70262. * updated when calling resetPose(). This should be called in only
  70263. * sitting-space experiences.
  70264. */
  70265. resetPose(): void;
  70266. /**
  70267. * The VRLayer provided to the VRDisplay will be captured and presented
  70268. * in the HMD. Calling this function has the same effect on the source
  70269. * canvas as any other operation that uses its source image, and canvases
  70270. * created without preserveDrawingBuffer set to true will be cleared.
  70271. * @param pose Define the pose to submit
  70272. */
  70273. submitFrame(pose?: VRPose): void;
  70274. }
  70275. declare var VRDisplay: {
  70276. prototype: VRDisplay;
  70277. new(): VRDisplay;
  70278. };
  70279. interface VRLayer {
  70280. leftBounds?: number[] | Float32Array | null;
  70281. rightBounds?: number[] | Float32Array | null;
  70282. source?: HTMLCanvasElement | null;
  70283. }
  70284. interface VRDisplayCapabilities {
  70285. readonly canPresent: boolean;
  70286. readonly hasExternalDisplay: boolean;
  70287. readonly hasOrientation: boolean;
  70288. readonly hasPosition: boolean;
  70289. readonly maxLayers: number;
  70290. }
  70291. interface VREyeParameters {
  70292. /** @deprecated */
  70293. readonly fieldOfView: VRFieldOfView;
  70294. readonly offset: Float32Array;
  70295. readonly renderHeight: number;
  70296. readonly renderWidth: number;
  70297. }
  70298. interface VRFieldOfView {
  70299. readonly downDegrees: number;
  70300. readonly leftDegrees: number;
  70301. readonly rightDegrees: number;
  70302. readonly upDegrees: number;
  70303. }
  70304. interface VRFrameData {
  70305. readonly leftProjectionMatrix: Float32Array;
  70306. readonly leftViewMatrix: Float32Array;
  70307. readonly pose: VRPose;
  70308. readonly rightProjectionMatrix: Float32Array;
  70309. readonly rightViewMatrix: Float32Array;
  70310. readonly timestamp: number;
  70311. }
  70312. interface VRPose {
  70313. readonly angularAcceleration: Float32Array | null;
  70314. readonly angularVelocity: Float32Array | null;
  70315. readonly linearAcceleration: Float32Array | null;
  70316. readonly linearVelocity: Float32Array | null;
  70317. readonly orientation: Float32Array | null;
  70318. readonly position: Float32Array | null;
  70319. readonly timestamp: number;
  70320. }
  70321. interface VRStageParameters {
  70322. sittingToStandingTransform?: Float32Array;
  70323. sizeX?: number;
  70324. sizeY?: number;
  70325. }
  70326. interface Navigator {
  70327. getVRDisplays(): Promise<VRDisplay[]>;
  70328. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70329. }
  70330. interface Window {
  70331. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70332. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70333. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70334. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70335. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70336. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70337. }
  70338. interface Gamepad {
  70339. readonly displayId: number;
  70340. }
  70341. type XRSessionMode =
  70342. | "inline"
  70343. | "immersive-vr"
  70344. | "immersive-ar";
  70345. type XRReferenceSpaceType =
  70346. | "viewer"
  70347. | "local"
  70348. | "local-floor"
  70349. | "bounded-floor"
  70350. | "unbounded";
  70351. type XREnvironmentBlendMode =
  70352. | "opaque"
  70353. | "additive"
  70354. | "alpha-blend";
  70355. type XRVisibilityState =
  70356. | "visible"
  70357. | "visible-blurred"
  70358. | "hidden";
  70359. type XRHandedness =
  70360. | "none"
  70361. | "left"
  70362. | "right";
  70363. type XRTargetRayMode =
  70364. | "gaze"
  70365. | "tracked-pointer"
  70366. | "screen";
  70367. type XREye =
  70368. | "none"
  70369. | "left"
  70370. | "right";
  70371. interface XRSpace extends EventTarget {
  70372. }
  70373. interface XRRenderState {
  70374. depthNear?: number;
  70375. depthFar?: number;
  70376. inlineVerticalFieldOfView?: number;
  70377. baseLayer?: XRWebGLLayer;
  70378. }
  70379. interface XRInputSource {
  70380. handedness: XRHandedness;
  70381. targetRayMode: XRTargetRayMode;
  70382. targetRaySpace: XRSpace;
  70383. gripSpace: XRSpace | undefined;
  70384. gamepad: Gamepad | undefined;
  70385. profiles: Array<string>;
  70386. }
  70387. interface XRSessionInit {
  70388. optionalFeatures?: XRReferenceSpaceType[];
  70389. requiredFeatures?: XRReferenceSpaceType[];
  70390. }
  70391. interface XRSession extends XRAnchorCreator {
  70392. addEventListener: Function;
  70393. removeEventListener: Function;
  70394. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70395. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70396. requestAnimationFrame: Function;
  70397. end(): Promise<void>;
  70398. renderState: XRRenderState;
  70399. inputSources: Array<XRInputSource>;
  70400. // AR hit test
  70401. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70402. updateWorldTrackingState(options: {
  70403. planeDetectionState?: { enabled: boolean; }
  70404. }): void;
  70405. }
  70406. interface XRReferenceSpace extends XRSpace {
  70407. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70408. onreset: any;
  70409. }
  70410. type XRPlaneSet = Set<XRPlane>;
  70411. type XRAnchorSet = Set<XRAnchor>;
  70412. interface XRFrame {
  70413. session: XRSession;
  70414. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70415. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70416. // Anchors
  70417. trackedAnchors?: XRAnchorSet;
  70418. // Planes
  70419. worldInformation: {
  70420. detectedPlanes?: XRPlaneSet;
  70421. };
  70422. }
  70423. interface XRViewerPose extends XRPose {
  70424. views: Array<XRView>;
  70425. }
  70426. interface XRPose {
  70427. transform: XRRigidTransform;
  70428. emulatedPosition: boolean;
  70429. }
  70430. interface XRWebGLLayerOptions {
  70431. antialias?: boolean;
  70432. depth?: boolean;
  70433. stencil?: boolean;
  70434. alpha?: boolean;
  70435. multiview?: boolean;
  70436. framebufferScaleFactor?: number;
  70437. }
  70438. declare var XRWebGLLayer: {
  70439. prototype: XRWebGLLayer;
  70440. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70441. };
  70442. interface XRWebGLLayer {
  70443. framebuffer: WebGLFramebuffer;
  70444. framebufferWidth: number;
  70445. framebufferHeight: number;
  70446. getViewport: Function;
  70447. }
  70448. declare class XRRigidTransform {
  70449. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70450. position: DOMPointReadOnly;
  70451. orientation: DOMPointReadOnly;
  70452. matrix: Float32Array;
  70453. inverse: XRRigidTransform;
  70454. }
  70455. interface XRView {
  70456. eye: XREye;
  70457. projectionMatrix: Float32Array;
  70458. transform: XRRigidTransform;
  70459. }
  70460. interface XRInputSourceChangeEvent {
  70461. session: XRSession;
  70462. removed: Array<XRInputSource>;
  70463. added: Array<XRInputSource>;
  70464. }
  70465. interface XRInputSourceEvent extends Event {
  70466. readonly frame: XRFrame;
  70467. readonly inputSource: XRInputSource;
  70468. }
  70469. // Experimental(er) features
  70470. declare class XRRay {
  70471. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70472. origin: DOMPointReadOnly;
  70473. direction: DOMPointReadOnly;
  70474. matrix: Float32Array;
  70475. }
  70476. interface XRHitResult {
  70477. hitMatrix: Float32Array;
  70478. }
  70479. interface XRAnchor {
  70480. // remove?
  70481. id?: string;
  70482. anchorSpace: XRSpace;
  70483. lastChangedTime: number;
  70484. detach(): void;
  70485. }
  70486. interface XRPlane extends XRAnchorCreator {
  70487. orientation: "Horizontal" | "Vertical";
  70488. planeSpace: XRSpace;
  70489. polygon: Array<DOMPointReadOnly>;
  70490. lastChangedTime: number;
  70491. }
  70492. interface XRAnchorCreator {
  70493. // AR Anchors
  70494. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  70495. }
  70496. /**
  70497. * @ignore
  70498. */
  70499. declare module BABYLON.GLTF2.Exporter {
  70500. }
  70501. /**
  70502. * @ignore
  70503. */
  70504. declare module BABYLON.GLTF1 {
  70505. }
  70506. declare module BABYLON.GUI {
  70507. /**
  70508. * Class used to specific a value and its associated unit
  70509. */
  70510. export class ValueAndUnit {
  70511. /** defines the unit to store */
  70512. unit: number;
  70513. /** defines a boolean indicating if the value can be negative */
  70514. negativeValueAllowed: boolean;
  70515. private _value;
  70516. private _originalUnit;
  70517. /**
  70518. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70519. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70520. */
  70521. ignoreAdaptiveScaling: boolean;
  70522. /**
  70523. * Creates a new ValueAndUnit
  70524. * @param value defines the value to store
  70525. * @param unit defines the unit to store
  70526. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70527. */
  70528. constructor(value: number,
  70529. /** defines the unit to store */
  70530. unit?: number,
  70531. /** defines a boolean indicating if the value can be negative */
  70532. negativeValueAllowed?: boolean);
  70533. /** Gets a boolean indicating if the value is a percentage */
  70534. get isPercentage(): boolean;
  70535. /** Gets a boolean indicating if the value is store as pixel */
  70536. get isPixel(): boolean;
  70537. /** Gets direct internal value */
  70538. get internalValue(): number;
  70539. /**
  70540. * Gets value as pixel
  70541. * @param host defines the root host
  70542. * @param refValue defines the reference value for percentages
  70543. * @returns the value as pixel
  70544. */
  70545. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70546. /**
  70547. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70548. * @param value defines the value to store
  70549. * @param unit defines the unit to store
  70550. * @returns the current ValueAndUnit
  70551. */
  70552. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70553. /**
  70554. * Gets the value accordingly to its unit
  70555. * @param host defines the root host
  70556. * @returns the value
  70557. */
  70558. getValue(host: AdvancedDynamicTexture): number;
  70559. /**
  70560. * Gets a string representation of the value
  70561. * @param host defines the root host
  70562. * @param decimals defines an optional number of decimals to display
  70563. * @returns a string
  70564. */
  70565. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70566. /**
  70567. * Store a value parsed from a string
  70568. * @param source defines the source string
  70569. * @returns true if the value was successfully parsed
  70570. */
  70571. fromString(source: string | number): boolean;
  70572. private static _Regex;
  70573. private static _UNITMODE_PERCENTAGE;
  70574. private static _UNITMODE_PIXEL;
  70575. /** UNITMODE_PERCENTAGE */
  70576. static get UNITMODE_PERCENTAGE(): number;
  70577. /** UNITMODE_PIXEL */
  70578. static get UNITMODE_PIXEL(): number;
  70579. }
  70580. }
  70581. declare module BABYLON.GUI {
  70582. /**
  70583. * Define a style used by control to automatically setup properties based on a template.
  70584. * Only support font related properties so far
  70585. */
  70586. export class Style implements BABYLON.IDisposable {
  70587. private _fontFamily;
  70588. private _fontStyle;
  70589. private _fontWeight;
  70590. /** @hidden */
  70591. _host: AdvancedDynamicTexture;
  70592. /** @hidden */
  70593. _fontSize: ValueAndUnit;
  70594. /**
  70595. * BABYLON.Observable raised when the style values are changed
  70596. */
  70597. onChangedObservable: BABYLON.Observable<Style>;
  70598. /**
  70599. * Creates a new style object
  70600. * @param host defines the AdvancedDynamicTexture which hosts this style
  70601. */
  70602. constructor(host: AdvancedDynamicTexture);
  70603. /**
  70604. * Gets or sets the font size
  70605. */
  70606. get fontSize(): string | number;
  70607. set fontSize(value: string | number);
  70608. /**
  70609. * Gets or sets the font family
  70610. */
  70611. get fontFamily(): string;
  70612. set fontFamily(value: string);
  70613. /**
  70614. * Gets or sets the font style
  70615. */
  70616. get fontStyle(): string;
  70617. set fontStyle(value: string);
  70618. /** Gets or sets font weight */
  70619. get fontWeight(): string;
  70620. set fontWeight(value: string);
  70621. /** Dispose all associated resources */
  70622. dispose(): void;
  70623. }
  70624. }
  70625. declare module BABYLON.GUI {
  70626. /**
  70627. * Class used to transport BABYLON.Vector2 information for pointer events
  70628. */
  70629. export class Vector2WithInfo extends BABYLON.Vector2 {
  70630. /** defines the current mouse button index */
  70631. buttonIndex: number;
  70632. /**
  70633. * Creates a new Vector2WithInfo
  70634. * @param source defines the vector2 data to transport
  70635. * @param buttonIndex defines the current mouse button index
  70636. */
  70637. constructor(source: BABYLON.Vector2,
  70638. /** defines the current mouse button index */
  70639. buttonIndex?: number);
  70640. }
  70641. /** Class used to provide 2D matrix features */
  70642. export class Matrix2D {
  70643. /** Gets the internal array of 6 floats used to store matrix data */
  70644. m: Float32Array;
  70645. /**
  70646. * Creates a new matrix
  70647. * @param m00 defines value for (0, 0)
  70648. * @param m01 defines value for (0, 1)
  70649. * @param m10 defines value for (1, 0)
  70650. * @param m11 defines value for (1, 1)
  70651. * @param m20 defines value for (2, 0)
  70652. * @param m21 defines value for (2, 1)
  70653. */
  70654. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70655. /**
  70656. * Fills the matrix from direct values
  70657. * @param m00 defines value for (0, 0)
  70658. * @param m01 defines value for (0, 1)
  70659. * @param m10 defines value for (1, 0)
  70660. * @param m11 defines value for (1, 1)
  70661. * @param m20 defines value for (2, 0)
  70662. * @param m21 defines value for (2, 1)
  70663. * @returns the current modified matrix
  70664. */
  70665. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70666. /**
  70667. * Gets matrix determinant
  70668. * @returns the determinant
  70669. */
  70670. determinant(): number;
  70671. /**
  70672. * Inverses the matrix and stores it in a target matrix
  70673. * @param result defines the target matrix
  70674. * @returns the current matrix
  70675. */
  70676. invertToRef(result: Matrix2D): Matrix2D;
  70677. /**
  70678. * Multiplies the current matrix with another one
  70679. * @param other defines the second operand
  70680. * @param result defines the target matrix
  70681. * @returns the current matrix
  70682. */
  70683. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70684. /**
  70685. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70686. * @param x defines the x coordinate to transform
  70687. * @param y defines the x coordinate to transform
  70688. * @param result defines the target vector2
  70689. * @returns the current matrix
  70690. */
  70691. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70692. /**
  70693. * Creates an identity matrix
  70694. * @returns a new matrix
  70695. */
  70696. static Identity(): Matrix2D;
  70697. /**
  70698. * Creates a translation matrix and stores it in a target matrix
  70699. * @param x defines the x coordinate of the translation
  70700. * @param y defines the y coordinate of the translation
  70701. * @param result defines the target matrix
  70702. */
  70703. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70704. /**
  70705. * Creates a scaling matrix and stores it in a target matrix
  70706. * @param x defines the x coordinate of the scaling
  70707. * @param y defines the y coordinate of the scaling
  70708. * @param result defines the target matrix
  70709. */
  70710. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70711. /**
  70712. * Creates a rotation matrix and stores it in a target matrix
  70713. * @param angle defines the rotation angle
  70714. * @param result defines the target matrix
  70715. */
  70716. static RotationToRef(angle: number, result: Matrix2D): void;
  70717. private static _TempPreTranslationMatrix;
  70718. private static _TempPostTranslationMatrix;
  70719. private static _TempRotationMatrix;
  70720. private static _TempScalingMatrix;
  70721. private static _TempCompose0;
  70722. private static _TempCompose1;
  70723. private static _TempCompose2;
  70724. /**
  70725. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70726. * @param tx defines the x coordinate of the translation
  70727. * @param ty defines the y coordinate of the translation
  70728. * @param angle defines the rotation angle
  70729. * @param scaleX defines the x coordinate of the scaling
  70730. * @param scaleY defines the y coordinate of the scaling
  70731. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70732. * @param result defines the target matrix
  70733. */
  70734. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70735. }
  70736. }
  70737. declare module BABYLON.GUI {
  70738. /**
  70739. * Class used to store 2D control sizes
  70740. */
  70741. export class Measure {
  70742. /** defines left coordinate */
  70743. left: number;
  70744. /** defines top coordinate */
  70745. top: number;
  70746. /** defines width dimension */
  70747. width: number;
  70748. /** defines height dimension */
  70749. height: number;
  70750. /**
  70751. * Creates a new measure
  70752. * @param left defines left coordinate
  70753. * @param top defines top coordinate
  70754. * @param width defines width dimension
  70755. * @param height defines height dimension
  70756. */
  70757. constructor(
  70758. /** defines left coordinate */
  70759. left: number,
  70760. /** defines top coordinate */
  70761. top: number,
  70762. /** defines width dimension */
  70763. width: number,
  70764. /** defines height dimension */
  70765. height: number);
  70766. /**
  70767. * Copy from another measure
  70768. * @param other defines the other measure to copy from
  70769. */
  70770. copyFrom(other: Measure): void;
  70771. /**
  70772. * Copy from a group of 4 floats
  70773. * @param left defines left coordinate
  70774. * @param top defines top coordinate
  70775. * @param width defines width dimension
  70776. * @param height defines height dimension
  70777. */
  70778. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70779. /**
  70780. * Computes the axis aligned bounding box measure for two given measures
  70781. * @param a Input measure
  70782. * @param b Input measure
  70783. * @param result the resulting bounding measure
  70784. */
  70785. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70786. /**
  70787. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  70788. * @param transform the matrix to transform the measure before computing the AABB
  70789. * @param result the resulting AABB
  70790. */
  70791. transformToRef(transform: Matrix2D, result: Measure): void;
  70792. /**
  70793. * Check equality between this measure and another one
  70794. * @param other defines the other measures
  70795. * @returns true if both measures are equals
  70796. */
  70797. isEqualsTo(other: Measure): boolean;
  70798. /**
  70799. * Creates an empty measure
  70800. * @returns a new measure
  70801. */
  70802. static Empty(): Measure;
  70803. }
  70804. }
  70805. declare module BABYLON.GUI {
  70806. /**
  70807. * Interface used to define a control that can receive focus
  70808. */
  70809. export interface IFocusableControl {
  70810. /**
  70811. * Function called when the control receives the focus
  70812. */
  70813. onFocus(): void;
  70814. /**
  70815. * Function called when the control loses the focus
  70816. */
  70817. onBlur(): void;
  70818. /**
  70819. * Function called to let the control handle keyboard events
  70820. * @param evt defines the current keyboard event
  70821. */
  70822. processKeyboard(evt: KeyboardEvent): void;
  70823. /**
  70824. * Function called to get the list of controls that should not steal the focus from this control
  70825. * @returns an array of controls
  70826. */
  70827. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70828. }
  70829. /**
  70830. * Class used to create texture to support 2D GUI elements
  70831. * @see http://doc.babylonjs.com/how_to/gui
  70832. */
  70833. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70834. private _isDirty;
  70835. private _renderObserver;
  70836. private _resizeObserver;
  70837. private _preKeyboardObserver;
  70838. private _pointerMoveObserver;
  70839. private _pointerObserver;
  70840. private _canvasPointerOutObserver;
  70841. private _background;
  70842. /** @hidden */
  70843. _rootContainer: Container;
  70844. /** @hidden */
  70845. _lastPickedControl: Control;
  70846. /** @hidden */
  70847. _lastControlOver: {
  70848. [pointerId: number]: Control;
  70849. };
  70850. /** @hidden */
  70851. _lastControlDown: {
  70852. [pointerId: number]: Control;
  70853. };
  70854. /** @hidden */
  70855. _capturingControl: {
  70856. [pointerId: number]: Control;
  70857. };
  70858. /** @hidden */
  70859. _shouldBlockPointer: boolean;
  70860. /** @hidden */
  70861. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70862. /** @hidden */
  70863. _linkedControls: Control[];
  70864. private _isFullscreen;
  70865. private _fullscreenViewport;
  70866. private _idealWidth;
  70867. private _idealHeight;
  70868. private _useSmallestIdeal;
  70869. private _renderAtIdealSize;
  70870. private _focusedControl;
  70871. private _blockNextFocusCheck;
  70872. private _renderScale;
  70873. private _rootElement;
  70874. private _cursorChanged;
  70875. private _defaultMousePointerId;
  70876. /** @hidden */
  70877. _numLayoutCalls: number;
  70878. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70879. get numLayoutCalls(): number;
  70880. /** @hidden */
  70881. _numRenderCalls: number;
  70882. /** Gets the number of render calls made the last time the ADT has been rendered */
  70883. get numRenderCalls(): number;
  70884. /**
  70885. * Define type to string to ensure compatibility across browsers
  70886. * Safari doesn't support DataTransfer constructor
  70887. */
  70888. private _clipboardData;
  70889. /**
  70890. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70891. */
  70892. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70893. /**
  70894. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70895. */
  70896. onControlPickedObservable: BABYLON.Observable<Control>;
  70897. /**
  70898. * BABYLON.Observable event triggered before layout is evaluated
  70899. */
  70900. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70901. /**
  70902. * BABYLON.Observable event triggered after the layout was evaluated
  70903. */
  70904. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70905. /**
  70906. * BABYLON.Observable event triggered before the texture is rendered
  70907. */
  70908. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70909. /**
  70910. * BABYLON.Observable event triggered after the texture was rendered
  70911. */
  70912. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70913. /**
  70914. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70915. */
  70916. premulAlpha: boolean;
  70917. /**
  70918. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70919. * Useful when you want more antialiasing
  70920. */
  70921. get renderScale(): number;
  70922. set renderScale(value: number);
  70923. /** Gets or sets the background color */
  70924. get background(): string;
  70925. set background(value: string);
  70926. /**
  70927. * Gets or sets the ideal width used to design controls.
  70928. * The GUI will then rescale everything accordingly
  70929. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70930. */
  70931. get idealWidth(): number;
  70932. set idealWidth(value: number);
  70933. /**
  70934. * Gets or sets the ideal height used to design controls.
  70935. * The GUI will then rescale everything accordingly
  70936. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70937. */
  70938. get idealHeight(): number;
  70939. set idealHeight(value: number);
  70940. /**
  70941. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70942. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70943. */
  70944. get useSmallestIdeal(): boolean;
  70945. set useSmallestIdeal(value: boolean);
  70946. /**
  70947. * Gets or sets a boolean indicating if adaptive scaling must be used
  70948. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70949. */
  70950. get renderAtIdealSize(): boolean;
  70951. set renderAtIdealSize(value: boolean);
  70952. /**
  70953. * Gets the ratio used when in "ideal mode"
  70954. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70955. * */
  70956. get idealRatio(): number;
  70957. /**
  70958. * Gets the underlying layer used to render the texture when in fullscreen mode
  70959. */
  70960. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70961. /**
  70962. * Gets the root container control
  70963. */
  70964. get rootContainer(): Container;
  70965. /**
  70966. * Returns an array containing the root container.
  70967. * This is mostly used to let the Inspector introspects the ADT
  70968. * @returns an array containing the rootContainer
  70969. */
  70970. getChildren(): Array<Container>;
  70971. /**
  70972. * Will return all controls that are inside this texture
  70973. * @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
  70974. * @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
  70975. * @return all child controls
  70976. */
  70977. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70978. /**
  70979. * Gets or sets the current focused control
  70980. */
  70981. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70982. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70983. /**
  70984. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70985. */
  70986. get isForeground(): boolean;
  70987. set isForeground(value: boolean);
  70988. /**
  70989. * Gets or set information about clipboardData
  70990. */
  70991. get clipboardData(): string;
  70992. set clipboardData(value: string);
  70993. /**
  70994. * Creates a new AdvancedDynamicTexture
  70995. * @param name defines the name of the texture
  70996. * @param width defines the width of the texture
  70997. * @param height defines the height of the texture
  70998. * @param scene defines the hosting scene
  70999. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71000. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71001. */
  71002. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71003. /**
  71004. * Get the current class name of the texture useful for serialization or dynamic coding.
  71005. * @returns "AdvancedDynamicTexture"
  71006. */
  71007. getClassName(): string;
  71008. /**
  71009. * Function used to execute a function on all controls
  71010. * @param func defines the function to execute
  71011. * @param container defines the container where controls belong. If null the root container will be used
  71012. */
  71013. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71014. private _useInvalidateRectOptimization;
  71015. /**
  71016. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71017. */
  71018. get useInvalidateRectOptimization(): boolean;
  71019. set useInvalidateRectOptimization(value: boolean);
  71020. private _invalidatedRectangle;
  71021. /**
  71022. * Invalidates a rectangle area on the gui texture
  71023. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71024. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71025. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71026. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71027. */
  71028. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71029. /**
  71030. * Marks the texture as dirty forcing a complete update
  71031. */
  71032. markAsDirty(): void;
  71033. /**
  71034. * Helper function used to create a new style
  71035. * @returns a new style
  71036. * @see http://doc.babylonjs.com/how_to/gui#styles
  71037. */
  71038. createStyle(): Style;
  71039. /**
  71040. * Adds a new control to the root container
  71041. * @param control defines the control to add
  71042. * @returns the current texture
  71043. */
  71044. addControl(control: Control): AdvancedDynamicTexture;
  71045. /**
  71046. * Removes a control from the root container
  71047. * @param control defines the control to remove
  71048. * @returns the current texture
  71049. */
  71050. removeControl(control: Control): AdvancedDynamicTexture;
  71051. /**
  71052. * Release all resources
  71053. */
  71054. dispose(): void;
  71055. private _onResize;
  71056. /** @hidden */
  71057. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71058. /**
  71059. * Get screen coordinates for a vector3
  71060. * @param position defines the position to project
  71061. * @param worldMatrix defines the world matrix to use
  71062. * @returns the projected position
  71063. */
  71064. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71065. private _checkUpdate;
  71066. private _clearMeasure;
  71067. private _render;
  71068. /** @hidden */
  71069. _changeCursor(cursor: string): void;
  71070. /** @hidden */
  71071. _registerLastControlDown(control: Control, pointerId: number): void;
  71072. private _doPicking;
  71073. /** @hidden */
  71074. _cleanControlAfterRemovalFromList(list: {
  71075. [pointerId: number]: Control;
  71076. }, control: Control): void;
  71077. /** @hidden */
  71078. _cleanControlAfterRemoval(control: Control): void;
  71079. /** Attach to all scene events required to support pointer events */
  71080. attach(): void;
  71081. /** @hidden */
  71082. private onClipboardCopy;
  71083. /** @hidden */
  71084. private onClipboardCut;
  71085. /** @hidden */
  71086. private onClipboardPaste;
  71087. /**
  71088. * Register the clipboard Events onto the canvas
  71089. */
  71090. registerClipboardEvents(): void;
  71091. /**
  71092. * Unregister the clipboard Events from the canvas
  71093. */
  71094. unRegisterClipboardEvents(): void;
  71095. /**
  71096. * Connect the texture to a hosting mesh to enable interactions
  71097. * @param mesh defines the mesh to attach to
  71098. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71099. */
  71100. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71101. /**
  71102. * Move the focus to a specific control
  71103. * @param control defines the control which will receive the focus
  71104. */
  71105. moveFocusToControl(control: IFocusableControl): void;
  71106. private _manageFocus;
  71107. private _attachToOnPointerOut;
  71108. /**
  71109. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71110. * @param mesh defines the mesh which will receive the texture
  71111. * @param width defines the texture width (1024 by default)
  71112. * @param height defines the texture height (1024 by default)
  71113. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71114. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71115. * @returns a new AdvancedDynamicTexture
  71116. */
  71117. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71118. /**
  71119. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71120. * In this mode the texture will rely on a layer for its rendering.
  71121. * This allows it to be treated like any other layer.
  71122. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71123. * LayerMask is set through advancedTexture.layer.layerMask
  71124. * @param name defines name for the texture
  71125. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71126. * @param scene defines the hsoting scene
  71127. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71128. * @returns a new AdvancedDynamicTexture
  71129. */
  71130. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71131. }
  71132. }
  71133. declare module BABYLON.GUI {
  71134. /**
  71135. * Root class used for all 2D controls
  71136. * @see http://doc.babylonjs.com/how_to/gui#controls
  71137. */
  71138. export class Control {
  71139. /** defines the name of the control */
  71140. name?: string | undefined;
  71141. /**
  71142. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71143. */
  71144. static AllowAlphaInheritance: boolean;
  71145. private _alpha;
  71146. private _alphaSet;
  71147. private _zIndex;
  71148. /** @hidden */
  71149. _host: AdvancedDynamicTexture;
  71150. /** Gets or sets the control parent */
  71151. parent: BABYLON.Nullable<Container>;
  71152. /** @hidden */
  71153. _currentMeasure: Measure;
  71154. private _fontFamily;
  71155. private _fontStyle;
  71156. private _fontWeight;
  71157. private _fontSize;
  71158. private _font;
  71159. /** @hidden */
  71160. _width: ValueAndUnit;
  71161. /** @hidden */
  71162. _height: ValueAndUnit;
  71163. /** @hidden */
  71164. protected _fontOffset: {
  71165. ascent: number;
  71166. height: number;
  71167. descent: number;
  71168. };
  71169. private _color;
  71170. private _style;
  71171. private _styleObserver;
  71172. /** @hidden */
  71173. protected _horizontalAlignment: number;
  71174. /** @hidden */
  71175. protected _verticalAlignment: number;
  71176. /** @hidden */
  71177. protected _isDirty: boolean;
  71178. /** @hidden */
  71179. protected _wasDirty: boolean;
  71180. /** @hidden */
  71181. _tempParentMeasure: Measure;
  71182. /** @hidden */
  71183. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71184. /** @hidden */
  71185. protected _cachedParentMeasure: Measure;
  71186. private _paddingLeft;
  71187. private _paddingRight;
  71188. private _paddingTop;
  71189. private _paddingBottom;
  71190. /** @hidden */
  71191. _left: ValueAndUnit;
  71192. /** @hidden */
  71193. _top: ValueAndUnit;
  71194. private _scaleX;
  71195. private _scaleY;
  71196. private _rotation;
  71197. private _transformCenterX;
  71198. private _transformCenterY;
  71199. /** @hidden */
  71200. _transformMatrix: Matrix2D;
  71201. /** @hidden */
  71202. protected _invertTransformMatrix: Matrix2D;
  71203. /** @hidden */
  71204. protected _transformedPosition: BABYLON.Vector2;
  71205. private _isMatrixDirty;
  71206. private _cachedOffsetX;
  71207. private _cachedOffsetY;
  71208. private _isVisible;
  71209. private _isHighlighted;
  71210. /** @hidden */
  71211. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71212. private _fontSet;
  71213. private _dummyVector2;
  71214. private _downCount;
  71215. private _enterCount;
  71216. private _doNotRender;
  71217. private _downPointerIds;
  71218. protected _isEnabled: boolean;
  71219. protected _disabledColor: string;
  71220. protected _disabledColorItem: string;
  71221. /** @hidden */
  71222. protected _rebuildLayout: boolean;
  71223. /** @hidden */
  71224. _customData: any;
  71225. /** @hidden */
  71226. _isClipped: boolean;
  71227. /** @hidden */
  71228. _automaticSize: boolean;
  71229. /** @hidden */
  71230. _tag: any;
  71231. /**
  71232. * 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
  71233. */
  71234. uniqueId: number;
  71235. /**
  71236. * Gets or sets an object used to store user defined information for the node
  71237. */
  71238. metadata: any;
  71239. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71240. isHitTestVisible: boolean;
  71241. /** Gets or sets a boolean indicating if the control can block pointer events */
  71242. isPointerBlocker: boolean;
  71243. /** Gets or sets a boolean indicating if the control can be focusable */
  71244. isFocusInvisible: boolean;
  71245. /**
  71246. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71247. * 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
  71248. */
  71249. clipChildren: boolean;
  71250. /**
  71251. * Gets or sets a boolean indicating that control content must be clipped
  71252. * 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
  71253. */
  71254. clipContent: boolean;
  71255. /**
  71256. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71257. */
  71258. useBitmapCache: boolean;
  71259. private _cacheData;
  71260. private _shadowOffsetX;
  71261. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71262. get shadowOffsetX(): number;
  71263. set shadowOffsetX(value: number);
  71264. private _shadowOffsetY;
  71265. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71266. get shadowOffsetY(): number;
  71267. set shadowOffsetY(value: number);
  71268. private _shadowBlur;
  71269. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71270. get shadowBlur(): number;
  71271. set shadowBlur(value: number);
  71272. private _shadowColor;
  71273. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71274. get shadowColor(): string;
  71275. set shadowColor(value: string);
  71276. /** Gets or sets the cursor to use when the control is hovered */
  71277. hoverCursor: string;
  71278. /** @hidden */
  71279. protected _linkOffsetX: ValueAndUnit;
  71280. /** @hidden */
  71281. protected _linkOffsetY: ValueAndUnit;
  71282. /** Gets the control type name */
  71283. get typeName(): string;
  71284. /**
  71285. * Get the current class name of the control.
  71286. * @returns current class name
  71287. */
  71288. getClassName(): string;
  71289. /**
  71290. * An event triggered when pointer wheel is scrolled
  71291. */
  71292. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71293. /**
  71294. * An event triggered when the pointer move over the control.
  71295. */
  71296. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71297. /**
  71298. * An event triggered when the pointer move out of the control.
  71299. */
  71300. onPointerOutObservable: BABYLON.Observable<Control>;
  71301. /**
  71302. * An event triggered when the pointer taps the control
  71303. */
  71304. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71305. /**
  71306. * An event triggered when pointer up
  71307. */
  71308. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71309. /**
  71310. * An event triggered when a control is clicked on
  71311. */
  71312. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71313. /**
  71314. * An event triggered when pointer enters the control
  71315. */
  71316. onPointerEnterObservable: BABYLON.Observable<Control>;
  71317. /**
  71318. * An event triggered when the control is marked as dirty
  71319. */
  71320. onDirtyObservable: BABYLON.Observable<Control>;
  71321. /**
  71322. * An event triggered before drawing the control
  71323. */
  71324. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71325. /**
  71326. * An event triggered after the control was drawn
  71327. */
  71328. onAfterDrawObservable: BABYLON.Observable<Control>;
  71329. /**
  71330. * Get the hosting AdvancedDynamicTexture
  71331. */
  71332. get host(): AdvancedDynamicTexture;
  71333. /** Gets or set information about font offsets (used to render and align text) */
  71334. get fontOffset(): {
  71335. ascent: number;
  71336. height: number;
  71337. descent: number;
  71338. };
  71339. set fontOffset(offset: {
  71340. ascent: number;
  71341. height: number;
  71342. descent: number;
  71343. });
  71344. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71345. get alpha(): number;
  71346. set alpha(value: number);
  71347. /**
  71348. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71349. */
  71350. get isHighlighted(): boolean;
  71351. set isHighlighted(value: boolean);
  71352. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71353. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71354. */
  71355. get scaleX(): number;
  71356. set scaleX(value: number);
  71357. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71358. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71359. */
  71360. get scaleY(): number;
  71361. set scaleY(value: number);
  71362. /** Gets or sets the rotation angle (0 by default)
  71363. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71364. */
  71365. get rotation(): number;
  71366. set rotation(value: number);
  71367. /** Gets or sets the transformation center on Y axis (0 by default)
  71368. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71369. */
  71370. get transformCenterY(): number;
  71371. set transformCenterY(value: number);
  71372. /** Gets or sets the transformation center on X axis (0 by default)
  71373. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71374. */
  71375. get transformCenterX(): number;
  71376. set transformCenterX(value: number);
  71377. /**
  71378. * Gets or sets the horizontal alignment
  71379. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71380. */
  71381. get horizontalAlignment(): number;
  71382. set horizontalAlignment(value: number);
  71383. /**
  71384. * Gets or sets the vertical alignment
  71385. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71386. */
  71387. get verticalAlignment(): number;
  71388. set verticalAlignment(value: number);
  71389. /**
  71390. * Gets or sets control width
  71391. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71392. */
  71393. get width(): string | number;
  71394. set width(value: string | number);
  71395. /**
  71396. * Gets or sets the control width in pixel
  71397. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71398. */
  71399. get widthInPixels(): number;
  71400. set widthInPixels(value: number);
  71401. /**
  71402. * Gets or sets control height
  71403. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71404. */
  71405. get height(): string | number;
  71406. set height(value: string | number);
  71407. /**
  71408. * Gets or sets control height in pixel
  71409. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71410. */
  71411. get heightInPixels(): number;
  71412. set heightInPixels(value: number);
  71413. /** Gets or set font family */
  71414. get fontFamily(): string;
  71415. set fontFamily(value: string);
  71416. /** Gets or sets font style */
  71417. get fontStyle(): string;
  71418. set fontStyle(value: string);
  71419. /** Gets or sets font weight */
  71420. get fontWeight(): string;
  71421. set fontWeight(value: string);
  71422. /**
  71423. * Gets or sets style
  71424. * @see http://doc.babylonjs.com/how_to/gui#styles
  71425. */
  71426. get style(): BABYLON.Nullable<Style>;
  71427. set style(value: BABYLON.Nullable<Style>);
  71428. /** @hidden */
  71429. get _isFontSizeInPercentage(): boolean;
  71430. /** Gets or sets font size in pixels */
  71431. get fontSizeInPixels(): number;
  71432. set fontSizeInPixels(value: number);
  71433. /** Gets or sets font size */
  71434. get fontSize(): string | number;
  71435. set fontSize(value: string | number);
  71436. /** Gets or sets foreground color */
  71437. get color(): string;
  71438. set color(value: string);
  71439. /** Gets or sets z index which is used to reorder controls on the z axis */
  71440. get zIndex(): number;
  71441. set zIndex(value: number);
  71442. /** Gets or sets a boolean indicating if the control can be rendered */
  71443. get notRenderable(): boolean;
  71444. set notRenderable(value: boolean);
  71445. /** Gets or sets a boolean indicating if the control is visible */
  71446. get isVisible(): boolean;
  71447. set isVisible(value: boolean);
  71448. /** Gets a boolean indicating that the control needs to update its rendering */
  71449. get isDirty(): boolean;
  71450. /**
  71451. * Gets the current linked mesh (or null if none)
  71452. */
  71453. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71454. /**
  71455. * Gets or sets a value indicating the padding to use on the left of the control
  71456. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71457. */
  71458. get paddingLeft(): string | number;
  71459. set paddingLeft(value: string | number);
  71460. /**
  71461. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71462. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71463. */
  71464. get paddingLeftInPixels(): number;
  71465. set paddingLeftInPixels(value: number);
  71466. /**
  71467. * Gets or sets a value indicating the padding to use on the right of the control
  71468. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71469. */
  71470. get paddingRight(): string | number;
  71471. set paddingRight(value: string | number);
  71472. /**
  71473. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71474. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71475. */
  71476. get paddingRightInPixels(): number;
  71477. set paddingRightInPixels(value: number);
  71478. /**
  71479. * Gets or sets a value indicating the padding to use on the top of the control
  71480. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71481. */
  71482. get paddingTop(): string | number;
  71483. set paddingTop(value: string | number);
  71484. /**
  71485. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71486. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71487. */
  71488. get paddingTopInPixels(): number;
  71489. set paddingTopInPixels(value: number);
  71490. /**
  71491. * Gets or sets a value indicating the padding to use on the bottom of the control
  71492. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71493. */
  71494. get paddingBottom(): string | number;
  71495. set paddingBottom(value: string | number);
  71496. /**
  71497. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  71498. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71499. */
  71500. get paddingBottomInPixels(): number;
  71501. set paddingBottomInPixels(value: number);
  71502. /**
  71503. * Gets or sets a value indicating the left coordinate of the control
  71504. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71505. */
  71506. get left(): string | number;
  71507. set left(value: string | number);
  71508. /**
  71509. * Gets or sets a value indicating the left coordinate in pixels of the control
  71510. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71511. */
  71512. get leftInPixels(): number;
  71513. set leftInPixels(value: number);
  71514. /**
  71515. * Gets or sets a value indicating the top coordinate of the control
  71516. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71517. */
  71518. get top(): string | number;
  71519. set top(value: string | number);
  71520. /**
  71521. * Gets or sets a value indicating the top coordinate in pixels of the control
  71522. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71523. */
  71524. get topInPixels(): number;
  71525. set topInPixels(value: number);
  71526. /**
  71527. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71528. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71529. */
  71530. get linkOffsetX(): string | number;
  71531. set linkOffsetX(value: string | number);
  71532. /**
  71533. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71534. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71535. */
  71536. get linkOffsetXInPixels(): number;
  71537. set linkOffsetXInPixels(value: number);
  71538. /**
  71539. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71540. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71541. */
  71542. get linkOffsetY(): string | number;
  71543. set linkOffsetY(value: string | number);
  71544. /**
  71545. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71546. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71547. */
  71548. get linkOffsetYInPixels(): number;
  71549. set linkOffsetYInPixels(value: number);
  71550. /** Gets the center coordinate on X axis */
  71551. get centerX(): number;
  71552. /** Gets the center coordinate on Y axis */
  71553. get centerY(): number;
  71554. /** Gets or sets if control is Enabled*/
  71555. get isEnabled(): boolean;
  71556. set isEnabled(value: boolean);
  71557. /** Gets or sets background color of control if it's disabled*/
  71558. get disabledColor(): string;
  71559. set disabledColor(value: string);
  71560. /** Gets or sets front color of control if it's disabled*/
  71561. get disabledColorItem(): string;
  71562. set disabledColorItem(value: string);
  71563. /**
  71564. * Creates a new control
  71565. * @param name defines the name of the control
  71566. */
  71567. constructor(
  71568. /** defines the name of the control */
  71569. name?: string | undefined);
  71570. /** @hidden */
  71571. protected _getTypeName(): string;
  71572. /**
  71573. * Gets the first ascendant in the hierarchy of the given type
  71574. * @param className defines the required type
  71575. * @returns the ascendant or null if not found
  71576. */
  71577. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71578. /** @hidden */
  71579. _resetFontCache(): void;
  71580. /**
  71581. * Determines if a container is an ascendant of the current control
  71582. * @param container defines the container to look for
  71583. * @returns true if the container is one of the ascendant of the control
  71584. */
  71585. isAscendant(container: Control): boolean;
  71586. /**
  71587. * Gets coordinates in local control space
  71588. * @param globalCoordinates defines the coordinates to transform
  71589. * @returns the new coordinates in local space
  71590. */
  71591. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71592. /**
  71593. * Gets coordinates in local control space
  71594. * @param globalCoordinates defines the coordinates to transform
  71595. * @param result defines the target vector2 where to store the result
  71596. * @returns the current control
  71597. */
  71598. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71599. /**
  71600. * Gets coordinates in parent local control space
  71601. * @param globalCoordinates defines the coordinates to transform
  71602. * @returns the new coordinates in parent local space
  71603. */
  71604. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71605. /**
  71606. * Move the current control to a vector3 position projected onto the screen.
  71607. * @param position defines the target position
  71608. * @param scene defines the hosting scene
  71609. */
  71610. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71611. /**
  71612. * Will store all controls that have this control as ascendant in a given array
  71613. * @param results defines the array where to store the descendants
  71614. * @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
  71615. * @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
  71616. */
  71617. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71618. /**
  71619. * Will return all controls that have this control as ascendant
  71620. * @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
  71621. * @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
  71622. * @return all child controls
  71623. */
  71624. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71625. /**
  71626. * Link current control with a target mesh
  71627. * @param mesh defines the mesh to link with
  71628. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71629. */
  71630. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71631. /** @hidden */
  71632. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71633. /** @hidden */
  71634. _offsetLeft(offset: number): void;
  71635. /** @hidden */
  71636. _offsetTop(offset: number): void;
  71637. /** @hidden */
  71638. _markMatrixAsDirty(): void;
  71639. /** @hidden */
  71640. _flagDescendantsAsMatrixDirty(): void;
  71641. /** @hidden */
  71642. _intersectsRect(rect: Measure): boolean;
  71643. /** @hidden */
  71644. protected invalidateRect(): void;
  71645. /** @hidden */
  71646. _markAsDirty(force?: boolean): void;
  71647. /** @hidden */
  71648. _markAllAsDirty(): void;
  71649. /** @hidden */
  71650. _link(host: AdvancedDynamicTexture): void;
  71651. /** @hidden */
  71652. protected _transform(context?: CanvasRenderingContext2D): void;
  71653. /** @hidden */
  71654. _renderHighlight(context: CanvasRenderingContext2D): void;
  71655. /** @hidden */
  71656. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71657. /** @hidden */
  71658. protected _applyStates(context: CanvasRenderingContext2D): void;
  71659. /** @hidden */
  71660. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71661. /** @hidden */
  71662. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71663. protected _evaluateClippingState(parentMeasure: Measure): void;
  71664. /** @hidden */
  71665. _measure(): void;
  71666. /** @hidden */
  71667. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71668. /** @hidden */
  71669. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71670. /** @hidden */
  71671. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71672. /** @hidden */
  71673. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71674. private static _ClipMeasure;
  71675. private _tmpMeasureA;
  71676. private _clip;
  71677. /** @hidden */
  71678. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71679. /** @hidden */
  71680. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71681. /**
  71682. * Tests if a given coordinates belong to the current control
  71683. * @param x defines x coordinate to test
  71684. * @param y defines y coordinate to test
  71685. * @returns true if the coordinates are inside the control
  71686. */
  71687. contains(x: number, y: number): boolean;
  71688. /** @hidden */
  71689. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71690. /** @hidden */
  71691. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71692. /** @hidden */
  71693. _onPointerEnter(target: Control): boolean;
  71694. /** @hidden */
  71695. _onPointerOut(target: Control, force?: boolean): void;
  71696. /** @hidden */
  71697. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71698. /** @hidden */
  71699. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71700. /** @hidden */
  71701. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71702. /** @hidden */
  71703. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  71704. /** @hidden */
  71705. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71706. private _prepareFont;
  71707. /** Releases associated resources */
  71708. dispose(): void;
  71709. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71710. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71711. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71712. private static _VERTICAL_ALIGNMENT_TOP;
  71713. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71714. private static _VERTICAL_ALIGNMENT_CENTER;
  71715. /** HORIZONTAL_ALIGNMENT_LEFT */
  71716. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71717. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71718. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71719. /** HORIZONTAL_ALIGNMENT_CENTER */
  71720. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71721. /** VERTICAL_ALIGNMENT_TOP */
  71722. static get VERTICAL_ALIGNMENT_TOP(): number;
  71723. /** VERTICAL_ALIGNMENT_BOTTOM */
  71724. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71725. /** VERTICAL_ALIGNMENT_CENTER */
  71726. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71727. private static _FontHeightSizes;
  71728. /** @hidden */
  71729. static _GetFontOffset(font: string): {
  71730. ascent: number;
  71731. height: number;
  71732. descent: number;
  71733. };
  71734. /**
  71735. * Creates a stack panel that can be used to render headers
  71736. * @param control defines the control to associate with the header
  71737. * @param text defines the text of the header
  71738. * @param size defines the size of the header
  71739. * @param options defines options used to configure the header
  71740. * @returns a new StackPanel
  71741. * @ignore
  71742. * @hidden
  71743. */
  71744. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71745. isHorizontal: boolean;
  71746. controlFirst: boolean;
  71747. }) => any;
  71748. /** @hidden */
  71749. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71750. }
  71751. }
  71752. declare module BABYLON.GUI {
  71753. /**
  71754. * Root class for 2D containers
  71755. * @see http://doc.babylonjs.com/how_to/gui#containers
  71756. */
  71757. export class Container extends Control {
  71758. name?: string | undefined;
  71759. /** @hidden */
  71760. _children: Control[];
  71761. /** @hidden */
  71762. protected _measureForChildren: Measure;
  71763. /** @hidden */
  71764. protected _background: string;
  71765. /** @hidden */
  71766. protected _adaptWidthToChildren: boolean;
  71767. /** @hidden */
  71768. protected _adaptHeightToChildren: boolean;
  71769. /**
  71770. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71771. */
  71772. logLayoutCycleErrors: boolean;
  71773. /**
  71774. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71775. */
  71776. maxLayoutCycle: number;
  71777. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71778. get adaptHeightToChildren(): boolean;
  71779. set adaptHeightToChildren(value: boolean);
  71780. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71781. get adaptWidthToChildren(): boolean;
  71782. set adaptWidthToChildren(value: boolean);
  71783. /** Gets or sets background color */
  71784. get background(): string;
  71785. set background(value: string);
  71786. /** Gets the list of children */
  71787. get children(): Control[];
  71788. /**
  71789. * Creates a new Container
  71790. * @param name defines the name of the container
  71791. */
  71792. constructor(name?: string | undefined);
  71793. protected _getTypeName(): string;
  71794. _flagDescendantsAsMatrixDirty(): void;
  71795. /**
  71796. * Gets a child using its name
  71797. * @param name defines the child name to look for
  71798. * @returns the child control if found
  71799. */
  71800. getChildByName(name: string): BABYLON.Nullable<Control>;
  71801. /**
  71802. * Gets a child using its type and its name
  71803. * @param name defines the child name to look for
  71804. * @param type defines the child type to look for
  71805. * @returns the child control if found
  71806. */
  71807. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  71808. /**
  71809. * Search for a specific control in children
  71810. * @param control defines the control to look for
  71811. * @returns true if the control is in child list
  71812. */
  71813. containsControl(control: Control): boolean;
  71814. /**
  71815. * Adds a new control to the current container
  71816. * @param control defines the control to add
  71817. * @returns the current container
  71818. */
  71819. addControl(control: BABYLON.Nullable<Control>): Container;
  71820. /**
  71821. * Removes all controls from the current container
  71822. * @returns the current container
  71823. */
  71824. clearControls(): Container;
  71825. /**
  71826. * Removes a control from the current container
  71827. * @param control defines the control to remove
  71828. * @returns the current container
  71829. */
  71830. removeControl(control: Control): Container;
  71831. /** @hidden */
  71832. _reOrderControl(control: Control): void;
  71833. /** @hidden */
  71834. _offsetLeft(offset: number): void;
  71835. /** @hidden */
  71836. _offsetTop(offset: number): void;
  71837. /** @hidden */
  71838. _markAllAsDirty(): void;
  71839. /** @hidden */
  71840. protected _localDraw(context: CanvasRenderingContext2D): void;
  71841. /** @hidden */
  71842. _link(host: AdvancedDynamicTexture): void;
  71843. /** @hidden */
  71844. protected _beforeLayout(): void;
  71845. /** @hidden */
  71846. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71847. /** @hidden */
  71848. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71849. protected _postMeasure(): void;
  71850. /** @hidden */
  71851. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71852. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71853. /** @hidden */
  71854. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71855. /** @hidden */
  71856. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71857. /** Releases associated resources */
  71858. dispose(): void;
  71859. }
  71860. }
  71861. declare module BABYLON.GUI {
  71862. /** Class used to create rectangle container */
  71863. export class Rectangle extends Container {
  71864. name?: string | undefined;
  71865. private _thickness;
  71866. private _cornerRadius;
  71867. /** Gets or sets border thickness */
  71868. get thickness(): number;
  71869. set thickness(value: number);
  71870. /** Gets or sets the corner radius angle */
  71871. get cornerRadius(): number;
  71872. set cornerRadius(value: number);
  71873. /**
  71874. * Creates a new Rectangle
  71875. * @param name defines the control name
  71876. */
  71877. constructor(name?: string | undefined);
  71878. protected _getTypeName(): string;
  71879. protected _localDraw(context: CanvasRenderingContext2D): void;
  71880. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71881. private _drawRoundedRect;
  71882. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71883. }
  71884. }
  71885. declare module BABYLON.GUI {
  71886. /**
  71887. * Enum that determines the text-wrapping mode to use.
  71888. */
  71889. export enum TextWrapping {
  71890. /**
  71891. * Clip the text when it's larger than Control.width; this is the default mode.
  71892. */
  71893. Clip = 0,
  71894. /**
  71895. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71896. */
  71897. WordWrap = 1,
  71898. /**
  71899. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71900. */
  71901. Ellipsis = 2
  71902. }
  71903. /**
  71904. * Class used to create text block control
  71905. */
  71906. export class TextBlock extends Control {
  71907. /**
  71908. * Defines the name of the control
  71909. */
  71910. name?: string | undefined;
  71911. private _text;
  71912. private _textWrapping;
  71913. private _textHorizontalAlignment;
  71914. private _textVerticalAlignment;
  71915. private _lines;
  71916. private _resizeToFit;
  71917. private _lineSpacing;
  71918. private _outlineWidth;
  71919. private _outlineColor;
  71920. /**
  71921. * An event triggered after the text is changed
  71922. */
  71923. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71924. /**
  71925. * An event triggered after the text was broken up into lines
  71926. */
  71927. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71928. /**
  71929. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71930. */
  71931. get lines(): any[];
  71932. /**
  71933. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71934. */
  71935. get resizeToFit(): boolean;
  71936. /**
  71937. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71938. */
  71939. set resizeToFit(value: boolean);
  71940. /**
  71941. * Gets or sets a boolean indicating if text must be wrapped
  71942. */
  71943. get textWrapping(): TextWrapping | boolean;
  71944. /**
  71945. * Gets or sets a boolean indicating if text must be wrapped
  71946. */
  71947. set textWrapping(value: TextWrapping | boolean);
  71948. /**
  71949. * Gets or sets text to display
  71950. */
  71951. get text(): string;
  71952. /**
  71953. * Gets or sets text to display
  71954. */
  71955. set text(value: string);
  71956. /**
  71957. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71958. */
  71959. get textHorizontalAlignment(): number;
  71960. /**
  71961. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71962. */
  71963. set textHorizontalAlignment(value: number);
  71964. /**
  71965. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71966. */
  71967. get textVerticalAlignment(): number;
  71968. /**
  71969. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71970. */
  71971. set textVerticalAlignment(value: number);
  71972. /**
  71973. * Gets or sets line spacing value
  71974. */
  71975. set lineSpacing(value: string | number);
  71976. /**
  71977. * Gets or sets line spacing value
  71978. */
  71979. get lineSpacing(): string | number;
  71980. /**
  71981. * Gets or sets outlineWidth of the text to display
  71982. */
  71983. get outlineWidth(): number;
  71984. /**
  71985. * Gets or sets outlineWidth of the text to display
  71986. */
  71987. set outlineWidth(value: number);
  71988. /**
  71989. * Gets or sets outlineColor of the text to display
  71990. */
  71991. get outlineColor(): string;
  71992. /**
  71993. * Gets or sets outlineColor of the text to display
  71994. */
  71995. set outlineColor(value: string);
  71996. /**
  71997. * Creates a new TextBlock object
  71998. * @param name defines the name of the control
  71999. * @param text defines the text to display (emptry string by default)
  72000. */
  72001. constructor(
  72002. /**
  72003. * Defines the name of the control
  72004. */
  72005. name?: string | undefined, text?: string);
  72006. protected _getTypeName(): string;
  72007. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72008. private _drawText;
  72009. /** @hidden */
  72010. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72011. protected _applyStates(context: CanvasRenderingContext2D): void;
  72012. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72013. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72014. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72015. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72016. protected _renderLines(context: CanvasRenderingContext2D): void;
  72017. /**
  72018. * Given a width constraint applied on the text block, find the expected height
  72019. * @returns expected height
  72020. */
  72021. computeExpectedHeight(): number;
  72022. dispose(): void;
  72023. }
  72024. }
  72025. declare module BABYLON.GUI {
  72026. /**
  72027. * Class used to create 2D images
  72028. */
  72029. export class Image extends Control {
  72030. name?: string | undefined;
  72031. private _workingCanvas;
  72032. private _domImage;
  72033. private _imageWidth;
  72034. private _imageHeight;
  72035. private _loaded;
  72036. private _stretch;
  72037. private _source;
  72038. private _autoScale;
  72039. private _sourceLeft;
  72040. private _sourceTop;
  72041. private _sourceWidth;
  72042. private _sourceHeight;
  72043. private _svgAttributesComputationCompleted;
  72044. private _isSVG;
  72045. private _cellWidth;
  72046. private _cellHeight;
  72047. private _cellId;
  72048. private _populateNinePatchSlicesFromImage;
  72049. private _sliceLeft;
  72050. private _sliceRight;
  72051. private _sliceTop;
  72052. private _sliceBottom;
  72053. private _detectPointerOnOpaqueOnly;
  72054. /**
  72055. * BABYLON.Observable notified when the content is loaded
  72056. */
  72057. onImageLoadedObservable: BABYLON.Observable<Image>;
  72058. /**
  72059. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72060. */
  72061. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72062. /**
  72063. * Gets a boolean indicating that the content is loaded
  72064. */
  72065. get isLoaded(): boolean;
  72066. /**
  72067. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72068. */
  72069. get populateNinePatchSlicesFromImage(): boolean;
  72070. set populateNinePatchSlicesFromImage(value: boolean);
  72071. /**
  72072. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72073. * Beware using this as this will comsume more memory as the image has to be stored twice
  72074. */
  72075. get detectPointerOnOpaqueOnly(): boolean;
  72076. set detectPointerOnOpaqueOnly(value: boolean);
  72077. /**
  72078. * Gets or sets the left value for slicing (9-patch)
  72079. */
  72080. get sliceLeft(): number;
  72081. set sliceLeft(value: number);
  72082. /**
  72083. * Gets or sets the right value for slicing (9-patch)
  72084. */
  72085. get sliceRight(): number;
  72086. set sliceRight(value: number);
  72087. /**
  72088. * Gets or sets the top value for slicing (9-patch)
  72089. */
  72090. get sliceTop(): number;
  72091. set sliceTop(value: number);
  72092. /**
  72093. * Gets or sets the bottom value for slicing (9-patch)
  72094. */
  72095. get sliceBottom(): number;
  72096. set sliceBottom(value: number);
  72097. /**
  72098. * Gets or sets the left coordinate in the source image
  72099. */
  72100. get sourceLeft(): number;
  72101. set sourceLeft(value: number);
  72102. /**
  72103. * Gets or sets the top coordinate in the source image
  72104. */
  72105. get sourceTop(): number;
  72106. set sourceTop(value: number);
  72107. /**
  72108. * Gets or sets the width to capture in the source image
  72109. */
  72110. get sourceWidth(): number;
  72111. set sourceWidth(value: number);
  72112. /**
  72113. * Gets or sets the height to capture in the source image
  72114. */
  72115. get sourceHeight(): number;
  72116. set sourceHeight(value: number);
  72117. /** Indicates if the format of the image is SVG */
  72118. get isSVG(): boolean;
  72119. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72120. get svgAttributesComputationCompleted(): boolean;
  72121. /**
  72122. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72123. * @see http://doc.babylonjs.com/how_to/gui#image
  72124. */
  72125. get autoScale(): boolean;
  72126. set autoScale(value: boolean);
  72127. /** Gets or sets the streching mode used by the image */
  72128. get stretch(): number;
  72129. set stretch(value: number);
  72130. /** @hidden */
  72131. _rotate90(n: number, preserveProperties?: boolean): Image;
  72132. private _handleRotationForSVGImage;
  72133. private _rotate90SourceProperties;
  72134. /**
  72135. * Gets or sets the internal DOM image used to render the control
  72136. */
  72137. set domImage(value: HTMLImageElement);
  72138. get domImage(): HTMLImageElement;
  72139. private _onImageLoaded;
  72140. private _extractNinePatchSliceDataFromImage;
  72141. /**
  72142. * Gets or sets image source url
  72143. */
  72144. set source(value: BABYLON.Nullable<string>);
  72145. /**
  72146. * Checks for svg document with icon id present
  72147. */
  72148. private _svgCheck;
  72149. /**
  72150. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72151. * given external svg file and icon id
  72152. */
  72153. private _getSVGAttribs;
  72154. /**
  72155. * Gets or sets the cell width to use when animation sheet is enabled
  72156. * @see http://doc.babylonjs.com/how_to/gui#image
  72157. */
  72158. get cellWidth(): number;
  72159. set cellWidth(value: number);
  72160. /**
  72161. * Gets or sets the cell height to use when animation sheet is enabled
  72162. * @see http://doc.babylonjs.com/how_to/gui#image
  72163. */
  72164. get cellHeight(): number;
  72165. set cellHeight(value: number);
  72166. /**
  72167. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72168. * @see http://doc.babylonjs.com/how_to/gui#image
  72169. */
  72170. get cellId(): number;
  72171. set cellId(value: number);
  72172. /**
  72173. * Creates a new Image
  72174. * @param name defines the control name
  72175. * @param url defines the image url
  72176. */
  72177. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72178. /**
  72179. * Tests if a given coordinates belong to the current control
  72180. * @param x defines x coordinate to test
  72181. * @param y defines y coordinate to test
  72182. * @returns true if the coordinates are inside the control
  72183. */
  72184. contains(x: number, y: number): boolean;
  72185. protected _getTypeName(): string;
  72186. /** Force the control to synchronize with its content */
  72187. synchronizeSizeWithContent(): void;
  72188. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72189. private _prepareWorkingCanvasForOpaqueDetection;
  72190. private _drawImage;
  72191. _draw(context: CanvasRenderingContext2D): void;
  72192. private _renderCornerPatch;
  72193. private _renderNinePatch;
  72194. dispose(): void;
  72195. /** STRETCH_NONE */
  72196. static readonly STRETCH_NONE: number;
  72197. /** STRETCH_FILL */
  72198. static readonly STRETCH_FILL: number;
  72199. /** STRETCH_UNIFORM */
  72200. static readonly STRETCH_UNIFORM: number;
  72201. /** STRETCH_EXTEND */
  72202. static readonly STRETCH_EXTEND: number;
  72203. /** NINE_PATCH */
  72204. static readonly STRETCH_NINE_PATCH: number;
  72205. }
  72206. }
  72207. declare module BABYLON.GUI {
  72208. /**
  72209. * Class used to create 2D buttons
  72210. */
  72211. export class Button extends Rectangle {
  72212. name?: string | undefined;
  72213. /**
  72214. * Function called to generate a pointer enter animation
  72215. */
  72216. pointerEnterAnimation: () => void;
  72217. /**
  72218. * Function called to generate a pointer out animation
  72219. */
  72220. pointerOutAnimation: () => void;
  72221. /**
  72222. * Function called to generate a pointer down animation
  72223. */
  72224. pointerDownAnimation: () => void;
  72225. /**
  72226. * Function called to generate a pointer up animation
  72227. */
  72228. pointerUpAnimation: () => void;
  72229. /**
  72230. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72231. */
  72232. delegatePickingToChildren: boolean;
  72233. private _image;
  72234. /**
  72235. * Returns the image part of the button (if any)
  72236. */
  72237. get image(): BABYLON.Nullable<Image>;
  72238. private _textBlock;
  72239. /**
  72240. * Returns the image part of the button (if any)
  72241. */
  72242. get textBlock(): BABYLON.Nullable<TextBlock>;
  72243. /**
  72244. * Creates a new Button
  72245. * @param name defines the name of the button
  72246. */
  72247. constructor(name?: string | undefined);
  72248. protected _getTypeName(): string;
  72249. /** @hidden */
  72250. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72251. /** @hidden */
  72252. _onPointerEnter(target: Control): boolean;
  72253. /** @hidden */
  72254. _onPointerOut(target: Control, force?: boolean): void;
  72255. /** @hidden */
  72256. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72257. /** @hidden */
  72258. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72259. /**
  72260. * Creates a new button made with an image and a text
  72261. * @param name defines the name of the button
  72262. * @param text defines the text of the button
  72263. * @param imageUrl defines the url of the image
  72264. * @returns a new Button
  72265. */
  72266. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72267. /**
  72268. * Creates a new button made with an image
  72269. * @param name defines the name of the button
  72270. * @param imageUrl defines the url of the image
  72271. * @returns a new Button
  72272. */
  72273. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72274. /**
  72275. * Creates a new button made with a text
  72276. * @param name defines the name of the button
  72277. * @param text defines the text of the button
  72278. * @returns a new Button
  72279. */
  72280. static CreateSimpleButton(name: string, text: string): Button;
  72281. /**
  72282. * Creates a new button made with an image and a centered text
  72283. * @param name defines the name of the button
  72284. * @param text defines the text of the button
  72285. * @param imageUrl defines the url of the image
  72286. * @returns a new Button
  72287. */
  72288. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72289. }
  72290. }
  72291. declare module BABYLON.GUI {
  72292. /**
  72293. * Class used to create a 2D stack panel container
  72294. */
  72295. export class StackPanel extends Container {
  72296. name?: string | undefined;
  72297. private _isVertical;
  72298. private _manualWidth;
  72299. private _manualHeight;
  72300. private _doNotTrackManualChanges;
  72301. /**
  72302. * Gets or sets a boolean indicating that layou warnings should be ignored
  72303. */
  72304. ignoreLayoutWarnings: boolean;
  72305. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72306. get isVertical(): boolean;
  72307. set isVertical(value: boolean);
  72308. /**
  72309. * Gets or sets panel width.
  72310. * This value should not be set when in horizontal mode as it will be computed automatically
  72311. */
  72312. set width(value: string | number);
  72313. get width(): string | number;
  72314. /**
  72315. * Gets or sets panel height.
  72316. * This value should not be set when in vertical mode as it will be computed automatically
  72317. */
  72318. set height(value: string | number);
  72319. get height(): string | number;
  72320. /**
  72321. * Creates a new StackPanel
  72322. * @param name defines control name
  72323. */
  72324. constructor(name?: string | undefined);
  72325. protected _getTypeName(): string;
  72326. /** @hidden */
  72327. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72328. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72329. protected _postMeasure(): void;
  72330. }
  72331. }
  72332. declare module BABYLON.GUI {
  72333. /**
  72334. * Class used to represent a 2D checkbox
  72335. */
  72336. export class Checkbox extends Control {
  72337. name?: string | undefined;
  72338. private _isChecked;
  72339. private _background;
  72340. private _checkSizeRatio;
  72341. private _thickness;
  72342. /** Gets or sets border thickness */
  72343. get thickness(): number;
  72344. set thickness(value: number);
  72345. /**
  72346. * BABYLON.Observable raised when isChecked property changes
  72347. */
  72348. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72349. /** Gets or sets a value indicating the ratio between overall size and check size */
  72350. get checkSizeRatio(): number;
  72351. set checkSizeRatio(value: number);
  72352. /** Gets or sets background color */
  72353. get background(): string;
  72354. set background(value: string);
  72355. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72356. get isChecked(): boolean;
  72357. set isChecked(value: boolean);
  72358. /**
  72359. * Creates a new CheckBox
  72360. * @param name defines the control name
  72361. */
  72362. constructor(name?: string | undefined);
  72363. protected _getTypeName(): string;
  72364. /** @hidden */
  72365. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72366. /** @hidden */
  72367. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72368. /**
  72369. * Utility function to easily create a checkbox with a header
  72370. * @param title defines the label to use for the header
  72371. * @param onValueChanged defines the callback to call when value changes
  72372. * @returns a StackPanel containing the checkbox and a textBlock
  72373. */
  72374. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72375. }
  72376. }
  72377. declare module BABYLON.GUI {
  72378. /**
  72379. * Class used to store key control properties
  72380. */
  72381. export class KeyPropertySet {
  72382. /** Width */
  72383. width?: string;
  72384. /** Height */
  72385. height?: string;
  72386. /** Left padding */
  72387. paddingLeft?: string;
  72388. /** Right padding */
  72389. paddingRight?: string;
  72390. /** Top padding */
  72391. paddingTop?: string;
  72392. /** Bottom padding */
  72393. paddingBottom?: string;
  72394. /** Foreground color */
  72395. color?: string;
  72396. /** Background color */
  72397. background?: string;
  72398. }
  72399. /**
  72400. * Class used to create virtual keyboard
  72401. */
  72402. export class VirtualKeyboard extends StackPanel {
  72403. /** BABYLON.Observable raised when a key is pressed */
  72404. onKeyPressObservable: BABYLON.Observable<string>;
  72405. /** Gets or sets default key button width */
  72406. defaultButtonWidth: string;
  72407. /** Gets or sets default key button height */
  72408. defaultButtonHeight: string;
  72409. /** Gets or sets default key button left padding */
  72410. defaultButtonPaddingLeft: string;
  72411. /** Gets or sets default key button right padding */
  72412. defaultButtonPaddingRight: string;
  72413. /** Gets or sets default key button top padding */
  72414. defaultButtonPaddingTop: string;
  72415. /** Gets or sets default key button bottom padding */
  72416. defaultButtonPaddingBottom: string;
  72417. /** Gets or sets default key button foreground color */
  72418. defaultButtonColor: string;
  72419. /** Gets or sets default key button background color */
  72420. defaultButtonBackground: string;
  72421. /** Gets or sets shift button foreground color */
  72422. shiftButtonColor: string;
  72423. /** Gets or sets shift button thickness*/
  72424. selectedShiftThickness: number;
  72425. /** Gets shift key state */
  72426. shiftState: number;
  72427. protected _getTypeName(): string;
  72428. private _createKey;
  72429. /**
  72430. * Adds a new row of keys
  72431. * @param keys defines the list of keys to add
  72432. * @param propertySets defines the associated property sets
  72433. */
  72434. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72435. /**
  72436. * Set the shift key to a specific state
  72437. * @param shiftState defines the new shift state
  72438. */
  72439. applyShiftState(shiftState: number): void;
  72440. private _currentlyConnectedInputText;
  72441. private _connectedInputTexts;
  72442. private _onKeyPressObserver;
  72443. /** Gets the input text control currently attached to the keyboard */
  72444. get connectedInputText(): BABYLON.Nullable<InputText>;
  72445. /**
  72446. * Connects the keyboard with an input text control
  72447. *
  72448. * @param input defines the target control
  72449. */
  72450. connect(input: InputText): void;
  72451. /**
  72452. * Disconnects the keyboard from connected InputText controls
  72453. *
  72454. * @param input optionally defines a target control, otherwise all are disconnected
  72455. */
  72456. disconnect(input?: InputText): void;
  72457. private _removeConnectedInputObservables;
  72458. /**
  72459. * Release all resources
  72460. */
  72461. dispose(): void;
  72462. /**
  72463. * Creates a new keyboard using a default layout
  72464. *
  72465. * @param name defines control name
  72466. * @returns a new VirtualKeyboard
  72467. */
  72468. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72469. }
  72470. }
  72471. declare module BABYLON.GUI {
  72472. /**
  72473. * Class used to create input text control
  72474. */
  72475. export class InputText extends Control implements IFocusableControl {
  72476. name?: string | undefined;
  72477. private _text;
  72478. private _placeholderText;
  72479. private _background;
  72480. private _focusedBackground;
  72481. private _focusedColor;
  72482. private _placeholderColor;
  72483. private _thickness;
  72484. private _margin;
  72485. private _autoStretchWidth;
  72486. private _maxWidth;
  72487. private _isFocused;
  72488. private _blinkTimeout;
  72489. private _blinkIsEven;
  72490. private _cursorOffset;
  72491. private _scrollLeft;
  72492. private _textWidth;
  72493. private _clickedCoordinate;
  72494. private _deadKey;
  72495. private _addKey;
  72496. private _currentKey;
  72497. private _isTextHighlightOn;
  72498. private _textHighlightColor;
  72499. private _highligherOpacity;
  72500. private _highlightedText;
  72501. private _startHighlightIndex;
  72502. private _endHighlightIndex;
  72503. private _cursorIndex;
  72504. private _onFocusSelectAll;
  72505. private _isPointerDown;
  72506. private _onClipboardObserver;
  72507. private _onPointerDblTapObserver;
  72508. /** @hidden */
  72509. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72510. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72511. promptMessage: string;
  72512. /** Force disable prompt on mobile device */
  72513. disableMobilePrompt: boolean;
  72514. /** BABYLON.Observable raised when the text changes */
  72515. onTextChangedObservable: BABYLON.Observable<InputText>;
  72516. /** BABYLON.Observable raised just before an entered character is to be added */
  72517. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72518. /** BABYLON.Observable raised when the control gets the focus */
  72519. onFocusObservable: BABYLON.Observable<InputText>;
  72520. /** BABYLON.Observable raised when the control loses the focus */
  72521. onBlurObservable: BABYLON.Observable<InputText>;
  72522. /**Observable raised when the text is highlighted */
  72523. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72524. /**Observable raised when copy event is triggered */
  72525. onTextCopyObservable: BABYLON.Observable<InputText>;
  72526. /** BABYLON.Observable raised when cut event is triggered */
  72527. onTextCutObservable: BABYLON.Observable<InputText>;
  72528. /** BABYLON.Observable raised when paste event is triggered */
  72529. onTextPasteObservable: BABYLON.Observable<InputText>;
  72530. /** BABYLON.Observable raised when a key event was processed */
  72531. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72532. /** Gets or sets the maximum width allowed by the control */
  72533. get maxWidth(): string | number;
  72534. /** Gets the maximum width allowed by the control in pixels */
  72535. get maxWidthInPixels(): number;
  72536. set maxWidth(value: string | number);
  72537. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72538. get highligherOpacity(): number;
  72539. set highligherOpacity(value: number);
  72540. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72541. get onFocusSelectAll(): boolean;
  72542. set onFocusSelectAll(value: boolean);
  72543. /** Gets or sets the text hightlight color */
  72544. get textHighlightColor(): string;
  72545. set textHighlightColor(value: string);
  72546. /** Gets or sets control margin */
  72547. get margin(): string;
  72548. /** Gets control margin in pixels */
  72549. get marginInPixels(): number;
  72550. set margin(value: string);
  72551. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72552. get autoStretchWidth(): boolean;
  72553. set autoStretchWidth(value: boolean);
  72554. /** Gets or sets border thickness */
  72555. get thickness(): number;
  72556. set thickness(value: number);
  72557. /** Gets or sets the background color when focused */
  72558. get focusedBackground(): string;
  72559. set focusedBackground(value: string);
  72560. /** Gets or sets the background color when focused */
  72561. get focusedColor(): string;
  72562. set focusedColor(value: string);
  72563. /** Gets or sets the background color */
  72564. get background(): string;
  72565. set background(value: string);
  72566. /** Gets or sets the placeholder color */
  72567. get placeholderColor(): string;
  72568. set placeholderColor(value: string);
  72569. /** Gets or sets the text displayed when the control is empty */
  72570. get placeholderText(): string;
  72571. set placeholderText(value: string);
  72572. /** Gets or sets the dead key flag */
  72573. get deadKey(): boolean;
  72574. set deadKey(flag: boolean);
  72575. /** Gets or sets the highlight text */
  72576. get highlightedText(): string;
  72577. set highlightedText(text: string);
  72578. /** Gets or sets if the current key should be added */
  72579. get addKey(): boolean;
  72580. set addKey(flag: boolean);
  72581. /** Gets or sets the value of the current key being entered */
  72582. get currentKey(): string;
  72583. set currentKey(key: string);
  72584. /** Gets or sets the text displayed in the control */
  72585. get text(): string;
  72586. set text(value: string);
  72587. /** Gets or sets control width */
  72588. get width(): string | number;
  72589. set width(value: string | number);
  72590. /**
  72591. * Creates a new InputText
  72592. * @param name defines the control name
  72593. * @param text defines the text of the control
  72594. */
  72595. constructor(name?: string | undefined, text?: string);
  72596. /** @hidden */
  72597. onBlur(): void;
  72598. /** @hidden */
  72599. onFocus(): void;
  72600. protected _getTypeName(): string;
  72601. /**
  72602. * Function called to get the list of controls that should not steal the focus from this control
  72603. * @returns an array of controls
  72604. */
  72605. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72606. /** @hidden */
  72607. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72608. /** @hidden */
  72609. private _updateValueFromCursorIndex;
  72610. /** @hidden */
  72611. private _processDblClick;
  72612. /** @hidden */
  72613. private _selectAllText;
  72614. /**
  72615. * Handles the keyboard event
  72616. * @param evt Defines the KeyboardEvent
  72617. */
  72618. processKeyboard(evt: KeyboardEvent): void;
  72619. /** @hidden */
  72620. private _onCopyText;
  72621. /** @hidden */
  72622. private _onCutText;
  72623. /** @hidden */
  72624. private _onPasteText;
  72625. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72626. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72627. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72628. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72629. protected _beforeRenderText(text: string): string;
  72630. dispose(): void;
  72631. }
  72632. }
  72633. declare module BABYLON.GUI {
  72634. /**
  72635. * Class used to create a 2D grid container
  72636. */
  72637. export class Grid extends Container {
  72638. name?: string | undefined;
  72639. private _rowDefinitions;
  72640. private _columnDefinitions;
  72641. private _cells;
  72642. private _childControls;
  72643. /**
  72644. * Gets the number of columns
  72645. */
  72646. get columnCount(): number;
  72647. /**
  72648. * Gets the number of rows
  72649. */
  72650. get rowCount(): number;
  72651. /** Gets the list of children */
  72652. get children(): Control[];
  72653. /** Gets the list of cells (e.g. the containers) */
  72654. get cells(): {
  72655. [key: string]: Container;
  72656. };
  72657. /**
  72658. * Gets the definition of a specific row
  72659. * @param index defines the index of the row
  72660. * @returns the row definition
  72661. */
  72662. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72663. /**
  72664. * Gets the definition of a specific column
  72665. * @param index defines the index of the column
  72666. * @returns the column definition
  72667. */
  72668. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72669. /**
  72670. * Adds a new row to the grid
  72671. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72672. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72673. * @returns the current grid
  72674. */
  72675. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72676. /**
  72677. * Adds a new column to the grid
  72678. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72679. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72680. * @returns the current grid
  72681. */
  72682. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72683. /**
  72684. * Update a row definition
  72685. * @param index defines the index of the row to update
  72686. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72687. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72688. * @returns the current grid
  72689. */
  72690. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72691. /**
  72692. * Update a column definition
  72693. * @param index defines the index of the column to update
  72694. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72695. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72696. * @returns the current grid
  72697. */
  72698. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72699. /**
  72700. * Gets the list of children stored in a specific cell
  72701. * @param row defines the row to check
  72702. * @param column defines the column to check
  72703. * @returns the list of controls
  72704. */
  72705. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72706. /**
  72707. * Gets a string representing the child cell info (row x column)
  72708. * @param child defines the control to get info from
  72709. * @returns a string containing the child cell info (row x column)
  72710. */
  72711. getChildCellInfo(child: Control): string;
  72712. private _removeCell;
  72713. private _offsetCell;
  72714. /**
  72715. * Remove a column definition at specified index
  72716. * @param index defines the index of the column to remove
  72717. * @returns the current grid
  72718. */
  72719. removeColumnDefinition(index: number): Grid;
  72720. /**
  72721. * Remove a row definition at specified index
  72722. * @param index defines the index of the row to remove
  72723. * @returns the current grid
  72724. */
  72725. removeRowDefinition(index: number): Grid;
  72726. /**
  72727. * Adds a new control to the current grid
  72728. * @param control defines the control to add
  72729. * @param row defines the row where to add the control (0 by default)
  72730. * @param column defines the column where to add the control (0 by default)
  72731. * @returns the current grid
  72732. */
  72733. addControl(control: Control, row?: number, column?: number): Grid;
  72734. /**
  72735. * Removes a control from the current container
  72736. * @param control defines the control to remove
  72737. * @returns the current container
  72738. */
  72739. removeControl(control: Control): Container;
  72740. /**
  72741. * Creates a new Grid
  72742. * @param name defines control name
  72743. */
  72744. constructor(name?: string | undefined);
  72745. protected _getTypeName(): string;
  72746. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72747. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72748. _flagDescendantsAsMatrixDirty(): void;
  72749. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72750. /** Releases associated resources */
  72751. dispose(): void;
  72752. }
  72753. }
  72754. declare module BABYLON.GUI {
  72755. /** Class used to create color pickers */
  72756. export class ColorPicker extends Control {
  72757. name?: string | undefined;
  72758. private static _Epsilon;
  72759. private _colorWheelCanvas;
  72760. private _value;
  72761. private _tmpColor;
  72762. private _pointerStartedOnSquare;
  72763. private _pointerStartedOnWheel;
  72764. private _squareLeft;
  72765. private _squareTop;
  72766. private _squareSize;
  72767. private _h;
  72768. private _s;
  72769. private _v;
  72770. private _lastPointerDownID;
  72771. /**
  72772. * BABYLON.Observable raised when the value changes
  72773. */
  72774. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72775. /** Gets or sets the color of the color picker */
  72776. get value(): BABYLON.Color3;
  72777. set value(value: BABYLON.Color3);
  72778. /**
  72779. * Gets or sets control width
  72780. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72781. */
  72782. get width(): string | number;
  72783. set width(value: string | number);
  72784. /**
  72785. * Gets or sets control height
  72786. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72787. */
  72788. get height(): string | number;
  72789. /** Gets or sets control height */
  72790. set height(value: string | number);
  72791. /** Gets or sets control size */
  72792. get size(): string | number;
  72793. set size(value: string | number);
  72794. /**
  72795. * Creates a new ColorPicker
  72796. * @param name defines the control name
  72797. */
  72798. constructor(name?: string | undefined);
  72799. protected _getTypeName(): string;
  72800. /** @hidden */
  72801. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72802. private _updateSquareProps;
  72803. private _drawGradientSquare;
  72804. private _drawCircle;
  72805. private _createColorWheelCanvas;
  72806. /** @hidden */
  72807. _draw(context: CanvasRenderingContext2D): void;
  72808. private _pointerIsDown;
  72809. private _updateValueFromPointer;
  72810. private _isPointOnSquare;
  72811. private _isPointOnWheel;
  72812. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72813. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72814. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72815. /**
  72816. * This function expands the color picker by creating a color picker dialog with manual
  72817. * color value input and the ability to save colors into an array to be used later in
  72818. * subsequent launches of the dialogue.
  72819. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72820. * @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.
  72821. * @returns picked color as a hex string and the saved colors array as hex strings.
  72822. */
  72823. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72824. pickerWidth?: string;
  72825. pickerHeight?: string;
  72826. headerHeight?: string;
  72827. lastColor?: string;
  72828. swatchLimit?: number;
  72829. numSwatchesPerLine?: number;
  72830. savedColors?: Array<string>;
  72831. }): Promise<{
  72832. savedColors?: string[];
  72833. pickedColor: string;
  72834. }>;
  72835. }
  72836. }
  72837. declare module BABYLON.GUI {
  72838. /** Class used to create 2D ellipse containers */
  72839. export class Ellipse extends Container {
  72840. name?: string | undefined;
  72841. private _thickness;
  72842. /** Gets or sets border thickness */
  72843. get thickness(): number;
  72844. set thickness(value: number);
  72845. /**
  72846. * Creates a new Ellipse
  72847. * @param name defines the control name
  72848. */
  72849. constructor(name?: string | undefined);
  72850. protected _getTypeName(): string;
  72851. protected _localDraw(context: CanvasRenderingContext2D): void;
  72852. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72853. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72854. }
  72855. }
  72856. declare module BABYLON.GUI {
  72857. /**
  72858. * Class used to create a password control
  72859. */
  72860. export class InputPassword extends InputText {
  72861. protected _beforeRenderText(text: string): string;
  72862. }
  72863. }
  72864. declare module BABYLON.GUI {
  72865. /** Class used to render 2D lines */
  72866. export class Line extends Control {
  72867. name?: string | undefined;
  72868. private _lineWidth;
  72869. private _x1;
  72870. private _y1;
  72871. private _x2;
  72872. private _y2;
  72873. private _dash;
  72874. private _connectedControl;
  72875. private _connectedControlDirtyObserver;
  72876. /** Gets or sets the dash pattern */
  72877. get dash(): Array<number>;
  72878. set dash(value: Array<number>);
  72879. /** Gets or sets the control connected with the line end */
  72880. get connectedControl(): Control;
  72881. set connectedControl(value: Control);
  72882. /** Gets or sets start coordinates on X axis */
  72883. get x1(): string | number;
  72884. set x1(value: string | number);
  72885. /** Gets or sets start coordinates on Y axis */
  72886. get y1(): string | number;
  72887. set y1(value: string | number);
  72888. /** Gets or sets end coordinates on X axis */
  72889. get x2(): string | number;
  72890. set x2(value: string | number);
  72891. /** Gets or sets end coordinates on Y axis */
  72892. get y2(): string | number;
  72893. set y2(value: string | number);
  72894. /** Gets or sets line width */
  72895. get lineWidth(): number;
  72896. set lineWidth(value: number);
  72897. /** Gets or sets horizontal alignment */
  72898. set horizontalAlignment(value: number);
  72899. /** Gets or sets vertical alignment */
  72900. set verticalAlignment(value: number);
  72901. private get _effectiveX2();
  72902. private get _effectiveY2();
  72903. /**
  72904. * Creates a new Line
  72905. * @param name defines the control name
  72906. */
  72907. constructor(name?: string | undefined);
  72908. protected _getTypeName(): string;
  72909. _draw(context: CanvasRenderingContext2D): void;
  72910. _measure(): void;
  72911. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72912. /**
  72913. * Move one end of the line given 3D cartesian coordinates.
  72914. * @param position Targeted world position
  72915. * @param scene BABYLON.Scene
  72916. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72917. */
  72918. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72919. /**
  72920. * Move one end of the line to a position in screen absolute space.
  72921. * @param projectedPosition Position in screen absolute space (X, Y)
  72922. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72923. */
  72924. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72925. }
  72926. }
  72927. declare module BABYLON.GUI {
  72928. /**
  72929. * Class used to store a point for a MultiLine object.
  72930. * The point can be pure 2D coordinates, a mesh or a control
  72931. */
  72932. export class MultiLinePoint {
  72933. private _multiLine;
  72934. private _x;
  72935. private _y;
  72936. private _control;
  72937. private _mesh;
  72938. private _controlObserver;
  72939. private _meshObserver;
  72940. /** @hidden */
  72941. _point: BABYLON.Vector2;
  72942. /**
  72943. * Creates a new MultiLinePoint
  72944. * @param multiLine defines the source MultiLine object
  72945. */
  72946. constructor(multiLine: MultiLine);
  72947. /** Gets or sets x coordinate */
  72948. get x(): string | number;
  72949. set x(value: string | number);
  72950. /** Gets or sets y coordinate */
  72951. get y(): string | number;
  72952. set y(value: string | number);
  72953. /** Gets or sets the control associated with this point */
  72954. get control(): BABYLON.Nullable<Control>;
  72955. set control(value: BABYLON.Nullable<Control>);
  72956. /** Gets or sets the mesh associated with this point */
  72957. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72958. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72959. /** Resets links */
  72960. resetLinks(): void;
  72961. /**
  72962. * Gets a translation vector
  72963. * @returns the translation vector
  72964. */
  72965. translate(): BABYLON.Vector2;
  72966. private _translatePoint;
  72967. /** Release associated resources */
  72968. dispose(): void;
  72969. }
  72970. }
  72971. declare module BABYLON.GUI {
  72972. /**
  72973. * Class used to create multi line control
  72974. */
  72975. export class MultiLine extends Control {
  72976. name?: string | undefined;
  72977. private _lineWidth;
  72978. private _dash;
  72979. private _points;
  72980. private _minX;
  72981. private _minY;
  72982. private _maxX;
  72983. private _maxY;
  72984. /**
  72985. * Creates a new MultiLine
  72986. * @param name defines the control name
  72987. */
  72988. constructor(name?: string | undefined);
  72989. /** Gets or sets dash pattern */
  72990. get dash(): Array<number>;
  72991. set dash(value: Array<number>);
  72992. /**
  72993. * Gets point stored at specified index
  72994. * @param index defines the index to look for
  72995. * @returns the requested point if found
  72996. */
  72997. getAt(index: number): MultiLinePoint;
  72998. /** Function called when a point is updated */
  72999. onPointUpdate: () => void;
  73000. /**
  73001. * Adds new points to the point collection
  73002. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73003. * @returns the list of created MultiLinePoint
  73004. */
  73005. add(...items: (AbstractMesh | Control | {
  73006. x: string | number;
  73007. y: string | number;
  73008. })[]): MultiLinePoint[];
  73009. /**
  73010. * Adds a new point to the point collection
  73011. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73012. * @returns the created MultiLinePoint
  73013. */
  73014. push(item?: (AbstractMesh | Control | {
  73015. x: string | number;
  73016. y: string | number;
  73017. })): MultiLinePoint;
  73018. /**
  73019. * Remove a specific value or point from the active point collection
  73020. * @param value defines the value or point to remove
  73021. */
  73022. remove(value: number | MultiLinePoint): void;
  73023. /**
  73024. * Resets this object to initial state (no point)
  73025. */
  73026. reset(): void;
  73027. /**
  73028. * Resets all links
  73029. */
  73030. resetLinks(): void;
  73031. /** Gets or sets line width */
  73032. get lineWidth(): number;
  73033. set lineWidth(value: number);
  73034. set horizontalAlignment(value: number);
  73035. set verticalAlignment(value: number);
  73036. protected _getTypeName(): string;
  73037. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73038. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73039. _measure(): void;
  73040. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73041. dispose(): void;
  73042. }
  73043. }
  73044. declare module BABYLON.GUI {
  73045. /**
  73046. * Class used to create radio button controls
  73047. */
  73048. export class RadioButton extends Control {
  73049. name?: string | undefined;
  73050. private _isChecked;
  73051. private _background;
  73052. private _checkSizeRatio;
  73053. private _thickness;
  73054. /** Gets or sets border thickness */
  73055. get thickness(): number;
  73056. set thickness(value: number);
  73057. /** Gets or sets group name */
  73058. group: string;
  73059. /** BABYLON.Observable raised when isChecked is changed */
  73060. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73061. /** Gets or sets a value indicating the ratio between overall size and check size */
  73062. get checkSizeRatio(): number;
  73063. set checkSizeRatio(value: number);
  73064. /** Gets or sets background color */
  73065. get background(): string;
  73066. set background(value: string);
  73067. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73068. get isChecked(): boolean;
  73069. set isChecked(value: boolean);
  73070. /**
  73071. * Creates a new RadioButton
  73072. * @param name defines the control name
  73073. */
  73074. constructor(name?: string | undefined);
  73075. protected _getTypeName(): string;
  73076. _draw(context: CanvasRenderingContext2D): void;
  73077. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73078. /**
  73079. * Utility function to easily create a radio button with a header
  73080. * @param title defines the label to use for the header
  73081. * @param group defines the group to use for the radio button
  73082. * @param isChecked defines the initial state of the radio button
  73083. * @param onValueChanged defines the callback to call when value changes
  73084. * @returns a StackPanel containing the radio button and a textBlock
  73085. */
  73086. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73087. }
  73088. }
  73089. declare module BABYLON.GUI {
  73090. /**
  73091. * Class used to create slider controls
  73092. */
  73093. export class BaseSlider extends Control {
  73094. name?: string | undefined;
  73095. protected _thumbWidth: ValueAndUnit;
  73096. private _minimum;
  73097. private _maximum;
  73098. private _value;
  73099. private _isVertical;
  73100. protected _barOffset: ValueAndUnit;
  73101. private _isThumbClamped;
  73102. protected _displayThumb: boolean;
  73103. private _step;
  73104. private _lastPointerDownID;
  73105. protected _effectiveBarOffset: number;
  73106. protected _renderLeft: number;
  73107. protected _renderTop: number;
  73108. protected _renderWidth: number;
  73109. protected _renderHeight: number;
  73110. protected _backgroundBoxLength: number;
  73111. protected _backgroundBoxThickness: number;
  73112. protected _effectiveThumbThickness: number;
  73113. /** BABYLON.Observable raised when the sldier value changes */
  73114. onValueChangedObservable: BABYLON.Observable<number>;
  73115. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73116. get displayThumb(): boolean;
  73117. set displayThumb(value: boolean);
  73118. /** Gets or sets a step to apply to values (0 by default) */
  73119. get step(): number;
  73120. set step(value: number);
  73121. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73122. get barOffset(): string | number;
  73123. /** Gets main bar offset in pixels*/
  73124. get barOffsetInPixels(): number;
  73125. set barOffset(value: string | number);
  73126. /** Gets or sets thumb width */
  73127. get thumbWidth(): string | number;
  73128. /** Gets thumb width in pixels */
  73129. get thumbWidthInPixels(): number;
  73130. set thumbWidth(value: string | number);
  73131. /** Gets or sets minimum value */
  73132. get minimum(): number;
  73133. set minimum(value: number);
  73134. /** Gets or sets maximum value */
  73135. get maximum(): number;
  73136. set maximum(value: number);
  73137. /** Gets or sets current value */
  73138. get value(): number;
  73139. set value(value: number);
  73140. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73141. get isVertical(): boolean;
  73142. set isVertical(value: boolean);
  73143. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73144. get isThumbClamped(): boolean;
  73145. set isThumbClamped(value: boolean);
  73146. /**
  73147. * Creates a new BaseSlider
  73148. * @param name defines the control name
  73149. */
  73150. constructor(name?: string | undefined);
  73151. protected _getTypeName(): string;
  73152. protected _getThumbPosition(): number;
  73153. protected _getThumbThickness(type: string): number;
  73154. protected _prepareRenderingData(type: string): void;
  73155. private _pointerIsDown;
  73156. /** @hidden */
  73157. protected _updateValueFromPointer(x: number, y: number): void;
  73158. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73159. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73160. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73161. }
  73162. }
  73163. declare module BABYLON.GUI {
  73164. /**
  73165. * Class used to create slider controls
  73166. */
  73167. export class Slider extends BaseSlider {
  73168. name?: string | undefined;
  73169. private _background;
  73170. private _borderColor;
  73171. private _isThumbCircle;
  73172. protected _displayValueBar: boolean;
  73173. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73174. get displayValueBar(): boolean;
  73175. set displayValueBar(value: boolean);
  73176. /** Gets or sets border color */
  73177. get borderColor(): string;
  73178. set borderColor(value: string);
  73179. /** Gets or sets background color */
  73180. get background(): string;
  73181. set background(value: string);
  73182. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73183. get isThumbCircle(): boolean;
  73184. set isThumbCircle(value: boolean);
  73185. /**
  73186. * Creates a new Slider
  73187. * @param name defines the control name
  73188. */
  73189. constructor(name?: string | undefined);
  73190. protected _getTypeName(): string;
  73191. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73192. }
  73193. }
  73194. declare module BABYLON.GUI {
  73195. /** Class used to create a RadioGroup
  73196. * which contains groups of radio buttons
  73197. */
  73198. export class SelectorGroup {
  73199. /** name of SelectorGroup */
  73200. name: string;
  73201. private _groupPanel;
  73202. private _selectors;
  73203. private _groupHeader;
  73204. /**
  73205. * Creates a new SelectorGroup
  73206. * @param name of group, used as a group heading
  73207. */
  73208. constructor(
  73209. /** name of SelectorGroup */
  73210. name: string);
  73211. /** Gets the groupPanel of the SelectorGroup */
  73212. get groupPanel(): StackPanel;
  73213. /** Gets the selectors array */
  73214. get selectors(): StackPanel[];
  73215. /** Gets and sets the group header */
  73216. get header(): string;
  73217. set header(label: string);
  73218. /** @hidden */
  73219. private _addGroupHeader;
  73220. /** @hidden*/
  73221. _getSelector(selectorNb: number): StackPanel | undefined;
  73222. /** Removes the selector at the given position
  73223. * @param selectorNb the position of the selector within the group
  73224. */
  73225. removeSelector(selectorNb: number): void;
  73226. }
  73227. /** Class used to create a CheckboxGroup
  73228. * which contains groups of checkbox buttons
  73229. */
  73230. export class CheckboxGroup extends SelectorGroup {
  73231. /** Adds a checkbox as a control
  73232. * @param text is the label for the selector
  73233. * @param func is the function called when the Selector is checked
  73234. * @param checked is true when Selector is checked
  73235. */
  73236. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73237. /** @hidden */
  73238. _setSelectorLabel(selectorNb: number, label: string): void;
  73239. /** @hidden */
  73240. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73241. /** @hidden */
  73242. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73243. /** @hidden */
  73244. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73245. }
  73246. /** Class used to create a RadioGroup
  73247. * which contains groups of radio buttons
  73248. */
  73249. export class RadioGroup extends SelectorGroup {
  73250. private _selectNb;
  73251. /** Adds a radio button as a control
  73252. * @param label is the label for the selector
  73253. * @param func is the function called when the Selector is checked
  73254. * @param checked is true when Selector is checked
  73255. */
  73256. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73257. /** @hidden */
  73258. _setSelectorLabel(selectorNb: number, label: string): void;
  73259. /** @hidden */
  73260. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73261. /** @hidden */
  73262. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73263. /** @hidden */
  73264. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73265. }
  73266. /** Class used to create a SliderGroup
  73267. * which contains groups of slider buttons
  73268. */
  73269. export class SliderGroup extends SelectorGroup {
  73270. /**
  73271. * Adds a slider to the SelectorGroup
  73272. * @param label is the label for the SliderBar
  73273. * @param func is the function called when the Slider moves
  73274. * @param unit is a string describing the units used, eg degrees or metres
  73275. * @param min is the minimum value for the Slider
  73276. * @param max is the maximum value for the Slider
  73277. * @param value is the start value for the Slider between min and max
  73278. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73279. */
  73280. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73281. /** @hidden */
  73282. _setSelectorLabel(selectorNb: number, label: string): void;
  73283. /** @hidden */
  73284. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73285. /** @hidden */
  73286. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73287. /** @hidden */
  73288. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73289. }
  73290. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73291. * @see http://doc.babylonjs.com/how_to/selector
  73292. */
  73293. export class SelectionPanel extends Rectangle {
  73294. /** name of SelectionPanel */
  73295. name: string;
  73296. /** an array of SelectionGroups */
  73297. groups: SelectorGroup[];
  73298. private _panel;
  73299. private _buttonColor;
  73300. private _buttonBackground;
  73301. private _headerColor;
  73302. private _barColor;
  73303. private _barHeight;
  73304. private _spacerHeight;
  73305. private _labelColor;
  73306. private _groups;
  73307. private _bars;
  73308. /**
  73309. * Creates a new SelectionPanel
  73310. * @param name of SelectionPanel
  73311. * @param groups is an array of SelectionGroups
  73312. */
  73313. constructor(
  73314. /** name of SelectionPanel */
  73315. name: string,
  73316. /** an array of SelectionGroups */
  73317. groups?: SelectorGroup[]);
  73318. protected _getTypeName(): string;
  73319. /** Gets or sets the headerColor */
  73320. get headerColor(): string;
  73321. set headerColor(color: string);
  73322. private _setHeaderColor;
  73323. /** Gets or sets the button color */
  73324. get buttonColor(): string;
  73325. set buttonColor(color: string);
  73326. private _setbuttonColor;
  73327. /** Gets or sets the label color */
  73328. get labelColor(): string;
  73329. set labelColor(color: string);
  73330. private _setLabelColor;
  73331. /** Gets or sets the button background */
  73332. get buttonBackground(): string;
  73333. set buttonBackground(color: string);
  73334. private _setButtonBackground;
  73335. /** Gets or sets the color of separator bar */
  73336. get barColor(): string;
  73337. set barColor(color: string);
  73338. private _setBarColor;
  73339. /** Gets or sets the height of separator bar */
  73340. get barHeight(): string;
  73341. set barHeight(value: string);
  73342. private _setBarHeight;
  73343. /** Gets or sets the height of spacers*/
  73344. get spacerHeight(): string;
  73345. set spacerHeight(value: string);
  73346. private _setSpacerHeight;
  73347. /** Adds a bar between groups */
  73348. private _addSpacer;
  73349. /** Add a group to the selection panel
  73350. * @param group is the selector group to add
  73351. */
  73352. addGroup(group: SelectorGroup): void;
  73353. /** Remove the group from the given position
  73354. * @param groupNb is the position of the group in the list
  73355. */
  73356. removeGroup(groupNb: number): void;
  73357. /** Change a group header label
  73358. * @param label is the new group header label
  73359. * @param groupNb is the number of the group to relabel
  73360. * */
  73361. setHeaderName(label: string, groupNb: number): void;
  73362. /** Change selector label to the one given
  73363. * @param label is the new selector label
  73364. * @param groupNb is the number of the groupcontaining the selector
  73365. * @param selectorNb is the number of the selector within a group to relabel
  73366. * */
  73367. relabel(label: string, groupNb: number, selectorNb: number): void;
  73368. /** For a given group position remove the selector at the given position
  73369. * @param groupNb is the number of the group to remove the selector from
  73370. * @param selectorNb is the number of the selector within the group
  73371. */
  73372. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73373. /** For a given group position of correct type add a checkbox button
  73374. * @param groupNb is the number of the group to remove the selector from
  73375. * @param label is the label for the selector
  73376. * @param func is the function called when the Selector is checked
  73377. * @param checked is true when Selector is checked
  73378. */
  73379. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73380. /** For a given group position of correct type add a radio button
  73381. * @param groupNb is the number of the group to remove the selector from
  73382. * @param label is the label for the selector
  73383. * @param func is the function called when the Selector is checked
  73384. * @param checked is true when Selector is checked
  73385. */
  73386. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73387. /**
  73388. * For a given slider group add a slider
  73389. * @param groupNb is the number of the group to add the slider to
  73390. * @param label is the label for the Slider
  73391. * @param func is the function called when the Slider moves
  73392. * @param unit is a string describing the units used, eg degrees or metres
  73393. * @param min is the minimum value for the Slider
  73394. * @param max is the maximum value for the Slider
  73395. * @param value is the start value for the Slider between min and max
  73396. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73397. */
  73398. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73399. }
  73400. }
  73401. declare module BABYLON.GUI {
  73402. /**
  73403. * Class used to hold a the container for ScrollViewer
  73404. * @hidden
  73405. */
  73406. export class _ScrollViewerWindow extends Container {
  73407. parentClientWidth: number;
  73408. parentClientHeight: number;
  73409. private _freezeControls;
  73410. private _parentMeasure;
  73411. private _oldLeft;
  73412. private _oldTop;
  73413. get freezeControls(): boolean;
  73414. set freezeControls(value: boolean);
  73415. private _bucketWidth;
  73416. private _bucketHeight;
  73417. private _buckets;
  73418. private _bucketLen;
  73419. get bucketWidth(): number;
  73420. get bucketHeight(): number;
  73421. setBucketSizes(width: number, height: number): void;
  73422. private _useBuckets;
  73423. private _makeBuckets;
  73424. private _dispatchInBuckets;
  73425. private _updateMeasures;
  73426. private _updateChildrenMeasures;
  73427. private _restoreMeasures;
  73428. /**
  73429. * Creates a new ScrollViewerWindow
  73430. * @param name of ScrollViewerWindow
  73431. */
  73432. constructor(name?: string);
  73433. protected _getTypeName(): string;
  73434. /** @hidden */
  73435. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73436. /** @hidden */
  73437. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73438. private _scrollChildren;
  73439. private _scrollChildrenWithBuckets;
  73440. /** @hidden */
  73441. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73442. protected _postMeasure(): void;
  73443. }
  73444. }
  73445. declare module BABYLON.GUI {
  73446. /**
  73447. * Class used to create slider controls
  73448. */
  73449. export class ScrollBar extends BaseSlider {
  73450. name?: string | undefined;
  73451. private _background;
  73452. private _borderColor;
  73453. private _tempMeasure;
  73454. /** Gets or sets border color */
  73455. get borderColor(): string;
  73456. set borderColor(value: string);
  73457. /** Gets or sets background color */
  73458. get background(): string;
  73459. set background(value: string);
  73460. /**
  73461. * Creates a new Slider
  73462. * @param name defines the control name
  73463. */
  73464. constructor(name?: string | undefined);
  73465. protected _getTypeName(): string;
  73466. protected _getThumbThickness(): number;
  73467. _draw(context: CanvasRenderingContext2D): void;
  73468. private _first;
  73469. private _originX;
  73470. private _originY;
  73471. /** @hidden */
  73472. protected _updateValueFromPointer(x: number, y: number): void;
  73473. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73474. }
  73475. }
  73476. declare module BABYLON.GUI {
  73477. /**
  73478. * Class used to create slider controls
  73479. */
  73480. export class ImageScrollBar extends BaseSlider {
  73481. name?: string | undefined;
  73482. private _backgroundBaseImage;
  73483. private _backgroundImage;
  73484. private _thumbImage;
  73485. private _thumbBaseImage;
  73486. private _thumbLength;
  73487. private _thumbHeight;
  73488. private _barImageHeight;
  73489. private _tempMeasure;
  73490. /** Number of 90° rotation to apply on the images when in vertical mode */
  73491. num90RotationInVerticalMode: number;
  73492. /**
  73493. * Gets or sets the image used to render the background for horizontal bar
  73494. */
  73495. get backgroundImage(): Image;
  73496. set backgroundImage(value: Image);
  73497. /**
  73498. * Gets or sets the image used to render the thumb
  73499. */
  73500. get thumbImage(): Image;
  73501. set thumbImage(value: Image);
  73502. /**
  73503. * Gets or sets the length of the thumb
  73504. */
  73505. get thumbLength(): number;
  73506. set thumbLength(value: number);
  73507. /**
  73508. * Gets or sets the height of the thumb
  73509. */
  73510. get thumbHeight(): number;
  73511. set thumbHeight(value: number);
  73512. /**
  73513. * Gets or sets the height of the bar image
  73514. */
  73515. get barImageHeight(): number;
  73516. set barImageHeight(value: number);
  73517. /**
  73518. * Creates a new ImageScrollBar
  73519. * @param name defines the control name
  73520. */
  73521. constructor(name?: string | undefined);
  73522. protected _getTypeName(): string;
  73523. protected _getThumbThickness(): number;
  73524. _draw(context: CanvasRenderingContext2D): void;
  73525. private _first;
  73526. private _originX;
  73527. private _originY;
  73528. /** @hidden */
  73529. protected _updateValueFromPointer(x: number, y: number): void;
  73530. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73531. }
  73532. }
  73533. declare module BABYLON.GUI {
  73534. /**
  73535. * Class used to hold a viewer window and sliders in a grid
  73536. */
  73537. export class ScrollViewer extends Rectangle {
  73538. private _grid;
  73539. private _horizontalBarSpace;
  73540. private _verticalBarSpace;
  73541. private _dragSpace;
  73542. private _horizontalBar;
  73543. private _verticalBar;
  73544. private _barColor;
  73545. private _barBackground;
  73546. private _barImage;
  73547. private _horizontalBarImage;
  73548. private _verticalBarImage;
  73549. private _barBackgroundImage;
  73550. private _horizontalBarBackgroundImage;
  73551. private _verticalBarBackgroundImage;
  73552. private _barSize;
  73553. private _window;
  73554. private _pointerIsOver;
  73555. private _wheelPrecision;
  73556. private _onWheelObserver;
  73557. private _clientWidth;
  73558. private _clientHeight;
  73559. private _useImageBar;
  73560. private _thumbLength;
  73561. private _thumbHeight;
  73562. private _barImageHeight;
  73563. private _horizontalBarImageHeight;
  73564. private _verticalBarImageHeight;
  73565. /**
  73566. * Gets the horizontal scrollbar
  73567. */
  73568. get horizontalBar(): ScrollBar | ImageScrollBar;
  73569. /**
  73570. * Gets the vertical scrollbar
  73571. */
  73572. get verticalBar(): ScrollBar | ImageScrollBar;
  73573. /**
  73574. * Adds a new control to the current container
  73575. * @param control defines the control to add
  73576. * @returns the current container
  73577. */
  73578. addControl(control: BABYLON.Nullable<Control>): Container;
  73579. /**
  73580. * Removes a control from the current container
  73581. * @param control defines the control to remove
  73582. * @returns the current container
  73583. */
  73584. removeControl(control: Control): Container;
  73585. /** Gets the list of children */
  73586. get children(): Control[];
  73587. _flagDescendantsAsMatrixDirty(): void;
  73588. /**
  73589. * Freezes or unfreezes the controls in the window.
  73590. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73591. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73592. */
  73593. get freezeControls(): boolean;
  73594. set freezeControls(value: boolean);
  73595. /** Gets the bucket width */
  73596. get bucketWidth(): number;
  73597. /** Gets the bucket height */
  73598. get bucketHeight(): number;
  73599. /**
  73600. * Sets the bucket sizes.
  73601. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73602. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73603. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73604. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73605. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73606. * used), that's why it is not enabled by default.
  73607. * @param width width of the bucket
  73608. * @param height height of the bucket
  73609. */
  73610. setBucketSizes(width: number, height: number): void;
  73611. private _forceHorizontalBar;
  73612. private _forceVerticalBar;
  73613. /**
  73614. * Forces the horizontal scroll bar to be displayed
  73615. */
  73616. get forceHorizontalBar(): boolean;
  73617. set forceHorizontalBar(value: boolean);
  73618. /**
  73619. * Forces the vertical scroll bar to be displayed
  73620. */
  73621. get forceVerticalBar(): boolean;
  73622. set forceVerticalBar(value: boolean);
  73623. /**
  73624. * Creates a new ScrollViewer
  73625. * @param name of ScrollViewer
  73626. */
  73627. constructor(name?: string, isImageBased?: boolean);
  73628. /** Reset the scroll viewer window to initial size */
  73629. resetWindow(): void;
  73630. protected _getTypeName(): string;
  73631. private _buildClientSizes;
  73632. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73633. protected _postMeasure(): void;
  73634. /**
  73635. * Gets or sets the mouse wheel precision
  73636. * from 0 to 1 with a default value of 0.05
  73637. * */
  73638. get wheelPrecision(): number;
  73639. set wheelPrecision(value: number);
  73640. /** Gets or sets the scroll bar container background color */
  73641. get scrollBackground(): string;
  73642. set scrollBackground(color: string);
  73643. /** Gets or sets the bar color */
  73644. get barColor(): string;
  73645. set barColor(color: string);
  73646. /** Gets or sets the bar image */
  73647. get thumbImage(): Image;
  73648. set thumbImage(value: Image);
  73649. /** Gets or sets the horizontal bar image */
  73650. get horizontalThumbImage(): Image;
  73651. set horizontalThumbImage(value: Image);
  73652. /** Gets or sets the vertical bar image */
  73653. get verticalThumbImage(): Image;
  73654. set verticalThumbImage(value: Image);
  73655. /** Gets or sets the size of the bar */
  73656. get barSize(): number;
  73657. set barSize(value: number);
  73658. /** Gets or sets the length of the thumb */
  73659. get thumbLength(): number;
  73660. set thumbLength(value: number);
  73661. /** Gets or sets the height of the thumb */
  73662. get thumbHeight(): number;
  73663. set thumbHeight(value: number);
  73664. /** Gets or sets the height of the bar image */
  73665. get barImageHeight(): number;
  73666. set barImageHeight(value: number);
  73667. /** Gets or sets the height of the horizontal bar image */
  73668. get horizontalBarImageHeight(): number;
  73669. set horizontalBarImageHeight(value: number);
  73670. /** Gets or sets the height of the vertical bar image */
  73671. get verticalBarImageHeight(): number;
  73672. set verticalBarImageHeight(value: number);
  73673. /** Gets or sets the bar background */
  73674. get barBackground(): string;
  73675. set barBackground(color: string);
  73676. /** Gets or sets the bar background image */
  73677. get barImage(): Image;
  73678. set barImage(value: Image);
  73679. /** Gets or sets the horizontal bar background image */
  73680. get horizontalBarImage(): Image;
  73681. set horizontalBarImage(value: Image);
  73682. /** Gets or sets the vertical bar background image */
  73683. get verticalBarImage(): Image;
  73684. set verticalBarImage(value: Image);
  73685. private _setWindowPosition;
  73686. /** @hidden */
  73687. private _updateScroller;
  73688. _link(host: AdvancedDynamicTexture): void;
  73689. /** @hidden */
  73690. private _addBar;
  73691. /** @hidden */
  73692. private _attachWheel;
  73693. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73694. /** Releases associated resources */
  73695. dispose(): void;
  73696. }
  73697. }
  73698. declare module BABYLON.GUI {
  73699. /** Class used to render a grid */
  73700. export class DisplayGrid extends Control {
  73701. name?: string | undefined;
  73702. private _cellWidth;
  73703. private _cellHeight;
  73704. private _minorLineTickness;
  73705. private _minorLineColor;
  73706. private _majorLineTickness;
  73707. private _majorLineColor;
  73708. private _majorLineFrequency;
  73709. private _background;
  73710. private _displayMajorLines;
  73711. private _displayMinorLines;
  73712. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73713. get displayMinorLines(): boolean;
  73714. set displayMinorLines(value: boolean);
  73715. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73716. get displayMajorLines(): boolean;
  73717. set displayMajorLines(value: boolean);
  73718. /** Gets or sets background color (Black by default) */
  73719. get background(): string;
  73720. set background(value: string);
  73721. /** Gets or sets the width of each cell (20 by default) */
  73722. get cellWidth(): number;
  73723. set cellWidth(value: number);
  73724. /** Gets or sets the height of each cell (20 by default) */
  73725. get cellHeight(): number;
  73726. set cellHeight(value: number);
  73727. /** Gets or sets the tickness of minor lines (1 by default) */
  73728. get minorLineTickness(): number;
  73729. set minorLineTickness(value: number);
  73730. /** Gets or sets the color of minor lines (DarkGray by default) */
  73731. get minorLineColor(): string;
  73732. set minorLineColor(value: string);
  73733. /** Gets or sets the tickness of major lines (2 by default) */
  73734. get majorLineTickness(): number;
  73735. set majorLineTickness(value: number);
  73736. /** Gets or sets the color of major lines (White by default) */
  73737. get majorLineColor(): string;
  73738. set majorLineColor(value: string);
  73739. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73740. get majorLineFrequency(): number;
  73741. set majorLineFrequency(value: number);
  73742. /**
  73743. * Creates a new GridDisplayRectangle
  73744. * @param name defines the control name
  73745. */
  73746. constructor(name?: string | undefined);
  73747. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73748. protected _getTypeName(): string;
  73749. }
  73750. }
  73751. declare module BABYLON.GUI {
  73752. /**
  73753. * Class used to create slider controls based on images
  73754. */
  73755. export class ImageBasedSlider extends BaseSlider {
  73756. name?: string | undefined;
  73757. private _backgroundImage;
  73758. private _thumbImage;
  73759. private _valueBarImage;
  73760. private _tempMeasure;
  73761. get displayThumb(): boolean;
  73762. set displayThumb(value: boolean);
  73763. /**
  73764. * Gets or sets the image used to render the background
  73765. */
  73766. get backgroundImage(): Image;
  73767. set backgroundImage(value: Image);
  73768. /**
  73769. * Gets or sets the image used to render the value bar
  73770. */
  73771. get valueBarImage(): Image;
  73772. set valueBarImage(value: Image);
  73773. /**
  73774. * Gets or sets the image used to render the thumb
  73775. */
  73776. get thumbImage(): Image;
  73777. set thumbImage(value: Image);
  73778. /**
  73779. * Creates a new ImageBasedSlider
  73780. * @param name defines the control name
  73781. */
  73782. constructor(name?: string | undefined);
  73783. protected _getTypeName(): string;
  73784. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73785. }
  73786. }
  73787. declare module BABYLON.GUI {
  73788. /**
  73789. * Forcing an export so that this code will execute
  73790. * @hidden
  73791. */
  73792. const name = "Statics";
  73793. }
  73794. declare module BABYLON.GUI {
  73795. /**
  73796. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  73797. */
  73798. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  73799. /**
  73800. * Define the instrumented AdvancedDynamicTexture.
  73801. */
  73802. texture: AdvancedDynamicTexture;
  73803. private _captureRenderTime;
  73804. private _renderTime;
  73805. private _captureLayoutTime;
  73806. private _layoutTime;
  73807. private _onBeginRenderObserver;
  73808. private _onEndRenderObserver;
  73809. private _onBeginLayoutObserver;
  73810. private _onEndLayoutObserver;
  73811. /**
  73812. * Gets the perf counter used to capture render time
  73813. */
  73814. get renderTimeCounter(): BABYLON.PerfCounter;
  73815. /**
  73816. * Gets the perf counter used to capture layout time
  73817. */
  73818. get layoutTimeCounter(): BABYLON.PerfCounter;
  73819. /**
  73820. * Enable or disable the render time capture
  73821. */
  73822. get captureRenderTime(): boolean;
  73823. set captureRenderTime(value: boolean);
  73824. /**
  73825. * Enable or disable the layout time capture
  73826. */
  73827. get captureLayoutTime(): boolean;
  73828. set captureLayoutTime(value: boolean);
  73829. /**
  73830. * Instantiates a new advanced dynamic texture instrumentation.
  73831. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73832. * @param texture Defines the AdvancedDynamicTexture to instrument
  73833. */
  73834. constructor(
  73835. /**
  73836. * Define the instrumented AdvancedDynamicTexture.
  73837. */
  73838. texture: AdvancedDynamicTexture);
  73839. /**
  73840. * Dispose and release associated resources.
  73841. */
  73842. dispose(): void;
  73843. }
  73844. }
  73845. declare module BABYLON.GUI {
  73846. /**
  73847. * Class used to load GUI via XML.
  73848. */
  73849. export class XmlLoader {
  73850. private _nodes;
  73851. private _nodeTypes;
  73852. private _isLoaded;
  73853. private _objectAttributes;
  73854. private _parentClass;
  73855. /**
  73856. * Create a new xml loader
  73857. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73858. */
  73859. constructor(parentClass?: null);
  73860. private _getChainElement;
  73861. private _getClassAttribute;
  73862. private _createGuiElement;
  73863. private _parseGrid;
  73864. private _parseElement;
  73865. private _prepareSourceElement;
  73866. private _parseElementsFromSource;
  73867. private _parseXml;
  73868. /**
  73869. * Gets if the loading has finished.
  73870. * @returns whether the loading has finished or not
  73871. */
  73872. isLoaded(): boolean;
  73873. /**
  73874. * Gets a loaded node / control by id.
  73875. * @param id the Controls id set in the xml
  73876. * @returns element of type Control
  73877. */
  73878. getNodeById(id: string): any;
  73879. /**
  73880. * Gets all loaded nodes / controls
  73881. * @returns Array of controls
  73882. */
  73883. getNodes(): any;
  73884. /**
  73885. * Initiates the xml layout loading
  73886. * @param xmlFile defines the xml layout to load
  73887. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73888. * @param callback defines the callback called on layout load.
  73889. */
  73890. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73891. }
  73892. }
  73893. declare module BABYLON.GUI {
  73894. /**
  73895. * Class used to create containers for controls
  73896. */
  73897. export class Container3D extends Control3D {
  73898. private _blockLayout;
  73899. /**
  73900. * Gets the list of child controls
  73901. */
  73902. protected _children: Control3D[];
  73903. /**
  73904. * Gets the list of child controls
  73905. */
  73906. get children(): Array<Control3D>;
  73907. /**
  73908. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73909. * This is helpful to optimize layout operation when adding multiple children in a row
  73910. */
  73911. get blockLayout(): boolean;
  73912. set blockLayout(value: boolean);
  73913. /**
  73914. * Creates a new container
  73915. * @param name defines the container name
  73916. */
  73917. constructor(name?: string);
  73918. /**
  73919. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73920. * @returns the current container
  73921. */
  73922. updateLayout(): Container3D;
  73923. /**
  73924. * Gets a boolean indicating if the given control is in the children of this control
  73925. * @param control defines the control to check
  73926. * @returns true if the control is in the child list
  73927. */
  73928. containsControl(control: Control3D): boolean;
  73929. /**
  73930. * Adds a control to the children of this control
  73931. * @param control defines the control to add
  73932. * @returns the current container
  73933. */
  73934. addControl(control: Control3D): Container3D;
  73935. /**
  73936. * This function will be called everytime a new control is added
  73937. */
  73938. protected _arrangeChildren(): void;
  73939. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73940. /**
  73941. * Removes a control from the children of this control
  73942. * @param control defines the control to remove
  73943. * @returns the current container
  73944. */
  73945. removeControl(control: Control3D): Container3D;
  73946. protected _getTypeName(): string;
  73947. /**
  73948. * Releases all associated resources
  73949. */
  73950. dispose(): void;
  73951. /** Control rotation will remain unchanged */
  73952. static readonly UNSET_ORIENTATION: number;
  73953. /** Control will rotate to make it look at sphere central axis */
  73954. static readonly FACEORIGIN_ORIENTATION: number;
  73955. /** Control will rotate to make it look back at sphere central axis */
  73956. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73957. /** Control will rotate to look at z axis (0, 0, 1) */
  73958. static readonly FACEFORWARD_ORIENTATION: number;
  73959. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73960. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73961. }
  73962. }
  73963. declare module BABYLON.GUI {
  73964. /**
  73965. * Class used to manage 3D user interface
  73966. * @see http://doc.babylonjs.com/how_to/gui3d
  73967. */
  73968. export class GUI3DManager implements BABYLON.IDisposable {
  73969. private _scene;
  73970. private _sceneDisposeObserver;
  73971. private _utilityLayer;
  73972. private _rootContainer;
  73973. private _pointerObserver;
  73974. private _pointerOutObserver;
  73975. /** @hidden */
  73976. _lastPickedControl: Control3D;
  73977. /** @hidden */
  73978. _lastControlOver: {
  73979. [pointerId: number]: Control3D;
  73980. };
  73981. /** @hidden */
  73982. _lastControlDown: {
  73983. [pointerId: number]: Control3D;
  73984. };
  73985. /**
  73986. * BABYLON.Observable raised when the point picked by the pointer events changed
  73987. */
  73988. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73989. /** @hidden */
  73990. _sharedMaterials: {
  73991. [key: string]: BABYLON.Material;
  73992. };
  73993. /** Gets the hosting scene */
  73994. get scene(): BABYLON.Scene;
  73995. /** Gets associated utility layer */
  73996. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73997. /**
  73998. * Creates a new GUI3DManager
  73999. * @param scene
  74000. */
  74001. constructor(scene?: BABYLON.Scene);
  74002. private _handlePointerOut;
  74003. private _doPicking;
  74004. /**
  74005. * Gets the root container
  74006. */
  74007. get rootContainer(): Container3D;
  74008. /**
  74009. * Gets a boolean indicating if the given control is in the root child list
  74010. * @param control defines the control to check
  74011. * @returns true if the control is in the root child list
  74012. */
  74013. containsControl(control: Control3D): boolean;
  74014. /**
  74015. * Adds a control to the root child list
  74016. * @param control defines the control to add
  74017. * @returns the current manager
  74018. */
  74019. addControl(control: Control3D): GUI3DManager;
  74020. /**
  74021. * Removes a control from the root child list
  74022. * @param control defines the control to remove
  74023. * @returns the current container
  74024. */
  74025. removeControl(control: Control3D): GUI3DManager;
  74026. /**
  74027. * Releases all associated resources
  74028. */
  74029. dispose(): void;
  74030. }
  74031. }
  74032. declare module BABYLON.GUI {
  74033. /**
  74034. * Class used to transport BABYLON.Vector3 information for pointer events
  74035. */
  74036. export class Vector3WithInfo extends BABYLON.Vector3 {
  74037. /** defines the current mouse button index */
  74038. buttonIndex: number;
  74039. /**
  74040. * Creates a new Vector3WithInfo
  74041. * @param source defines the vector3 data to transport
  74042. * @param buttonIndex defines the current mouse button index
  74043. */
  74044. constructor(source: BABYLON.Vector3,
  74045. /** defines the current mouse button index */
  74046. buttonIndex?: number);
  74047. }
  74048. }
  74049. declare module BABYLON.GUI {
  74050. /**
  74051. * Class used as base class for controls
  74052. */
  74053. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74054. /** Defines the control name */
  74055. name?: string | undefined;
  74056. /** @hidden */
  74057. _host: GUI3DManager;
  74058. private _node;
  74059. private _downCount;
  74060. private _enterCount;
  74061. private _downPointerIds;
  74062. private _isVisible;
  74063. /** Gets or sets the control position in world space */
  74064. get position(): BABYLON.Vector3;
  74065. set position(value: BABYLON.Vector3);
  74066. /** Gets or sets the control scaling in world space */
  74067. get scaling(): BABYLON.Vector3;
  74068. set scaling(value: BABYLON.Vector3);
  74069. /** Callback used to start pointer enter animation */
  74070. pointerEnterAnimation: () => void;
  74071. /** Callback used to start pointer out animation */
  74072. pointerOutAnimation: () => void;
  74073. /** Callback used to start pointer down animation */
  74074. pointerDownAnimation: () => void;
  74075. /** Callback used to start pointer up animation */
  74076. pointerUpAnimation: () => void;
  74077. /**
  74078. * An event triggered when the pointer move over the control
  74079. */
  74080. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74081. /**
  74082. * An event triggered when the pointer move out of the control
  74083. */
  74084. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74085. /**
  74086. * An event triggered when the pointer taps the control
  74087. */
  74088. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74089. /**
  74090. * An event triggered when pointer is up
  74091. */
  74092. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74093. /**
  74094. * An event triggered when a control is clicked on (with a mouse)
  74095. */
  74096. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74097. /**
  74098. * An event triggered when pointer enters the control
  74099. */
  74100. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74101. /**
  74102. * Gets or sets the parent container
  74103. */
  74104. parent: BABYLON.Nullable<Container3D>;
  74105. private _behaviors;
  74106. /**
  74107. * Gets the list of attached behaviors
  74108. * @see http://doc.babylonjs.com/features/behaviour
  74109. */
  74110. get behaviors(): BABYLON.Behavior<Control3D>[];
  74111. /**
  74112. * Attach a behavior to the control
  74113. * @see http://doc.babylonjs.com/features/behaviour
  74114. * @param behavior defines the behavior to attach
  74115. * @returns the current control
  74116. */
  74117. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74118. /**
  74119. * Remove an attached behavior
  74120. * @see http://doc.babylonjs.com/features/behaviour
  74121. * @param behavior defines the behavior to attach
  74122. * @returns the current control
  74123. */
  74124. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74125. /**
  74126. * Gets an attached behavior by name
  74127. * @param name defines the name of the behavior to look for
  74128. * @see http://doc.babylonjs.com/features/behaviour
  74129. * @returns null if behavior was not found else the requested behavior
  74130. */
  74131. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74132. /** Gets or sets a boolean indicating if the control is visible */
  74133. get isVisible(): boolean;
  74134. set isVisible(value: boolean);
  74135. /**
  74136. * Creates a new control
  74137. * @param name defines the control name
  74138. */
  74139. constructor(
  74140. /** Defines the control name */
  74141. name?: string | undefined);
  74142. /**
  74143. * Gets a string representing the class name
  74144. */
  74145. get typeName(): string;
  74146. /**
  74147. * Get the current class name of the control.
  74148. * @returns current class name
  74149. */
  74150. getClassName(): string;
  74151. protected _getTypeName(): string;
  74152. /**
  74153. * Gets the transform node used by this control
  74154. */
  74155. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74156. /**
  74157. * Gets the mesh used to render this control
  74158. */
  74159. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74160. /**
  74161. * Link the control as child of the given node
  74162. * @param node defines the node to link to. Use null to unlink the control
  74163. * @returns the current control
  74164. */
  74165. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74166. /** @hidden **/
  74167. _prepareNode(scene: BABYLON.Scene): void;
  74168. /**
  74169. * Node creation.
  74170. * Can be overriden by children
  74171. * @param scene defines the scene where the node must be attached
  74172. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74173. */
  74174. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74175. /**
  74176. * Affect a material to the given mesh
  74177. * @param mesh defines the mesh which will represent the control
  74178. */
  74179. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74180. /** @hidden */
  74181. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74182. /** @hidden */
  74183. _onPointerEnter(target: Control3D): boolean;
  74184. /** @hidden */
  74185. _onPointerOut(target: Control3D): void;
  74186. /** @hidden */
  74187. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74188. /** @hidden */
  74189. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74190. /** @hidden */
  74191. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74192. /** @hidden */
  74193. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74194. /** @hidden */
  74195. _disposeNode(): void;
  74196. /**
  74197. * Releases all associated resources
  74198. */
  74199. dispose(): void;
  74200. }
  74201. }
  74202. declare module BABYLON.GUI {
  74203. /**
  74204. * Class used as a root to all buttons
  74205. */
  74206. export class AbstractButton3D extends Control3D {
  74207. /**
  74208. * Creates a new button
  74209. * @param name defines the control name
  74210. */
  74211. constructor(name?: string);
  74212. protected _getTypeName(): string;
  74213. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74214. }
  74215. }
  74216. declare module BABYLON.GUI {
  74217. /**
  74218. * Class used to create a button in 3D
  74219. */
  74220. export class Button3D extends AbstractButton3D {
  74221. /** @hidden */
  74222. protected _currentMaterial: BABYLON.Material;
  74223. private _facadeTexture;
  74224. private _content;
  74225. private _contentResolution;
  74226. private _contentScaleRatio;
  74227. /**
  74228. * Gets or sets the texture resolution used to render content (512 by default)
  74229. */
  74230. get contentResolution(): BABYLON.int;
  74231. set contentResolution(value: BABYLON.int);
  74232. /**
  74233. * Gets or sets the texture scale ratio used to render content (2 by default)
  74234. */
  74235. get contentScaleRatio(): number;
  74236. set contentScaleRatio(value: number);
  74237. protected _disposeFacadeTexture(): void;
  74238. protected _resetContent(): void;
  74239. /**
  74240. * Creates a new button
  74241. * @param name defines the control name
  74242. */
  74243. constructor(name?: string);
  74244. /**
  74245. * Gets or sets the GUI 2D content used to display the button's facade
  74246. */
  74247. get content(): Control;
  74248. set content(value: Control);
  74249. /**
  74250. * Apply the facade texture (created from the content property).
  74251. * This function can be overloaded by child classes
  74252. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74253. */
  74254. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74255. protected _getTypeName(): string;
  74256. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74257. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74258. /**
  74259. * Releases all associated resources
  74260. */
  74261. dispose(): void;
  74262. }
  74263. }
  74264. declare module BABYLON.GUI {
  74265. /**
  74266. * Abstract class used to create a container panel deployed on the surface of a volume
  74267. */
  74268. export abstract class VolumeBasedPanel extends Container3D {
  74269. private _columns;
  74270. private _rows;
  74271. private _rowThenColum;
  74272. private _orientation;
  74273. protected _cellWidth: number;
  74274. protected _cellHeight: number;
  74275. /**
  74276. * Gets or sets the distance between elements
  74277. */
  74278. margin: number;
  74279. /**
  74280. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74281. * | Value | Type | Description |
  74282. * | ----- | ----------------------------------- | ----------- |
  74283. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74284. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74285. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74286. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74287. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74288. */
  74289. get orientation(): number;
  74290. set orientation(value: number);
  74291. /**
  74292. * Gets or sets the number of columns requested (10 by default).
  74293. * The panel will automatically compute the number of rows based on number of child controls.
  74294. */
  74295. get columns(): BABYLON.int;
  74296. set columns(value: BABYLON.int);
  74297. /**
  74298. * Gets or sets a the number of rows requested.
  74299. * The panel will automatically compute the number of columns based on number of child controls.
  74300. */
  74301. get rows(): BABYLON.int;
  74302. set rows(value: BABYLON.int);
  74303. /**
  74304. * Creates new VolumeBasedPanel
  74305. */
  74306. constructor();
  74307. protected _arrangeChildren(): void;
  74308. /** Child classes must implement this function to provide correct control positioning */
  74309. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74310. /** Child classes can implement this function to provide additional processing */
  74311. protected _finalProcessing(): void;
  74312. }
  74313. }
  74314. declare module BABYLON.GUI {
  74315. /**
  74316. * Class used to create a container panel deployed on the surface of a cylinder
  74317. */
  74318. export class CylinderPanel extends VolumeBasedPanel {
  74319. private _radius;
  74320. /**
  74321. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74322. */
  74323. get radius(): BABYLON.float;
  74324. set radius(value: BABYLON.float);
  74325. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74326. private _cylindricalMapping;
  74327. }
  74328. }
  74329. declare module BABYLON.GUI {
  74330. /** @hidden */
  74331. export var fluentVertexShader: {
  74332. name: string;
  74333. shader: string;
  74334. };
  74335. }
  74336. declare module BABYLON.GUI {
  74337. /** @hidden */
  74338. export var fluentPixelShader: {
  74339. name: string;
  74340. shader: string;
  74341. };
  74342. }
  74343. declare module BABYLON.GUI {
  74344. /** @hidden */
  74345. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74346. INNERGLOW: boolean;
  74347. BORDER: boolean;
  74348. HOVERLIGHT: boolean;
  74349. TEXTURE: boolean;
  74350. constructor();
  74351. }
  74352. /**
  74353. * Class used to render controls with fluent desgin
  74354. */
  74355. export class FluentMaterial extends BABYLON.PushMaterial {
  74356. /**
  74357. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74358. */
  74359. innerGlowColorIntensity: number;
  74360. /**
  74361. * Gets or sets the inner glow color (white by default)
  74362. */
  74363. innerGlowColor: BABYLON.Color3;
  74364. /**
  74365. * Gets or sets alpha value (default is 1.0)
  74366. */
  74367. alpha: number;
  74368. /**
  74369. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74370. */
  74371. albedoColor: BABYLON.Color3;
  74372. /**
  74373. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74374. */
  74375. renderBorders: boolean;
  74376. /**
  74377. * Gets or sets border width (default is 0.5)
  74378. */
  74379. borderWidth: number;
  74380. /**
  74381. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74382. */
  74383. edgeSmoothingValue: number;
  74384. /**
  74385. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74386. */
  74387. borderMinValue: number;
  74388. /**
  74389. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74390. */
  74391. renderHoverLight: boolean;
  74392. /**
  74393. * Gets or sets the radius used to render the hover light (default is 1.0)
  74394. */
  74395. hoverRadius: number;
  74396. /**
  74397. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74398. */
  74399. hoverColor: BABYLON.Color4;
  74400. /**
  74401. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74402. */
  74403. hoverPosition: BABYLON.Vector3;
  74404. private _albedoTexture;
  74405. /** Gets or sets the texture to use for albedo color */
  74406. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74407. /**
  74408. * Creates a new Fluent material
  74409. * @param name defines the name of the material
  74410. * @param scene defines the hosting scene
  74411. */
  74412. constructor(name: string, scene: BABYLON.Scene);
  74413. needAlphaBlending(): boolean;
  74414. needAlphaTesting(): boolean;
  74415. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74416. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74417. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74418. getActiveTextures(): BABYLON.BaseTexture[];
  74419. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74420. dispose(forceDisposeEffect?: boolean): void;
  74421. clone(name: string): FluentMaterial;
  74422. serialize(): any;
  74423. getClassName(): string;
  74424. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74425. }
  74426. }
  74427. declare module BABYLON.GUI {
  74428. /**
  74429. * Class used to create a holographic button in 3D
  74430. */
  74431. export class HolographicButton extends Button3D {
  74432. private _backPlate;
  74433. private _textPlate;
  74434. private _frontPlate;
  74435. private _text;
  74436. private _imageUrl;
  74437. private _shareMaterials;
  74438. private _frontMaterial;
  74439. private _backMaterial;
  74440. private _plateMaterial;
  74441. private _pickedPointObserver;
  74442. private _tooltipFade;
  74443. private _tooltipTextBlock;
  74444. private _tooltipTexture;
  74445. private _tooltipMesh;
  74446. private _tooltipHoverObserver;
  74447. private _tooltipOutObserver;
  74448. private _disposeTooltip;
  74449. /**
  74450. * Rendering ground id of all the mesh in the button
  74451. */
  74452. set renderingGroupId(id: number);
  74453. get renderingGroupId(): number;
  74454. /**
  74455. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74456. */
  74457. set tooltipText(text: BABYLON.Nullable<string>);
  74458. get tooltipText(): BABYLON.Nullable<string>;
  74459. /**
  74460. * Gets or sets text for the button
  74461. */
  74462. get text(): string;
  74463. set text(value: string);
  74464. /**
  74465. * Gets or sets the image url for the button
  74466. */
  74467. get imageUrl(): string;
  74468. set imageUrl(value: string);
  74469. /**
  74470. * Gets the back material used by this button
  74471. */
  74472. get backMaterial(): FluentMaterial;
  74473. /**
  74474. * Gets the front material used by this button
  74475. */
  74476. get frontMaterial(): FluentMaterial;
  74477. /**
  74478. * Gets the plate material used by this button
  74479. */
  74480. get plateMaterial(): BABYLON.StandardMaterial;
  74481. /**
  74482. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74483. */
  74484. get shareMaterials(): boolean;
  74485. /**
  74486. * Creates a new button
  74487. * @param name defines the control name
  74488. */
  74489. constructor(name?: string, shareMaterials?: boolean);
  74490. protected _getTypeName(): string;
  74491. private _rebuildContent;
  74492. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74493. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74494. private _createBackMaterial;
  74495. private _createFrontMaterial;
  74496. private _createPlateMaterial;
  74497. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  74498. /**
  74499. * Releases all associated resources
  74500. */
  74501. dispose(): void;
  74502. }
  74503. }
  74504. declare module BABYLON.GUI {
  74505. /**
  74506. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  74507. */
  74508. export class MeshButton3D extends Button3D {
  74509. /** @hidden */
  74510. protected _currentMesh: BABYLON.Mesh;
  74511. /**
  74512. * Creates a new 3D button based on a mesh
  74513. * @param mesh mesh to become a 3D button
  74514. * @param name defines the control name
  74515. */
  74516. constructor(mesh: BABYLON.Mesh, name?: string);
  74517. protected _getTypeName(): string;
  74518. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74519. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74520. }
  74521. }
  74522. declare module BABYLON.GUI {
  74523. /**
  74524. * Class used to create a container panel deployed on the surface of a plane
  74525. */
  74526. export class PlanePanel extends VolumeBasedPanel {
  74527. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74528. }
  74529. }
  74530. declare module BABYLON.GUI {
  74531. /**
  74532. * Class used to create a container panel where items get randomized planar mapping
  74533. */
  74534. export class ScatterPanel extends VolumeBasedPanel {
  74535. private _iteration;
  74536. /**
  74537. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74538. */
  74539. get iteration(): BABYLON.float;
  74540. set iteration(value: BABYLON.float);
  74541. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74542. private _scatterMapping;
  74543. protected _finalProcessing(): void;
  74544. }
  74545. }
  74546. declare module BABYLON.GUI {
  74547. /**
  74548. * Class used to create a container panel deployed on the surface of a sphere
  74549. */
  74550. export class SpherePanel extends VolumeBasedPanel {
  74551. private _radius;
  74552. /**
  74553. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74554. */
  74555. get radius(): BABYLON.float;
  74556. set radius(value: BABYLON.float);
  74557. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74558. private _sphericalMapping;
  74559. }
  74560. }
  74561. declare module BABYLON.GUI {
  74562. /**
  74563. * Class used to create a stack panel in 3D on XY plane
  74564. */
  74565. export class StackPanel3D extends Container3D {
  74566. private _isVertical;
  74567. /**
  74568. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74569. */
  74570. get isVertical(): boolean;
  74571. set isVertical(value: boolean);
  74572. /**
  74573. * Gets or sets the distance between elements
  74574. */
  74575. margin: number;
  74576. /**
  74577. * Creates new StackPanel
  74578. * @param isVertical
  74579. */
  74580. constructor(isVertical?: boolean);
  74581. protected _arrangeChildren(): void;
  74582. }
  74583. }
  74584. declare module BABYLON {
  74585. /**
  74586. * Configuration for glTF validation
  74587. */
  74588. export interface IGLTFValidationConfiguration {
  74589. /**
  74590. * The url of the glTF validator.
  74591. */
  74592. url: string;
  74593. }
  74594. /**
  74595. * glTF validation
  74596. */
  74597. export class GLTFValidation {
  74598. /**
  74599. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74600. */
  74601. static Configuration: IGLTFValidationConfiguration;
  74602. private static _LoadScriptPromise;
  74603. /**
  74604. * Validate a glTF asset using the glTF-Validator.
  74605. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74606. * @param rootUrl The root url for the glTF
  74607. * @param fileName The file name for the glTF
  74608. * @param getExternalResource The callback to get external resources for the glTF validator
  74609. * @returns A promise that resolves with the glTF validation results once complete
  74610. */
  74611. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74612. }
  74613. }
  74614. declare module BABYLON {
  74615. /**
  74616. * Mode that determines the coordinate system to use.
  74617. */
  74618. export enum GLTFLoaderCoordinateSystemMode {
  74619. /**
  74620. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74621. */
  74622. AUTO = 0,
  74623. /**
  74624. * Sets the useRightHandedSystem flag on the scene.
  74625. */
  74626. FORCE_RIGHT_HANDED = 1
  74627. }
  74628. /**
  74629. * Mode that determines what animations will start.
  74630. */
  74631. export enum GLTFLoaderAnimationStartMode {
  74632. /**
  74633. * No animation will start.
  74634. */
  74635. NONE = 0,
  74636. /**
  74637. * The first animation will start.
  74638. */
  74639. FIRST = 1,
  74640. /**
  74641. * All animations will start.
  74642. */
  74643. ALL = 2
  74644. }
  74645. /**
  74646. * Interface that contains the data for the glTF asset.
  74647. */
  74648. export interface IGLTFLoaderData {
  74649. /**
  74650. * The object that represents the glTF JSON.
  74651. */
  74652. json: Object;
  74653. /**
  74654. * The BIN chunk of a binary glTF.
  74655. */
  74656. bin: Nullable<IDataBuffer>;
  74657. }
  74658. /**
  74659. * Interface for extending the loader.
  74660. */
  74661. export interface IGLTFLoaderExtension {
  74662. /**
  74663. * The name of this extension.
  74664. */
  74665. readonly name: string;
  74666. /**
  74667. * Defines whether this extension is enabled.
  74668. */
  74669. enabled: boolean;
  74670. /**
  74671. * Defines the order of this extension.
  74672. * The loader sorts the extensions using these values when loading.
  74673. */
  74674. order?: number;
  74675. }
  74676. /**
  74677. * Loader state.
  74678. */
  74679. export enum GLTFLoaderState {
  74680. /**
  74681. * The asset is loading.
  74682. */
  74683. LOADING = 0,
  74684. /**
  74685. * The asset is ready for rendering.
  74686. */
  74687. READY = 1,
  74688. /**
  74689. * The asset is completely loaded.
  74690. */
  74691. COMPLETE = 2
  74692. }
  74693. /** @hidden */
  74694. export interface IImportMeshAsyncOutput {
  74695. meshes: AbstractMesh[];
  74696. particleSystems: IParticleSystem[];
  74697. skeletons: Skeleton[];
  74698. animationGroups: AnimationGroup[];
  74699. lights: Light[];
  74700. transformNodes: TransformNode[];
  74701. }
  74702. /** @hidden */
  74703. export interface IGLTFLoader extends IDisposable {
  74704. readonly state: Nullable<GLTFLoaderState>;
  74705. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  74706. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74707. }
  74708. /**
  74709. * File loader for loading glTF files into a scene.
  74710. */
  74711. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74712. /** @hidden */
  74713. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74714. /** @hidden */
  74715. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74716. /**
  74717. * Raised when the asset has been parsed
  74718. */
  74719. onParsedObservable: Observable<IGLTFLoaderData>;
  74720. private _onParsedObserver;
  74721. /**
  74722. * Raised when the asset has been parsed
  74723. */
  74724. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74725. /**
  74726. * 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.
  74727. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74728. * Defaults to true.
  74729. * @hidden
  74730. */
  74731. static IncrementalLoading: boolean;
  74732. /**
  74733. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74734. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74735. * @hidden
  74736. */
  74737. static HomogeneousCoordinates: boolean;
  74738. /**
  74739. * The coordinate system mode. Defaults to AUTO.
  74740. */
  74741. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74742. /**
  74743. * The animation start mode. Defaults to FIRST.
  74744. */
  74745. animationStartMode: GLTFLoaderAnimationStartMode;
  74746. /**
  74747. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74748. */
  74749. compileMaterials: boolean;
  74750. /**
  74751. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74752. */
  74753. useClipPlane: boolean;
  74754. /**
  74755. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74756. */
  74757. compileShadowGenerators: boolean;
  74758. /**
  74759. * Defines if the Alpha blended materials are only applied as coverage.
  74760. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74761. * If true, no extra effects are applied to transparent pixels.
  74762. */
  74763. transparencyAsCoverage: boolean;
  74764. /**
  74765. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74766. * Enabling will disable offline support and glTF validator.
  74767. * Defaults to false.
  74768. */
  74769. useRangeRequests: boolean;
  74770. /**
  74771. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74772. */
  74773. createInstances: boolean;
  74774. /**
  74775. * Function called before loading a url referenced by the asset.
  74776. */
  74777. preprocessUrlAsync: (url: string) => Promise<string>;
  74778. /**
  74779. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74780. */
  74781. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74782. private _onMeshLoadedObserver;
  74783. /**
  74784. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74785. */
  74786. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  74787. /**
  74788. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  74789. */
  74790. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  74791. private _onTextureLoadedObserver;
  74792. /**
  74793. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  74794. */
  74795. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  74796. /**
  74797. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  74798. */
  74799. readonly onMaterialLoadedObservable: Observable<Material>;
  74800. private _onMaterialLoadedObserver;
  74801. /**
  74802. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  74803. */
  74804. set onMaterialLoaded(callback: (material: Material) => void);
  74805. /**
  74806. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  74807. */
  74808. readonly onCameraLoadedObservable: Observable<Camera>;
  74809. private _onCameraLoadedObserver;
  74810. /**
  74811. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  74812. */
  74813. set onCameraLoaded(callback: (camera: Camera) => void);
  74814. /**
  74815. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  74816. * For assets with LODs, raised when all of the LODs are complete.
  74817. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74818. */
  74819. readonly onCompleteObservable: Observable<void>;
  74820. private _onCompleteObserver;
  74821. /**
  74822. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74823. * For assets with LODs, raised when all of the LODs are complete.
  74824. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74825. */
  74826. set onComplete(callback: () => void);
  74827. /**
  74828. * Observable raised when an error occurs.
  74829. */
  74830. readonly onErrorObservable: Observable<any>;
  74831. private _onErrorObserver;
  74832. /**
  74833. * Callback raised when an error occurs.
  74834. */
  74835. set onError(callback: (reason: any) => void);
  74836. /**
  74837. * Observable raised after the loader is disposed.
  74838. */
  74839. readonly onDisposeObservable: Observable<void>;
  74840. private _onDisposeObserver;
  74841. /**
  74842. * Callback raised after the loader is disposed.
  74843. */
  74844. set onDispose(callback: () => void);
  74845. /**
  74846. * Observable raised after a loader extension is created.
  74847. * Set additional options for a loader extension in this event.
  74848. */
  74849. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74850. private _onExtensionLoadedObserver;
  74851. /**
  74852. * Callback raised after a loader extension is created.
  74853. */
  74854. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74855. /**
  74856. * Defines if the loader logging is enabled.
  74857. */
  74858. get loggingEnabled(): boolean;
  74859. set loggingEnabled(value: boolean);
  74860. /**
  74861. * Defines if the loader should capture performance counters.
  74862. */
  74863. get capturePerformanceCounters(): boolean;
  74864. set capturePerformanceCounters(value: boolean);
  74865. /**
  74866. * Defines if the loader should validate the asset.
  74867. */
  74868. validate: boolean;
  74869. /**
  74870. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74871. */
  74872. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74873. private _onValidatedObserver;
  74874. /**
  74875. * Callback raised after a loader extension is created.
  74876. */
  74877. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74878. private _loader;
  74879. /**
  74880. * Name of the loader ("gltf")
  74881. */
  74882. name: string;
  74883. /** @hidden */
  74884. extensions: ISceneLoaderPluginExtensions;
  74885. /**
  74886. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74887. */
  74888. dispose(): void;
  74889. /** @hidden */
  74890. _clear(): void;
  74891. /** @hidden */
  74892. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74893. /** @hidden */
  74894. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74895. /** @hidden */
  74896. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74897. meshes: AbstractMesh[];
  74898. particleSystems: IParticleSystem[];
  74899. skeletons: Skeleton[];
  74900. animationGroups: AnimationGroup[];
  74901. }>;
  74902. /** @hidden */
  74903. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74904. /** @hidden */
  74905. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74906. /** @hidden */
  74907. canDirectLoad(data: string): boolean;
  74908. /** @hidden */
  74909. directLoad(scene: Scene, data: string): any;
  74910. /**
  74911. * The callback that allows custom handling of the root url based on the response url.
  74912. * @param rootUrl the original root url
  74913. * @param responseURL the response url if available
  74914. * @returns the new root url
  74915. */
  74916. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74917. /** @hidden */
  74918. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74919. /**
  74920. * The loader state or null if the loader is not active.
  74921. */
  74922. get loaderState(): Nullable<GLTFLoaderState>;
  74923. /**
  74924. * Returns a promise that resolves when the asset is completely loaded.
  74925. * @returns a promise that resolves when the asset is completely loaded.
  74926. */
  74927. whenCompleteAsync(): Promise<void>;
  74928. private _validate;
  74929. private _getLoader;
  74930. private _parseJson;
  74931. private _unpackBinaryAsync;
  74932. private _unpackBinaryV1Async;
  74933. private _unpackBinaryV2Async;
  74934. private static _parseVersion;
  74935. private static _compareVersion;
  74936. private static readonly _logSpaces;
  74937. private _logIndentLevel;
  74938. private _loggingEnabled;
  74939. /** @hidden */
  74940. _log: (message: string) => void;
  74941. /** @hidden */
  74942. _logOpen(message: string): void;
  74943. /** @hidden */
  74944. _logClose(): void;
  74945. private _logEnabled;
  74946. private _logDisabled;
  74947. private _capturePerformanceCounters;
  74948. /** @hidden */
  74949. _startPerformanceCounter: (counterName: string) => void;
  74950. /** @hidden */
  74951. _endPerformanceCounter: (counterName: string) => void;
  74952. private _startPerformanceCounterEnabled;
  74953. private _startPerformanceCounterDisabled;
  74954. private _endPerformanceCounterEnabled;
  74955. private _endPerformanceCounterDisabled;
  74956. }
  74957. }
  74958. declare module BABYLON.GLTF1 {
  74959. /**
  74960. * Enums
  74961. * @hidden
  74962. */
  74963. export enum EComponentType {
  74964. BYTE = 5120,
  74965. UNSIGNED_BYTE = 5121,
  74966. SHORT = 5122,
  74967. UNSIGNED_SHORT = 5123,
  74968. FLOAT = 5126
  74969. }
  74970. /** @hidden */
  74971. export enum EShaderType {
  74972. FRAGMENT = 35632,
  74973. VERTEX = 35633
  74974. }
  74975. /** @hidden */
  74976. export enum EParameterType {
  74977. BYTE = 5120,
  74978. UNSIGNED_BYTE = 5121,
  74979. SHORT = 5122,
  74980. UNSIGNED_SHORT = 5123,
  74981. INT = 5124,
  74982. UNSIGNED_INT = 5125,
  74983. FLOAT = 5126,
  74984. FLOAT_VEC2 = 35664,
  74985. FLOAT_VEC3 = 35665,
  74986. FLOAT_VEC4 = 35666,
  74987. INT_VEC2 = 35667,
  74988. INT_VEC3 = 35668,
  74989. INT_VEC4 = 35669,
  74990. BOOL = 35670,
  74991. BOOL_VEC2 = 35671,
  74992. BOOL_VEC3 = 35672,
  74993. BOOL_VEC4 = 35673,
  74994. FLOAT_MAT2 = 35674,
  74995. FLOAT_MAT3 = 35675,
  74996. FLOAT_MAT4 = 35676,
  74997. SAMPLER_2D = 35678
  74998. }
  74999. /** @hidden */
  75000. export enum ETextureWrapMode {
  75001. CLAMP_TO_EDGE = 33071,
  75002. MIRRORED_REPEAT = 33648,
  75003. REPEAT = 10497
  75004. }
  75005. /** @hidden */
  75006. export enum ETextureFilterType {
  75007. NEAREST = 9728,
  75008. LINEAR = 9728,
  75009. NEAREST_MIPMAP_NEAREST = 9984,
  75010. LINEAR_MIPMAP_NEAREST = 9985,
  75011. NEAREST_MIPMAP_LINEAR = 9986,
  75012. LINEAR_MIPMAP_LINEAR = 9987
  75013. }
  75014. /** @hidden */
  75015. export enum ETextureFormat {
  75016. ALPHA = 6406,
  75017. RGB = 6407,
  75018. RGBA = 6408,
  75019. LUMINANCE = 6409,
  75020. LUMINANCE_ALPHA = 6410
  75021. }
  75022. /** @hidden */
  75023. export enum ECullingType {
  75024. FRONT = 1028,
  75025. BACK = 1029,
  75026. FRONT_AND_BACK = 1032
  75027. }
  75028. /** @hidden */
  75029. export enum EBlendingFunction {
  75030. ZERO = 0,
  75031. ONE = 1,
  75032. SRC_COLOR = 768,
  75033. ONE_MINUS_SRC_COLOR = 769,
  75034. DST_COLOR = 774,
  75035. ONE_MINUS_DST_COLOR = 775,
  75036. SRC_ALPHA = 770,
  75037. ONE_MINUS_SRC_ALPHA = 771,
  75038. DST_ALPHA = 772,
  75039. ONE_MINUS_DST_ALPHA = 773,
  75040. CONSTANT_COLOR = 32769,
  75041. ONE_MINUS_CONSTANT_COLOR = 32770,
  75042. CONSTANT_ALPHA = 32771,
  75043. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75044. SRC_ALPHA_SATURATE = 776
  75045. }
  75046. /** @hidden */
  75047. export interface IGLTFProperty {
  75048. extensions?: {
  75049. [key: string]: any;
  75050. };
  75051. extras?: Object;
  75052. }
  75053. /** @hidden */
  75054. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75055. name?: string;
  75056. }
  75057. /** @hidden */
  75058. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75059. bufferView: string;
  75060. byteOffset: number;
  75061. byteStride: number;
  75062. count: number;
  75063. type: string;
  75064. componentType: EComponentType;
  75065. max?: number[];
  75066. min?: number[];
  75067. name?: string;
  75068. }
  75069. /** @hidden */
  75070. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75071. buffer: string;
  75072. byteOffset: number;
  75073. byteLength: number;
  75074. byteStride: number;
  75075. target?: number;
  75076. }
  75077. /** @hidden */
  75078. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75079. uri: string;
  75080. byteLength?: number;
  75081. type?: string;
  75082. }
  75083. /** @hidden */
  75084. export interface IGLTFShader extends IGLTFChildRootProperty {
  75085. uri: string;
  75086. type: EShaderType;
  75087. }
  75088. /** @hidden */
  75089. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75090. attributes: string[];
  75091. fragmentShader: string;
  75092. vertexShader: string;
  75093. }
  75094. /** @hidden */
  75095. export interface IGLTFTechniqueParameter {
  75096. type: number;
  75097. count?: number;
  75098. semantic?: string;
  75099. node?: string;
  75100. value?: number | boolean | string | Array<any>;
  75101. source?: string;
  75102. babylonValue?: any;
  75103. }
  75104. /** @hidden */
  75105. export interface IGLTFTechniqueCommonProfile {
  75106. lightingModel: string;
  75107. texcoordBindings: Object;
  75108. parameters?: Array<any>;
  75109. }
  75110. /** @hidden */
  75111. export interface IGLTFTechniqueStatesFunctions {
  75112. blendColor?: number[];
  75113. blendEquationSeparate?: number[];
  75114. blendFuncSeparate?: number[];
  75115. colorMask: boolean[];
  75116. cullFace: number[];
  75117. }
  75118. /** @hidden */
  75119. export interface IGLTFTechniqueStates {
  75120. enable: number[];
  75121. functions: IGLTFTechniqueStatesFunctions;
  75122. }
  75123. /** @hidden */
  75124. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75125. parameters: {
  75126. [key: string]: IGLTFTechniqueParameter;
  75127. };
  75128. program: string;
  75129. attributes: {
  75130. [key: string]: string;
  75131. };
  75132. uniforms: {
  75133. [key: string]: string;
  75134. };
  75135. states: IGLTFTechniqueStates;
  75136. }
  75137. /** @hidden */
  75138. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75139. technique?: string;
  75140. values: string[];
  75141. }
  75142. /** @hidden */
  75143. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75144. attributes: {
  75145. [key: string]: string;
  75146. };
  75147. indices: string;
  75148. material: string;
  75149. mode?: number;
  75150. }
  75151. /** @hidden */
  75152. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75153. primitives: IGLTFMeshPrimitive[];
  75154. }
  75155. /** @hidden */
  75156. export interface IGLTFImage extends IGLTFChildRootProperty {
  75157. uri: string;
  75158. }
  75159. /** @hidden */
  75160. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75161. magFilter?: number;
  75162. minFilter?: number;
  75163. wrapS?: number;
  75164. wrapT?: number;
  75165. }
  75166. /** @hidden */
  75167. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75168. sampler: string;
  75169. source: string;
  75170. format?: ETextureFormat;
  75171. internalFormat?: ETextureFormat;
  75172. target?: number;
  75173. type?: number;
  75174. babylonTexture?: Texture;
  75175. }
  75176. /** @hidden */
  75177. export interface IGLTFAmbienLight {
  75178. color?: number[];
  75179. }
  75180. /** @hidden */
  75181. export interface IGLTFDirectionalLight {
  75182. color?: number[];
  75183. }
  75184. /** @hidden */
  75185. export interface IGLTFPointLight {
  75186. color?: number[];
  75187. constantAttenuation?: number;
  75188. linearAttenuation?: number;
  75189. quadraticAttenuation?: number;
  75190. }
  75191. /** @hidden */
  75192. export interface IGLTFSpotLight {
  75193. color?: number[];
  75194. constantAttenuation?: number;
  75195. fallOfAngle?: number;
  75196. fallOffExponent?: number;
  75197. linearAttenuation?: number;
  75198. quadraticAttenuation?: number;
  75199. }
  75200. /** @hidden */
  75201. export interface IGLTFLight extends IGLTFChildRootProperty {
  75202. type: string;
  75203. }
  75204. /** @hidden */
  75205. export interface IGLTFCameraOrthographic {
  75206. xmag: number;
  75207. ymag: number;
  75208. zfar: number;
  75209. znear: number;
  75210. }
  75211. /** @hidden */
  75212. export interface IGLTFCameraPerspective {
  75213. aspectRatio: number;
  75214. yfov: number;
  75215. zfar: number;
  75216. znear: number;
  75217. }
  75218. /** @hidden */
  75219. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75220. type: string;
  75221. }
  75222. /** @hidden */
  75223. export interface IGLTFAnimationChannelTarget {
  75224. id: string;
  75225. path: string;
  75226. }
  75227. /** @hidden */
  75228. export interface IGLTFAnimationChannel {
  75229. sampler: string;
  75230. target: IGLTFAnimationChannelTarget;
  75231. }
  75232. /** @hidden */
  75233. export interface IGLTFAnimationSampler {
  75234. input: string;
  75235. output: string;
  75236. interpolation?: string;
  75237. }
  75238. /** @hidden */
  75239. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75240. channels?: IGLTFAnimationChannel[];
  75241. parameters?: {
  75242. [key: string]: string;
  75243. };
  75244. samplers?: {
  75245. [key: string]: IGLTFAnimationSampler;
  75246. };
  75247. }
  75248. /** @hidden */
  75249. export interface IGLTFNodeInstanceSkin {
  75250. skeletons: string[];
  75251. skin: string;
  75252. meshes: string[];
  75253. }
  75254. /** @hidden */
  75255. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75256. bindShapeMatrix: number[];
  75257. inverseBindMatrices: string;
  75258. jointNames: string[];
  75259. babylonSkeleton?: Skeleton;
  75260. }
  75261. /** @hidden */
  75262. export interface IGLTFNode extends IGLTFChildRootProperty {
  75263. camera?: string;
  75264. children: string[];
  75265. skin?: string;
  75266. jointName?: string;
  75267. light?: string;
  75268. matrix: number[];
  75269. mesh?: string;
  75270. meshes?: string[];
  75271. rotation?: number[];
  75272. scale?: number[];
  75273. translation?: number[];
  75274. babylonNode?: Node;
  75275. }
  75276. /** @hidden */
  75277. export interface IGLTFScene extends IGLTFChildRootProperty {
  75278. nodes: string[];
  75279. }
  75280. /** @hidden */
  75281. export interface IGLTFRuntime {
  75282. extensions: {
  75283. [key: string]: any;
  75284. };
  75285. accessors: {
  75286. [key: string]: IGLTFAccessor;
  75287. };
  75288. buffers: {
  75289. [key: string]: IGLTFBuffer;
  75290. };
  75291. bufferViews: {
  75292. [key: string]: IGLTFBufferView;
  75293. };
  75294. meshes: {
  75295. [key: string]: IGLTFMesh;
  75296. };
  75297. lights: {
  75298. [key: string]: IGLTFLight;
  75299. };
  75300. cameras: {
  75301. [key: string]: IGLTFCamera;
  75302. };
  75303. nodes: {
  75304. [key: string]: IGLTFNode;
  75305. };
  75306. images: {
  75307. [key: string]: IGLTFImage;
  75308. };
  75309. textures: {
  75310. [key: string]: IGLTFTexture;
  75311. };
  75312. shaders: {
  75313. [key: string]: IGLTFShader;
  75314. };
  75315. programs: {
  75316. [key: string]: IGLTFProgram;
  75317. };
  75318. samplers: {
  75319. [key: string]: IGLTFSampler;
  75320. };
  75321. techniques: {
  75322. [key: string]: IGLTFTechnique;
  75323. };
  75324. materials: {
  75325. [key: string]: IGLTFMaterial;
  75326. };
  75327. animations: {
  75328. [key: string]: IGLTFAnimation;
  75329. };
  75330. skins: {
  75331. [key: string]: IGLTFSkins;
  75332. };
  75333. currentScene?: Object;
  75334. scenes: {
  75335. [key: string]: IGLTFScene;
  75336. };
  75337. extensionsUsed: string[];
  75338. extensionsRequired?: string[];
  75339. buffersCount: number;
  75340. shaderscount: number;
  75341. scene: Scene;
  75342. rootUrl: string;
  75343. loadedBufferCount: number;
  75344. loadedBufferViews: {
  75345. [name: string]: ArrayBufferView;
  75346. };
  75347. loadedShaderCount: number;
  75348. importOnlyMeshes: boolean;
  75349. importMeshesNames?: string[];
  75350. dummyNodes: Node[];
  75351. forAssetContainer: boolean;
  75352. }
  75353. /** @hidden */
  75354. export interface INodeToRoot {
  75355. bone: Bone;
  75356. node: IGLTFNode;
  75357. id: string;
  75358. }
  75359. /** @hidden */
  75360. export interface IJointNode {
  75361. node: IGLTFNode;
  75362. id: string;
  75363. }
  75364. }
  75365. declare module BABYLON.GLTF1 {
  75366. /**
  75367. * Utils functions for GLTF
  75368. * @hidden
  75369. */
  75370. export class GLTFUtils {
  75371. /**
  75372. * Sets the given "parameter" matrix
  75373. * @param scene: the Scene object
  75374. * @param source: the source node where to pick the matrix
  75375. * @param parameter: the GLTF technique parameter
  75376. * @param uniformName: the name of the shader's uniform
  75377. * @param shaderMaterial: the shader material
  75378. */
  75379. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75380. /**
  75381. * Sets the given "parameter" matrix
  75382. * @param shaderMaterial: the shader material
  75383. * @param uniform: the name of the shader's uniform
  75384. * @param value: the value of the uniform
  75385. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75386. */
  75387. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75388. /**
  75389. * Returns the wrap mode of the texture
  75390. * @param mode: the mode value
  75391. */
  75392. static GetWrapMode(mode: number): number;
  75393. /**
  75394. * Returns the byte stride giving an accessor
  75395. * @param accessor: the GLTF accessor objet
  75396. */
  75397. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75398. /**
  75399. * Returns the texture filter mode giving a mode value
  75400. * @param mode: the filter mode value
  75401. */
  75402. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75403. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75404. /**
  75405. * Returns a buffer from its accessor
  75406. * @param gltfRuntime: the GLTF runtime
  75407. * @param accessor: the GLTF accessor
  75408. */
  75409. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75410. /**
  75411. * Decodes a buffer view into a string
  75412. * @param view: the buffer view
  75413. */
  75414. static DecodeBufferToText(view: ArrayBufferView): string;
  75415. /**
  75416. * Returns the default material of gltf. Related to
  75417. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75418. * @param scene: the Babylon.js scene
  75419. */
  75420. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75421. private static _DefaultMaterial;
  75422. }
  75423. }
  75424. declare module BABYLON.GLTF1 {
  75425. /**
  75426. * Implementation of the base glTF spec
  75427. * @hidden
  75428. */
  75429. export class GLTFLoaderBase {
  75430. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75431. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75432. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75433. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75434. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75435. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75436. }
  75437. /**
  75438. * glTF V1 Loader
  75439. * @hidden
  75440. */
  75441. export class GLTFLoader implements IGLTFLoader {
  75442. static Extensions: {
  75443. [name: string]: GLTFLoaderExtension;
  75444. };
  75445. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75446. state: Nullable<GLTFLoaderState>;
  75447. dispose(): void;
  75448. private _importMeshAsync;
  75449. /**
  75450. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75451. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75452. * @param scene the scene the meshes should be added to
  75453. * @param forAssetContainer defines if the entities must be stored in the scene
  75454. * @param data gltf data containing information of the meshes in a loaded file
  75455. * @param rootUrl root url to load from
  75456. * @param onProgress event that fires when loading progress has occured
  75457. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75458. */
  75459. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75460. private _loadAsync;
  75461. /**
  75462. * Imports all objects from a loaded gltf file and adds them to the scene
  75463. * @param scene the scene the objects should be added to
  75464. * @param data gltf data containing information of the meshes in a loaded file
  75465. * @param rootUrl root url to load from
  75466. * @param onProgress event that fires when loading progress has occured
  75467. * @returns a promise which completes when objects have been loaded to the scene
  75468. */
  75469. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75470. private _loadShadersAsync;
  75471. private _loadBuffersAsync;
  75472. private _createNodes;
  75473. }
  75474. /** @hidden */
  75475. export abstract class GLTFLoaderExtension {
  75476. private _name;
  75477. constructor(name: string);
  75478. get name(): string;
  75479. /**
  75480. * Defines an override for loading the runtime
  75481. * Return true to stop further extensions from loading the runtime
  75482. */
  75483. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75484. /**
  75485. * Defines an onverride for creating gltf runtime
  75486. * Return true to stop further extensions from creating the runtime
  75487. */
  75488. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75489. /**
  75490. * Defines an override for loading buffers
  75491. * Return true to stop further extensions from loading this buffer
  75492. */
  75493. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  75494. /**
  75495. * Defines an override for loading texture buffers
  75496. * Return true to stop further extensions from loading this texture data
  75497. */
  75498. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75499. /**
  75500. * Defines an override for creating textures
  75501. * Return true to stop further extensions from loading this texture
  75502. */
  75503. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  75504. /**
  75505. * Defines an override for loading shader strings
  75506. * Return true to stop further extensions from loading this shader data
  75507. */
  75508. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75509. /**
  75510. * Defines an override for loading materials
  75511. * Return true to stop further extensions from loading this material
  75512. */
  75513. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75514. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75515. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75516. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75517. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75518. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75519. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75520. private static LoadTextureBufferAsync;
  75521. private static CreateTextureAsync;
  75522. private static ApplyExtensions;
  75523. }
  75524. }
  75525. declare module BABYLON.GLTF1 {
  75526. /** @hidden */
  75527. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75528. private _bin;
  75529. constructor();
  75530. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75531. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75532. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75533. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75534. }
  75535. }
  75536. declare module BABYLON.GLTF1 {
  75537. /** @hidden */
  75538. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75539. constructor();
  75540. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75541. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75542. private _loadTexture;
  75543. }
  75544. }
  75545. declare module BABYLON.GLTF2.Loader {
  75546. /**
  75547. * Loader interface with an index field.
  75548. */
  75549. export interface IArrayItem {
  75550. /**
  75551. * The index of this item in the array.
  75552. */
  75553. index: number;
  75554. }
  75555. /**
  75556. * Loader interface with additional members.
  75557. */
  75558. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75559. /** @hidden */
  75560. _data?: Promise<ArrayBufferView>;
  75561. /** @hidden */
  75562. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75563. }
  75564. /**
  75565. * Loader interface with additional members.
  75566. */
  75567. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75568. }
  75569. /** @hidden */
  75570. export interface _IAnimationSamplerData {
  75571. input: Float32Array;
  75572. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75573. output: Float32Array;
  75574. }
  75575. /**
  75576. * Loader interface with additional members.
  75577. */
  75578. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75579. /** @hidden */
  75580. _data?: Promise<_IAnimationSamplerData>;
  75581. }
  75582. /**
  75583. * Loader interface with additional members.
  75584. */
  75585. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75586. channels: IAnimationChannel[];
  75587. samplers: IAnimationSampler[];
  75588. /** @hidden */
  75589. _babylonAnimationGroup?: AnimationGroup;
  75590. }
  75591. /**
  75592. * Loader interface with additional members.
  75593. */
  75594. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75595. /** @hidden */
  75596. _data?: Promise<ArrayBufferView>;
  75597. }
  75598. /**
  75599. * Loader interface with additional members.
  75600. */
  75601. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75602. /** @hidden */
  75603. _data?: Promise<ArrayBufferView>;
  75604. /** @hidden */
  75605. _babylonBuffer?: Promise<Buffer>;
  75606. }
  75607. /**
  75608. * Loader interface with additional members.
  75609. */
  75610. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75611. }
  75612. /**
  75613. * Loader interface with additional members.
  75614. */
  75615. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75616. /** @hidden */
  75617. _data?: Promise<ArrayBufferView>;
  75618. }
  75619. /**
  75620. * Loader interface with additional members.
  75621. */
  75622. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75623. }
  75624. /**
  75625. * Loader interface with additional members.
  75626. */
  75627. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75628. }
  75629. /**
  75630. * Loader interface with additional members.
  75631. */
  75632. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75633. baseColorTexture?: ITextureInfo;
  75634. metallicRoughnessTexture?: ITextureInfo;
  75635. }
  75636. /**
  75637. * Loader interface with additional members.
  75638. */
  75639. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75640. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75641. normalTexture?: IMaterialNormalTextureInfo;
  75642. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75643. emissiveTexture?: ITextureInfo;
  75644. /** @hidden */
  75645. _data?: {
  75646. [babylonDrawMode: number]: {
  75647. babylonMaterial: Material;
  75648. babylonMeshes: AbstractMesh[];
  75649. promise: Promise<void>;
  75650. };
  75651. };
  75652. }
  75653. /**
  75654. * Loader interface with additional members.
  75655. */
  75656. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75657. primitives: IMeshPrimitive[];
  75658. }
  75659. /**
  75660. * Loader interface with additional members.
  75661. */
  75662. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75663. /** @hidden */
  75664. _instanceData?: {
  75665. babylonSourceMesh: Mesh;
  75666. promise: Promise<any>;
  75667. };
  75668. }
  75669. /**
  75670. * Loader interface with additional members.
  75671. */
  75672. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75673. /**
  75674. * The parent glTF node.
  75675. */
  75676. parent?: INode;
  75677. /** @hidden */
  75678. _babylonTransformNode?: TransformNode;
  75679. /** @hidden */
  75680. _primitiveBabylonMeshes?: AbstractMesh[];
  75681. /** @hidden */
  75682. _babylonBones?: Bone[];
  75683. /** @hidden */
  75684. _numMorphTargets?: number;
  75685. }
  75686. /** @hidden */
  75687. export interface _ISamplerData {
  75688. noMipMaps: boolean;
  75689. samplingMode: number;
  75690. wrapU: number;
  75691. wrapV: number;
  75692. }
  75693. /**
  75694. * Loader interface with additional members.
  75695. */
  75696. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75697. /** @hidden */
  75698. _data?: _ISamplerData;
  75699. }
  75700. /**
  75701. * Loader interface with additional members.
  75702. */
  75703. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75704. }
  75705. /**
  75706. * Loader interface with additional members.
  75707. */
  75708. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75709. /** @hidden */
  75710. _data?: {
  75711. babylonSkeleton: Skeleton;
  75712. promise: Promise<void>;
  75713. };
  75714. }
  75715. /**
  75716. * Loader interface with additional members.
  75717. */
  75718. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75719. }
  75720. /**
  75721. * Loader interface with additional members.
  75722. */
  75723. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75724. }
  75725. /**
  75726. * Loader interface with additional members.
  75727. */
  75728. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75729. accessors?: IAccessor[];
  75730. animations?: IAnimation[];
  75731. buffers?: IBuffer[];
  75732. bufferViews?: IBufferView[];
  75733. cameras?: ICamera[];
  75734. images?: IImage[];
  75735. materials?: IMaterial[];
  75736. meshes?: IMesh[];
  75737. nodes?: INode[];
  75738. samplers?: ISampler[];
  75739. scenes?: IScene[];
  75740. skins?: ISkin[];
  75741. textures?: ITexture[];
  75742. }
  75743. }
  75744. declare module BABYLON.GLTF2 {
  75745. /**
  75746. * Interface for a glTF loader extension.
  75747. */
  75748. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75749. /**
  75750. * Called after the loader state changes to LOADING.
  75751. */
  75752. onLoading?(): void;
  75753. /**
  75754. * Called after the loader state changes to READY.
  75755. */
  75756. onReady?(): void;
  75757. /**
  75758. * Define this method to modify the default behavior when loading scenes.
  75759. * @param context The context when loading the asset
  75760. * @param scene The glTF scene property
  75761. * @returns A promise that resolves when the load is complete or null if not handled
  75762. */
  75763. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75764. /**
  75765. * Define this method to modify the default behavior when loading nodes.
  75766. * @param context The context when loading the asset
  75767. * @param node The glTF node property
  75768. * @param assign A function called synchronously after parsing the glTF properties
  75769. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75770. */
  75771. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75772. /**
  75773. * Define this method to modify the default behavior when loading cameras.
  75774. * @param context The context when loading the asset
  75775. * @param camera The glTF camera property
  75776. * @param assign A function called synchronously after parsing the glTF properties
  75777. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75778. */
  75779. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75780. /**
  75781. * @hidden
  75782. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75783. * @param context The context when loading the asset
  75784. * @param primitive The glTF mesh primitive property
  75785. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75786. */
  75787. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75788. /**
  75789. * @hidden
  75790. * Define this method to modify the default behavior when loading data for mesh primitives.
  75791. * @param context The context when loading the asset
  75792. * @param name The mesh name when loading the asset
  75793. * @param node The glTF node when loading the asset
  75794. * @param mesh The glTF mesh when loading the asset
  75795. * @param primitive The glTF mesh primitive property
  75796. * @param assign A function called synchronously after parsing the glTF properties
  75797. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75798. */
  75799. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75800. /**
  75801. * @hidden
  75802. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  75803. * @param context The context when loading the asset
  75804. * @param material The glTF material property
  75805. * @param assign A function called synchronously after parsing the glTF properties
  75806. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  75807. */
  75808. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75809. /**
  75810. * Define this method to modify the default behavior when creating materials.
  75811. * @param context The context when loading the asset
  75812. * @param material The glTF material property
  75813. * @param babylonDrawMode The draw mode for the Babylon material
  75814. * @returns The Babylon material or null if not handled
  75815. */
  75816. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75817. /**
  75818. * Define this method to modify the default behavior when loading material properties.
  75819. * @param context The context when loading the asset
  75820. * @param material The glTF material property
  75821. * @param babylonMaterial The Babylon material
  75822. * @returns A promise that resolves when the load is complete or null if not handled
  75823. */
  75824. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75825. /**
  75826. * Define this method to modify the default behavior when loading texture infos.
  75827. * @param context The context when loading the asset
  75828. * @param textureInfo The glTF texture info property
  75829. * @param assign A function called synchronously after parsing the glTF properties
  75830. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75831. */
  75832. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75833. /**
  75834. * @hidden
  75835. * Define this method to modify the default behavior when loading textures.
  75836. * @param context The context when loading the asset
  75837. * @param texture The glTF texture property
  75838. * @param assign A function called synchronously after parsing the glTF properties
  75839. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75840. */
  75841. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75842. /**
  75843. * Define this method to modify the default behavior when loading animations.
  75844. * @param context The context when loading the asset
  75845. * @param animation The glTF animation property
  75846. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75847. */
  75848. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75849. /**
  75850. * @hidden
  75851. * Define this method to modify the default behavior when loading skins.
  75852. * @param context The context when loading the asset
  75853. * @param node The glTF node property
  75854. * @param skin The glTF skin property
  75855. * @returns A promise that resolves when the load is complete or null if not handled
  75856. */
  75857. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75858. /**
  75859. * @hidden
  75860. * Define this method to modify the default behavior when loading uris.
  75861. * @param context The context when loading the asset
  75862. * @param property The glTF property associated with the uri
  75863. * @param uri The uri to load
  75864. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75865. */
  75866. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75867. /**
  75868. * Define this method to modify the default behavior when loading buffer views.
  75869. * @param context The context when loading the asset
  75870. * @param bufferView The glTF buffer view property
  75871. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75872. */
  75873. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75874. /**
  75875. * Define this method to modify the default behavior when loading buffers.
  75876. * @param context The context when loading the asset
  75877. * @param buffer The glTF buffer property
  75878. * @param byteOffset The byte offset to load
  75879. * @param byteLength The byte length to load
  75880. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75881. */
  75882. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75883. }
  75884. }
  75885. declare module BABYLON.GLTF2 {
  75886. /**
  75887. * Helper class for working with arrays when loading the glTF asset
  75888. */
  75889. export class ArrayItem {
  75890. /**
  75891. * Gets an item from the given array.
  75892. * @param context The context when loading the asset
  75893. * @param array The array to get the item from
  75894. * @param index The index to the array
  75895. * @returns The array item
  75896. */
  75897. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75898. /**
  75899. * Assign an `index` field to each item of the given array.
  75900. * @param array The array of items
  75901. */
  75902. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75903. }
  75904. /**
  75905. * The glTF 2.0 loader
  75906. */
  75907. export class GLTFLoader implements IGLTFLoader {
  75908. /** @hidden */
  75909. _completePromises: Promise<any>[];
  75910. /** @hidden */
  75911. _forAssetContainer: boolean;
  75912. /** Storage */
  75913. _babylonLights: Light[];
  75914. private _disposed;
  75915. private _parent;
  75916. private _state;
  75917. private _extensions;
  75918. private _rootUrl;
  75919. private _fileName;
  75920. private _uniqueRootUrl;
  75921. private _gltf;
  75922. private _bin;
  75923. private _babylonScene;
  75924. private _rootBabylonMesh;
  75925. private _defaultBabylonMaterialData;
  75926. private _progressCallback?;
  75927. private _requests;
  75928. private static _RegisteredExtensions;
  75929. /**
  75930. * The default glTF sampler.
  75931. */
  75932. static readonly DefaultSampler: ISampler;
  75933. /**
  75934. * Registers a loader extension.
  75935. * @param name The name of the loader extension.
  75936. * @param factory The factory function that creates the loader extension.
  75937. */
  75938. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75939. /**
  75940. * Unregisters a loader extension.
  75941. * @param name The name of the loader extension.
  75942. * @returns A boolean indicating whether the extension has been unregistered
  75943. */
  75944. static UnregisterExtension(name: string): boolean;
  75945. /**
  75946. * The loader state.
  75947. */
  75948. get state(): Nullable<GLTFLoaderState>;
  75949. /**
  75950. * The object that represents the glTF JSON.
  75951. */
  75952. get gltf(): IGLTF;
  75953. /**
  75954. * The BIN chunk of a binary glTF.
  75955. */
  75956. get bin(): Nullable<IDataBuffer>;
  75957. /**
  75958. * The parent file loader.
  75959. */
  75960. get parent(): GLTFFileLoader;
  75961. /**
  75962. * The Babylon scene when loading the asset.
  75963. */
  75964. get babylonScene(): Scene;
  75965. /**
  75966. * The root Babylon mesh when loading the asset.
  75967. */
  75968. get rootBabylonMesh(): Mesh;
  75969. /** @hidden */
  75970. constructor(parent: GLTFFileLoader);
  75971. /** @hidden */
  75972. dispose(): void;
  75973. /** @hidden */
  75974. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  75975. /** @hidden */
  75976. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75977. private _loadAsync;
  75978. private _loadData;
  75979. private _setupData;
  75980. private _loadExtensions;
  75981. private _checkExtensions;
  75982. private _setState;
  75983. private _createRootNode;
  75984. /**
  75985. * Loads a glTF scene.
  75986. * @param context The context when loading the asset
  75987. * @param scene The glTF scene property
  75988. * @returns A promise that resolves when the load is complete
  75989. */
  75990. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75991. private _forEachPrimitive;
  75992. private _getMeshes;
  75993. private _getTransformNodes;
  75994. private _getSkeletons;
  75995. private _getAnimationGroups;
  75996. private _startAnimations;
  75997. /**
  75998. * Loads a glTF node.
  75999. * @param context The context when loading the asset
  76000. * @param node The glTF node property
  76001. * @param assign A function called synchronously after parsing the glTF properties
  76002. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76003. */
  76004. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76005. private _loadMeshAsync;
  76006. /**
  76007. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76008. * @param context The context when loading the asset
  76009. * @param name The mesh name when loading the asset
  76010. * @param node The glTF node when loading the asset
  76011. * @param mesh The glTF mesh when loading the asset
  76012. * @param primitive The glTF mesh primitive property
  76013. * @param assign A function called synchronously after parsing the glTF properties
  76014. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76015. */
  76016. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76017. private _loadVertexDataAsync;
  76018. private _createMorphTargets;
  76019. private _loadMorphTargetsAsync;
  76020. private _loadMorphTargetVertexDataAsync;
  76021. private static _LoadTransform;
  76022. private _loadSkinAsync;
  76023. private _loadBones;
  76024. private _loadBone;
  76025. private _loadSkinInverseBindMatricesDataAsync;
  76026. private _updateBoneMatrices;
  76027. private _getNodeMatrix;
  76028. /**
  76029. * Loads a glTF camera.
  76030. * @param context The context when loading the asset
  76031. * @param camera The glTF camera property
  76032. * @param assign A function called synchronously after parsing the glTF properties
  76033. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76034. */
  76035. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76036. private _loadAnimationsAsync;
  76037. /**
  76038. * Loads a glTF animation.
  76039. * @param context The context when loading the asset
  76040. * @param animation The glTF animation property
  76041. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76042. */
  76043. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76044. /**
  76045. * @hidden Loads a glTF animation channel.
  76046. * @param context The context when loading the asset
  76047. * @param animationContext The context of the animation when loading the asset
  76048. * @param animation The glTF animation property
  76049. * @param channel The glTF animation channel property
  76050. * @param babylonAnimationGroup The babylon animation group property
  76051. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76052. * @returns A void promise when the channel load is complete
  76053. */
  76054. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76055. private _loadAnimationSamplerAsync;
  76056. private _loadBufferAsync;
  76057. /**
  76058. * Loads a glTF buffer view.
  76059. * @param context The context when loading the asset
  76060. * @param bufferView The glTF buffer view property
  76061. * @returns A promise that resolves with the loaded data when the load is complete
  76062. */
  76063. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76064. private _loadAccessorAsync;
  76065. /** @hidden */
  76066. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76067. private _loadIndicesAccessorAsync;
  76068. private _loadVertexBufferViewAsync;
  76069. private _loadVertexAccessorAsync;
  76070. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76071. /** @hidden */
  76072. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76073. private _createDefaultMaterial;
  76074. /**
  76075. * Creates a Babylon material from a glTF material.
  76076. * @param context The context when loading the asset
  76077. * @param material The glTF material property
  76078. * @param babylonDrawMode The draw mode for the Babylon material
  76079. * @returns The Babylon material
  76080. */
  76081. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76082. /**
  76083. * Loads properties from a glTF material into a Babylon material.
  76084. * @param context The context when loading the asset
  76085. * @param material The glTF material property
  76086. * @param babylonMaterial The Babylon material
  76087. * @returns A promise that resolves when the load is complete
  76088. */
  76089. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76090. /**
  76091. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76092. * @param context The context when loading the asset
  76093. * @param material The glTF material property
  76094. * @param babylonMaterial The Babylon material
  76095. * @returns A promise that resolves when the load is complete
  76096. */
  76097. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76098. /**
  76099. * Loads the alpha properties from a glTF material into a Babylon material.
  76100. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76101. * @param context The context when loading the asset
  76102. * @param material The glTF material property
  76103. * @param babylonMaterial The Babylon material
  76104. */
  76105. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76106. /**
  76107. * Loads a glTF texture info.
  76108. * @param context The context when loading the asset
  76109. * @param textureInfo The glTF texture info property
  76110. * @param assign A function called synchronously after parsing the glTF properties
  76111. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76112. */
  76113. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76114. /** @hidden */
  76115. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76116. /** @hidden */
  76117. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76118. private _loadSampler;
  76119. /**
  76120. * Loads a glTF image.
  76121. * @param context The context when loading the asset
  76122. * @param image The glTF image property
  76123. * @returns A promise that resolves with the loaded data when the load is complete
  76124. */
  76125. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76126. /**
  76127. * Loads a glTF uri.
  76128. * @param context The context when loading the asset
  76129. * @param property The glTF property associated with the uri
  76130. * @param uri The base64 or relative uri
  76131. * @returns A promise that resolves with the loaded data when the load is complete
  76132. */
  76133. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76134. private _onProgress;
  76135. /**
  76136. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76137. * @param babylonObject the Babylon object with metadata
  76138. * @param pointer the JSON pointer
  76139. */
  76140. static AddPointerMetadata(babylonObject: {
  76141. metadata: any;
  76142. }, pointer: string): void;
  76143. private static _GetTextureWrapMode;
  76144. private static _GetTextureSamplingMode;
  76145. private static _GetTypedArrayConstructor;
  76146. private static _GetTypedArray;
  76147. private static _GetNumComponents;
  76148. private static _ValidateUri;
  76149. private static _GetDrawMode;
  76150. private _compileMaterialsAsync;
  76151. private _compileShadowGeneratorsAsync;
  76152. private _forEachExtensions;
  76153. private _applyExtensions;
  76154. private _extensionsOnLoading;
  76155. private _extensionsOnReady;
  76156. private _extensionsLoadSceneAsync;
  76157. private _extensionsLoadNodeAsync;
  76158. private _extensionsLoadCameraAsync;
  76159. private _extensionsLoadVertexDataAsync;
  76160. private _extensionsLoadMeshPrimitiveAsync;
  76161. private _extensionsLoadMaterialAsync;
  76162. private _extensionsCreateMaterial;
  76163. private _extensionsLoadMaterialPropertiesAsync;
  76164. private _extensionsLoadTextureInfoAsync;
  76165. private _extensionsLoadTextureAsync;
  76166. private _extensionsLoadAnimationAsync;
  76167. private _extensionsLoadSkinAsync;
  76168. private _extensionsLoadUriAsync;
  76169. private _extensionsLoadBufferViewAsync;
  76170. private _extensionsLoadBufferAsync;
  76171. /**
  76172. * Helper method called by a loader extension to load an glTF extension.
  76173. * @param context The context when loading the asset
  76174. * @param property The glTF property to load the extension from
  76175. * @param extensionName The name of the extension to load
  76176. * @param actionAsync The action to run
  76177. * @returns The promise returned by actionAsync or null if the extension does not exist
  76178. */
  76179. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76180. /**
  76181. * Helper method called by a loader extension to load a glTF extra.
  76182. * @param context The context when loading the asset
  76183. * @param property The glTF property to load the extra from
  76184. * @param extensionName The name of the extension to load
  76185. * @param actionAsync The action to run
  76186. * @returns The promise returned by actionAsync or null if the extra does not exist
  76187. */
  76188. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76189. /**
  76190. * Checks for presence of an extension.
  76191. * @param name The name of the extension to check
  76192. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76193. */
  76194. isExtensionUsed(name: string): boolean;
  76195. /**
  76196. * Increments the indentation level and logs a message.
  76197. * @param message The message to log
  76198. */
  76199. logOpen(message: string): void;
  76200. /**
  76201. * Decrements the indentation level.
  76202. */
  76203. logClose(): void;
  76204. /**
  76205. * Logs a message
  76206. * @param message The message to log
  76207. */
  76208. log(message: string): void;
  76209. /**
  76210. * Starts a performance counter.
  76211. * @param counterName The name of the performance counter
  76212. */
  76213. startPerformanceCounter(counterName: string): void;
  76214. /**
  76215. * Ends a performance counter.
  76216. * @param counterName The name of the performance counter
  76217. */
  76218. endPerformanceCounter(counterName: string): void;
  76219. }
  76220. }
  76221. declare module BABYLON.GLTF2.Loader.Extensions {
  76222. /**
  76223. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76224. */
  76225. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76226. /**
  76227. * The name of this extension.
  76228. */
  76229. readonly name: string;
  76230. /**
  76231. * Defines whether this extension is enabled.
  76232. */
  76233. enabled: boolean;
  76234. private _loader;
  76235. private _lights?;
  76236. /** @hidden */
  76237. constructor(loader: GLTFLoader);
  76238. /** @hidden */
  76239. dispose(): void;
  76240. /** @hidden */
  76241. onLoading(): void;
  76242. /** @hidden */
  76243. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76244. private _loadLightAsync;
  76245. }
  76246. }
  76247. declare module BABYLON.GLTF2.Loader.Extensions {
  76248. /**
  76249. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76250. */
  76251. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76252. /**
  76253. * The name of this extension.
  76254. */
  76255. readonly name: string;
  76256. /**
  76257. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76258. */
  76259. dracoCompression?: DracoCompression;
  76260. /**
  76261. * Defines whether this extension is enabled.
  76262. */
  76263. enabled: boolean;
  76264. private _loader;
  76265. /** @hidden */
  76266. constructor(loader: GLTFLoader);
  76267. /** @hidden */
  76268. dispose(): void;
  76269. /** @hidden */
  76270. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76271. }
  76272. }
  76273. declare module BABYLON.GLTF2.Loader.Extensions {
  76274. /**
  76275. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76276. */
  76277. export class KHR_lights implements IGLTFLoaderExtension {
  76278. /**
  76279. * The name of this extension.
  76280. */
  76281. readonly name: string;
  76282. /**
  76283. * Defines whether this extension is enabled.
  76284. */
  76285. enabled: boolean;
  76286. private _loader;
  76287. private _lights?;
  76288. /** @hidden */
  76289. constructor(loader: GLTFLoader);
  76290. /** @hidden */
  76291. dispose(): void;
  76292. /** @hidden */
  76293. onLoading(): void;
  76294. /** @hidden */
  76295. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76296. }
  76297. }
  76298. declare module BABYLON.GLTF2.Loader.Extensions {
  76299. /**
  76300. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76301. */
  76302. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76303. /**
  76304. * The name of this extension.
  76305. */
  76306. readonly name: string;
  76307. /**
  76308. * Defines whether this extension is enabled.
  76309. */
  76310. enabled: boolean;
  76311. /**
  76312. * Defines a number that determines the order the extensions are applied.
  76313. */
  76314. order: number;
  76315. private _loader;
  76316. /** @hidden */
  76317. constructor(loader: GLTFLoader);
  76318. /** @hidden */
  76319. dispose(): void;
  76320. /** @hidden */
  76321. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76322. private _loadSpecularGlossinessPropertiesAsync;
  76323. }
  76324. }
  76325. declare module BABYLON.GLTF2.Loader.Extensions {
  76326. /**
  76327. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76328. */
  76329. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76330. /**
  76331. * The name of this extension.
  76332. */
  76333. readonly name: string;
  76334. /**
  76335. * Defines whether this extension is enabled.
  76336. */
  76337. enabled: boolean;
  76338. /**
  76339. * Defines a number that determines the order the extensions are applied.
  76340. */
  76341. order: number;
  76342. private _loader;
  76343. /** @hidden */
  76344. constructor(loader: GLTFLoader);
  76345. /** @hidden */
  76346. dispose(): void;
  76347. /** @hidden */
  76348. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76349. private _loadUnlitPropertiesAsync;
  76350. }
  76351. }
  76352. declare module BABYLON.GLTF2.Loader.Extensions {
  76353. /**
  76354. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76355. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76356. * !!! Experimental Extension Subject to Changes !!!
  76357. */
  76358. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76359. /**
  76360. * The name of this extension.
  76361. */
  76362. readonly name: string;
  76363. /**
  76364. * Defines whether this extension is enabled.
  76365. */
  76366. enabled: boolean;
  76367. /**
  76368. * Defines a number that determines the order the extensions are applied.
  76369. */
  76370. order: number;
  76371. private _loader;
  76372. /** @hidden */
  76373. constructor(loader: GLTFLoader);
  76374. /** @hidden */
  76375. dispose(): void;
  76376. /** @hidden */
  76377. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76378. private _loadClearCoatPropertiesAsync;
  76379. }
  76380. }
  76381. declare module BABYLON.GLTF2.Loader.Extensions {
  76382. /**
  76383. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76384. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76385. * !!! Experimental Extension Subject to Changes !!!
  76386. */
  76387. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76388. /**
  76389. * The name of this extension.
  76390. */
  76391. readonly name: string;
  76392. /**
  76393. * Defines whether this extension is enabled.
  76394. */
  76395. enabled: boolean;
  76396. /**
  76397. * Defines a number that determines the order the extensions are applied.
  76398. */
  76399. order: number;
  76400. private _loader;
  76401. /** @hidden */
  76402. constructor(loader: GLTFLoader);
  76403. /** @hidden */
  76404. dispose(): void;
  76405. /** @hidden */
  76406. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76407. private _loadSheenPropertiesAsync;
  76408. }
  76409. }
  76410. declare module BABYLON.GLTF2.Loader.Extensions {
  76411. /**
  76412. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76413. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76414. * !!! Experimental Extension Subject to Changes !!!
  76415. */
  76416. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76417. /**
  76418. * The name of this extension.
  76419. */
  76420. readonly name: string;
  76421. /**
  76422. * Defines whether this extension is enabled.
  76423. */
  76424. enabled: boolean;
  76425. /**
  76426. * Defines a number that determines the order the extensions are applied.
  76427. */
  76428. order: number;
  76429. private _loader;
  76430. /** @hidden */
  76431. constructor(loader: GLTFLoader);
  76432. /** @hidden */
  76433. dispose(): void;
  76434. /** @hidden */
  76435. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76436. private _loadSpecularPropertiesAsync;
  76437. }
  76438. }
  76439. declare module BABYLON.GLTF2.Loader.Extensions {
  76440. /**
  76441. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76442. * [Playground Sample](//TODO)
  76443. * !!! Experimental Extension Subject to Changes !!!
  76444. */
  76445. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76446. /**
  76447. * The name of this extension.
  76448. */
  76449. readonly name: string;
  76450. /**
  76451. * Defines whether this extension is enabled.
  76452. */
  76453. enabled: boolean;
  76454. private _loader;
  76455. /** @hidden */
  76456. constructor(loader: GLTFLoader);
  76457. /** @hidden */
  76458. dispose(): void;
  76459. /** @hidden */
  76460. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76461. }
  76462. }
  76463. declare module BABYLON.GLTF2.Loader.Extensions {
  76464. /**
  76465. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76466. */
  76467. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76468. /**
  76469. * The name of this extension.
  76470. */
  76471. readonly name: string;
  76472. /**
  76473. * Defines whether this extension is enabled.
  76474. */
  76475. enabled: boolean;
  76476. /** @hidden */
  76477. constructor(loader: GLTFLoader);
  76478. /** @hidden */
  76479. dispose(): void;
  76480. }
  76481. }
  76482. declare module BABYLON.GLTF2.Loader.Extensions {
  76483. /**
  76484. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76485. * !!! Experimental Extension Subject to Changes !!!
  76486. */
  76487. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  76488. /** The name of this extension. */
  76489. readonly name: string;
  76490. /** Defines whether this extension is enabled. */
  76491. enabled: boolean;
  76492. private _loader;
  76493. /** @hidden */
  76494. constructor(loader: GLTFLoader);
  76495. /** @hidden */
  76496. dispose(): void;
  76497. /** @hidden */
  76498. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76499. }
  76500. }
  76501. declare module BABYLON.GLTF2.Loader.Extensions {
  76502. /**
  76503. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  76504. */
  76505. export class KHR_texture_transform implements IGLTFLoaderExtension {
  76506. /**
  76507. * The name of this extension.
  76508. */
  76509. readonly name: string;
  76510. /**
  76511. * Defines whether this extension is enabled.
  76512. */
  76513. enabled: boolean;
  76514. private _loader;
  76515. /** @hidden */
  76516. constructor(loader: GLTFLoader);
  76517. /** @hidden */
  76518. dispose(): void;
  76519. /** @hidden */
  76520. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76521. }
  76522. }
  76523. declare module BABYLON.GLTF2.Loader.Extensions {
  76524. /**
  76525. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  76526. */
  76527. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  76528. /**
  76529. * The name of this extension.
  76530. */
  76531. readonly name: string;
  76532. /**
  76533. * Defines whether this extension is enabled.
  76534. */
  76535. enabled: boolean;
  76536. private _loader;
  76537. private _clips;
  76538. private _emitters;
  76539. /** @hidden */
  76540. constructor(loader: GLTFLoader);
  76541. /** @hidden */
  76542. dispose(): void;
  76543. /** @hidden */
  76544. onLoading(): void;
  76545. /** @hidden */
  76546. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76547. /** @hidden */
  76548. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76549. /** @hidden */
  76550. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76551. private _loadClipAsync;
  76552. private _loadEmitterAsync;
  76553. private _getEventAction;
  76554. private _loadAnimationEventAsync;
  76555. }
  76556. }
  76557. declare module BABYLON.GLTF2.Loader.Extensions {
  76558. /**
  76559. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76560. */
  76561. export class MSFT_lod implements IGLTFLoaderExtension {
  76562. /**
  76563. * The name of this extension.
  76564. */
  76565. readonly name: string;
  76566. /**
  76567. * Defines whether this extension is enabled.
  76568. */
  76569. enabled: boolean;
  76570. /**
  76571. * Defines a number that determines the order the extensions are applied.
  76572. */
  76573. order: number;
  76574. /**
  76575. * Maximum number of LODs to load, starting from the lowest LOD.
  76576. */
  76577. maxLODsToLoad: number;
  76578. /**
  76579. * Observable raised when all node LODs of one level are loaded.
  76580. * The event data is the index of the loaded LOD starting from zero.
  76581. * Dispose the loader to cancel the loading of the next level of LODs.
  76582. */
  76583. onNodeLODsLoadedObservable: Observable<number>;
  76584. /**
  76585. * Observable raised when all material LODs of one level are loaded.
  76586. * The event data is the index of the loaded LOD starting from zero.
  76587. * Dispose the loader to cancel the loading of the next level of LODs.
  76588. */
  76589. onMaterialLODsLoadedObservable: Observable<number>;
  76590. private _loader;
  76591. private _nodeIndexLOD;
  76592. private _nodeSignalLODs;
  76593. private _nodePromiseLODs;
  76594. private _materialIndexLOD;
  76595. private _materialSignalLODs;
  76596. private _materialPromiseLODs;
  76597. private _indexLOD;
  76598. private _bufferLODs;
  76599. /** @hidden */
  76600. constructor(loader: GLTFLoader);
  76601. /** @hidden */
  76602. dispose(): void;
  76603. /** @hidden */
  76604. onReady(): void;
  76605. /** @hidden */
  76606. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76607. /** @hidden */
  76608. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76609. /** @hidden */
  76610. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76611. /** @hidden */
  76612. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76613. /** @hidden */
  76614. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76615. private _loadBufferLOD;
  76616. /**
  76617. * Gets an array of LOD properties from lowest to highest.
  76618. */
  76619. private _getLODs;
  76620. private _disposeTransformNode;
  76621. private _disposeMaterials;
  76622. }
  76623. }
  76624. declare module BABYLON.GLTF2.Loader.Extensions {
  76625. /** @hidden */
  76626. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76627. readonly name: string;
  76628. enabled: boolean;
  76629. private _loader;
  76630. constructor(loader: GLTFLoader);
  76631. dispose(): void;
  76632. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76633. }
  76634. }
  76635. declare module BABYLON.GLTF2.Loader.Extensions {
  76636. /** @hidden */
  76637. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76638. readonly name: string;
  76639. enabled: boolean;
  76640. private _loader;
  76641. constructor(loader: GLTFLoader);
  76642. dispose(): void;
  76643. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76644. }
  76645. }
  76646. declare module BABYLON.GLTF2.Loader.Extensions {
  76647. /**
  76648. * Store glTF extras (if present) in BJS objects' metadata
  76649. */
  76650. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76651. /**
  76652. * The name of this extension.
  76653. */
  76654. readonly name: string;
  76655. /**
  76656. * Defines whether this extension is enabled.
  76657. */
  76658. enabled: boolean;
  76659. private _loader;
  76660. private _assignExtras;
  76661. /** @hidden */
  76662. constructor(loader: GLTFLoader);
  76663. /** @hidden */
  76664. dispose(): void;
  76665. /** @hidden */
  76666. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76667. /** @hidden */
  76668. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76669. /** @hidden */
  76670. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76671. }
  76672. }
  76673. declare module BABYLON {
  76674. /**
  76675. * Class reading and parsing the MTL file bundled with the obj file.
  76676. */
  76677. export class MTLFileLoader {
  76678. /**
  76679. * Invert Y-Axis of referenced textures on load
  76680. */
  76681. static INVERT_TEXTURE_Y: boolean;
  76682. /**
  76683. * All material loaded from the mtl will be set here
  76684. */
  76685. materials: StandardMaterial[];
  76686. /**
  76687. * This function will read the mtl file and create each material described inside
  76688. * This function could be improve by adding :
  76689. * -some component missing (Ni, Tf...)
  76690. * -including the specific options available
  76691. *
  76692. * @param scene defines the scene the material will be created in
  76693. * @param data defines the mtl data to parse
  76694. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76695. * @param forAssetContainer defines if the material should be registered in the scene
  76696. */
  76697. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  76698. /**
  76699. * Gets the texture for the material.
  76700. *
  76701. * If the material is imported from input file,
  76702. * We sanitize the url to ensure it takes the textre from aside the material.
  76703. *
  76704. * @param rootUrl The root url to load from
  76705. * @param value The value stored in the mtl
  76706. * @return The Texture
  76707. */
  76708. private static _getTexture;
  76709. }
  76710. }
  76711. declare module BABYLON {
  76712. /**
  76713. * Options for loading OBJ/MTL files
  76714. */
  76715. type MeshLoadOptions = {
  76716. /**
  76717. * Defines if UVs are optimized by default during load.
  76718. */
  76719. OptimizeWithUV: boolean;
  76720. /**
  76721. * Defines custom scaling of UV coordinates of loaded meshes.
  76722. */
  76723. UVScaling: Vector2;
  76724. /**
  76725. * Invert model on y-axis (does a model scaling inversion)
  76726. */
  76727. InvertY: boolean;
  76728. /**
  76729. * Invert Y-Axis of referenced textures on load
  76730. */
  76731. InvertTextureY: boolean;
  76732. /**
  76733. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76734. */
  76735. ImportVertexColors: boolean;
  76736. /**
  76737. * Compute the normals for the model, even if normals are present in the file.
  76738. */
  76739. ComputeNormals: boolean;
  76740. /**
  76741. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76742. */
  76743. SkipMaterials: boolean;
  76744. /**
  76745. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76746. */
  76747. MaterialLoadingFailsSilently: boolean;
  76748. };
  76749. /**
  76750. * OBJ file type loader.
  76751. * This is a babylon scene loader plugin.
  76752. */
  76753. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76754. /**
  76755. * Defines if UVs are optimized by default during load.
  76756. */
  76757. static OPTIMIZE_WITH_UV: boolean;
  76758. /**
  76759. * Invert model on y-axis (does a model scaling inversion)
  76760. */
  76761. static INVERT_Y: boolean;
  76762. /**
  76763. * Invert Y-Axis of referenced textures on load
  76764. */
  76765. static get INVERT_TEXTURE_Y(): boolean;
  76766. static set INVERT_TEXTURE_Y(value: boolean);
  76767. /**
  76768. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76769. */
  76770. static IMPORT_VERTEX_COLORS: boolean;
  76771. /**
  76772. * Compute the normals for the model, even if normals are present in the file.
  76773. */
  76774. static COMPUTE_NORMALS: boolean;
  76775. /**
  76776. * Defines custom scaling of UV coordinates of loaded meshes.
  76777. */
  76778. static UV_SCALING: Vector2;
  76779. /**
  76780. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76781. */
  76782. static SKIP_MATERIALS: boolean;
  76783. /**
  76784. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76785. *
  76786. * Defaults to true for backwards compatibility.
  76787. */
  76788. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  76789. /**
  76790. * Defines the name of the plugin.
  76791. */
  76792. name: string;
  76793. /**
  76794. * Defines the extension the plugin is able to load.
  76795. */
  76796. extensions: string;
  76797. /** @hidden */
  76798. obj: RegExp;
  76799. /** @hidden */
  76800. group: RegExp;
  76801. /** @hidden */
  76802. mtllib: RegExp;
  76803. /** @hidden */
  76804. usemtl: RegExp;
  76805. /** @hidden */
  76806. smooth: RegExp;
  76807. /** @hidden */
  76808. vertexPattern: RegExp;
  76809. /** @hidden */
  76810. normalPattern: RegExp;
  76811. /** @hidden */
  76812. uvPattern: RegExp;
  76813. /** @hidden */
  76814. facePattern1: RegExp;
  76815. /** @hidden */
  76816. facePattern2: RegExp;
  76817. /** @hidden */
  76818. facePattern3: RegExp;
  76819. /** @hidden */
  76820. facePattern4: RegExp;
  76821. /** @hidden */
  76822. facePattern5: RegExp;
  76823. private _forAssetContainer;
  76824. private _meshLoadOptions;
  76825. /**
  76826. * Creates loader for .OBJ files
  76827. *
  76828. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  76829. */
  76830. constructor(meshLoadOptions?: MeshLoadOptions);
  76831. private static get currentMeshLoadOptions();
  76832. /**
  76833. * Calls synchronously the MTL file attached to this obj.
  76834. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  76835. * Without this function materials are not displayed in the first frame (but displayed after).
  76836. * In consequence it is impossible to get material information in your HTML file
  76837. *
  76838. * @param url The URL of the MTL file
  76839. * @param rootUrl
  76840. * @param onSuccess Callback function to be called when the MTL file is loaded
  76841. * @private
  76842. */
  76843. private _loadMTL;
  76844. /**
  76845. * Instantiates a OBJ file loader plugin.
  76846. * @returns the created plugin
  76847. */
  76848. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  76849. /**
  76850. * If the data string can be loaded directly.
  76851. *
  76852. * @param data string containing the file data
  76853. * @returns if the data can be loaded directly
  76854. */
  76855. canDirectLoad(data: string): boolean;
  76856. /**
  76857. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  76858. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76859. * @param scene the scene the meshes should be added to
  76860. * @param data the OBJ data to load
  76861. * @param rootUrl root url to load from
  76862. * @param onProgress event that fires when loading progress has occured
  76863. * @param fileName Defines the name of the file to load
  76864. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76865. */
  76866. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76867. meshes: AbstractMesh[];
  76868. particleSystems: IParticleSystem[];
  76869. skeletons: Skeleton[];
  76870. animationGroups: AnimationGroup[];
  76871. }>;
  76872. /**
  76873. * Imports all objects from the loaded OBJ data and adds them to the scene
  76874. * @param scene the scene the objects should be added to
  76875. * @param data the OBJ data to load
  76876. * @param rootUrl root url to load from
  76877. * @param onProgress event that fires when loading progress has occured
  76878. * @param fileName Defines the name of the file to load
  76879. * @returns a promise which completes when objects have been loaded to the scene
  76880. */
  76881. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76882. /**
  76883. * Load into an asset container.
  76884. * @param scene The scene to load into
  76885. * @param data The data to import
  76886. * @param rootUrl The root url for scene and resources
  76887. * @param onProgress The callback when the load progresses
  76888. * @param fileName Defines the name of the file to load
  76889. * @returns The loaded asset container
  76890. */
  76891. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76892. /**
  76893. * Read the OBJ file and create an Array of meshes.
  76894. * Each mesh contains all information given by the OBJ and the MTL file.
  76895. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76896. *
  76897. * @param meshesNames
  76898. * @param scene Scene The scene where are displayed the data
  76899. * @param data String The content of the obj file
  76900. * @param rootUrl String The path to the folder
  76901. * @returns Array<AbstractMesh>
  76902. * @private
  76903. */
  76904. private _parseSolid;
  76905. }
  76906. }
  76907. declare module BABYLON {
  76908. /**
  76909. * STL file type loader.
  76910. * This is a babylon scene loader plugin.
  76911. */
  76912. export class STLFileLoader implements ISceneLoaderPlugin {
  76913. /** @hidden */
  76914. solidPattern: RegExp;
  76915. /** @hidden */
  76916. facetsPattern: RegExp;
  76917. /** @hidden */
  76918. normalPattern: RegExp;
  76919. /** @hidden */
  76920. vertexPattern: RegExp;
  76921. /**
  76922. * Defines the name of the plugin.
  76923. */
  76924. name: string;
  76925. /**
  76926. * Defines the extensions the stl loader is able to load.
  76927. * force data to come in as an ArrayBuffer
  76928. * we'll convert to string if it looks like it's an ASCII .stl
  76929. */
  76930. extensions: ISceneLoaderPluginExtensions;
  76931. /**
  76932. * Import meshes into a scene.
  76933. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76934. * @param scene The scene to import into
  76935. * @param data The data to import
  76936. * @param rootUrl The root url for scene and resources
  76937. * @param meshes The meshes array to import into
  76938. * @param particleSystems The particle systems array to import into
  76939. * @param skeletons The skeletons array to import into
  76940. * @param onError The callback when import fails
  76941. * @returns True if successful or false otherwise
  76942. */
  76943. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76944. /**
  76945. * Load into a scene.
  76946. * @param scene The scene to load into
  76947. * @param data The data to import
  76948. * @param rootUrl The root url for scene and resources
  76949. * @param onError The callback when import fails
  76950. * @returns true if successful or false otherwise
  76951. */
  76952. load(scene: Scene, data: any, rootUrl: string): boolean;
  76953. /**
  76954. * Load into an asset container.
  76955. * @param scene The scene to load into
  76956. * @param data The data to import
  76957. * @param rootUrl The root url for scene and resources
  76958. * @param onError The callback when import fails
  76959. * @returns The loaded asset container
  76960. */
  76961. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76962. private _isBinary;
  76963. private _parseBinary;
  76964. private _parseASCII;
  76965. }
  76966. }
  76967. declare module BABYLON {
  76968. /**
  76969. * Class for generating OBJ data from a Babylon scene.
  76970. */
  76971. export class OBJExport {
  76972. /**
  76973. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76974. * @param mesh defines the list of meshes to serialize
  76975. * @param materials defines if materials should be exported
  76976. * @param matlibname defines the name of the associated mtl file
  76977. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76978. * @returns the OBJ content
  76979. */
  76980. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76981. /**
  76982. * Exports the material(s) of a mesh in .MTL file format (text)
  76983. * @param mesh defines the mesh to extract the material from
  76984. * @returns the mtl content
  76985. */
  76986. static MTL(mesh: Mesh): string;
  76987. }
  76988. }
  76989. declare module BABYLON {
  76990. /** @hidden */
  76991. export var __IGLTFExporterExtension: number;
  76992. /**
  76993. * Interface for extending the exporter
  76994. * @hidden
  76995. */
  76996. export interface IGLTFExporterExtension {
  76997. /**
  76998. * The name of this extension
  76999. */
  77000. readonly name: string;
  77001. /**
  77002. * Defines whether this extension is enabled
  77003. */
  77004. enabled: boolean;
  77005. /**
  77006. * Defines whether this extension is required
  77007. */
  77008. required: boolean;
  77009. }
  77010. }
  77011. declare module BABYLON.GLTF2.Exporter {
  77012. /** @hidden */
  77013. export var __IGLTFExporterExtensionV2: number;
  77014. /**
  77015. * Interface for a glTF exporter extension
  77016. * @hidden
  77017. */
  77018. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77019. /**
  77020. * Define this method to modify the default behavior before exporting a texture
  77021. * @param context The context when loading the asset
  77022. * @param babylonTexture The Babylon.js texture
  77023. * @param mimeType The mime-type of the generated image
  77024. * @returns A promise that resolves with the exported texture
  77025. */
  77026. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77027. /**
  77028. * Define this method to get notified when a texture info is created
  77029. * @param context The context when loading the asset
  77030. * @param textureInfo The glTF texture info
  77031. * @param babylonTexture The Babylon.js texture
  77032. */
  77033. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77034. /**
  77035. * Define this method to modify the default behavior when exporting texture info
  77036. * @param context The context when loading the asset
  77037. * @param meshPrimitive glTF mesh primitive
  77038. * @param babylonSubMesh Babylon submesh
  77039. * @param binaryWriter glTF serializer binary writer instance
  77040. * @returns nullable IMeshPrimitive promise
  77041. */
  77042. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77043. /**
  77044. * Define this method to modify the default behavior when exporting a node
  77045. * @param context The context when exporting the node
  77046. * @param node glTF node
  77047. * @param babylonNode BabylonJS node
  77048. * @returns nullable INode promise
  77049. */
  77050. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77051. [key: number]: number;
  77052. }): Promise<Nullable<INode>>;
  77053. /**
  77054. * Define this method to modify the default behavior when exporting a material
  77055. * @param material glTF material
  77056. * @param babylonMaterial BabylonJS material
  77057. * @returns nullable IMaterial promise
  77058. */
  77059. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77060. /**
  77061. * Define this method to return additional textures to export from a material
  77062. * @param material glTF material
  77063. * @param babylonMaterial BabylonJS material
  77064. * @returns List of textures
  77065. */
  77066. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77067. /** Gets a boolean indicating that this extension was used */
  77068. wasUsed: boolean;
  77069. /** Gets a boolean indicating that this extension is required for the file to work */
  77070. required: boolean;
  77071. /**
  77072. * Called after the exporter state changes to EXPORTING
  77073. */
  77074. onExporting?(): void;
  77075. }
  77076. }
  77077. declare module BABYLON.GLTF2.Exporter {
  77078. /**
  77079. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77080. * @hidden
  77081. */
  77082. export class _GLTFMaterialExporter {
  77083. /**
  77084. * Represents the dielectric specular values for R, G and B
  77085. */
  77086. private static readonly _DielectricSpecular;
  77087. /**
  77088. * Allows the maximum specular power to be defined for material calculations
  77089. */
  77090. private static readonly _MaxSpecularPower;
  77091. /**
  77092. * Mapping to store textures
  77093. */
  77094. private _textureMap;
  77095. /**
  77096. * Numeric tolerance value
  77097. */
  77098. private static readonly _Epsilon;
  77099. /**
  77100. * Reference to the glTF Exporter
  77101. */
  77102. private _exporter;
  77103. constructor(exporter: _Exporter);
  77104. /**
  77105. * Specifies if two colors are approximately equal in value
  77106. * @param color1 first color to compare to
  77107. * @param color2 second color to compare to
  77108. * @param epsilon threshold value
  77109. */
  77110. private static FuzzyEquals;
  77111. /**
  77112. * Gets the materials from a Babylon scene and converts them to glTF materials
  77113. * @param scene babylonjs scene
  77114. * @param mimeType texture mime type
  77115. * @param images array of images
  77116. * @param textures array of textures
  77117. * @param materials array of materials
  77118. * @param imageData mapping of texture names to base64 textures
  77119. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77120. */
  77121. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77122. /**
  77123. * Makes a copy of the glTF material without the texture parameters
  77124. * @param originalMaterial original glTF material
  77125. * @returns glTF material without texture parameters
  77126. */
  77127. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77128. /**
  77129. * Specifies if the material has any texture parameters present
  77130. * @param material glTF Material
  77131. * @returns boolean specifying if texture parameters are present
  77132. */
  77133. _hasTexturesPresent(material: IMaterial): boolean;
  77134. /**
  77135. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77136. * @param babylonStandardMaterial
  77137. * @returns glTF Metallic Roughness Material representation
  77138. */
  77139. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77140. /**
  77141. * Computes the metallic factor
  77142. * @param diffuse diffused value
  77143. * @param specular specular value
  77144. * @param oneMinusSpecularStrength one minus the specular strength
  77145. * @returns metallic value
  77146. */
  77147. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77148. /**
  77149. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77150. * @param glTFMaterial glTF material
  77151. * @param babylonMaterial Babylon material
  77152. */
  77153. private static _SetAlphaMode;
  77154. /**
  77155. * Converts a Babylon Standard Material to a glTF Material
  77156. * @param babylonStandardMaterial BJS Standard Material
  77157. * @param mimeType mime type to use for the textures
  77158. * @param images array of glTF image interfaces
  77159. * @param textures array of glTF texture interfaces
  77160. * @param materials array of glTF material interfaces
  77161. * @param imageData map of image file name to data
  77162. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77163. */
  77164. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77165. private _finishMaterial;
  77166. /**
  77167. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77168. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77169. * @param mimeType mime type to use for the textures
  77170. * @param images array of glTF image interfaces
  77171. * @param textures array of glTF texture interfaces
  77172. * @param materials array of glTF material interfaces
  77173. * @param imageData map of image file name to data
  77174. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77175. */
  77176. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77177. /**
  77178. * Converts an image typed array buffer to a base64 image
  77179. * @param buffer typed array buffer
  77180. * @param width width of the image
  77181. * @param height height of the image
  77182. * @param mimeType mimetype of the image
  77183. * @returns base64 image string
  77184. */
  77185. private _createBase64FromCanvasAsync;
  77186. /**
  77187. * Generates a white texture based on the specified width and height
  77188. * @param width width of the texture in pixels
  77189. * @param height height of the texture in pixels
  77190. * @param scene babylonjs scene
  77191. * @returns white texture
  77192. */
  77193. private _createWhiteTexture;
  77194. /**
  77195. * 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
  77196. * @param texture1 first texture to resize
  77197. * @param texture2 second texture to resize
  77198. * @param scene babylonjs scene
  77199. * @returns resized textures or null
  77200. */
  77201. private _resizeTexturesToSameDimensions;
  77202. /**
  77203. * Converts an array of pixels to a Float32Array
  77204. * Throws an error if the pixel format is not supported
  77205. * @param pixels - array buffer containing pixel values
  77206. * @returns Float32 of pixels
  77207. */
  77208. private _convertPixelArrayToFloat32;
  77209. /**
  77210. * Convert Specular Glossiness Textures to Metallic Roughness
  77211. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77212. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77213. * @param diffuseTexture texture used to store diffuse information
  77214. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77215. * @param factors specular glossiness material factors
  77216. * @param mimeType the mime type to use for the texture
  77217. * @returns pbr metallic roughness interface or null
  77218. */
  77219. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77220. /**
  77221. * Converts specular glossiness material properties to metallic roughness
  77222. * @param specularGlossiness interface with specular glossiness material properties
  77223. * @returns interface with metallic roughness material properties
  77224. */
  77225. private _convertSpecularGlossinessToMetallicRoughness;
  77226. /**
  77227. * Calculates the surface reflectance, independent of lighting conditions
  77228. * @param color Color source to calculate brightness from
  77229. * @returns number representing the perceived brightness, or zero if color is undefined
  77230. */
  77231. private _getPerceivedBrightness;
  77232. /**
  77233. * Returns the maximum color component value
  77234. * @param color
  77235. * @returns maximum color component value, or zero if color is null or undefined
  77236. */
  77237. private _getMaxComponent;
  77238. /**
  77239. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77240. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77241. * @param mimeType mime type to use for the textures
  77242. * @param images array of glTF image interfaces
  77243. * @param textures array of glTF texture interfaces
  77244. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77245. * @param imageData map of image file name to data
  77246. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77247. * @returns glTF PBR Metallic Roughness factors
  77248. */
  77249. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77250. private _getGLTFTextureSampler;
  77251. private _getGLTFTextureWrapMode;
  77252. private _getGLTFTextureWrapModesSampler;
  77253. /**
  77254. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77255. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77256. * @param mimeType mime type to use for the textures
  77257. * @param images array of glTF image interfaces
  77258. * @param textures array of glTF texture interfaces
  77259. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77260. * @param imageData map of image file name to data
  77261. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77262. * @returns glTF PBR Metallic Roughness factors
  77263. */
  77264. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77265. /**
  77266. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77267. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77268. * @param mimeType mime type to use for the textures
  77269. * @param images array of glTF image interfaces
  77270. * @param textures array of glTF texture interfaces
  77271. * @param materials array of glTF material interfaces
  77272. * @param imageData map of image file name to data
  77273. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77274. */
  77275. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77276. private setMetallicRoughnessPbrMaterial;
  77277. private getPixelsFromTexture;
  77278. /**
  77279. * Extracts a texture from a Babylon texture into file data and glTF data
  77280. * @param babylonTexture Babylon texture to extract
  77281. * @param mimeType Mime Type of the babylonTexture
  77282. * @return glTF texture info, or null if the texture format is not supported
  77283. */
  77284. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77285. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77286. /**
  77287. * Builds a texture from base64 string
  77288. * @param base64Texture base64 texture string
  77289. * @param baseTextureName Name to use for the texture
  77290. * @param mimeType image mime type for the texture
  77291. * @param images array of images
  77292. * @param textures array of textures
  77293. * @param imageData map of image data
  77294. * @returns glTF texture info, or null if the texture format is not supported
  77295. */
  77296. private _getTextureInfoFromBase64;
  77297. }
  77298. }
  77299. declare module BABYLON {
  77300. /**
  77301. * Class for holding and downloading glTF file data
  77302. */
  77303. export class GLTFData {
  77304. /**
  77305. * Object which contains the file name as the key and its data as the value
  77306. */
  77307. glTFFiles: {
  77308. [fileName: string]: string | Blob;
  77309. };
  77310. /**
  77311. * Initializes the glTF file object
  77312. */
  77313. constructor();
  77314. /**
  77315. * Downloads the glTF data as files based on their names and data
  77316. */
  77317. downloadFiles(): void;
  77318. }
  77319. }
  77320. declare module BABYLON {
  77321. /**
  77322. * Holds a collection of exporter options and parameters
  77323. */
  77324. export interface IExportOptions {
  77325. /**
  77326. * Function which indicates whether a babylon node should be exported or not
  77327. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77328. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77329. */
  77330. shouldExportNode?(node: Node): boolean;
  77331. /**
  77332. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77333. * @param metadata source metadata to read from
  77334. * @returns the data to store to glTF node extras
  77335. */
  77336. metadataSelector?(metadata: any): any;
  77337. /**
  77338. * The sample rate to bake animation curves
  77339. */
  77340. animationSampleRate?: number;
  77341. /**
  77342. * Begin serialization without waiting for the scene to be ready
  77343. */
  77344. exportWithoutWaitingForScene?: boolean;
  77345. /**
  77346. * Indicates if coordinate system swapping root nodes should be included in export
  77347. */
  77348. includeCoordinateSystemConversionNodes?: boolean;
  77349. }
  77350. /**
  77351. * Class for generating glTF data from a Babylon scene.
  77352. */
  77353. export class GLTF2Export {
  77354. /**
  77355. * Exports the geometry of the scene to .gltf file format asynchronously
  77356. * @param scene Babylon scene with scene hierarchy information
  77357. * @param filePrefix File prefix to use when generating the glTF file
  77358. * @param options Exporter options
  77359. * @returns Returns an object with a .gltf file and associates texture names
  77360. * as keys and their data and paths as values
  77361. */
  77362. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77363. private static _PreExportAsync;
  77364. private static _PostExportAsync;
  77365. /**
  77366. * Exports the geometry of the scene to .glb file format asychronously
  77367. * @param scene Babylon scene with scene hierarchy information
  77368. * @param filePrefix File prefix to use when generating glb file
  77369. * @param options Exporter options
  77370. * @returns Returns an object with a .glb filename as key and data as value
  77371. */
  77372. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77373. }
  77374. }
  77375. declare module BABYLON.GLTF2.Exporter {
  77376. /**
  77377. * @hidden
  77378. */
  77379. export class _GLTFUtilities {
  77380. /**
  77381. * Creates a buffer view based on the supplied arguments
  77382. * @param bufferIndex index value of the specified buffer
  77383. * @param byteOffset byte offset value
  77384. * @param byteLength byte length of the bufferView
  77385. * @param byteStride byte distance between conequential elements
  77386. * @param name name of the buffer view
  77387. * @returns bufferView for glTF
  77388. */
  77389. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77390. /**
  77391. * Creates an accessor based on the supplied arguments
  77392. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77393. * @param name The name of the accessor
  77394. * @param type The type of the accessor
  77395. * @param componentType The datatype of components in the attribute
  77396. * @param count The number of attributes referenced by this accessor
  77397. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77398. * @param min Minimum value of each component in this attribute
  77399. * @param max Maximum value of each component in this attribute
  77400. * @returns accessor for glTF
  77401. */
  77402. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77403. /**
  77404. * Calculates the minimum and maximum values of an array of position floats
  77405. * @param positions Positions array of a mesh
  77406. * @param vertexStart Starting vertex offset to calculate min and max values
  77407. * @param vertexCount Number of vertices to check for min and max values
  77408. * @returns min number array and max number array
  77409. */
  77410. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77411. min: number[];
  77412. max: number[];
  77413. };
  77414. /**
  77415. * Converts a new right-handed Vector3
  77416. * @param vector vector3 array
  77417. * @returns right-handed Vector3
  77418. */
  77419. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77420. /**
  77421. * Converts a Vector3 to right-handed
  77422. * @param vector Vector3 to convert to right-handed
  77423. */
  77424. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77425. /**
  77426. * Converts a three element number array to right-handed
  77427. * @param vector number array to convert to right-handed
  77428. */
  77429. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77430. /**
  77431. * Converts a new right-handed Vector3
  77432. * @param vector vector3 array
  77433. * @returns right-handed Vector3
  77434. */
  77435. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77436. /**
  77437. * Converts a Vector3 to right-handed
  77438. * @param vector Vector3 to convert to right-handed
  77439. */
  77440. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77441. /**
  77442. * Converts a three element number array to right-handed
  77443. * @param vector number array to convert to right-handed
  77444. */
  77445. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77446. /**
  77447. * Converts a Vector4 to right-handed
  77448. * @param vector Vector4 to convert to right-handed
  77449. */
  77450. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77451. /**
  77452. * Converts a Vector4 to right-handed
  77453. * @param vector Vector4 to convert to right-handed
  77454. */
  77455. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77456. /**
  77457. * Converts a Quaternion to right-handed
  77458. * @param quaternion Source quaternion to convert to right-handed
  77459. */
  77460. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77461. /**
  77462. * Converts a Quaternion to right-handed
  77463. * @param quaternion Source quaternion to convert to right-handed
  77464. */
  77465. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77466. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77467. }
  77468. }
  77469. declare module BABYLON.GLTF2.Exporter {
  77470. /**
  77471. * Converts Babylon Scene into glTF 2.0.
  77472. * @hidden
  77473. */
  77474. export class _Exporter {
  77475. /**
  77476. * Stores the glTF to export
  77477. */
  77478. _glTF: IGLTF;
  77479. /**
  77480. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77481. */
  77482. _bufferViews: IBufferView[];
  77483. /**
  77484. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77485. */
  77486. _accessors: IAccessor[];
  77487. /**
  77488. * Stores all the generated nodes, which contains transform and/or mesh information per node
  77489. */
  77490. _nodes: INode[];
  77491. /**
  77492. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  77493. */
  77494. private _scenes;
  77495. /**
  77496. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  77497. */
  77498. private _meshes;
  77499. /**
  77500. * Stores all the generated material information, which represents the appearance of each primitive
  77501. */
  77502. _materials: IMaterial[];
  77503. _materialMap: {
  77504. [materialID: number]: number;
  77505. };
  77506. /**
  77507. * Stores all the generated texture information, which is referenced by glTF materials
  77508. */
  77509. _textures: ITexture[];
  77510. /**
  77511. * Stores all the generated image information, which is referenced by glTF textures
  77512. */
  77513. _images: IImage[];
  77514. /**
  77515. * Stores all the texture samplers
  77516. */
  77517. _samplers: ISampler[];
  77518. /**
  77519. * Stores all the generated animation samplers, which is referenced by glTF animations
  77520. */
  77521. /**
  77522. * Stores the animations for glTF models
  77523. */
  77524. private _animations;
  77525. /**
  77526. * Stores the total amount of bytes stored in the glTF buffer
  77527. */
  77528. private _totalByteLength;
  77529. /**
  77530. * Stores a reference to the Babylon scene containing the source geometry and material information
  77531. */
  77532. _babylonScene: Scene;
  77533. /**
  77534. * Stores a map of the image data, where the key is the file name and the value
  77535. * is the image data
  77536. */
  77537. _imageData: {
  77538. [fileName: string]: {
  77539. data: Uint8Array;
  77540. mimeType: ImageMimeType;
  77541. };
  77542. };
  77543. /**
  77544. * Stores a map of the unique id of a node to its index in the node array
  77545. */
  77546. _nodeMap: {
  77547. [key: number]: number;
  77548. };
  77549. /**
  77550. * Specifies if the source Babylon scene was left handed, and needed conversion.
  77551. */
  77552. _convertToRightHandedSystem: boolean;
  77553. /**
  77554. * Specifies if a Babylon node should be converted to right-handed on export
  77555. */
  77556. _convertToRightHandedSystemMap: {
  77557. [nodeId: number]: boolean;
  77558. };
  77559. _includeCoordinateSystemConversionNodes: boolean;
  77560. /**
  77561. * Baked animation sample rate
  77562. */
  77563. private _animationSampleRate;
  77564. private _options;
  77565. private _localEngine;
  77566. _glTFMaterialExporter: _GLTFMaterialExporter;
  77567. private _extensions;
  77568. private static _ExtensionNames;
  77569. private static _ExtensionFactories;
  77570. private _applyExtension;
  77571. private _applyExtensions;
  77572. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77573. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77574. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77575. [key: number]: number;
  77576. }): Promise<Nullable<INode>>;
  77577. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77578. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77579. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77580. private _forEachExtensions;
  77581. private _extensionsOnExporting;
  77582. /**
  77583. * Load glTF serializer extensions
  77584. */
  77585. private _loadExtensions;
  77586. /**
  77587. * Creates a glTF Exporter instance, which can accept optional exporter options
  77588. * @param babylonScene Babylon scene object
  77589. * @param options Options to modify the behavior of the exporter
  77590. */
  77591. constructor(babylonScene: Scene, options?: IExportOptions);
  77592. dispose(): void;
  77593. /**
  77594. * Registers a glTF exporter extension
  77595. * @param name Name of the extension to export
  77596. * @param factory The factory function that creates the exporter extension
  77597. */
  77598. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77599. /**
  77600. * Un-registers an exporter extension
  77601. * @param name The name fo the exporter extension
  77602. * @returns A boolean indicating whether the extension has been un-registered
  77603. */
  77604. static UnregisterExtension(name: string): boolean;
  77605. /**
  77606. * Lazy load a local engine
  77607. */
  77608. _getLocalEngine(): Engine;
  77609. private reorderIndicesBasedOnPrimitiveMode;
  77610. /**
  77611. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77612. * clock-wise during export to glTF
  77613. * @param submesh BabylonJS submesh
  77614. * @param primitiveMode Primitive mode of the mesh
  77615. * @param sideOrientation the winding order of the submesh
  77616. * @param vertexBufferKind The type of vertex attribute
  77617. * @param meshAttributeArray The vertex attribute data
  77618. * @param byteOffset The offset to the binary data
  77619. * @param binaryWriter The binary data for the glTF file
  77620. * @param convertToRightHandedSystem Converts the values to right-handed
  77621. */
  77622. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77623. /**
  77624. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77625. * clock-wise during export to glTF
  77626. * @param submesh BabylonJS submesh
  77627. * @param primitiveMode Primitive mode of the mesh
  77628. * @param sideOrientation the winding order of the submesh
  77629. * @param vertexBufferKind The type of vertex attribute
  77630. * @param meshAttributeArray The vertex attribute data
  77631. * @param byteOffset The offset to the binary data
  77632. * @param binaryWriter The binary data for the glTF file
  77633. * @param convertToRightHandedSystem Converts the values to right-handed
  77634. */
  77635. private reorderTriangleFillMode;
  77636. /**
  77637. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77638. * clock-wise during export to glTF
  77639. * @param submesh BabylonJS submesh
  77640. * @param primitiveMode Primitive mode of the mesh
  77641. * @param sideOrientation the winding order of the submesh
  77642. * @param vertexBufferKind The type of vertex attribute
  77643. * @param meshAttributeArray The vertex attribute data
  77644. * @param byteOffset The offset to the binary data
  77645. * @param binaryWriter The binary data for the glTF file
  77646. * @param convertToRightHandedSystem Converts the values to right-handed
  77647. */
  77648. private reorderTriangleStripDrawMode;
  77649. /**
  77650. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77651. * clock-wise during export to glTF
  77652. * @param submesh BabylonJS submesh
  77653. * @param primitiveMode Primitive mode of the mesh
  77654. * @param sideOrientation the winding order of the submesh
  77655. * @param vertexBufferKind The type of vertex attribute
  77656. * @param meshAttributeArray The vertex attribute data
  77657. * @param byteOffset The offset to the binary data
  77658. * @param binaryWriter The binary data for the glTF file
  77659. * @param convertToRightHandedSystem Converts the values to right-handed
  77660. */
  77661. private reorderTriangleFanMode;
  77662. /**
  77663. * Writes the vertex attribute data to binary
  77664. * @param vertices The vertices to write to the binary writer
  77665. * @param byteOffset The offset into the binary writer to overwrite binary data
  77666. * @param vertexAttributeKind The vertex attribute type
  77667. * @param meshAttributeArray The vertex attribute data
  77668. * @param binaryWriter The writer containing the binary data
  77669. * @param convertToRightHandedSystem Converts the values to right-handed
  77670. */
  77671. private writeVertexAttributeData;
  77672. /**
  77673. * Writes mesh attribute data to a data buffer
  77674. * Returns the bytelength of the data
  77675. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77676. * @param meshAttributeArray Array containing the attribute data
  77677. * @param binaryWriter The buffer to write the binary data to
  77678. * @param indices Used to specify the order of the vertex data
  77679. * @param convertToRightHandedSystem Converts the values to right-handed
  77680. */
  77681. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  77682. /**
  77683. * Generates glTF json data
  77684. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77685. * @param glTFPrefix Text to use when prefixing a glTF file
  77686. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77687. * @returns json data as string
  77688. */
  77689. private generateJSON;
  77690. /**
  77691. * Generates data for .gltf and .bin files based on the glTF prefix string
  77692. * @param glTFPrefix Text to use when prefixing a glTF file
  77693. * @param dispose Dispose the exporter
  77694. * @returns GLTFData with glTF file data
  77695. */
  77696. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77697. /**
  77698. * Creates a binary buffer for glTF
  77699. * @returns array buffer for binary data
  77700. */
  77701. private _generateBinaryAsync;
  77702. /**
  77703. * Pads the number to a multiple of 4
  77704. * @param num number to pad
  77705. * @returns padded number
  77706. */
  77707. private _getPadding;
  77708. /**
  77709. * @hidden
  77710. */
  77711. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77712. /**
  77713. * Sets the TRS for each node
  77714. * @param node glTF Node for storing the transformation data
  77715. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77716. * @param convertToRightHandedSystem Converts the values to right-handed
  77717. */
  77718. private setNodeTransformation;
  77719. private getVertexBufferFromMesh;
  77720. /**
  77721. * Creates a bufferview based on the vertices type for the Babylon mesh
  77722. * @param kind Indicates the type of vertices data
  77723. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77724. * @param binaryWriter The buffer to write the bufferview data to
  77725. * @param convertToRightHandedSystem Converts the values to right-handed
  77726. */
  77727. private createBufferViewKind;
  77728. /**
  77729. * The primitive mode of the Babylon mesh
  77730. * @param babylonMesh The BabylonJS mesh
  77731. */
  77732. private getMeshPrimitiveMode;
  77733. /**
  77734. * Sets the primitive mode of the glTF mesh primitive
  77735. * @param meshPrimitive glTF mesh primitive
  77736. * @param primitiveMode The primitive mode
  77737. */
  77738. private setPrimitiveMode;
  77739. /**
  77740. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77741. * @param meshPrimitive glTF mesh primitive
  77742. * @param attributeKind vertex attribute
  77743. * @returns boolean specifying if uv coordinates are present
  77744. */
  77745. private setAttributeKind;
  77746. /**
  77747. * Sets data for the primitive attributes of each submesh
  77748. * @param mesh glTF Mesh object to store the primitive attribute information
  77749. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77750. * @param binaryWriter Buffer to write the attribute data to
  77751. * @param convertToRightHandedSystem Converts the values to right-handed
  77752. */
  77753. private setPrimitiveAttributesAsync;
  77754. /**
  77755. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  77756. * @param node The node to check
  77757. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  77758. */
  77759. private isBabylonCoordinateSystemConvertingNode;
  77760. /**
  77761. * Creates a glTF scene based on the array of meshes
  77762. * Returns the the total byte offset
  77763. * @param babylonScene Babylon scene to get the mesh data from
  77764. * @param binaryWriter Buffer to write binary data to
  77765. */
  77766. private createSceneAsync;
  77767. /**
  77768. * Creates a mapping of Node unique id to node index and handles animations
  77769. * @param babylonScene Babylon Scene
  77770. * @param nodes Babylon transform nodes
  77771. * @param binaryWriter Buffer to write binary data to
  77772. * @returns Node mapping of unique id to index
  77773. */
  77774. private createNodeMapAndAnimationsAsync;
  77775. /**
  77776. * Creates a glTF node from a Babylon mesh
  77777. * @param babylonMesh Source Babylon mesh
  77778. * @param binaryWriter Buffer for storing geometry data
  77779. * @param convertToRightHandedSystem Converts the values to right-handed
  77780. * @param nodeMap Node mapping of unique id to glTF node index
  77781. * @returns glTF node
  77782. */
  77783. private createNodeAsync;
  77784. }
  77785. /**
  77786. * @hidden
  77787. *
  77788. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  77789. */
  77790. export class _BinaryWriter {
  77791. /**
  77792. * Array buffer which stores all binary data
  77793. */
  77794. private _arrayBuffer;
  77795. /**
  77796. * View of the array buffer
  77797. */
  77798. private _dataView;
  77799. /**
  77800. * byte offset of data in array buffer
  77801. */
  77802. private _byteOffset;
  77803. /**
  77804. * Initialize binary writer with an initial byte length
  77805. * @param byteLength Initial byte length of the array buffer
  77806. */
  77807. constructor(byteLength: number);
  77808. /**
  77809. * Resize the array buffer to the specified byte length
  77810. * @param byteLength
  77811. */
  77812. private resizeBuffer;
  77813. /**
  77814. * Get an array buffer with the length of the byte offset
  77815. * @returns ArrayBuffer resized to the byte offset
  77816. */
  77817. getArrayBuffer(): ArrayBuffer;
  77818. /**
  77819. * Get the byte offset of the array buffer
  77820. * @returns byte offset
  77821. */
  77822. getByteOffset(): number;
  77823. /**
  77824. * Stores an UInt8 in the array buffer
  77825. * @param entry
  77826. * @param byteOffset If defined, specifies where to set the value as an offset.
  77827. */
  77828. setUInt8(entry: number, byteOffset?: number): void;
  77829. /**
  77830. * Gets an UInt32 in the array buffer
  77831. * @param entry
  77832. * @param byteOffset If defined, specifies where to set the value as an offset.
  77833. */
  77834. getUInt32(byteOffset: number): number;
  77835. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77836. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77837. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77838. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77839. /**
  77840. * Stores a Float32 in the array buffer
  77841. * @param entry
  77842. */
  77843. setFloat32(entry: number, byteOffset?: number): void;
  77844. /**
  77845. * Stores an UInt32 in the array buffer
  77846. * @param entry
  77847. * @param byteOffset If defined, specifies where to set the value as an offset.
  77848. */
  77849. setUInt32(entry: number, byteOffset?: number): void;
  77850. }
  77851. }
  77852. declare module BABYLON.GLTF2.Exporter {
  77853. /**
  77854. * @hidden
  77855. * Interface to store animation data.
  77856. */
  77857. export interface _IAnimationData {
  77858. /**
  77859. * Keyframe data.
  77860. */
  77861. inputs: number[];
  77862. /**
  77863. * Value data.
  77864. */
  77865. outputs: number[][];
  77866. /**
  77867. * Animation interpolation data.
  77868. */
  77869. samplerInterpolation: AnimationSamplerInterpolation;
  77870. /**
  77871. * Minimum keyframe value.
  77872. */
  77873. inputsMin: number;
  77874. /**
  77875. * Maximum keyframe value.
  77876. */
  77877. inputsMax: number;
  77878. }
  77879. /**
  77880. * @hidden
  77881. */
  77882. export interface _IAnimationInfo {
  77883. /**
  77884. * The target channel for the animation
  77885. */
  77886. animationChannelTargetPath: AnimationChannelTargetPath;
  77887. /**
  77888. * The glTF accessor type for the data.
  77889. */
  77890. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  77891. /**
  77892. * Specifies if quaternions should be used.
  77893. */
  77894. useQuaternion: boolean;
  77895. }
  77896. /**
  77897. * @hidden
  77898. * Utility class for generating glTF animation data from BabylonJS.
  77899. */
  77900. export class _GLTFAnimation {
  77901. /**
  77902. * @ignore
  77903. *
  77904. * Creates glTF channel animation from BabylonJS animation.
  77905. * @param babylonTransformNode - BabylonJS mesh.
  77906. * @param animation - animation.
  77907. * @param animationChannelTargetPath - The target animation channel.
  77908. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  77909. * @param useQuaternion - Specifies if quaternions are used.
  77910. * @returns nullable IAnimationData
  77911. */
  77912. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  77913. private static _DeduceAnimationInfo;
  77914. /**
  77915. * @ignore
  77916. * Create node animations from the transform node animations
  77917. * @param babylonNode
  77918. * @param runtimeGLTFAnimation
  77919. * @param idleGLTFAnimations
  77920. * @param nodeMap
  77921. * @param nodes
  77922. * @param binaryWriter
  77923. * @param bufferViews
  77924. * @param accessors
  77925. * @param convertToRightHandedSystem
  77926. * @param animationSampleRate
  77927. */
  77928. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77929. [key: number]: number;
  77930. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77931. /**
  77932. * @ignore
  77933. * Create node animations from the animation groups
  77934. * @param babylonScene
  77935. * @param glTFAnimations
  77936. * @param nodeMap
  77937. * @param nodes
  77938. * @param binaryWriter
  77939. * @param bufferViews
  77940. * @param accessors
  77941. * @param convertToRightHandedSystemMap
  77942. * @param animationSampleRate
  77943. */
  77944. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77945. [key: number]: number;
  77946. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  77947. [nodeId: number]: boolean;
  77948. }, animationSampleRate: number): void;
  77949. private static AddAnimation;
  77950. /**
  77951. * Create a baked animation
  77952. * @param babylonTransformNode BabylonJS mesh
  77953. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77954. * @param animationChannelTargetPath animation target channel
  77955. * @param minFrame minimum animation frame
  77956. * @param maxFrame maximum animation frame
  77957. * @param fps frames per second of the animation
  77958. * @param inputs input key frames of the animation
  77959. * @param outputs output key frame data of the animation
  77960. * @param convertToRightHandedSystem converts the values to right-handed
  77961. * @param useQuaternion specifies if quaternions should be used
  77962. */
  77963. private static _CreateBakedAnimation;
  77964. private static _ConvertFactorToVector3OrQuaternion;
  77965. private static _SetInterpolatedValue;
  77966. /**
  77967. * Creates linear animation from the animation key frames
  77968. * @param babylonTransformNode BabylonJS mesh
  77969. * @param animation BabylonJS animation
  77970. * @param animationChannelTargetPath The target animation channel
  77971. * @param frameDelta The difference between the last and first frame of the animation
  77972. * @param inputs Array to store the key frame times
  77973. * @param outputs Array to store the key frame data
  77974. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77975. * @param useQuaternion Specifies if quaternions are used in the animation
  77976. */
  77977. private static _CreateLinearOrStepAnimation;
  77978. /**
  77979. * Creates cubic spline animation from the animation key frames
  77980. * @param babylonTransformNode BabylonJS mesh
  77981. * @param animation BabylonJS animation
  77982. * @param animationChannelTargetPath The target animation channel
  77983. * @param frameDelta The difference between the last and first frame of the animation
  77984. * @param inputs Array to store the key frame times
  77985. * @param outputs Array to store the key frame data
  77986. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77987. * @param useQuaternion Specifies if quaternions are used in the animation
  77988. */
  77989. private static _CreateCubicSplineAnimation;
  77990. private static _GetBasePositionRotationOrScale;
  77991. /**
  77992. * Adds a key frame value
  77993. * @param keyFrame
  77994. * @param animation
  77995. * @param outputs
  77996. * @param animationChannelTargetPath
  77997. * @param basePositionRotationOrScale
  77998. * @param convertToRightHandedSystem
  77999. * @param useQuaternion
  78000. */
  78001. private static _AddKeyframeValue;
  78002. /**
  78003. * Determine the interpolation based on the key frames
  78004. * @param keyFrames
  78005. * @param animationChannelTargetPath
  78006. * @param useQuaternion
  78007. */
  78008. private static _DeduceInterpolation;
  78009. /**
  78010. * Adds an input tangent or output tangent to the output data
  78011. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78012. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78013. * @param outputs The animation data by keyframe
  78014. * @param animationChannelTargetPath The target animation channel
  78015. * @param interpolation The interpolation type
  78016. * @param keyFrame The key frame with the animation data
  78017. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78018. * @param useQuaternion Specifies if quaternions are used
  78019. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78020. */
  78021. private static AddSplineTangent;
  78022. /**
  78023. * Get the minimum and maximum key frames' frame values
  78024. * @param keyFrames animation key frames
  78025. * @returns the minimum and maximum key frame value
  78026. */
  78027. private static calculateMinMaxKeyFrames;
  78028. }
  78029. }
  78030. declare module BABYLON.GLTF2.Exporter {
  78031. /** @hidden */
  78032. export var textureTransformPixelShader: {
  78033. name: string;
  78034. shader: string;
  78035. };
  78036. }
  78037. declare module BABYLON.GLTF2.Exporter.Extensions {
  78038. /**
  78039. * @hidden
  78040. */
  78041. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78042. private _recordedTextures;
  78043. /** Name of this extension */
  78044. readonly name: string;
  78045. /** Defines whether this extension is enabled */
  78046. enabled: boolean;
  78047. /** Defines whether this extension is required */
  78048. required: boolean;
  78049. /** Reference to the glTF exporter */
  78050. private _wasUsed;
  78051. constructor(exporter: _Exporter);
  78052. dispose(): void;
  78053. /** @hidden */
  78054. get wasUsed(): boolean;
  78055. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78056. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78057. /**
  78058. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78059. * @param babylonTexture
  78060. * @param offset
  78061. * @param rotation
  78062. * @param scale
  78063. * @param scene
  78064. */
  78065. private _textureTransformTextureAsync;
  78066. }
  78067. }
  78068. declare module BABYLON.GLTF2.Exporter.Extensions {
  78069. /**
  78070. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78071. */
  78072. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78073. /** The name of this extension. */
  78074. readonly name: string;
  78075. /** Defines whether this extension is enabled. */
  78076. enabled: boolean;
  78077. /** Defines whether this extension is required */
  78078. required: boolean;
  78079. /** Reference to the glTF exporter */
  78080. private _exporter;
  78081. private _lights;
  78082. /** @hidden */
  78083. constructor(exporter: _Exporter);
  78084. /** @hidden */
  78085. dispose(): void;
  78086. /** @hidden */
  78087. get wasUsed(): boolean;
  78088. /** @hidden */
  78089. onExporting(): void;
  78090. /**
  78091. * Define this method to modify the default behavior when exporting a node
  78092. * @param context The context when exporting the node
  78093. * @param node glTF node
  78094. * @param babylonNode BabylonJS node
  78095. * @param nodeMap Node mapping of unique id to glTF node index
  78096. * @returns nullable INode promise
  78097. */
  78098. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78099. [key: number]: number;
  78100. }): Promise<Nullable<INode>>;
  78101. }
  78102. }
  78103. declare module BABYLON.GLTF2.Exporter.Extensions {
  78104. /**
  78105. * @hidden
  78106. */
  78107. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78108. /** Name of this extension */
  78109. readonly name: string;
  78110. /** Defines whether this extension is enabled */
  78111. enabled: boolean;
  78112. /** Defines whether this extension is required */
  78113. required: boolean;
  78114. /** Reference to the glTF exporter */
  78115. private _textureInfos;
  78116. private _exportedTextures;
  78117. private _wasUsed;
  78118. constructor(exporter: _Exporter);
  78119. dispose(): void;
  78120. /** @hidden */
  78121. get wasUsed(): boolean;
  78122. private _getTextureIndex;
  78123. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78124. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78125. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78126. }
  78127. }
  78128. declare module BABYLON {
  78129. /**
  78130. * Class for generating STL data from a Babylon scene.
  78131. */
  78132. export class STLExport {
  78133. /**
  78134. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78135. * @param meshes list defines the mesh to serialize
  78136. * @param download triggers the automatic download of the file.
  78137. * @param fileName changes the downloads fileName.
  78138. * @param binary changes the STL to a binary type.
  78139. * @param isLittleEndian toggle for binary type exporter.
  78140. * @returns the STL as UTF8 string
  78141. */
  78142. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78143. }
  78144. }
  78145. declare module "babylonjs-gltf2interface" {
  78146. export = BABYLON.GLTF2;
  78147. }
  78148. /**
  78149. * Module for glTF 2.0 Interface
  78150. */
  78151. declare module BABYLON.GLTF2 {
  78152. /**
  78153. * The datatype of the components in the attribute
  78154. */
  78155. const enum AccessorComponentType {
  78156. /**
  78157. * Byte
  78158. */
  78159. BYTE = 5120,
  78160. /**
  78161. * Unsigned Byte
  78162. */
  78163. UNSIGNED_BYTE = 5121,
  78164. /**
  78165. * Short
  78166. */
  78167. SHORT = 5122,
  78168. /**
  78169. * Unsigned Short
  78170. */
  78171. UNSIGNED_SHORT = 5123,
  78172. /**
  78173. * Unsigned Int
  78174. */
  78175. UNSIGNED_INT = 5125,
  78176. /**
  78177. * Float
  78178. */
  78179. FLOAT = 5126,
  78180. }
  78181. /**
  78182. * Specifies if the attirbute is a scalar, vector, or matrix
  78183. */
  78184. const enum AccessorType {
  78185. /**
  78186. * Scalar
  78187. */
  78188. SCALAR = "SCALAR",
  78189. /**
  78190. * Vector2
  78191. */
  78192. VEC2 = "VEC2",
  78193. /**
  78194. * Vector3
  78195. */
  78196. VEC3 = "VEC3",
  78197. /**
  78198. * Vector4
  78199. */
  78200. VEC4 = "VEC4",
  78201. /**
  78202. * Matrix2x2
  78203. */
  78204. MAT2 = "MAT2",
  78205. /**
  78206. * Matrix3x3
  78207. */
  78208. MAT3 = "MAT3",
  78209. /**
  78210. * Matrix4x4
  78211. */
  78212. MAT4 = "MAT4",
  78213. }
  78214. /**
  78215. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78216. */
  78217. const enum AnimationChannelTargetPath {
  78218. /**
  78219. * Translation
  78220. */
  78221. TRANSLATION = "translation",
  78222. /**
  78223. * Rotation
  78224. */
  78225. ROTATION = "rotation",
  78226. /**
  78227. * Scale
  78228. */
  78229. SCALE = "scale",
  78230. /**
  78231. * Weights
  78232. */
  78233. WEIGHTS = "weights",
  78234. }
  78235. /**
  78236. * Interpolation algorithm
  78237. */
  78238. const enum AnimationSamplerInterpolation {
  78239. /**
  78240. * The animated values are linearly interpolated between keyframes
  78241. */
  78242. LINEAR = "LINEAR",
  78243. /**
  78244. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78245. */
  78246. STEP = "STEP",
  78247. /**
  78248. * The animation's interpolation is computed using a cubic spline with specified tangents
  78249. */
  78250. CUBICSPLINE = "CUBICSPLINE",
  78251. }
  78252. /**
  78253. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78254. */
  78255. const enum CameraType {
  78256. /**
  78257. * A perspective camera containing properties to create a perspective projection matrix
  78258. */
  78259. PERSPECTIVE = "perspective",
  78260. /**
  78261. * An orthographic camera containing properties to create an orthographic projection matrix
  78262. */
  78263. ORTHOGRAPHIC = "orthographic",
  78264. }
  78265. /**
  78266. * The mime-type of the image
  78267. */
  78268. const enum ImageMimeType {
  78269. /**
  78270. * JPEG Mime-type
  78271. */
  78272. JPEG = "image/jpeg",
  78273. /**
  78274. * PNG Mime-type
  78275. */
  78276. PNG = "image/png",
  78277. }
  78278. /**
  78279. * The alpha rendering mode of the material
  78280. */
  78281. const enum MaterialAlphaMode {
  78282. /**
  78283. * The alpha value is ignored and the rendered output is fully opaque
  78284. */
  78285. OPAQUE = "OPAQUE",
  78286. /**
  78287. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78288. */
  78289. MASK = "MASK",
  78290. /**
  78291. * 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)
  78292. */
  78293. BLEND = "BLEND",
  78294. }
  78295. /**
  78296. * The type of the primitives to render
  78297. */
  78298. const enum MeshPrimitiveMode {
  78299. /**
  78300. * Points
  78301. */
  78302. POINTS = 0,
  78303. /**
  78304. * Lines
  78305. */
  78306. LINES = 1,
  78307. /**
  78308. * Line Loop
  78309. */
  78310. LINE_LOOP = 2,
  78311. /**
  78312. * Line Strip
  78313. */
  78314. LINE_STRIP = 3,
  78315. /**
  78316. * Triangles
  78317. */
  78318. TRIANGLES = 4,
  78319. /**
  78320. * Triangle Strip
  78321. */
  78322. TRIANGLE_STRIP = 5,
  78323. /**
  78324. * Triangle Fan
  78325. */
  78326. TRIANGLE_FAN = 6,
  78327. }
  78328. /**
  78329. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78330. */
  78331. const enum TextureMagFilter {
  78332. /**
  78333. * Nearest
  78334. */
  78335. NEAREST = 9728,
  78336. /**
  78337. * Linear
  78338. */
  78339. LINEAR = 9729,
  78340. }
  78341. /**
  78342. * Minification filter. All valid values correspond to WebGL enums
  78343. */
  78344. const enum TextureMinFilter {
  78345. /**
  78346. * Nearest
  78347. */
  78348. NEAREST = 9728,
  78349. /**
  78350. * Linear
  78351. */
  78352. LINEAR = 9729,
  78353. /**
  78354. * Nearest Mip-Map Nearest
  78355. */
  78356. NEAREST_MIPMAP_NEAREST = 9984,
  78357. /**
  78358. * Linear Mipmap Nearest
  78359. */
  78360. LINEAR_MIPMAP_NEAREST = 9985,
  78361. /**
  78362. * Nearest Mipmap Linear
  78363. */
  78364. NEAREST_MIPMAP_LINEAR = 9986,
  78365. /**
  78366. * Linear Mipmap Linear
  78367. */
  78368. LINEAR_MIPMAP_LINEAR = 9987,
  78369. }
  78370. /**
  78371. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78372. */
  78373. const enum TextureWrapMode {
  78374. /**
  78375. * Clamp to Edge
  78376. */
  78377. CLAMP_TO_EDGE = 33071,
  78378. /**
  78379. * Mirrored Repeat
  78380. */
  78381. MIRRORED_REPEAT = 33648,
  78382. /**
  78383. * Repeat
  78384. */
  78385. REPEAT = 10497,
  78386. }
  78387. /**
  78388. * glTF Property
  78389. */
  78390. interface IProperty {
  78391. /**
  78392. * Dictionary object with extension-specific objects
  78393. */
  78394. extensions?: {
  78395. [key: string]: any;
  78396. };
  78397. /**
  78398. * Application-Specific data
  78399. */
  78400. extras?: any;
  78401. }
  78402. /**
  78403. * glTF Child of Root Property
  78404. */
  78405. interface IChildRootProperty extends IProperty {
  78406. /**
  78407. * The user-defined name of this object
  78408. */
  78409. name?: string;
  78410. }
  78411. /**
  78412. * Indices of those attributes that deviate from their initialization value
  78413. */
  78414. interface IAccessorSparseIndices extends IProperty {
  78415. /**
  78416. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78417. */
  78418. bufferView: number;
  78419. /**
  78420. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78421. */
  78422. byteOffset?: number;
  78423. /**
  78424. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78425. */
  78426. componentType: AccessorComponentType;
  78427. }
  78428. /**
  78429. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78430. */
  78431. interface IAccessorSparseValues extends IProperty {
  78432. /**
  78433. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78434. */
  78435. bufferView: number;
  78436. /**
  78437. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78438. */
  78439. byteOffset?: number;
  78440. }
  78441. /**
  78442. * Sparse storage of attributes that deviate from their initialization value
  78443. */
  78444. interface IAccessorSparse extends IProperty {
  78445. /**
  78446. * The number of attributes encoded in this sparse accessor
  78447. */
  78448. count: number;
  78449. /**
  78450. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78451. */
  78452. indices: IAccessorSparseIndices;
  78453. /**
  78454. * 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
  78455. */
  78456. values: IAccessorSparseValues;
  78457. }
  78458. /**
  78459. * 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
  78460. */
  78461. interface IAccessor extends IChildRootProperty {
  78462. /**
  78463. * The index of the bufferview
  78464. */
  78465. bufferView?: number;
  78466. /**
  78467. * The offset relative to the start of the bufferView in bytes
  78468. */
  78469. byteOffset?: number;
  78470. /**
  78471. * The datatype of components in the attribute
  78472. */
  78473. componentType: AccessorComponentType;
  78474. /**
  78475. * Specifies whether integer data values should be normalized
  78476. */
  78477. normalized?: boolean;
  78478. /**
  78479. * The number of attributes referenced by this accessor
  78480. */
  78481. count: number;
  78482. /**
  78483. * Specifies if the attribute is a scalar, vector, or matrix
  78484. */
  78485. type: AccessorType;
  78486. /**
  78487. * Maximum value of each component in this attribute
  78488. */
  78489. max?: number[];
  78490. /**
  78491. * Minimum value of each component in this attribute
  78492. */
  78493. min?: number[];
  78494. /**
  78495. * Sparse storage of attributes that deviate from their initialization value
  78496. */
  78497. sparse?: IAccessorSparse;
  78498. }
  78499. /**
  78500. * Targets an animation's sampler at a node's property
  78501. */
  78502. interface IAnimationChannel extends IProperty {
  78503. /**
  78504. * The index of a sampler in this animation used to compute the value for the target
  78505. */
  78506. sampler: number;
  78507. /**
  78508. * The index of the node and TRS property to target
  78509. */
  78510. target: IAnimationChannelTarget;
  78511. }
  78512. /**
  78513. * The index of the node and TRS property that an animation channel targets
  78514. */
  78515. interface IAnimationChannelTarget extends IProperty {
  78516. /**
  78517. * The index of the node to target
  78518. */
  78519. node: number;
  78520. /**
  78521. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78522. */
  78523. path: AnimationChannelTargetPath;
  78524. }
  78525. /**
  78526. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78527. */
  78528. interface IAnimationSampler extends IProperty {
  78529. /**
  78530. * The index of an accessor containing keyframe input values, e.g., time
  78531. */
  78532. input: number;
  78533. /**
  78534. * Interpolation algorithm
  78535. */
  78536. interpolation?: AnimationSamplerInterpolation;
  78537. /**
  78538. * The index of an accessor, containing keyframe output values
  78539. */
  78540. output: number;
  78541. }
  78542. /**
  78543. * A keyframe animation
  78544. */
  78545. interface IAnimation extends IChildRootProperty {
  78546. /**
  78547. * An array of channels, each of which targets an animation's sampler at a node's property
  78548. */
  78549. channels: IAnimationChannel[];
  78550. /**
  78551. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78552. */
  78553. samplers: IAnimationSampler[];
  78554. }
  78555. /**
  78556. * Metadata about the glTF asset
  78557. */
  78558. interface IAsset extends IChildRootProperty {
  78559. /**
  78560. * A copyright message suitable for display to credit the content creator
  78561. */
  78562. copyright?: string;
  78563. /**
  78564. * Tool that generated this glTF model. Useful for debugging
  78565. */
  78566. generator?: string;
  78567. /**
  78568. * The glTF version that this asset targets
  78569. */
  78570. version: string;
  78571. /**
  78572. * The minimum glTF version that this asset targets
  78573. */
  78574. minVersion?: string;
  78575. }
  78576. /**
  78577. * A buffer points to binary geometry, animation, or skins
  78578. */
  78579. interface IBuffer extends IChildRootProperty {
  78580. /**
  78581. * 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
  78582. */
  78583. uri?: string;
  78584. /**
  78585. * The length of the buffer in bytes
  78586. */
  78587. byteLength: number;
  78588. }
  78589. /**
  78590. * A view into a buffer generally representing a subset of the buffer
  78591. */
  78592. interface IBufferView extends IChildRootProperty {
  78593. /**
  78594. * The index of the buffer
  78595. */
  78596. buffer: number;
  78597. /**
  78598. * The offset into the buffer in bytes
  78599. */
  78600. byteOffset?: number;
  78601. /**
  78602. * The lenth of the bufferView in bytes
  78603. */
  78604. byteLength: number;
  78605. /**
  78606. * The stride, in bytes
  78607. */
  78608. byteStride?: number;
  78609. }
  78610. /**
  78611. * An orthographic camera containing properties to create an orthographic projection matrix
  78612. */
  78613. interface ICameraOrthographic extends IProperty {
  78614. /**
  78615. * The floating-point horizontal magnification of the view. Must not be zero
  78616. */
  78617. xmag: number;
  78618. /**
  78619. * The floating-point vertical magnification of the view. Must not be zero
  78620. */
  78621. ymag: number;
  78622. /**
  78623. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78624. */
  78625. zfar: number;
  78626. /**
  78627. * The floating-point distance to the near clipping plane
  78628. */
  78629. znear: number;
  78630. }
  78631. /**
  78632. * A perspective camera containing properties to create a perspective projection matrix
  78633. */
  78634. interface ICameraPerspective extends IProperty {
  78635. /**
  78636. * The floating-point aspect ratio of the field of view
  78637. */
  78638. aspectRatio?: number;
  78639. /**
  78640. * The floating-point vertical field of view in radians
  78641. */
  78642. yfov: number;
  78643. /**
  78644. * The floating-point distance to the far clipping plane
  78645. */
  78646. zfar?: number;
  78647. /**
  78648. * The floating-point distance to the near clipping plane
  78649. */
  78650. znear: number;
  78651. }
  78652. /**
  78653. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78654. */
  78655. interface ICamera extends IChildRootProperty {
  78656. /**
  78657. * An orthographic camera containing properties to create an orthographic projection matrix
  78658. */
  78659. orthographic?: ICameraOrthographic;
  78660. /**
  78661. * A perspective camera containing properties to create a perspective projection matrix
  78662. */
  78663. perspective?: ICameraPerspective;
  78664. /**
  78665. * Specifies if the camera uses a perspective or orthographic projection
  78666. */
  78667. type: CameraType;
  78668. }
  78669. /**
  78670. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78671. */
  78672. interface IImage extends IChildRootProperty {
  78673. /**
  78674. * 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
  78675. */
  78676. uri?: string;
  78677. /**
  78678. * The image's MIME type
  78679. */
  78680. mimeType?: ImageMimeType;
  78681. /**
  78682. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78683. */
  78684. bufferView?: number;
  78685. }
  78686. /**
  78687. * Material Normal Texture Info
  78688. */
  78689. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78690. /**
  78691. * The scalar multiplier applied to each normal vector of the normal texture
  78692. */
  78693. scale?: number;
  78694. }
  78695. /**
  78696. * Material Occlusion Texture Info
  78697. */
  78698. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78699. /**
  78700. * A scalar multiplier controlling the amount of occlusion applied
  78701. */
  78702. strength?: number;
  78703. }
  78704. /**
  78705. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78706. */
  78707. interface IMaterialPbrMetallicRoughness {
  78708. /**
  78709. * The material's base color factor
  78710. */
  78711. baseColorFactor?: number[];
  78712. /**
  78713. * The base color texture
  78714. */
  78715. baseColorTexture?: ITextureInfo;
  78716. /**
  78717. * The metalness of the material
  78718. */
  78719. metallicFactor?: number;
  78720. /**
  78721. * The roughness of the material
  78722. */
  78723. roughnessFactor?: number;
  78724. /**
  78725. * The metallic-roughness texture
  78726. */
  78727. metallicRoughnessTexture?: ITextureInfo;
  78728. }
  78729. /**
  78730. * The material appearance of a primitive
  78731. */
  78732. interface IMaterial extends IChildRootProperty {
  78733. /**
  78734. * 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
  78735. */
  78736. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78737. /**
  78738. * The normal map texture
  78739. */
  78740. normalTexture?: IMaterialNormalTextureInfo;
  78741. /**
  78742. * The occlusion map texture
  78743. */
  78744. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78745. /**
  78746. * The emissive map texture
  78747. */
  78748. emissiveTexture?: ITextureInfo;
  78749. /**
  78750. * 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
  78751. */
  78752. emissiveFactor?: number[];
  78753. /**
  78754. * The alpha rendering mode of the material
  78755. */
  78756. alphaMode?: MaterialAlphaMode;
  78757. /**
  78758. * The alpha cutoff value of the material
  78759. */
  78760. alphaCutoff?: number;
  78761. /**
  78762. * Specifies whether the material is double sided
  78763. */
  78764. doubleSided?: boolean;
  78765. }
  78766. /**
  78767. * Geometry to be rendered with the given material
  78768. */
  78769. interface IMeshPrimitive extends IProperty {
  78770. /**
  78771. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78772. */
  78773. attributes: {
  78774. [name: string]: number;
  78775. };
  78776. /**
  78777. * The index of the accessor that contains the indices
  78778. */
  78779. indices?: number;
  78780. /**
  78781. * The index of the material to apply to this primitive when rendering
  78782. */
  78783. material?: number;
  78784. /**
  78785. * The type of primitives to render. All valid values correspond to WebGL enums
  78786. */
  78787. mode?: MeshPrimitiveMode;
  78788. /**
  78789. * 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
  78790. */
  78791. targets?: {
  78792. [name: string]: number;
  78793. }[];
  78794. }
  78795. /**
  78796. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  78797. */
  78798. interface IMesh extends IChildRootProperty {
  78799. /**
  78800. * An array of primitives, each defining geometry to be rendered with a material
  78801. */
  78802. primitives: IMeshPrimitive[];
  78803. /**
  78804. * Array of weights to be applied to the Morph Targets
  78805. */
  78806. weights?: number[];
  78807. }
  78808. /**
  78809. * A node in the node hierarchy
  78810. */
  78811. interface INode extends IChildRootProperty {
  78812. /**
  78813. * The index of the camera referenced by this node
  78814. */
  78815. camera?: number;
  78816. /**
  78817. * The indices of this node's children
  78818. */
  78819. children?: number[];
  78820. /**
  78821. * The index of the skin referenced by this node
  78822. */
  78823. skin?: number;
  78824. /**
  78825. * A floating-point 4x4 transformation matrix stored in column-major order
  78826. */
  78827. matrix?: number[];
  78828. /**
  78829. * The index of the mesh in this node
  78830. */
  78831. mesh?: number;
  78832. /**
  78833. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  78834. */
  78835. rotation?: number[];
  78836. /**
  78837. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  78838. */
  78839. scale?: number[];
  78840. /**
  78841. * The node's translation along the x, y, and z axes
  78842. */
  78843. translation?: number[];
  78844. /**
  78845. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  78846. */
  78847. weights?: number[];
  78848. }
  78849. /**
  78850. * Texture sampler properties for filtering and wrapping modes
  78851. */
  78852. interface ISampler extends IChildRootProperty {
  78853. /**
  78854. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78855. */
  78856. magFilter?: TextureMagFilter;
  78857. /**
  78858. * Minification filter. All valid values correspond to WebGL enums
  78859. */
  78860. minFilter?: TextureMinFilter;
  78861. /**
  78862. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78863. */
  78864. wrapS?: TextureWrapMode;
  78865. /**
  78866. * T (V) wrapping mode. All valid values correspond to WebGL enums
  78867. */
  78868. wrapT?: TextureWrapMode;
  78869. }
  78870. /**
  78871. * The root nodes of a scene
  78872. */
  78873. interface IScene extends IChildRootProperty {
  78874. /**
  78875. * The indices of each root node
  78876. */
  78877. nodes: number[];
  78878. }
  78879. /**
  78880. * Joints and matrices defining a skin
  78881. */
  78882. interface ISkin extends IChildRootProperty {
  78883. /**
  78884. * 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
  78885. */
  78886. inverseBindMatrices?: number;
  78887. /**
  78888. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  78889. */
  78890. skeleton?: number;
  78891. /**
  78892. * 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)
  78893. */
  78894. joints: number[];
  78895. }
  78896. /**
  78897. * A texture and its sampler
  78898. */
  78899. interface ITexture extends IChildRootProperty {
  78900. /**
  78901. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  78902. */
  78903. sampler?: number;
  78904. /**
  78905. * The index of the image used by this texture
  78906. */
  78907. source: number;
  78908. }
  78909. /**
  78910. * Reference to a texture
  78911. */
  78912. interface ITextureInfo extends IProperty {
  78913. /**
  78914. * The index of the texture
  78915. */
  78916. index: number;
  78917. /**
  78918. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  78919. */
  78920. texCoord?: number;
  78921. }
  78922. /**
  78923. * The root object for a glTF asset
  78924. */
  78925. interface IGLTF extends IProperty {
  78926. /**
  78927. * An array of accessors. An accessor is a typed view into a bufferView
  78928. */
  78929. accessors?: IAccessor[];
  78930. /**
  78931. * An array of keyframe animations
  78932. */
  78933. animations?: IAnimation[];
  78934. /**
  78935. * Metadata about the glTF asset
  78936. */
  78937. asset: IAsset;
  78938. /**
  78939. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78940. */
  78941. buffers?: IBuffer[];
  78942. /**
  78943. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78944. */
  78945. bufferViews?: IBufferView[];
  78946. /**
  78947. * An array of cameras
  78948. */
  78949. cameras?: ICamera[];
  78950. /**
  78951. * Names of glTF extensions used somewhere in this asset
  78952. */
  78953. extensionsUsed?: string[];
  78954. /**
  78955. * Names of glTF extensions required to properly load this asset
  78956. */
  78957. extensionsRequired?: string[];
  78958. /**
  78959. * An array of images. An image defines data used to create a texture
  78960. */
  78961. images?: IImage[];
  78962. /**
  78963. * An array of materials. A material defines the appearance of a primitive
  78964. */
  78965. materials?: IMaterial[];
  78966. /**
  78967. * An array of meshes. A mesh is a set of primitives to be rendered
  78968. */
  78969. meshes?: IMesh[];
  78970. /**
  78971. * An array of nodes
  78972. */
  78973. nodes?: INode[];
  78974. /**
  78975. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78976. */
  78977. samplers?: ISampler[];
  78978. /**
  78979. * The index of the default scene
  78980. */
  78981. scene?: number;
  78982. /**
  78983. * An array of scenes
  78984. */
  78985. scenes?: IScene[];
  78986. /**
  78987. * An array of skins. A skin is defined by joints and matrices
  78988. */
  78989. skins?: ISkin[];
  78990. /**
  78991. * An array of textures
  78992. */
  78993. textures?: ITexture[];
  78994. }
  78995. /**
  78996. * The glTF validation results
  78997. * @ignore
  78998. */
  78999. interface IGLTFValidationResults {
  79000. info: {
  79001. generator: string;
  79002. hasAnimations: boolean;
  79003. hasDefaultScene: boolean;
  79004. hasMaterials: boolean;
  79005. hasMorphTargets: boolean;
  79006. hasSkins: boolean;
  79007. hasTextures: boolean;
  79008. maxAttributesUsed: number;
  79009. primitivesCount: number
  79010. };
  79011. issues: {
  79012. messages: Array<string>;
  79013. numErrors: number;
  79014. numHints: number;
  79015. numInfos: number;
  79016. numWarnings: number;
  79017. truncated: boolean
  79018. };
  79019. mimeType: string;
  79020. uri: string;
  79021. validatedAt: string;
  79022. validatorVersion: string;
  79023. }
  79024. /**
  79025. * The glTF validation options
  79026. */
  79027. interface IGLTFValidationOptions {
  79028. /** Uri to use */
  79029. uri?: string;
  79030. /** Function used to load external resources */
  79031. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79032. /** Boolean indicating that we need to validate accessor data */
  79033. validateAccessorData?: boolean;
  79034. /** max number of issues allowed */
  79035. maxIssues?: number;
  79036. /** Ignored issues */
  79037. ignoredIssues?: Array<string>;
  79038. /** Value to override severy settings */
  79039. severityOverrides?: Object;
  79040. }
  79041. /**
  79042. * The glTF validator object
  79043. * @ignore
  79044. */
  79045. interface IGLTFValidator {
  79046. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79047. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79048. }
  79049. }
  79050. declare module BABYLON {
  79051. /** @hidden */
  79052. export var cellPixelShader: {
  79053. name: string;
  79054. shader: string;
  79055. };
  79056. }
  79057. declare module BABYLON {
  79058. /** @hidden */
  79059. export var cellVertexShader: {
  79060. name: string;
  79061. shader: string;
  79062. };
  79063. }
  79064. declare module BABYLON {
  79065. export class CellMaterial extends BABYLON.PushMaterial {
  79066. private _diffuseTexture;
  79067. diffuseTexture: BABYLON.BaseTexture;
  79068. diffuseColor: BABYLON.Color3;
  79069. _computeHighLevel: boolean;
  79070. computeHighLevel: boolean;
  79071. private _disableLighting;
  79072. disableLighting: boolean;
  79073. private _maxSimultaneousLights;
  79074. maxSimultaneousLights: number;
  79075. private _renderId;
  79076. constructor(name: string, scene: BABYLON.Scene);
  79077. needAlphaBlending(): boolean;
  79078. needAlphaTesting(): boolean;
  79079. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79080. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79081. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79082. getAnimatables(): BABYLON.IAnimatable[];
  79083. getActiveTextures(): BABYLON.BaseTexture[];
  79084. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79085. dispose(forceDisposeEffect?: boolean): void;
  79086. getClassName(): string;
  79087. clone(name: string): CellMaterial;
  79088. serialize(): any;
  79089. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79090. }
  79091. }
  79092. declare module BABYLON {
  79093. export class CustomShaderStructure {
  79094. FragmentStore: string;
  79095. VertexStore: string;
  79096. constructor();
  79097. }
  79098. export class ShaderSpecialParts {
  79099. constructor();
  79100. Fragment_Begin: string;
  79101. Fragment_Definitions: string;
  79102. Fragment_MainBegin: string;
  79103. Fragment_Custom_Diffuse: string;
  79104. Fragment_Before_Lights: string;
  79105. Fragment_Before_Fog: string;
  79106. Fragment_Custom_Alpha: string;
  79107. Fragment_Before_FragColor: string;
  79108. Vertex_Begin: string;
  79109. Vertex_Definitions: string;
  79110. Vertex_MainBegin: string;
  79111. Vertex_Before_PositionUpdated: string;
  79112. Vertex_Before_NormalUpdated: string;
  79113. Vertex_MainEnd: string;
  79114. }
  79115. export class CustomMaterial extends BABYLON.StandardMaterial {
  79116. static ShaderIndexer: number;
  79117. CustomParts: ShaderSpecialParts;
  79118. _isCreatedShader: boolean;
  79119. _createdShaderName: string;
  79120. _customUniform: string[];
  79121. _newUniforms: string[];
  79122. _newUniformInstances: any[];
  79123. _newSamplerInstances: BABYLON.Texture[];
  79124. FragmentShader: string;
  79125. VertexShader: string;
  79126. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79127. ReviewUniform(name: string, arr: string[]): string[];
  79128. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  79129. constructor(name: string, scene: BABYLON.Scene);
  79130. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79131. Fragment_Begin(shaderPart: string): CustomMaterial;
  79132. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79133. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79134. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79135. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79136. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79137. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79138. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79139. Vertex_Begin(shaderPart: string): CustomMaterial;
  79140. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79141. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79142. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79143. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79144. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79145. }
  79146. }
  79147. declare module BABYLON {
  79148. export class ShaderAlebdoParts {
  79149. constructor();
  79150. Fragment_Begin: string;
  79151. Fragment_Definitions: string;
  79152. Fragment_MainBegin: string;
  79153. Fragment_Custom_Albedo: string;
  79154. Fragment_Before_Lights: string;
  79155. Fragment_Custom_MetallicRoughness: string;
  79156. Fragment_Custom_MicroSurface: string;
  79157. Fragment_Before_Fog: string;
  79158. Fragment_Custom_Alpha: string;
  79159. Fragment_Before_FragColor: string;
  79160. Vertex_Begin: string;
  79161. Vertex_Definitions: string;
  79162. Vertex_MainBegin: string;
  79163. Vertex_Before_PositionUpdated: string;
  79164. Vertex_Before_NormalUpdated: string;
  79165. Vertex_MainEnd: string;
  79166. }
  79167. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79168. static ShaderIndexer: number;
  79169. CustomParts: ShaderAlebdoParts;
  79170. _isCreatedShader: boolean;
  79171. _createdShaderName: string;
  79172. _customUniform: string[];
  79173. _newUniforms: string[];
  79174. _newUniformInstances: any[];
  79175. _newSamplerInstances: BABYLON.Texture[];
  79176. FragmentShader: string;
  79177. VertexShader: string;
  79178. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79179. ReviewUniform(name: string, arr: string[]): string[];
  79180. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  79181. constructor(name: string, scene: BABYLON.Scene);
  79182. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79183. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79184. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79185. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79186. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79187. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79188. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79189. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79190. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79191. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79192. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79193. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79194. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79195. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79196. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79197. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79198. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79199. }
  79200. }
  79201. declare module BABYLON {
  79202. /** @hidden */
  79203. export var firePixelShader: {
  79204. name: string;
  79205. shader: string;
  79206. };
  79207. }
  79208. declare module BABYLON {
  79209. /** @hidden */
  79210. export var fireVertexShader: {
  79211. name: string;
  79212. shader: string;
  79213. };
  79214. }
  79215. declare module BABYLON {
  79216. export class FireMaterial extends BABYLON.PushMaterial {
  79217. private _diffuseTexture;
  79218. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79219. private _distortionTexture;
  79220. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79221. private _opacityTexture;
  79222. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79223. diffuseColor: BABYLON.Color3;
  79224. speed: number;
  79225. private _scaledDiffuse;
  79226. private _renderId;
  79227. private _lastTime;
  79228. constructor(name: string, scene: BABYLON.Scene);
  79229. needAlphaBlending(): boolean;
  79230. needAlphaTesting(): boolean;
  79231. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79232. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79233. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79234. getAnimatables(): BABYLON.IAnimatable[];
  79235. getActiveTextures(): BABYLON.BaseTexture[];
  79236. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79237. getClassName(): string;
  79238. dispose(forceDisposeEffect?: boolean): void;
  79239. clone(name: string): FireMaterial;
  79240. serialize(): any;
  79241. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79242. }
  79243. }
  79244. declare module BABYLON {
  79245. /** @hidden */
  79246. export var furPixelShader: {
  79247. name: string;
  79248. shader: string;
  79249. };
  79250. }
  79251. declare module BABYLON {
  79252. /** @hidden */
  79253. export var furVertexShader: {
  79254. name: string;
  79255. shader: string;
  79256. };
  79257. }
  79258. declare module BABYLON {
  79259. export class FurMaterial extends BABYLON.PushMaterial {
  79260. private _diffuseTexture;
  79261. diffuseTexture: BABYLON.BaseTexture;
  79262. private _heightTexture;
  79263. heightTexture: BABYLON.BaseTexture;
  79264. diffuseColor: BABYLON.Color3;
  79265. furLength: number;
  79266. furAngle: number;
  79267. furColor: BABYLON.Color3;
  79268. furOffset: number;
  79269. furSpacing: number;
  79270. furGravity: BABYLON.Vector3;
  79271. furSpeed: number;
  79272. furDensity: number;
  79273. furOcclusion: number;
  79274. furTexture: BABYLON.DynamicTexture;
  79275. private _disableLighting;
  79276. disableLighting: boolean;
  79277. private _maxSimultaneousLights;
  79278. maxSimultaneousLights: number;
  79279. highLevelFur: boolean;
  79280. _meshes: BABYLON.AbstractMesh[];
  79281. private _renderId;
  79282. private _furTime;
  79283. constructor(name: string, scene: BABYLON.Scene);
  79284. get furTime(): number;
  79285. set furTime(furTime: number);
  79286. needAlphaBlending(): boolean;
  79287. needAlphaTesting(): boolean;
  79288. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79289. updateFur(): void;
  79290. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79291. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79292. getAnimatables(): BABYLON.IAnimatable[];
  79293. getActiveTextures(): BABYLON.BaseTexture[];
  79294. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79295. dispose(forceDisposeEffect?: boolean): void;
  79296. clone(name: string): FurMaterial;
  79297. serialize(): any;
  79298. getClassName(): string;
  79299. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79300. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79301. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79302. }
  79303. }
  79304. declare module BABYLON {
  79305. /** @hidden */
  79306. export var gradientPixelShader: {
  79307. name: string;
  79308. shader: string;
  79309. };
  79310. }
  79311. declare module BABYLON {
  79312. /** @hidden */
  79313. export var gradientVertexShader: {
  79314. name: string;
  79315. shader: string;
  79316. };
  79317. }
  79318. declare module BABYLON {
  79319. export class GradientMaterial extends BABYLON.PushMaterial {
  79320. private _maxSimultaneousLights;
  79321. maxSimultaneousLights: number;
  79322. topColor: BABYLON.Color3;
  79323. topColorAlpha: number;
  79324. bottomColor: BABYLON.Color3;
  79325. bottomColorAlpha: number;
  79326. offset: number;
  79327. scale: number;
  79328. smoothness: number;
  79329. private _disableLighting;
  79330. disableLighting: boolean;
  79331. private _renderId;
  79332. constructor(name: string, scene: BABYLON.Scene);
  79333. needAlphaBlending(): boolean;
  79334. needAlphaTesting(): boolean;
  79335. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79336. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79337. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79338. getAnimatables(): BABYLON.IAnimatable[];
  79339. dispose(forceDisposeEffect?: boolean): void;
  79340. clone(name: string): GradientMaterial;
  79341. serialize(): any;
  79342. getClassName(): string;
  79343. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79344. }
  79345. }
  79346. declare module BABYLON {
  79347. /** @hidden */
  79348. export var gridPixelShader: {
  79349. name: string;
  79350. shader: string;
  79351. };
  79352. }
  79353. declare module BABYLON {
  79354. /** @hidden */
  79355. export var gridVertexShader: {
  79356. name: string;
  79357. shader: string;
  79358. };
  79359. }
  79360. declare module BABYLON {
  79361. /**
  79362. * The grid materials allows you to wrap any shape with a grid.
  79363. * Colors are customizable.
  79364. */
  79365. export class GridMaterial extends BABYLON.PushMaterial {
  79366. /**
  79367. * Main color of the grid (e.g. between lines)
  79368. */
  79369. mainColor: BABYLON.Color3;
  79370. /**
  79371. * Color of the grid lines.
  79372. */
  79373. lineColor: BABYLON.Color3;
  79374. /**
  79375. * The scale of the grid compared to unit.
  79376. */
  79377. gridRatio: number;
  79378. /**
  79379. * Allows setting an offset for the grid lines.
  79380. */
  79381. gridOffset: BABYLON.Vector3;
  79382. /**
  79383. * The frequency of thicker lines.
  79384. */
  79385. majorUnitFrequency: number;
  79386. /**
  79387. * The visibility of minor units in the grid.
  79388. */
  79389. minorUnitVisibility: number;
  79390. /**
  79391. * The grid opacity outside of the lines.
  79392. */
  79393. opacity: number;
  79394. /**
  79395. * Determine RBG output is premultiplied by alpha value.
  79396. */
  79397. preMultiplyAlpha: boolean;
  79398. private _opacityTexture;
  79399. opacityTexture: BABYLON.BaseTexture;
  79400. private _gridControl;
  79401. private _renderId;
  79402. /**
  79403. * constructor
  79404. * @param name The name given to the material in order to identify it afterwards.
  79405. * @param scene The scene the material is used in.
  79406. */
  79407. constructor(name: string, scene: BABYLON.Scene);
  79408. /**
  79409. * Returns wehter or not the grid requires alpha blending.
  79410. */
  79411. needAlphaBlending(): boolean;
  79412. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79413. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79414. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79415. /**
  79416. * Dispose the material and its associated resources.
  79417. * @param forceDisposeEffect will also dispose the used effect when true
  79418. */
  79419. dispose(forceDisposeEffect?: boolean): void;
  79420. clone(name: string): GridMaterial;
  79421. serialize(): any;
  79422. getClassName(): string;
  79423. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79424. }
  79425. }
  79426. declare module BABYLON {
  79427. /** @hidden */
  79428. export var lavaPixelShader: {
  79429. name: string;
  79430. shader: string;
  79431. };
  79432. }
  79433. declare module BABYLON {
  79434. /** @hidden */
  79435. export var lavaVertexShader: {
  79436. name: string;
  79437. shader: string;
  79438. };
  79439. }
  79440. declare module BABYLON {
  79441. export class LavaMaterial extends BABYLON.PushMaterial {
  79442. private _diffuseTexture;
  79443. diffuseTexture: BABYLON.BaseTexture;
  79444. noiseTexture: BABYLON.BaseTexture;
  79445. fogColor: BABYLON.Color3;
  79446. speed: number;
  79447. movingSpeed: number;
  79448. lowFrequencySpeed: number;
  79449. fogDensity: number;
  79450. private _lastTime;
  79451. diffuseColor: BABYLON.Color3;
  79452. private _disableLighting;
  79453. disableLighting: boolean;
  79454. private _unlit;
  79455. unlit: boolean;
  79456. private _maxSimultaneousLights;
  79457. maxSimultaneousLights: number;
  79458. private _scaledDiffuse;
  79459. private _renderId;
  79460. constructor(name: string, scene: BABYLON.Scene);
  79461. needAlphaBlending(): boolean;
  79462. needAlphaTesting(): boolean;
  79463. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79464. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79465. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79466. getAnimatables(): BABYLON.IAnimatable[];
  79467. getActiveTextures(): BABYLON.BaseTexture[];
  79468. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79469. dispose(forceDisposeEffect?: boolean): void;
  79470. clone(name: string): LavaMaterial;
  79471. serialize(): any;
  79472. getClassName(): string;
  79473. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79474. }
  79475. }
  79476. declare module BABYLON {
  79477. /** @hidden */
  79478. export var mixPixelShader: {
  79479. name: string;
  79480. shader: string;
  79481. };
  79482. }
  79483. declare module BABYLON {
  79484. /** @hidden */
  79485. export var mixVertexShader: {
  79486. name: string;
  79487. shader: string;
  79488. };
  79489. }
  79490. declare module BABYLON {
  79491. export class MixMaterial extends BABYLON.PushMaterial {
  79492. /**
  79493. * Mix textures
  79494. */
  79495. private _mixTexture1;
  79496. mixTexture1: BABYLON.BaseTexture;
  79497. private _mixTexture2;
  79498. mixTexture2: BABYLON.BaseTexture;
  79499. /**
  79500. * Diffuse textures
  79501. */
  79502. private _diffuseTexture1;
  79503. diffuseTexture1: BABYLON.Texture;
  79504. private _diffuseTexture2;
  79505. diffuseTexture2: BABYLON.Texture;
  79506. private _diffuseTexture3;
  79507. diffuseTexture3: BABYLON.Texture;
  79508. private _diffuseTexture4;
  79509. diffuseTexture4: BABYLON.Texture;
  79510. private _diffuseTexture5;
  79511. diffuseTexture5: BABYLON.Texture;
  79512. private _diffuseTexture6;
  79513. diffuseTexture6: BABYLON.Texture;
  79514. private _diffuseTexture7;
  79515. diffuseTexture7: BABYLON.Texture;
  79516. private _diffuseTexture8;
  79517. diffuseTexture8: BABYLON.Texture;
  79518. /**
  79519. * Uniforms
  79520. */
  79521. diffuseColor: BABYLON.Color3;
  79522. specularColor: BABYLON.Color3;
  79523. specularPower: number;
  79524. private _disableLighting;
  79525. disableLighting: boolean;
  79526. private _maxSimultaneousLights;
  79527. maxSimultaneousLights: number;
  79528. private _renderId;
  79529. constructor(name: string, scene: BABYLON.Scene);
  79530. needAlphaBlending(): boolean;
  79531. needAlphaTesting(): boolean;
  79532. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79533. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79534. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79535. getAnimatables(): BABYLON.IAnimatable[];
  79536. getActiveTextures(): BABYLON.BaseTexture[];
  79537. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79538. dispose(forceDisposeEffect?: boolean): void;
  79539. clone(name: string): MixMaterial;
  79540. serialize(): any;
  79541. getClassName(): string;
  79542. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  79543. }
  79544. }
  79545. declare module BABYLON {
  79546. /** @hidden */
  79547. export var normalPixelShader: {
  79548. name: string;
  79549. shader: string;
  79550. };
  79551. }
  79552. declare module BABYLON {
  79553. /** @hidden */
  79554. export var normalVertexShader: {
  79555. name: string;
  79556. shader: string;
  79557. };
  79558. }
  79559. declare module BABYLON {
  79560. export class NormalMaterial extends BABYLON.PushMaterial {
  79561. private _diffuseTexture;
  79562. diffuseTexture: BABYLON.BaseTexture;
  79563. diffuseColor: BABYLON.Color3;
  79564. private _disableLighting;
  79565. disableLighting: boolean;
  79566. private _maxSimultaneousLights;
  79567. maxSimultaneousLights: number;
  79568. private _renderId;
  79569. constructor(name: string, scene: BABYLON.Scene);
  79570. needAlphaBlending(): boolean;
  79571. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79572. needAlphaTesting(): boolean;
  79573. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79574. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79575. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79576. getAnimatables(): BABYLON.IAnimatable[];
  79577. getActiveTextures(): BABYLON.BaseTexture[];
  79578. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79579. dispose(forceDisposeEffect?: boolean): void;
  79580. clone(name: string): NormalMaterial;
  79581. serialize(): any;
  79582. getClassName(): string;
  79583. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79584. }
  79585. }
  79586. declare module BABYLON {
  79587. /** @hidden */
  79588. export var shadowOnlyPixelShader: {
  79589. name: string;
  79590. shader: string;
  79591. };
  79592. }
  79593. declare module BABYLON {
  79594. /** @hidden */
  79595. export var shadowOnlyVertexShader: {
  79596. name: string;
  79597. shader: string;
  79598. };
  79599. }
  79600. declare module BABYLON {
  79601. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79602. private _renderId;
  79603. private _activeLight;
  79604. constructor(name: string, scene: BABYLON.Scene);
  79605. shadowColor: BABYLON.Color3;
  79606. needAlphaBlending(): boolean;
  79607. needAlphaTesting(): boolean;
  79608. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79609. get activeLight(): BABYLON.IShadowLight;
  79610. set activeLight(light: BABYLON.IShadowLight);
  79611. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79612. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79613. clone(name: string): ShadowOnlyMaterial;
  79614. serialize(): any;
  79615. getClassName(): string;
  79616. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79617. }
  79618. }
  79619. declare module BABYLON {
  79620. /** @hidden */
  79621. export var simplePixelShader: {
  79622. name: string;
  79623. shader: string;
  79624. };
  79625. }
  79626. declare module BABYLON {
  79627. /** @hidden */
  79628. export var simpleVertexShader: {
  79629. name: string;
  79630. shader: string;
  79631. };
  79632. }
  79633. declare module BABYLON {
  79634. export class SimpleMaterial extends BABYLON.PushMaterial {
  79635. private _diffuseTexture;
  79636. diffuseTexture: BABYLON.BaseTexture;
  79637. diffuseColor: BABYLON.Color3;
  79638. private _disableLighting;
  79639. disableLighting: boolean;
  79640. private _maxSimultaneousLights;
  79641. maxSimultaneousLights: number;
  79642. private _renderId;
  79643. constructor(name: string, scene: BABYLON.Scene);
  79644. needAlphaBlending(): boolean;
  79645. needAlphaTesting(): boolean;
  79646. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79647. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79648. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79649. getAnimatables(): BABYLON.IAnimatable[];
  79650. getActiveTextures(): BABYLON.BaseTexture[];
  79651. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79652. dispose(forceDisposeEffect?: boolean): void;
  79653. clone(name: string): SimpleMaterial;
  79654. serialize(): any;
  79655. getClassName(): string;
  79656. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79657. }
  79658. }
  79659. declare module BABYLON {
  79660. /** @hidden */
  79661. export var skyPixelShader: {
  79662. name: string;
  79663. shader: string;
  79664. };
  79665. }
  79666. declare module BABYLON {
  79667. /** @hidden */
  79668. export var skyVertexShader: {
  79669. name: string;
  79670. shader: string;
  79671. };
  79672. }
  79673. declare module BABYLON {
  79674. /**
  79675. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79676. * @see https://doc.babylonjs.com/extensions/sky
  79677. */
  79678. export class SkyMaterial extends BABYLON.PushMaterial {
  79679. /**
  79680. * Defines the overall luminance of sky in interval ]0, 1[.
  79681. */
  79682. luminance: number;
  79683. /**
  79684. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79685. */
  79686. turbidity: number;
  79687. /**
  79688. * Defines the sky appearance (light intensity).
  79689. */
  79690. rayleigh: number;
  79691. /**
  79692. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79693. */
  79694. mieCoefficient: number;
  79695. /**
  79696. * Defines the amount of haze particles following the Mie scattering theory.
  79697. */
  79698. mieDirectionalG: number;
  79699. /**
  79700. * Defines the distance of the sun according to the active scene camera.
  79701. */
  79702. distance: number;
  79703. /**
  79704. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79705. * "inclined".
  79706. */
  79707. inclination: number;
  79708. /**
  79709. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79710. * an object direction and a reference direction.
  79711. */
  79712. azimuth: number;
  79713. /**
  79714. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79715. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79716. */
  79717. sunPosition: BABYLON.Vector3;
  79718. /**
  79719. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79720. * .sunPosition property.
  79721. */
  79722. useSunPosition: boolean;
  79723. /**
  79724. * Defines an offset vector used to get a horizon offset.
  79725. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79726. */
  79727. cameraOffset: BABYLON.Vector3;
  79728. private _cameraPosition;
  79729. private _renderId;
  79730. /**
  79731. * Instantiates a new sky material.
  79732. * This material allows to create dynamic and texture free
  79733. * effects for skyboxes by taking care of the atmosphere state.
  79734. * @see https://doc.babylonjs.com/extensions/sky
  79735. * @param name Define the name of the material in the scene
  79736. * @param scene Define the scene the material belong to
  79737. */
  79738. constructor(name: string, scene: BABYLON.Scene);
  79739. /**
  79740. * Specifies if the material will require alpha blending
  79741. * @returns a boolean specifying if alpha blending is needed
  79742. */
  79743. needAlphaBlending(): boolean;
  79744. /**
  79745. * Specifies if this material should be rendered in alpha test mode
  79746. * @returns false as the sky material doesn't need alpha testing.
  79747. */
  79748. needAlphaTesting(): boolean;
  79749. /**
  79750. * Get the texture used for alpha test purpose.
  79751. * @returns null as the sky material has no texture.
  79752. */
  79753. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79754. /**
  79755. * Get if the submesh is ready to be used and all its information available.
  79756. * Child classes can use it to update shaders
  79757. * @param mesh defines the mesh to check
  79758. * @param subMesh defines which submesh to check
  79759. * @param useInstances specifies that instances should be used
  79760. * @returns a boolean indicating that the submesh is ready or not
  79761. */
  79762. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79763. /**
  79764. * Binds the submesh to this material by preparing the effect and shader to draw
  79765. * @param world defines the world transformation matrix
  79766. * @param mesh defines the mesh containing the submesh
  79767. * @param subMesh defines the submesh to bind the material to
  79768. */
  79769. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79770. /**
  79771. * Get the list of animatables in the material.
  79772. * @returns the list of animatables object used in the material
  79773. */
  79774. getAnimatables(): BABYLON.IAnimatable[];
  79775. /**
  79776. * Disposes the material
  79777. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79778. */
  79779. dispose(forceDisposeEffect?: boolean): void;
  79780. /**
  79781. * Makes a duplicate of the material, and gives it a new name
  79782. * @param name defines the new name for the duplicated material
  79783. * @returns the cloned material
  79784. */
  79785. clone(name: string): SkyMaterial;
  79786. /**
  79787. * Serializes this material in a JSON representation
  79788. * @returns the serialized material object
  79789. */
  79790. serialize(): any;
  79791. /**
  79792. * Gets the current class name of the material e.g. "SkyMaterial"
  79793. * Mainly use in serialization.
  79794. * @returns the class name
  79795. */
  79796. getClassName(): string;
  79797. /**
  79798. * Creates a sky material from parsed material data
  79799. * @param source defines the JSON representation of the material
  79800. * @param scene defines the hosting scene
  79801. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79802. * @returns a new sky material
  79803. */
  79804. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  79805. }
  79806. }
  79807. declare module BABYLON {
  79808. /** @hidden */
  79809. export var terrainPixelShader: {
  79810. name: string;
  79811. shader: string;
  79812. };
  79813. }
  79814. declare module BABYLON {
  79815. /** @hidden */
  79816. export var terrainVertexShader: {
  79817. name: string;
  79818. shader: string;
  79819. };
  79820. }
  79821. declare module BABYLON {
  79822. export class TerrainMaterial extends BABYLON.PushMaterial {
  79823. private _mixTexture;
  79824. mixTexture: BABYLON.BaseTexture;
  79825. private _diffuseTexture1;
  79826. diffuseTexture1: BABYLON.Texture;
  79827. private _diffuseTexture2;
  79828. diffuseTexture2: BABYLON.Texture;
  79829. private _diffuseTexture3;
  79830. diffuseTexture3: BABYLON.Texture;
  79831. private _bumpTexture1;
  79832. bumpTexture1: BABYLON.Texture;
  79833. private _bumpTexture2;
  79834. bumpTexture2: BABYLON.Texture;
  79835. private _bumpTexture3;
  79836. bumpTexture3: BABYLON.Texture;
  79837. diffuseColor: BABYLON.Color3;
  79838. specularColor: BABYLON.Color3;
  79839. specularPower: number;
  79840. private _disableLighting;
  79841. disableLighting: boolean;
  79842. private _maxSimultaneousLights;
  79843. maxSimultaneousLights: number;
  79844. private _renderId;
  79845. constructor(name: string, scene: BABYLON.Scene);
  79846. needAlphaBlending(): boolean;
  79847. needAlphaTesting(): boolean;
  79848. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79849. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79850. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79851. getAnimatables(): BABYLON.IAnimatable[];
  79852. getActiveTextures(): BABYLON.BaseTexture[];
  79853. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79854. dispose(forceDisposeEffect?: boolean): void;
  79855. clone(name: string): TerrainMaterial;
  79856. serialize(): any;
  79857. getClassName(): string;
  79858. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  79859. }
  79860. }
  79861. declare module BABYLON {
  79862. /** @hidden */
  79863. export var triplanarPixelShader: {
  79864. name: string;
  79865. shader: string;
  79866. };
  79867. }
  79868. declare module BABYLON {
  79869. /** @hidden */
  79870. export var triplanarVertexShader: {
  79871. name: string;
  79872. shader: string;
  79873. };
  79874. }
  79875. declare module BABYLON {
  79876. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  79877. mixTexture: BABYLON.BaseTexture;
  79878. private _diffuseTextureX;
  79879. diffuseTextureX: BABYLON.BaseTexture;
  79880. private _diffuseTextureY;
  79881. diffuseTextureY: BABYLON.BaseTexture;
  79882. private _diffuseTextureZ;
  79883. diffuseTextureZ: BABYLON.BaseTexture;
  79884. private _normalTextureX;
  79885. normalTextureX: BABYLON.BaseTexture;
  79886. private _normalTextureY;
  79887. normalTextureY: BABYLON.BaseTexture;
  79888. private _normalTextureZ;
  79889. normalTextureZ: BABYLON.BaseTexture;
  79890. tileSize: number;
  79891. diffuseColor: BABYLON.Color3;
  79892. specularColor: BABYLON.Color3;
  79893. specularPower: number;
  79894. private _disableLighting;
  79895. disableLighting: boolean;
  79896. private _maxSimultaneousLights;
  79897. maxSimultaneousLights: number;
  79898. private _renderId;
  79899. constructor(name: string, scene: BABYLON.Scene);
  79900. needAlphaBlending(): boolean;
  79901. needAlphaTesting(): boolean;
  79902. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79903. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79904. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79905. getAnimatables(): BABYLON.IAnimatable[];
  79906. getActiveTextures(): BABYLON.BaseTexture[];
  79907. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79908. dispose(forceDisposeEffect?: boolean): void;
  79909. clone(name: string): TriPlanarMaterial;
  79910. serialize(): any;
  79911. getClassName(): string;
  79912. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  79913. }
  79914. }
  79915. declare module BABYLON {
  79916. /** @hidden */
  79917. export var waterPixelShader: {
  79918. name: string;
  79919. shader: string;
  79920. };
  79921. }
  79922. declare module BABYLON {
  79923. /** @hidden */
  79924. export var waterVertexShader: {
  79925. name: string;
  79926. shader: string;
  79927. };
  79928. }
  79929. declare module BABYLON {
  79930. export class WaterMaterial extends BABYLON.PushMaterial {
  79931. renderTargetSize: BABYLON.Vector2;
  79932. private _bumpTexture;
  79933. bumpTexture: BABYLON.BaseTexture;
  79934. diffuseColor: BABYLON.Color3;
  79935. specularColor: BABYLON.Color3;
  79936. specularPower: number;
  79937. private _disableLighting;
  79938. disableLighting: boolean;
  79939. private _maxSimultaneousLights;
  79940. maxSimultaneousLights: number;
  79941. /**
  79942. * @param {number}: Represents the wind force
  79943. */
  79944. windForce: number;
  79945. /**
  79946. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79947. */
  79948. windDirection: BABYLON.Vector2;
  79949. /**
  79950. * @param {number}: Wave height, represents the height of the waves
  79951. */
  79952. waveHeight: number;
  79953. /**
  79954. * @param {number}: Bump height, represents the bump height related to the bump map
  79955. */
  79956. bumpHeight: number;
  79957. /**
  79958. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79959. */
  79960. private _bumpSuperimpose;
  79961. bumpSuperimpose: boolean;
  79962. /**
  79963. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79964. */
  79965. private _fresnelSeparate;
  79966. fresnelSeparate: boolean;
  79967. /**
  79968. * @param {boolean}: bump Waves modify the reflection.
  79969. */
  79970. private _bumpAffectsReflection;
  79971. bumpAffectsReflection: boolean;
  79972. /**
  79973. * @param {number}: The water color blended with the refraction (near)
  79974. */
  79975. waterColor: BABYLON.Color3;
  79976. /**
  79977. * @param {number}: The blend factor related to the water color
  79978. */
  79979. colorBlendFactor: number;
  79980. /**
  79981. * @param {number}: The water color blended with the reflection (far)
  79982. */
  79983. waterColor2: BABYLON.Color3;
  79984. /**
  79985. * @param {number}: The blend factor related to the water color (reflection, far)
  79986. */
  79987. colorBlendFactor2: number;
  79988. /**
  79989. * @param {number}: Represents the maximum length of a wave
  79990. */
  79991. waveLength: number;
  79992. /**
  79993. * @param {number}: Defines the waves speed
  79994. */
  79995. waveSpeed: number;
  79996. /**
  79997. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79998. * will avoid calculating useless pixels in the pixel shader of the water material.
  79999. */
  80000. disableClipPlane: boolean;
  80001. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80002. private _mesh;
  80003. private _refractionRTT;
  80004. private _reflectionRTT;
  80005. private _reflectionTransform;
  80006. private _lastTime;
  80007. private _lastDeltaTime;
  80008. private _renderId;
  80009. private _useLogarithmicDepth;
  80010. private _waitingRenderList;
  80011. private _imageProcessingConfiguration;
  80012. private _imageProcessingObserver;
  80013. /**
  80014. * Gets a boolean indicating that current material needs to register RTT
  80015. */
  80016. get hasRenderTargetTextures(): boolean;
  80017. /**
  80018. * Constructor
  80019. */
  80020. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80021. get useLogarithmicDepth(): boolean;
  80022. set useLogarithmicDepth(value: boolean);
  80023. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80024. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80025. addToRenderList(node: any): void;
  80026. enableRenderTargets(enable: boolean): void;
  80027. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80028. get renderTargetsEnabled(): boolean;
  80029. needAlphaBlending(): boolean;
  80030. needAlphaTesting(): boolean;
  80031. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80032. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80033. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80034. private _createRenderTargets;
  80035. getAnimatables(): BABYLON.IAnimatable[];
  80036. getActiveTextures(): BABYLON.BaseTexture[];
  80037. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80038. dispose(forceDisposeEffect?: boolean): void;
  80039. clone(name: string): WaterMaterial;
  80040. serialize(): any;
  80041. getClassName(): string;
  80042. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80043. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80044. }
  80045. }
  80046. declare module BABYLON {
  80047. /** @hidden */
  80048. export var asciiartPixelShader: {
  80049. name: string;
  80050. shader: string;
  80051. };
  80052. }
  80053. declare module BABYLON {
  80054. /**
  80055. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80056. *
  80057. * It basically takes care rendering the font front the given font size to a texture.
  80058. * This is used later on in the postprocess.
  80059. */
  80060. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80061. private _font;
  80062. private _text;
  80063. private _charSize;
  80064. /**
  80065. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80066. */
  80067. get charSize(): number;
  80068. /**
  80069. * Create a new instance of the Ascii Art FontTexture class
  80070. * @param name the name of the texture
  80071. * @param font the font to use, use the W3C CSS notation
  80072. * @param text the caracter set to use in the rendering.
  80073. * @param scene the scene that owns the texture
  80074. */
  80075. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80076. /**
  80077. * Gets the max char width of a font.
  80078. * @param font the font to use, use the W3C CSS notation
  80079. * @return the max char width
  80080. */
  80081. private getFontWidth;
  80082. /**
  80083. * Gets the max char height of a font.
  80084. * @param font the font to use, use the W3C CSS notation
  80085. * @return the max char height
  80086. */
  80087. private getFontHeight;
  80088. /**
  80089. * Clones the current AsciiArtTexture.
  80090. * @return the clone of the texture.
  80091. */
  80092. clone(): AsciiArtFontTexture;
  80093. /**
  80094. * Parses a json object representing the texture and returns an instance of it.
  80095. * @param source the source JSON representation
  80096. * @param scene the scene to create the texture for
  80097. * @return the parsed texture
  80098. */
  80099. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80100. }
  80101. /**
  80102. * Option available in the Ascii Art Post Process.
  80103. */
  80104. export interface IAsciiArtPostProcessOptions {
  80105. /**
  80106. * The font to use following the w3c font definition.
  80107. */
  80108. font?: string;
  80109. /**
  80110. * The character set to use in the postprocess.
  80111. */
  80112. characterSet?: string;
  80113. /**
  80114. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80115. * This number is defined between 0 and 1;
  80116. */
  80117. mixToTile?: number;
  80118. /**
  80119. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80120. * This number is defined between 0 and 1;
  80121. */
  80122. mixToNormal?: number;
  80123. }
  80124. /**
  80125. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80126. *
  80127. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80128. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80129. */
  80130. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80131. /**
  80132. * The font texture used to render the char in the post process.
  80133. */
  80134. private _asciiArtFontTexture;
  80135. /**
  80136. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80137. * This number is defined between 0 and 1;
  80138. */
  80139. mixToTile: number;
  80140. /**
  80141. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80142. * This number is defined between 0 and 1;
  80143. */
  80144. mixToNormal: number;
  80145. /**
  80146. * Instantiates a new Ascii Art Post Process.
  80147. * @param name the name to give to the postprocess
  80148. * @camera the camera to apply the post process to.
  80149. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80150. */
  80151. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80152. }
  80153. }
  80154. declare module BABYLON {
  80155. /** @hidden */
  80156. export var digitalrainPixelShader: {
  80157. name: string;
  80158. shader: string;
  80159. };
  80160. }
  80161. declare module BABYLON {
  80162. /**
  80163. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80164. *
  80165. * It basically takes care rendering the font front the given font size to a texture.
  80166. * This is used later on in the postprocess.
  80167. */
  80168. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80169. private _font;
  80170. private _text;
  80171. private _charSize;
  80172. /**
  80173. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80174. */
  80175. get charSize(): number;
  80176. /**
  80177. * Create a new instance of the Digital Rain FontTexture class
  80178. * @param name the name of the texture
  80179. * @param font the font to use, use the W3C CSS notation
  80180. * @param text the caracter set to use in the rendering.
  80181. * @param scene the scene that owns the texture
  80182. */
  80183. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80184. /**
  80185. * Gets the max char width of a font.
  80186. * @param font the font to use, use the W3C CSS notation
  80187. * @return the max char width
  80188. */
  80189. private getFontWidth;
  80190. /**
  80191. * Gets the max char height of a font.
  80192. * @param font the font to use, use the W3C CSS notation
  80193. * @return the max char height
  80194. */
  80195. private getFontHeight;
  80196. /**
  80197. * Clones the current DigitalRainFontTexture.
  80198. * @return the clone of the texture.
  80199. */
  80200. clone(): DigitalRainFontTexture;
  80201. /**
  80202. * Parses a json object representing the texture and returns an instance of it.
  80203. * @param source the source JSON representation
  80204. * @param scene the scene to create the texture for
  80205. * @return the parsed texture
  80206. */
  80207. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80208. }
  80209. /**
  80210. * Option available in the Digital Rain Post Process.
  80211. */
  80212. export interface IDigitalRainPostProcessOptions {
  80213. /**
  80214. * The font to use following the w3c font definition.
  80215. */
  80216. font?: string;
  80217. /**
  80218. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80219. * This number is defined between 0 and 1;
  80220. */
  80221. mixToTile?: number;
  80222. /**
  80223. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80224. * This number is defined between 0 and 1;
  80225. */
  80226. mixToNormal?: number;
  80227. }
  80228. /**
  80229. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80230. *
  80231. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80232. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80233. */
  80234. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80235. /**
  80236. * The font texture used to render the char in the post process.
  80237. */
  80238. private _digitalRainFontTexture;
  80239. /**
  80240. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80241. * This number is defined between 0 and 1;
  80242. */
  80243. mixToTile: number;
  80244. /**
  80245. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80246. * This number is defined between 0 and 1;
  80247. */
  80248. mixToNormal: number;
  80249. /**
  80250. * Instantiates a new Digital Rain Post Process.
  80251. * @param name the name to give to the postprocess
  80252. * @camera the camera to apply the post process to.
  80253. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80254. */
  80255. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80256. }
  80257. }
  80258. declare module BABYLON {
  80259. /** @hidden */
  80260. export var brickProceduralTexturePixelShader: {
  80261. name: string;
  80262. shader: string;
  80263. };
  80264. }
  80265. declare module BABYLON {
  80266. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80267. private _numberOfBricksHeight;
  80268. private _numberOfBricksWidth;
  80269. private _jointColor;
  80270. private _brickColor;
  80271. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80272. updateShaderUniforms(): void;
  80273. get numberOfBricksHeight(): number;
  80274. set numberOfBricksHeight(value: number);
  80275. get numberOfBricksWidth(): number;
  80276. set numberOfBricksWidth(value: number);
  80277. get jointColor(): BABYLON.Color3;
  80278. set jointColor(value: BABYLON.Color3);
  80279. get brickColor(): BABYLON.Color3;
  80280. set brickColor(value: BABYLON.Color3);
  80281. /**
  80282. * Serializes this brick procedural texture
  80283. * @returns a serialized brick procedural texture object
  80284. */
  80285. serialize(): any;
  80286. /**
  80287. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80288. * @param parsedTexture defines parsed texture data
  80289. * @param scene defines the current scene
  80290. * @param rootUrl defines the root URL containing brick procedural texture information
  80291. * @returns a parsed Brick Procedural BABYLON.Texture
  80292. */
  80293. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80294. }
  80295. }
  80296. declare module BABYLON {
  80297. /** @hidden */
  80298. export var cloudProceduralTexturePixelShader: {
  80299. name: string;
  80300. shader: string;
  80301. };
  80302. }
  80303. declare module BABYLON {
  80304. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80305. private _skyColor;
  80306. private _cloudColor;
  80307. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80308. updateShaderUniforms(): void;
  80309. get skyColor(): BABYLON.Color4;
  80310. set skyColor(value: BABYLON.Color4);
  80311. get cloudColor(): BABYLON.Color4;
  80312. set cloudColor(value: BABYLON.Color4);
  80313. /**
  80314. * Serializes this cloud procedural texture
  80315. * @returns a serialized cloud procedural texture object
  80316. */
  80317. serialize(): any;
  80318. /**
  80319. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80320. * @param parsedTexture defines parsed texture data
  80321. * @param scene defines the current scene
  80322. * @param rootUrl defines the root URL containing cloud procedural texture information
  80323. * @returns a parsed Cloud Procedural BABYLON.Texture
  80324. */
  80325. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80326. }
  80327. }
  80328. declare module BABYLON {
  80329. /** @hidden */
  80330. export var fireProceduralTexturePixelShader: {
  80331. name: string;
  80332. shader: string;
  80333. };
  80334. }
  80335. declare module BABYLON {
  80336. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80337. private _time;
  80338. private _speed;
  80339. private _autoGenerateTime;
  80340. private _fireColors;
  80341. private _alphaThreshold;
  80342. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80343. updateShaderUniforms(): void;
  80344. render(useCameraPostProcess?: boolean): void;
  80345. static get PurpleFireColors(): BABYLON.Color3[];
  80346. static get GreenFireColors(): BABYLON.Color3[];
  80347. static get RedFireColors(): BABYLON.Color3[];
  80348. static get BlueFireColors(): BABYLON.Color3[];
  80349. get autoGenerateTime(): boolean;
  80350. set autoGenerateTime(value: boolean);
  80351. get fireColors(): BABYLON.Color3[];
  80352. set fireColors(value: BABYLON.Color3[]);
  80353. get time(): number;
  80354. set time(value: number);
  80355. get speed(): BABYLON.Vector2;
  80356. set speed(value: BABYLON.Vector2);
  80357. get alphaThreshold(): number;
  80358. set alphaThreshold(value: number);
  80359. /**
  80360. * Serializes this fire procedural texture
  80361. * @returns a serialized fire procedural texture object
  80362. */
  80363. serialize(): any;
  80364. /**
  80365. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80366. * @param parsedTexture defines parsed texture data
  80367. * @param scene defines the current scene
  80368. * @param rootUrl defines the root URL containing fire procedural texture information
  80369. * @returns a parsed Fire Procedural BABYLON.Texture
  80370. */
  80371. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80372. }
  80373. }
  80374. declare module BABYLON {
  80375. /** @hidden */
  80376. export var grassProceduralTexturePixelShader: {
  80377. name: string;
  80378. shader: string;
  80379. };
  80380. }
  80381. declare module BABYLON {
  80382. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  80383. private _grassColors;
  80384. private _groundColor;
  80385. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80386. updateShaderUniforms(): void;
  80387. get grassColors(): BABYLON.Color3[];
  80388. set grassColors(value: BABYLON.Color3[]);
  80389. get groundColor(): BABYLON.Color3;
  80390. set groundColor(value: BABYLON.Color3);
  80391. /**
  80392. * Serializes this grass procedural texture
  80393. * @returns a serialized grass procedural texture object
  80394. */
  80395. serialize(): any;
  80396. /**
  80397. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80398. * @param parsedTexture defines parsed texture data
  80399. * @param scene defines the current scene
  80400. * @param rootUrl defines the root URL containing grass procedural texture information
  80401. * @returns a parsed Grass Procedural BABYLON.Texture
  80402. */
  80403. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80404. }
  80405. }
  80406. declare module BABYLON {
  80407. /** @hidden */
  80408. export var marbleProceduralTexturePixelShader: {
  80409. name: string;
  80410. shader: string;
  80411. };
  80412. }
  80413. declare module BABYLON {
  80414. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80415. private _numberOfTilesHeight;
  80416. private _numberOfTilesWidth;
  80417. private _amplitude;
  80418. private _jointColor;
  80419. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80420. updateShaderUniforms(): void;
  80421. get numberOfTilesHeight(): number;
  80422. set numberOfTilesHeight(value: number);
  80423. get amplitude(): number;
  80424. set amplitude(value: number);
  80425. get numberOfTilesWidth(): number;
  80426. set numberOfTilesWidth(value: number);
  80427. get jointColor(): BABYLON.Color3;
  80428. set jointColor(value: BABYLON.Color3);
  80429. /**
  80430. * Serializes this marble procedural texture
  80431. * @returns a serialized marble procedural texture object
  80432. */
  80433. serialize(): any;
  80434. /**
  80435. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80436. * @param parsedTexture defines parsed texture data
  80437. * @param scene defines the current scene
  80438. * @param rootUrl defines the root URL containing marble procedural texture information
  80439. * @returns a parsed Marble Procedural BABYLON.Texture
  80440. */
  80441. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80442. }
  80443. }
  80444. declare module BABYLON {
  80445. /** @hidden */
  80446. export var normalMapProceduralTexturePixelShader: {
  80447. name: string;
  80448. shader: string;
  80449. };
  80450. }
  80451. declare module BABYLON {
  80452. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80453. private _baseTexture;
  80454. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80455. updateShaderUniforms(): void;
  80456. render(useCameraPostProcess?: boolean): void;
  80457. resize(size: any, generateMipMaps: any): void;
  80458. get baseTexture(): BABYLON.Texture;
  80459. set baseTexture(texture: BABYLON.Texture);
  80460. /**
  80461. * Serializes this normal map procedural texture
  80462. * @returns a serialized normal map procedural texture object
  80463. */
  80464. serialize(): any;
  80465. /**
  80466. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80467. * @param parsedTexture defines parsed texture data
  80468. * @param scene defines the current scene
  80469. * @param rootUrl defines the root URL containing normal map procedural texture information
  80470. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80471. */
  80472. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80473. }
  80474. }
  80475. declare module BABYLON {
  80476. /** @hidden */
  80477. export var perlinNoiseProceduralTexturePixelShader: {
  80478. name: string;
  80479. shader: string;
  80480. };
  80481. }
  80482. declare module BABYLON {
  80483. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  80484. time: number;
  80485. timeScale: number;
  80486. translationSpeed: number;
  80487. private _currentTranslation;
  80488. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80489. updateShaderUniforms(): void;
  80490. render(useCameraPostProcess?: boolean): void;
  80491. resize(size: any, generateMipMaps: any): void;
  80492. /**
  80493. * Serializes this perlin noise procedural texture
  80494. * @returns a serialized perlin noise procedural texture object
  80495. */
  80496. serialize(): any;
  80497. /**
  80498. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  80499. * @param parsedTexture defines parsed texture data
  80500. * @param scene defines the current scene
  80501. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  80502. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  80503. */
  80504. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  80505. }
  80506. }
  80507. declare module BABYLON {
  80508. /** @hidden */
  80509. export var roadProceduralTexturePixelShader: {
  80510. name: string;
  80511. shader: string;
  80512. };
  80513. }
  80514. declare module BABYLON {
  80515. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  80516. private _roadColor;
  80517. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80518. updateShaderUniforms(): void;
  80519. get roadColor(): BABYLON.Color3;
  80520. set roadColor(value: BABYLON.Color3);
  80521. /**
  80522. * Serializes this road procedural texture
  80523. * @returns a serialized road procedural texture object
  80524. */
  80525. serialize(): any;
  80526. /**
  80527. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  80528. * @param parsedTexture defines parsed texture data
  80529. * @param scene defines the current scene
  80530. * @param rootUrl defines the root URL containing road procedural texture information
  80531. * @returns a parsed Road Procedural BABYLON.Texture
  80532. */
  80533. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  80534. }
  80535. }
  80536. declare module BABYLON {
  80537. /** @hidden */
  80538. export var starfieldProceduralTexturePixelShader: {
  80539. name: string;
  80540. shader: string;
  80541. };
  80542. }
  80543. declare module BABYLON {
  80544. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  80545. private _time;
  80546. private _alpha;
  80547. private _beta;
  80548. private _zoom;
  80549. private _formuparam;
  80550. private _stepsize;
  80551. private _tile;
  80552. private _brightness;
  80553. private _darkmatter;
  80554. private _distfading;
  80555. private _saturation;
  80556. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80557. updateShaderUniforms(): void;
  80558. get time(): number;
  80559. set time(value: number);
  80560. get alpha(): number;
  80561. set alpha(value: number);
  80562. get beta(): number;
  80563. set beta(value: number);
  80564. get formuparam(): number;
  80565. set formuparam(value: number);
  80566. get stepsize(): number;
  80567. set stepsize(value: number);
  80568. get zoom(): number;
  80569. set zoom(value: number);
  80570. get tile(): number;
  80571. set tile(value: number);
  80572. get brightness(): number;
  80573. set brightness(value: number);
  80574. get darkmatter(): number;
  80575. set darkmatter(value: number);
  80576. get distfading(): number;
  80577. set distfading(value: number);
  80578. get saturation(): number;
  80579. set saturation(value: number);
  80580. /**
  80581. * Serializes this starfield procedural texture
  80582. * @returns a serialized starfield procedural texture object
  80583. */
  80584. serialize(): any;
  80585. /**
  80586. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80587. * @param parsedTexture defines parsed texture data
  80588. * @param scene defines the current scene
  80589. * @param rootUrl defines the root URL containing startfield procedural texture information
  80590. * @returns a parsed Starfield Procedural BABYLON.Texture
  80591. */
  80592. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80593. }
  80594. }
  80595. declare module BABYLON {
  80596. /** @hidden */
  80597. export var woodProceduralTexturePixelShader: {
  80598. name: string;
  80599. shader: string;
  80600. };
  80601. }
  80602. declare module BABYLON {
  80603. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80604. private _ampScale;
  80605. private _woodColor;
  80606. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80607. updateShaderUniforms(): void;
  80608. get ampScale(): number;
  80609. set ampScale(value: number);
  80610. get woodColor(): BABYLON.Color3;
  80611. set woodColor(value: BABYLON.Color3);
  80612. /**
  80613. * Serializes this wood procedural texture
  80614. * @returns a serialized wood procedural texture object
  80615. */
  80616. serialize(): any;
  80617. /**
  80618. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80619. * @param parsedTexture defines parsed texture data
  80620. * @param scene defines the current scene
  80621. * @param rootUrl defines the root URL containing wood procedural texture information
  80622. * @returns a parsed Wood Procedural BABYLON.Texture
  80623. */
  80624. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80625. }
  80626. }